Log in

View Full Version : Problem to use WriteProcessMemory


RatDeLabo
March 7th, 2002, 22:39
i'm working on a certain dll. i've written a little proggy that patches, loads, uses, unloads then unpatch this dll (i want it to stay "bugged".
this solution is not very elegant, and i want to use WriteProcessMemory;
i've read several essays, but didn't succeeded to use it correctly.
in the examples i've seen, the executable is loaded with CreateProcess, but i use LoadLibrary, so i don't have the right handler.
does anybody have a solution for this ?

thanks

Solomon
March 8th, 2002, 03:23
DLL resides in the same process space as your loader. So u can use GetCurrentProcess( ) to retrieve a pseudo handle. Also you can directly assign a value to a certain address if it's not write-protected.

HMODULE hModule = LoadLibrary();
char *p = (char *)hModule;
*(p + RVA_to_patch) = Patched_Value; //patch it

RatDeLabo
March 8th, 2002, 10:46
thanks !
i'll try this this week-end

RatDeLabo
March 14th, 2002, 17:01
the process is write-protected... so i don't know how to make it.

but someone gave me libs & objs / headers from this dll...hehe