Advertisement
Guest User

Untitled

a guest
Apr 9th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. #include <windows.h>
  2. #include <dbghelp.h>
  3. #include <stdio.h>
  4. static BOOL CALLBACK FunkyCallback(HWND hWnd, LPARAM lParam ){
  5.     char b[100]; RECT Rect;
  6.     DWORD pid;
  7.     if(!GetParent(hWnd)){
  8.         GetWindowText(hWnd, b, 99); GetWindowRect(hWnd,&Rect);
  9.         GetWindowThreadProcessId(hWnd, &pid);
  10.         printf("%li: %s left:%li top:%li\n",pid,b,Rect.left,Rect.top);
  11.     }   return TRUE;
  12. }
  13. int main(int argc, char ** argv){
  14.     if (argc > 1){
  15.         HANDLE hFile = CreateFile(
  16.             "proc.dmp",
  17.             GENERIC_READ | GENERIC_WRITE,
  18.             FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
  19.             NULL,
  20.             CREATE_ALWAYS,
  21.             FILE_ATTRIBUTE_NORMAL,
  22.             NULL
  23.         );
  24.         DWORD procID = atoi(argv[1]);
  25.         HANDLE hProc = OpenProcess(
  26.             PROCESS_ALL_ACCESS,
  27.             FALSE,
  28.             procID
  29.         );
  30.         fprintf(stderr,"Dumping hProc %p\n",hProc);
  31.         if (!MiniDumpWriteDump(
  32.             hProc,
  33.             procID,
  34.             hFile,
  35.             MiniDumpNormal,
  36.             NULL,
  37.             NULL,
  38.             NULL
  39.         )) fprintf(stderr,"didn't work :(\n");
  40.         CloseHandle(hFile);
  41.     } else {
  42.         fprintf(stderr,"Usage: %s procID\n",argv[0]);
  43.         EnumChildWindows(GetDesktopWindow(),FunkyCallback, 0);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement