Question

Hi I try to call the VirtualQueryEx function to get some Information about Memory Protection, however my code gives me error 0x18 (ERROR_BAD_LENGTH) and i dont know whats wrong with my code;

code snippet:

PMEMORY_BASIC_INFORMATION alte;

VirtualQueryEx(processhandle,(LPVOID) (address),alte,sizeof(PMEMORY_BASIC_INFORMATION));

thanks for your help

Was it helpful?

Solution

alte needes to by declared as MEMORY_BASIC_INFORMATION not a pointer to one.

MEMORY_BASIC_INFORMATION alte;

VirtualQueryEx(processhandle,(LPVOID) (address),&alte,sizeof(MEMORY_BASIC_INFORMATION));

edit: Note its sizeof(MEMORY_BASIC_INFORMATION) not sizeof(PMEMORY_BASIC_INFORMATION).

Actually, it's better to write this anyway

VirtualQueryEx(processhandle,(LPVOID) (address),&alte,sizeof(alte));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top