Recent Posts
PHP | 3 sec ago
None | 5 sec ago
None | 11 sec ago
None | 20 sec ago
None | 55 sec ago
HTML | 1 min ago
None | 2 min ago
None | 2 min ago
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Domain Reports
Please check out our new and improved Firefox Add-on. hide message
By XYNTService Terminate chi... on the 12th of Mar 2010 04:38:30 AM Download | Raw | Embed | Report
  1. --- XYNTService-original.cpp    2008-02-22 15:00:30.000000000 +0000
  2. +++ XYNTService.cpp     2010-03-12 10:32:19.726000000 +0000
  3.  -7,6 +7,7 @@
  4.  #include <winbase.h>
  5.  #include <winsvc.h>
  6.  #include <process.h>
  7. +#include <Tlhelp32.h>
  8.  
  9.  
  10.  const int nBufferSize = 500;
  11.  -23,6 +24,7 @@
  12.  
  13.  VOID WINAPI XYNTServiceMain( DWORD dwArgc, LPTSTR *lpszArgv );
  14.  VOID WINAPI XYNTServiceHandler( DWORD fdwControl );
  15. +VOID RecursiveEndProcess(HANDLE parentProcess, DWORD parentID);
  16.  
  17.  CRITICAL_SECTION myCS;
  18.  
  19.  -154,6 +156,9 @@
  20.                 PostThreadMessage(pProcInfo[nIndex].dwThreadId,WM_QUIT,0,0);
  21.                 // sleep for a while so that the process has a chance to terminate itself
  22.                 ::Sleep(nPauseEnd>0?nPauseEnd:50);
  23. +
  24. +               //kill child processes
  25. +               RecursiveEndProcess(pProcInfo[nIndex].hProcess, pProcInfo[nIndex].dwProcessId);
  26.                 // terminate the process by force
  27.                 TerminateProcess(pProcInfo[nIndex].hProcess,0);
  28.                 try // close handles to avoid ERROR_NO_SYSTEM_RESOURCES
  29.  -167,6 +172,42 @@
  30.         }
  31.  }
  32.  
  33. +
  34. +void RecursiveEndProcess(HANDLE parentProcess, DWORD parentID)
  35. +{
  36. +       if (parentProcess == NULL)
  37. +       {
  38. +               return;
  39. +       }
  40. +
  41. +       PROCESSENTRY32 pe;
  42. +       memset(&pe, 0, sizeof(PROCESSENTRY32));
  43. +       pe.dwSize = sizeof(PROCESSENTRY32);
  44. +       HANDLE hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD, parentID);
  45. +
  46. +       if (::Process32First(hSnap, &pe))
  47. +       {
  48. +               BOOL bContinue = TRUE;
  49. +               // kill child processes
  50. +               while (bContinue)
  51. +               {
  52. +                       // only kill child processes
  53. +                       if (pe.th32ParentProcessID == parentID)
  54. +                       {
  55. +                               HANDLE hChildProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
  56. +                              
  57. +                               if (hChildProc)
  58. +                               {
  59. +                                       RecursiveEndProcess(hChildProc, pe.th32ProcessID);
  60. +                                       ::TerminateProcess(hChildProc, 0);
  61. +                                       ::CloseHandle(hChildProc);
  62. +                               }                              
  63. +                       }
  64. +                       bContinue = ::Process32Next(hSnap, &pe);
  65. +               }          
  66. +       }
  67. +}
  68. +
  69.  BOOL BounceProcess(char* pName, int nIndex)
  70.  {
  71.         // bounce the process with given index
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: