virtual memory
-
Please help me with this. I want to extract the information about subsequent pages using this function VirtualQuertEx()but i don't how i can go about it.
PROCESS_INFORMATION pi; STARTUPINFO si; HANDLE hProcess; BYTE buf[20000]; DWORD NumberOfBytesRead = 0; DWORD bufsize = sizeof buf; DWORD baseaddr = 0; DWORD lpAddr = 0; PMEMORY_BASIC_INFORMATION lpBuffer = 0; DWORD dwLength = 200000;/****/ DWORD flNewProtect =0; PDWORD lpflOldProtect = 0; DWORD dwSize =0; LPCVOID lpBaseAddress = 0; DWORD nSize = 0; VirtualQueryEx( hProcess, // handle to process &lpAddr, // address of region buf,// address of information buffer sizeof (MEMORY_BASIC_INFORMATION));// size of buffer VirtualProtectEx( hProcess, // handle to process lpAddr, // address of region of committed pages dwSize, // size of region flNewProtect, // desired access protection lpflOldProtect );// address of variable to get old protection ZeroMemory(buf, sizeof(buf)); if( ReadProcessMemory( hProcess, lpBaseAddress, buf, bufsize, &NumberOfBytesRead ) == FALSE ) { printf("\nProcess ID %d ",pi.dwProcessId); printf (" memory read failed (errcode: %d)", GetLastError()); } else { printf("\nProcess ID %d ",pi.dwProcessId); printf("memory read: \n",buf); GetLastError()); }
How can i retrieve the buff size from that function oam