R
Ryanivanka
hi,
I want to get some memory information.
the following codes are in a win32 DLL.
---------------------------------------------------------------------------------
MEMORY_BASIC_INFORMATION mbi;
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
DWORD dwOldProtect = 0;
HMODULE h;
/* the "pv" is a DWORD address ,for example,DWORD pv=0xf8003400,it's
an
address of code instruction or a function return address*/
VirtualProtect((LPVOID)pv,sizeof(HANDLE),PAGE_READWRITE,&dwOldProtect);
if(VirtualQuery((LPVOID)pv,&mbi,sizeof(MEMORY_BASIC_INFORMATION))!=0)
h=(HMODULE)mbi.AllocationBase;
----------------------------------------------------------------------------------
the values of "mbi" are all zero,it does not get any
information.VirtualProtect() return false and VirtualQuery()return 0.
MSDN
said if the pv address is kernel mode,the latter function will return
0.but
the address is just a normal one in an MFC supported DLL which is in
the
same process with my DLL.
Why do they fail?
could anyone help me to figure out the reason and solution? thank you.
regards,
Ryan
I want to get some memory information.
the following codes are in a win32 DLL.
---------------------------------------------------------------------------------
MEMORY_BASIC_INFORMATION mbi;
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
DWORD dwOldProtect = 0;
HMODULE h;
/* the "pv" is a DWORD address ,for example,DWORD pv=0xf8003400,it's
an
address of code instruction or a function return address*/
VirtualProtect((LPVOID)pv,sizeof(HANDLE),PAGE_READWRITE,&dwOldProtect);
if(VirtualQuery((LPVOID)pv,&mbi,sizeof(MEMORY_BASIC_INFORMATION))!=0)
h=(HMODULE)mbi.AllocationBase;
----------------------------------------------------------------------------------
the values of "mbi" are all zero,it does not get any
information.VirtualProtect() return false and VirtualQuery()return 0.
MSDN
said if the pv address is kernel mode,the latter function will return
0.but
the address is just a normal one in an MFC supported DLL which is in
the
same process with my DLL.
Why do they fail?
could anyone help me to figure out the reason and solution? thank you.
regards,
Ryan