Source code of Windows XP (NT5)
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.

135 lines
3.4 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. #include "precomp.h"
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <wdbgexts.h>
  11. #include <ntsdexts.h>
  12. #include "wmiext.h"
  13. #include "utils.h"
  14. WINDBG_EXTENSION_APIS ExtensionApis;
  15. BOOL APIENTRY DllMain( HANDLE hModule,
  16. DWORD ul_reason_for_call,
  17. LPVOID lpReserved
  18. )
  19. {
  20. switch (ul_reason_for_call)
  21. {
  22. case DLL_PROCESS_ATTACH:
  23. case DLL_THREAD_ATTACH:
  24. case DLL_THREAD_DETACH:
  25. case DLL_PROCESS_DETACH:
  26. break;
  27. }
  28. return TRUE;
  29. }
  30. //========================
  31. // output the wbem version
  32. //========================
  33. WMIEXT_API void wmiver(HANDLE hCurrentProcess,
  34. HANDLE hCurrentThread,
  35. DWORD dwCurrentPc,
  36. PWINDBG_EXTENSION_APIS lpExtensionApis,
  37. LPSTR lpArgumentString)
  38. {
  39. HKEY hCimomReg;
  40. char szWbemVersion[100];
  41. DWORD dwSize = 100;
  42. DWORD lResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\WBEM",
  43. NULL, KEY_READ, &hCimomReg);
  44. if (lResult==ERROR_SUCCESS)
  45. {
  46. lResult=RegQueryValueEx(hCimomReg, "Build", NULL, NULL,
  47. (unsigned char *)szWbemVersion, &dwSize);
  48. RegCloseKey(hCimomReg);
  49. }
  50. if(lResult==ERROR_SUCCESS)
  51. {
  52. lpExtensionApis->lpOutputRoutine("\nWMI build %s is installed.\n\n",szWbemVersion);
  53. }
  54. else
  55. {
  56. lpExtensionApis->lpOutputRoutine("\nHKLM\\SOFTWARE\\Microsoft\\WBEM\\BUILD registry key not found!\n\n");
  57. }
  58. }
  59. //====================================
  60. //Connect to mermaid\debug as smsadmin
  61. //====================================
  62. WMIEXT_API void mermaid(HANDLE hCurrentProcess,
  63. HANDLE hCurrentThread,
  64. DWORD dwCurrentPc,
  65. PWINDBG_EXTENSION_APIS lpExtensionApis,
  66. LPSTR lpArgumentString)
  67. {
  68. lpExtensionApis->lpOutputRoutine("\nConnecting to mermaid\\debug for source... ");
  69. //construct paths first
  70. //=====================
  71. char szFirst[MAX_PATH+100],szSecond[MAX_PATH+100];
  72. GetSystemDirectory(szFirst,MAX_PATH);
  73. strcat(szFirst,"\\net.exe");
  74. strcpy(szSecond,szFirst);
  75. strcat(szSecond," use \\\\mermaid\\debug /u:wbem\\smsadmin Elvis1");
  76. //now net use to mermaid\debug
  77. //============================
  78. DWORD dwRes=WaitOnProcess(szFirst,szSecond,false);
  79. if (0==dwRes)
  80. {
  81. lpExtensionApis->lpOutputRoutine("Succeeded!\n");
  82. }
  83. else
  84. {
  85. lpExtensionApis->lpOutputRoutine("Failed!\n");
  86. }
  87. }
  88. //=======================
  89. //Give memory information
  90. //=======================
  91. WMIEXT_API void mem(HANDLE hCurrentProcess,
  92. HANDLE hCurrentThread,
  93. DWORD dwCurrentPc,
  94. PWINDBG_EXTENSION_APIS lpExtensionApis,
  95. LPSTR lpArgumentString)
  96. {
  97. MEMORYSTATUS mem;
  98. memset(&mem, 0, sizeof(MEMORYSTATUS));
  99. mem.dwLength = sizeof(MEMORYSTATUS);
  100. GlobalMemoryStatus(&mem);
  101. lpExtensionApis->lpOutputRoutine("Total memory = %d mb / "
  102. "Available memory = %d mb\n",
  103. (mem.dwTotalPageFile+mem.dwTotalPhys)/(1 << 20),
  104. (mem.dwAvailPageFile+mem.dwAvailPhys)/(1 << 20));
  105. }