EXE and loaded DLL Address Space

Started by
0 comments, last by Zipster 13 years, 8 months ago
Hi all,

I have a stupid question, but vital for me :) .
Can a loaded DLL set variable owned by EXE, where Exe is executable that loaded DLL?
I think yes, but I have a little confusion about DLL are loaded.

Example, suppose I have a program say Test.exe and a Dll Library.dll with an Exported function DoIT().

DoIT function
-------------
DoIT()
{
int *pA = 0x12345678;
*pA = 200;
}
-------------


Test.exe in PseudoCode.

int A=100;
//Suppose A Address is 0x12345678

hLib = ::LoadLibrary ( "Library.dll" );

pointerDoIT = GetProcAddress( hLib, "DoIT" ); //Not using cast for simplicity

(*pointerDoIT)();

Question. Now A is 200?
Library.dll is loaded in EXE address space so I can change Exe vars?
Or Have I use ReadProcessMEmory and WriteProcessMemory?

Thanks in advance,
Max.










Advertisement
It's all the same address space, so as long as the address isn't write-protected what it points to can be modified. So for your own EXE's and DLL's, it should all work just fine. However I wouldn't go making up random addresses and trying to write to them ;)

This topic is closed to new replies.

Advertisement