Codeka, you were right. You need to specify the FULL path. However theres a problem, at least now I know its being modified.
But, its not rewriting what I had originally. My DLL before, is 900 kb. And after, its just 1 kb. Which is weird I think considering we are writing to the end of the file if Im not mistaken.
Random CRC on Application Launch
Quote:Original post by RogerThat123Whoops, I missed your parameters to the CreateFile function. It should be OPEN_EXISTING, not CREATE_ALWAYS (OPEN_EXISTING will open an existing file, and give you an error if the file doesn't exist; CREATE_ALWAYS will create the file if it doesn't exist, and overwrite the existing file if it does).
But, its not rewriting what I had originally. My DLL before, is 900 kb. And after, its just 1 kb. Which is weird I think considering we are writing to the end of the file if Im not mistaken.
yeah I started looking at that for a sec.
Ok so we have progress now, with the OPEN_EXISTING , we are reading it correctly.
And the first time my .exe is launched. The File changes its CRC perfect. But anytime after, it is identical. And the program is not growing in size slowly either.
EDIT: Damn, my DLL doesnt load properly when we write extra data to the end of it like this, it just doesnt load at all. I really thought this method was going to work @#$%.
Ok so we have progress now, with the OPEN_EXISTING , we are reading it correctly.
And the first time my .exe is launched. The File changes its CRC perfect. But anytime after, it is identical. And the program is not growing in size slowly either.
EDIT: Damn, my DLL doesnt load properly when we write extra data to the end of it like this, it just doesnt load at all. I really thought this method was going to work @#$%.
Quote:Original post by RogerThat123
EDIT: Damn, my DLL doesnt load properly when we write extra data to the end of it like this, it just doesnt load at all. I really thought this method was going to work @#$%.
I vaguely remember a discussion here a long time ago about problems encountered when hand-modifying EXEs or DLLs. I believe the solution had to do with a size-of-EXE (or possibly size-of-section) field somewhere in the header that needed to be updated correctly.
(Edit) Found it: Link
Thanks for the reply.
Would you happen to know how to change this value
After launching my exe that modifies my DLL. I try opening the modified DLL in PE Explorer, but it fails because it now says its not a valid library file.
19.08.2009 00:50:29 : Open File: C:\Users\Me\Desktop\Test.dll
19.08.2009 00:50:32 : File size: 553984 bytes.
19.08.2009 00:50:32 : Error: This is NOT EXE or DLL File! Processing cancelled.
19.08.2009 00:50:32 : Error! (Step: Examining File Headers)
19.08.2009 00:50:32 : Done.
[Edited by - RogerThat123 on August 18, 2009 11:09:49 PM]
Would you happen to know how to change this value
After launching my exe that modifies my DLL. I try opening the modified DLL in PE Explorer, but it fails because it now says its not a valid library file.
19.08.2009 00:50:29 : Open File: C:\Users\Me\Desktop\Test.dll
19.08.2009 00:50:32 : File size: 553984 bytes.
19.08.2009 00:50:32 : Error: This is NOT EXE or DLL File! Processing cancelled.
19.08.2009 00:50:32 : Error! (Step: Examining File Headers)
19.08.2009 00:50:32 : Done.
[Edited by - RogerThat123 on August 18, 2009 11:09:49 PM]
Quote:Original post by RogerThat123
Thanks for the reply.
Would you happen to know how to change this value
Documentation on PE format
Specification for PE/COFF
Stop messing around with the raw executable bits yourself and let the Windows API do the dirty work for you. As I mentioned earlier there's a perfectly standard API called UpdateResource you can use here.
E.g. something more or less like this (untested!):
E.g. something more or less like this (untested!):
void Scramble(LPCTSTR *name) { char random[64]; size_t i; HANDLE handle; srand(time(NULL)); for(i = 0; i < random; ++i) random = rand(); handle = BeginUpdateResource(name, FALSE); if(handle) { UpdateResource ( handle, RT_RCDATA, TEXT("UniquePadding"), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), random, sizeof random ); EndUpdateResource(handle, FALSE); }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement