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.

262 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. globals.c
  5. Abstract:
  6. This module implements all global variables used in dbghelp.dll
  7. Author:
  8. Pat Styles (patst) 14-July-2000
  9. Revision History:
  10. --*/
  11. #include <private.h>
  12. #include <symbols.h>
  13. #include <globals.h>
  14. GLOBALS g =
  15. {
  16. // HANDLE hinst
  17. // initialized in DllMain
  18. 0,
  19. // HANDLE hHeap
  20. 0,
  21. // DWORD tlsIndex
  22. (DWORD)-1,
  23. #ifdef IMAGEHLP_HEAP_DEBUG
  24. // LIST_ENTRY HeapHeader
  25. {NULL, NULL},
  26. // ULONG TotalMemory
  27. 0,
  28. // ULONG TotalAllocs
  29. 0,
  30. #endif
  31. // OSVERSIONINFO OSVerInfo
  32. // initialized in DllMain
  33. {0, 0, 0, 0, 0, ""},
  34. // API_VERSION ApiVersion
  35. {
  36. (VER_PRODUCTVERSION_W >> 8),
  37. (VER_PRODUCTVERSION_W & 0xff),
  38. API_VERSION_NUMBER,
  39. 0
  40. },
  41. // API_VERSION AppVersion
  42. // DON'T UPDATE THE FOLLOWING VERSION NUMBER!!!!
  43. //
  44. // If the app does not call ImagehlpApiVersionEx, always assume
  45. // that it is for NT 4.0.
  46. {4, 0, 5, 0},
  47. // ULONG MachineType;
  48. 0,
  49. // CRITICAL_SECTION threadlock;
  50. {
  51. (PRTL_CRITICAL_SECTION_DEBUG)0,
  52. (LONG)0,
  53. (LONG)0,
  54. (HANDLE)0,
  55. (HANDLE)0,
  56. (ULONG_PTR)0
  57. },
  58. #ifdef BUILD_DBGHELP
  59. // HINSTANCE hSymSrv
  60. 0,
  61. // PSYMBOLSERVERPROC fnSymbolServer
  62. NULL,
  63. // PSYMBOLSERVERCLOSEPROC fnSymbolServerClose
  64. NULL,
  65. // PSYMBOLSERVERSETOPTIONSPROC fnSymbolServerSetOptions
  66. NULL,
  67. // PSYMBOLSERVERPINGPROC fnSymbolServerPing
  68. NULL,
  69. // HINSTANCE hSrcSrv
  70. NULL,
  71. // PSRCSRVINITPROC fnSrcSrvInit
  72. NULL,
  73. // PSRCSRVCLEANUPPROC fnSrcSrvCleanup
  74. NULL,
  75. // PSRCSRVSETTARGETPATHPROC fnSrcSrvSetTargetPath
  76. NULL,
  77. // PSRCSRVSETOPTIONSPROC fnSrcSrvSetOptions
  78. NULL,
  79. // PSRCSRVGETOPTIONSPROC fnSrcSrvGetOptions
  80. NULL,
  81. // PSRCSRVLOADMODULEPROC fnSrcSrvLoadModule
  82. NULL,
  83. // PSRCSRVUNLOADMODULEPROC fnSrcSrvUnloadModule
  84. NULL,
  85. // PSRCSRVREGISTERCALLBACKPROC fnSrcSrvRegisterCallback
  86. NULL,
  87. // PSRCSRVGETFILEPROC fnSrcSrvGetFile
  88. NULL,
  89. // DWORD cProcessList
  90. 0,
  91. // LIST_ENTRY ProcessList
  92. {NULL, NULL},
  93. // BOOL SymInitialized
  94. FALSE,
  95. // DWORD SymOptions
  96. SYMOPT_UNDNAME,
  97. // ULONG LastSymLoadError
  98. 0,
  99. // char DebugModule[MAX_SYM_NAME + 1];
  100. "",
  101. // PREAD_PROCESS_MEMORY_ROUTINE ImagepUserReadMemory32
  102. NULL,
  103. // PFUNCTION_TABLE_ACCESS_ROUTINE ImagepUserFunctionTableAccess32
  104. NULL,
  105. // PGET_MODULE_BASE_ROUTINE ImagepUserGetModuleBase32
  106. NULL,
  107. // PTRANSLATE_ADDRESS_ROUTINE ImagepUserTranslateAddress32
  108. NULL,
  109. // HWND hwndParent;
  110. 0,
  111. // int hLog;
  112. 0,
  113. // BOOL fdbgout;
  114. false,
  115. // BOOL fbp;
  116. false, // set this to true and dbghelp internal debugging breakpoints will fire
  117. // BOOL fCoInit
  118. false,
  119. // char HomeDir[MAX_PATH + 1]
  120. "",
  121. // char SymDir[MAX_PATH + 1]
  122. "",
  123. // char SrcDir[MAX_PATH + 1]
  124. "",
  125. #endif
  126. };
  127. #ifdef BUILD_DBGHELP
  128. void
  129. tlsInit(PTLS ptls)
  130. {
  131. ZeroMemory(ptls, sizeof(TLS));
  132. }
  133. PTLS
  134. GetTlsPtr(void)
  135. {
  136. PTLS ptls = (PTLS)TlsGetValue(g.tlsIndex);
  137. if (!ptls) {
  138. ptls = (PTLS)MemAlloc(sizeof(TLS));
  139. if (ptls) {
  140. TlsSetValue(g.tlsIndex, ptls);
  141. tlsInit(ptls);
  142. }
  143. }
  144. assert(ptls);
  145. if (!ptls) {
  146. static TLS sos_tls;
  147. ptls = &sos_tls;
  148. }
  149. return ptls;
  150. }
  151. #endif // #ifdef BUILD_DBGHELP