win 32 API virtual memory
-
Please help me with this. I am using VirtualQueryEx() function to get information about regions of pages committed and save this information in a file. Here is part of my code
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 do i return this function call, i.e. to return information about pages commited and occupied pages oam