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.

233 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. common.h
  4. constants and globals that are common to LODCTR and UNLODCTR
  5. Author:
  6. Bob Watson (a-robw) 10 Feb 93
  7. Revision History:
  8. --*/
  9. #ifndef _LODCTR_COMMON_H_
  10. #define _LODCTR_COMMON_H_
  11. //
  12. // Local constants
  13. //
  14. #define RESERVED 0L
  15. #define LARGE_BUFFER_SIZE 0x10000 // 64K
  16. #define MEDIUM_BUFFER_SIZE 0x8000 // 32K
  17. #define SMALL_BUFFER_SIZE 0x1000 // 4K
  18. #define FILE_NAME_BUFFER_SIZE MAX_PATH
  19. #define DISP_BUFF_SIZE 256L
  20. #define SIZE_OF_OFFSET_STRING 15
  21. #define PERFLIB_BASE_INDEX 1847
  22. #define FIRST_EXT_COUNTER_INDEX 1848
  23. #define FIRST_EXT_HELP_INDEX 1849
  24. #define H_MUTEX_TIMEOUT 10000L
  25. #define LODCTR_UPNF_RESTORE 0x00000001
  26. //
  27. // Data structure and type definitions
  28. //
  29. typedef struct _NAME_ENTRY {
  30. struct _NAME_ENTRY *pNext;
  31. DWORD dwOffset;
  32. DWORD dwType;
  33. LPTSTR lpText;
  34. } NAME_ENTRY, *PNAME_ENTRY;
  35. typedef struct _LANGUAGE_LIST_ELEMENT {
  36. struct _LANGUAGE_LIST_ELEMENT *pNextLang; // next lang. list
  37. LPTSTR LangId; // lang ID string for this elem
  38. PNAME_ENTRY pFirstName; // head of name list
  39. PNAME_ENTRY pThisName; // pointer to current entry
  40. DWORD dwNumElements; // number of elements in array
  41. DWORD dwNameBuffSize;
  42. DWORD dwHelpBuffSize;
  43. PBYTE NameBuffer; // buffer to store strings
  44. PBYTE HelpBuffer; // buffer to store help strings
  45. } LANGUAGE_LIST_ELEMENT, *PLANGUAGE_LIST_ELEMENT;
  46. typedef struct _SYMBOL_TABLE_ENTRY {
  47. struct _SYMBOL_TABLE_ENTRY *pNext;
  48. LPTSTR SymbolName;
  49. DWORD Value;
  50. } SYMBOL_TABLE_ENTRY, *PSYMBOL_TABLE_ENTRY;
  51. //
  52. // Utility Routine prototypes for routines in common.c
  53. //
  54. #define StringToInt(in,out) \
  55. (((_stscanf ((in), (LPCTSTR)TEXT(" %d"), (out))) == 1) ? TRUE : FALSE)
  56. //#define _LOADPERF_SHOW_MEM_ALLOC 1
  57. #define MemorySize(x) \
  58. ((x != NULL) ? (DWORD) HeapSize(GetProcessHeap(), 0, x) : (DWORD) 0)
  59. #ifndef _LOADPERF_SHOW_MEM_ALLOC
  60. #define MemoryAllocate(x) \
  61. ((LPVOID) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, x))
  62. #define MemoryFree(x) \
  63. ((VOID) HeapFree(GetProcessHeap(), 0, x))
  64. #define MemoryResize(x,y) \
  65. ((LPVOID) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, x, y));
  66. #else
  67. __inline
  68. LPVOID LoadPerfHeapAlloc(LPSTR szSource, DWORD dwLine, SIZE_T x)
  69. {
  70. LPVOID lpReturn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, x);
  71. #ifdef _WIN64
  72. DbgPrint("HeapAlloc(%s#%d)(%I64d,0x%08X)\n",
  73. szSource, dwLine, (lpReturn != NULL ? x : 0), lpReturn);
  74. #else
  75. DbgPrint("HeapAlloc(%s#%d)(%d,0x%08X)\n",
  76. szSource, dwLine, (lpReturn != NULL ? x : 0), lpReturn);
  77. #endif
  78. return lpReturn;
  79. }
  80. __inline
  81. BOOL
  82. LoadPerfHeapFree(LPSTR szSource, DWORD dwLine, LPVOID x)
  83. {
  84. BOOL bReturn = TRUE;
  85. SIZE_T dwSize;
  86. if (x != NULL) {
  87. dwSize = HeapSize(GetProcessHeap(), 0, x);
  88. bReturn = HeapFree(GetProcessHeap(), 0, x);
  89. #ifdef _WIN64
  90. DbgPrint("HeapFree(%s#%d)(0x%08X,%I64d)\n",
  91. szSource, dwLine, x, (bReturn ? dwSize : 0));
  92. #else
  93. DbgPrint("HeapFree(%s#%d)(0x%08X,%d)\n",
  94. szSource, dwLine, x, (bReturn ? dwSize : 0));
  95. #endif
  96. }
  97. return bReturn;
  98. }
  99. __inline
  100. LPVOID
  101. LoadPerfHeapReAlloc(LPSTR szSource, DWORD dwLine, LPVOID x, SIZE_T y)
  102. {
  103. LPVOID lpReturn;
  104. SIZE_T dwSize;
  105. dwSize = HeapSize(GetProcessHeap(), 0, x);
  106. lpReturn = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, x, y);
  107. #ifdef _WIN64
  108. DbgPrint("HeapReAlloc(%s#%d)(0x%08X,%I64d)(0x%08X,%I64d)\n",
  109. szSource, dwLine, x, dwSize, lpReturn, (lpReturn != NULL ? y : 0));
  110. #else
  111. DbgPrint("HeapReAlloc(%s#%d)(0x%08X,%d)(0x%08X,%d)\n",
  112. szSource, dwLine, x, dwSize, lpReturn, (lpReturn != NULL ? y : 0));
  113. #endif
  114. return lpReturn;
  115. }
  116. #define MemoryAllocate(x) LoadPerfHeapAlloc(__FILE__,__LINE__,x)
  117. #define MemoryFree(x) LoadPerfHeapFree(__FILE__,__LINE__,x)
  118. #define MemoryResize(x,y) LoadPerfHeapReAlloc(__FILE__,__LINE__,x,y)
  119. #endif
  120. LPCTSTR
  121. GetStringResource (
  122. UINT wStringId
  123. );
  124. LPCTSTR
  125. GetFormatResource (
  126. UINT wStringId
  127. );
  128. VOID
  129. DisplayCommandHelp (
  130. UINT iFirstLine,
  131. UINT iLastLine
  132. );
  133. BOOL
  134. TrimSpaces (
  135. IN OUT LPTSTR szString
  136. );
  137. BOOL
  138. IsDelimiter (
  139. IN TCHAR cChar,
  140. IN TCHAR cDelimiter
  141. );
  142. LPCTSTR
  143. GetItemFromString (
  144. IN LPCTSTR szEntry,
  145. IN DWORD dwItem,
  146. IN TCHAR cDelimiter
  147. );
  148. BOOLEAN LoadPerfGrabMutex();
  149. void
  150. ReportLoadPerfEvent(
  151. IN WORD EventType,
  152. IN DWORD EventID,
  153. IN DWORD dwDataCount,
  154. IN DWORD dwData1,
  155. IN DWORD dwData2,
  156. IN DWORD dwData3,
  157. IN DWORD dwData4,
  158. IN WORD wStringCount,
  159. IN LPWSTR szString1,
  160. IN LPWSTR szString2,
  161. IN LPWSTR szString3
  162. );
  163. // defined in dumpload.c
  164. DWORD
  165. BackupPerfRegistryToFileW (
  166. IN LPCWSTR szFileName,
  167. IN LPCWSTR szCommentString
  168. );
  169. DWORD
  170. RestorePerfRegistryFromFileW (
  171. IN LPCWSTR szFileName,
  172. IN LPCWSTR szLangId
  173. );
  174. extern LPCTSTR NamesKey;
  175. extern LPCTSTR DefaultLangId;
  176. extern LPCTSTR DefaultLangTag;
  177. extern LPCTSTR Counters;
  178. extern LPCTSTR Help;
  179. extern LPCTSTR LastHelp;
  180. extern LPCTSTR LastCounter;
  181. extern LPCTSTR FirstHelp;
  182. extern LPCTSTR cszFirstCounter;
  183. extern LPCTSTR Busy;
  184. extern LPCTSTR Slash;
  185. extern LPCTSTR BlankString;
  186. extern LPCTSTR DriverPathRoot;
  187. extern LPCTSTR Performance;
  188. extern LPCTSTR CounterNameStr;
  189. extern LPCTSTR HelpNameStr;
  190. extern LPCTSTR AddCounterNameStr;
  191. extern LPCTSTR AddHelpNameStr;
  192. extern LPCTSTR VersionStr;
  193. extern LPCTSTR szObjectList;
  194. extern LPCTSTR szLibraryValidationCode;
  195. extern LPCTSTR szDisplayName;
  196. extern LPCTSTR szPerfIniPath;
  197. extern HANDLE hEventLog;
  198. extern HANDLE hLoadPerfMutex;
  199. #endif // _LODCTR_COMMON_H_