views:

163

answers:

1

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

+3  A: 

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));
John Knoeller
error C2664: 'VirtualQueryEx': Konvertierung des Parameters 3 von 'PMEMORY_BASIC_INFORMATION *__w64 ' in 'PMEMORY_BASIC_INFORMATION' nicht möglich
h3rock
that was a typo. sorry. it's fixed now.
John Knoeller
edit thanks it's working now
h3rock
I can't read error messages in that language. German? post your current code and use 4 space indent so that it looks like code
John Knoeller
Yes it's german and it says that it cannot convert the third parameter from 'PMEMORY_BASIC_INFORMATION *__w64 ' to 'PMEMORY_BASIC_INFORMATION'
Etan
oh. you didn't change the declaration of alte. look again
John Knoeller