Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 9th, 2012  |  syntax: C  |  size: 1.33 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         EnumChildWindows(GetDesktopWindow(),FunkyCallback, 0);
  43.         fprintf(stderr,"Usage: %s procID\n",argv[0]);
  44.     }
  45. }
clone this paste RAW Paste Data