Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. vcc.c
  5. Abstract:
  6. Proof of concept tool for win9x virus check checker.
  7. Enumerates the active processes on the machine looking for virus scanners that
  8. can cause problems when upgrading (or clean installing) NT 5.0 on a win9x system
  9. (Examples are virus scanners that lock the MBR, etc..)
  10. Author:
  11. Marc R. Whitten (marcw) 11-Sept-1998
  12. Revision History:
  13. <alias> <date> <comments>
  14. --*/
  15. #include "pch.h"
  16. #include "tlhelp32.h"
  17. BOOL
  18. Init (
  19. VOID
  20. )
  21. {
  22. HINSTANCE hInstance;
  23. hInstance = GetModuleHandle (NULL);
  24. return InitToolMode (hInstance);
  25. }
  26. VOID
  27. Terminate (
  28. VOID
  29. )
  30. {
  31. HINSTANCE hInstance;
  32. hInstance = GetModuleHandle (NULL);
  33. TerminateToolMode (hInstance);
  34. }
  35. BOOL
  36. InitMigDbEx (
  37. PCSTR MigDbFile
  38. );
  39. BOOL
  40. MigDbTestFile (
  41. IN OUT PFILE_HELPER_PARAMS Params
  42. );
  43. INT
  44. __cdecl
  45. main (
  46. INT argc,
  47. CHAR *argv[]
  48. )
  49. {
  50. HANDLE h;
  51. PROCESSENTRY32 pe;
  52. FILE_HELPER_PARAMS fileParams;
  53. PTSTR p;
  54. WIN32_FIND_DATA fd;
  55. HANDLE findHandle;
  56. PTSTR fileString;
  57. fileParams.VirtualFile = FALSE;
  58. if (!Init()) {
  59. printf ("Unable to initialize!\n");
  60. return 255;
  61. }
  62. //
  63. // Gather information on all the
  64. //
  65. h = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
  66. if (h != -1) {
  67. //
  68. // Initialize the virus scanner database.
  69. //
  70. fileString = JoinPaths (g_DllDir, TEXT("vscandb.inf"));
  71. if (!InitMigDbEx (fileString)) {
  72. printf ("vcc - Could not initialeze virus scanner database. (GLE: %d)\n", GetLastError());
  73. CloseHandle(h);
  74. return 255;
  75. }
  76. FreePathString (fileString);
  77. SetLastError(ERROR_SUCCESS);
  78. pe.dwSize = sizeof (PROCESSENTRY32);
  79. if (Process32First (h, &pe)) {
  80. do {
  81. printf ("*** ProcessInfo for process %x\n", pe.th32ProcessID);
  82. printf ("\tExeName: %s\n", pe.szExeFile);
  83. printf ("\tThread Count: %d\n\n",pe.cntThreads);
  84. //
  85. // Fill in the file helper params for this file..
  86. //
  87. ZeroMemory (&fileParams, sizeof(FILE_HELPER_PARAMS));
  88. fileParams.FullFileSpec = pe.szExeFile;
  89. p = _tcsrchr (pe.szExeFile, TEXT('\\'));
  90. if (p) {
  91. *p = 0;
  92. StringCopy (fileParams.DirSpec, pe.szExeFile);
  93. *p = TEXT('\\');
  94. }
  95. fileParams.Extension = GetFileExtensionFromPath (pe.szExeFile);
  96. findHandle = FindFirstFile (pe.szExeFile, &fd);
  97. if (findHandle != INVALID_HANDLE_VALUE) {
  98. fileParams.FindData = &fd;
  99. FindClose (findHandle);
  100. }
  101. MigDbTestFile (&fileParams);
  102. } while (Process32Next (h, &pe));
  103. }
  104. else {
  105. printf ("No processes to enumerate..(GLE: %d)\n", GetLastError());
  106. }
  107. DoneMigDb (REQUEST_RUN);
  108. CloseHandle (h);
  109. }
  110. else {
  111. printf ("Snapshot failed.\n");
  112. }
  113. Terminate();
  114. return 0;
  115. }