« first day (1321 days earlier)      last day (1538 days later) » 

3:14 PM
Hello guys
I am trying to create a file using 'CreateFileW' but it is always 0KB, and the variable 'BytesWritten' is zero
Can anyone tell me possibilities of the error?
DWORD BytesWritten = NULL;
HANDLE NewFile = CreateFileW(Path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (NewFile != INVALID_HANDLE_VALUE)
{
   WriteFile(NewFile, &Buffer, lstrlenA(PCHAR(Buffer)), &BytesWritten, NULL);
   CloseHandle(NewFile);
}
I am sorry I mean, the function WriteFile is giving me the error
@PeterT a hand? :)
 
3:41 PM
@Castiel chech GetLastError, both after CreateFileW and after WriteFile
 
Thanks, let me try
the bytes that i am writing are from a PBYTE
and for that, inside the function i am using lstrlenA(PCHAR("PBYTE here"))
now, for some reason it only write 3kb to the file
which is incorrect. Why would that be?
 
4:02 PM
well if it's a PBYTE, are you sure it doesn't contain any null-characters?
 
it might
Do I have to write then ?

 WriteFile(NewFile, &Buffer, lstrlenA(PCHAR(Buffer)) + 1, &BytesWritten, NULL);
 
I mean if it's binary data and there's a\0 in there in the middle then lstrlenA will not give you the correct length
 
And what would give the correct length instead of that?
sizeof() ?
 
@Castiel you should know how large the buffer is, you allocated and wrote into it
sizeof only works if it's allocated statically
 
it isn't allocated statically, but since the buffer is PBYTE, i would need to get it's length
 
4:15 PM
you wrote into the buffer, so at some point you know how much is in there, you need to keep track of that yourself, the C++ standard doesn't have a facility to "get number of bytes allocated at this pointer" for the generic case
 
Oh I understand
Oke, let me look into it.
 
4:40 PM
@PeterT Oh, I still need to get the size of using a function
I don't store the size itself
is there a way to convert from pbyte to dword?
 
@Castiel you need to store the size then somewhere, if for some reason you can store it anywhere else store it at the beginning of Buffer before the actual data
@Castiel converting it from pbyte to dword won't help you get the size
 
but if the size is unknown?
 
@Castiel it can not be unknown, you wrote into the buffer some data, when you wrote into it, you knew how much you wrote into it
it was allocated somewhere, it wasn't given to you at random
 
Hmm
 
5:19 PM
Peter my friend. :)
It seems like I still need to get out the size from within the pbyte
is there a way to use magic?
 
@Castiel what is the data that it points to ? is it a ascii/utf-8 string or is it some arbitrary binary data?
where did you get that pointer from?
 
i have a pvoid function which returns a pdword
i am calling this function inside PBYTE
the pvoid function is to get the current module base
I guess i need to get the size of the image from this pbyte
i know how much it is exactly, and with written integers the code is working, just idk how to get that size out dinamycally.
 
5:37 PM
quick googling tells me you can get a handle to the module from an address with GetModuleHandleExA, then you can use that handle with GetModuleInformation to get the size of the module
 
I wanted to do that, but i was thinking there is a simplier way..
 
how could it be simpler? You could try to scan the page-table mappings to guess the size from the pages around it, but that would be less reliable and more complicated.
 
I know that
 
 
2 hours later…
7:48 PM
as we know have large cloud providers, how has this changed backend development?
how does it change the role from say 10 years ago?
question 2) when netflix says it deploys its backend using aws, what would they have had to do if they didnt have aws? question 3) does it make their jobs worse/less important
question 4) does this tend to a world where you have large cloud providers and everyone else is small company that just has effectively a frontend providing an app for a parituclar business need/proposition
 
 
3 hours later…
10:35 PM
Hello.
Related to the decompression issue, if anyone can take a look now, would be much appreicate Thank you
0
Q: C/C++ RtlDecompression from PBYTE

CastielI am using RtlCompressBuffer to compress and write to an exiting file. The problem is when I try to decompress it. Through my code, later on the compressed result can be found into a PBYTE and unfortunately I cannot unpack it. This is the compress part: DWORD CompressBufferSize = 0; if (NT_SUCC...

 

« first day (1321 days earlier)      last day (1538 days later) »