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.

400 lines
8.4 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. sputils.w (generates sputils.h)
  5. Abstract:
  6. Header file for utility routines used primarily by setupapi that's also
  7. used by other components for convinience.
  8. Link to either sputils.lib (static version) or spapip.lib (dll version)
  9. For internal use only.
  10. Author:
  11. Jamie Hunter (jamiehun) Jun-26-2000
  12. Revision History:
  13. --*/
  14. #if defined(SPUTILSW) && defined(UNICODE)
  15. //
  16. // SPUTILSW.LIB is cut down version of SPUTILSU.LIB
  17. // with renamed API's
  18. // thus SPUTILSW.LIB can be used with SPUTILSA.LIB
  19. //
  20. #define pSetupDebugPrintEx pSetupDebugPrintExW
  21. #define pSetupStringTableInitialize pSetupStringTableInitializeW
  22. #define pSetupStringTableInitializeEx pSetupStringTableInitializeExW
  23. #define pSetupStringTableDestroy pSetupStringTableDestroyW
  24. #define pSetupStringTableAddString pSetupStringTableAddStringW
  25. #define pSetupStringTableAddStringEx pSetupStringTableAddStringExW
  26. #define pSetupStringTableLookUpString pSetupStringTableLookUpStringW
  27. #define pSetupStringTableLookUpStringEx pSetupStringTableLookUpStringExW
  28. #define pSetupStringTableGetExtraData pSetupStringTableGetExtraDataW
  29. #define pSetupStringTableSetExtraData pSetupStringTableSetExtraDataW
  30. #define PSTRTAB_ENUM_ROUTINE PSTRTAB_ENUM_ROUTINE_W
  31. #define pSetupStringTableEnum pSetupStringTableEnumW
  32. #define pSetupStringTableStringFromId pSetupStringTableStringFromIdW
  33. #define pSetupStringTableStringFromIdEx pSetupStringTableStringFromIdExW
  34. #define pSetupStringTableDuplicate pSetupStringTableDuplicateW
  35. //
  36. // fileutil.c
  37. //
  38. #define pSetupOpenAndMapFileForRead pSetupOpenAndMapFileForReadW
  39. #define pSetupFileExists pSetupFileExistsW
  40. #define pSetupMakeSurePathExists pSetupMakeSurePathExistsW
  41. #define pSetupDoesUserHavePrivilege pSetupDoesUserHavePrivilegeW
  42. #define pSetupEnablePrivilege pSetupEnablePrivilegeW
  43. #define pSetupRegistryDelnode pSetupRegistryDelnodeW
  44. #define pSetupRegistryDelnodeEx pSetupRegistryDelnodeExW
  45. //
  46. // miscutil.c
  47. //
  48. #define pSetupDuplicateString pSetupDuplicateStringW
  49. #define pSetupCaptureAndConvertAnsiArg pSetupCaptureAndConvertAnsiArgW
  50. #define pSetupConcatenatePaths pSetupConcatenatePathsW
  51. #define pSetupGetFileTitle pSetupGetFileTitleW
  52. #endif // SPUTILSW && UNICODE
  53. //
  54. //
  55. //
  56. // Initialization - must be called to use the tools (static version only)
  57. //
  58. BOOL
  59. pSetupInitializeUtils(
  60. VOID
  61. );
  62. BOOL
  63. pSetupUninitializeUtils(
  64. VOID
  65. );
  66. //
  67. // Memory allocation functions (also used by other functions below)
  68. //
  69. PVOID
  70. pSetupMalloc(
  71. IN DWORD Size
  72. );
  73. PVOID
  74. pSetupDebugMalloc(
  75. IN DWORD Size,
  76. IN PCSTR Filename,
  77. IN DWORD Line
  78. );
  79. PVOID
  80. pSetupDebugMallocWithTag(
  81. IN DWORD Size,
  82. IN PCSTR Filename,
  83. IN DWORD Line,
  84. IN DWORD Tag
  85. );
  86. PVOID
  87. pSetupRealloc(
  88. IN PVOID Block,
  89. IN DWORD NewSize
  90. );
  91. PVOID
  92. pSetupReallocWithTag(
  93. IN PVOID Block,
  94. IN DWORD NewSize,
  95. IN DWORD Tag
  96. );
  97. VOID
  98. pSetupFree(
  99. IN CONST VOID *Block
  100. );
  101. VOID
  102. pSetupFreeWithTag(
  103. IN CONST VOID *Block,
  104. IN DWORD Tag
  105. );
  106. VOID
  107. pSetupDebugPrintEx(
  108. DWORD Level,
  109. PCTSTR format,
  110. ... OPTIONAL
  111. );
  112. HANDLE
  113. pSetupGetHeap(
  114. VOID
  115. );
  116. #if DBG
  117. #define pSetupCheckedMalloc(Size) pSetupDebugMalloc(Size,__FILE__,__LINE__)
  118. #define pSetupMallocWithTag(Size,Tag) pSetupDebugMallocWithTag(Size,__FILE__,__LINE__,Tag)
  119. #else
  120. #define pSetupCheckedMalloc(Size) pSetupMalloc(Size)
  121. #define pSetupMallocWithTag(Size,Tag) pSetupMalloc(Size)
  122. #endif
  123. #if DBG
  124. #define pSetupCheckInternalHeap() pSetupHeapCheck()
  125. #else
  126. #define pSetupCheckInternalHeap()
  127. #endif
  128. //
  129. // String table functions
  130. //
  131. PVOID
  132. pSetupStringTableInitialize(
  133. VOID
  134. );
  135. PVOID
  136. pSetupStringTableInitializeEx(
  137. IN UINT ExtraDataSize, OPTIONAL
  138. IN UINT Reserved
  139. );
  140. VOID
  141. pSetupStringTableDestroy(
  142. IN PVOID StringTable
  143. );
  144. //
  145. // Flags to be used by pSetupStringTableAddString and pSetupStringTableLookUpString
  146. //
  147. #define STRTAB_CASE_INSENSITIVE 0x00000000
  148. #define STRTAB_CASE_SENSITIVE 0x00000001
  149. #define STRTAB_BUFFER_WRITEABLE 0x00000002
  150. #define STRTAB_NEW_EXTRADATA 0x00000004
  151. LONG
  152. pSetupStringTableAddString(
  153. IN PVOID StringTable,
  154. IN OUT PTSTR String,
  155. IN DWORD Flags
  156. );
  157. LONG
  158. pSetupStringTableAddStringEx(
  159. IN PVOID StringTable,
  160. IN PTSTR String,
  161. IN DWORD Flags,
  162. IN PVOID ExtraData, OPTIONAL
  163. IN UINT ExtraDataSize OPTIONAL
  164. );
  165. LONG
  166. pSetupStringTableLookUpString(
  167. IN PVOID StringTable,
  168. IN OUT PTSTR String,
  169. IN DWORD Flags
  170. );
  171. LONG
  172. pSetupStringTableLookUpStringEx(
  173. IN PVOID StringTable,
  174. IN OUT PTSTR String,
  175. IN DWORD Flags,
  176. OUT PVOID ExtraData, OPTIONAL
  177. IN UINT ExtraDataBufferSize OPTIONAL
  178. );
  179. BOOL
  180. pSetupStringTableGetExtraData(
  181. IN PVOID StringTable,
  182. IN LONG StringId,
  183. OUT PVOID ExtraData,
  184. IN UINT ExtraDataBufferSize
  185. );
  186. BOOL
  187. pSetupStringTableSetExtraData(
  188. IN PVOID StringTable,
  189. IN LONG StringId,
  190. IN PVOID ExtraData,
  191. IN UINT ExtraDataSize
  192. );
  193. //
  194. // Type for pSetupStringTableEnum
  195. //
  196. typedef
  197. BOOL
  198. (*PSTRTAB_ENUM_ROUTINE)(
  199. IN PVOID StringTable,
  200. IN LONG StringId,
  201. IN PCTSTR String,
  202. IN PVOID ExtraData,
  203. IN UINT ExtraDataSize,
  204. IN LPARAM lParam
  205. );
  206. BOOL
  207. pSetupStringTableEnum(
  208. IN PVOID StringTable,
  209. OUT PVOID ExtraDataBuffer, OPTIONAL
  210. IN UINT ExtraDataBufferSize, OPTIONAL
  211. IN PSTRTAB_ENUM_ROUTINE Callback,
  212. IN LPARAM lParam OPTIONAL
  213. );
  214. PTSTR
  215. pSetupStringTableStringFromId(
  216. IN PVOID StringTable,
  217. IN LONG StringId
  218. );
  219. BOOL
  220. pSetupStringTableStringFromIdEx(
  221. IN PVOID StringTable,
  222. IN LONG StringId,
  223. IN OUT PTSTR pBuffer,
  224. IN OUT PULONG pBufSize
  225. );
  226. PVOID
  227. pSetupStringTableDuplicate(
  228. IN PVOID StringTable
  229. );
  230. //
  231. // File functions in fileutil.c
  232. //
  233. DWORD
  234. pSetupOpenAndMapFileForRead(
  235. IN PCTSTR FileName,
  236. OUT PDWORD FileSize,
  237. OUT PHANDLE FileHandle,
  238. OUT PHANDLE MappingHandle,
  239. OUT PVOID *BaseAddress
  240. );
  241. DWORD
  242. pSetupMapFileForRead(
  243. IN HANDLE FileHandle,
  244. OUT PDWORD FileSize,
  245. OUT PHANDLE MappingHandle,
  246. OUT PVOID *BaseAddress
  247. );
  248. BOOL
  249. pSetupUnmapAndCloseFile(
  250. IN HANDLE FileHandle,
  251. IN HANDLE MappingHandle,
  252. IN PVOID BaseAddress
  253. );
  254. DWORD
  255. pSetupMakeSurePathExists(
  256. IN PCTSTR FullFilespec
  257. );
  258. BOOL
  259. pSetupFileExists(
  260. IN PCTSTR FileName,
  261. OUT PWIN32_FIND_DATA FindData OPTIONAL
  262. );
  263. //
  264. // Non-file-related security routines in security.c.
  265. //
  266. BOOL
  267. pSetupIsUserAdmin(
  268. VOID
  269. );
  270. BOOL
  271. pSetupDoesUserHavePrivilege(
  272. PCTSTR PrivilegeName
  273. );
  274. BOOL
  275. pSetupEnablePrivilege(
  276. IN PCTSTR PrivilegeName,
  277. IN BOOL Enable
  278. );
  279. BOOL
  280. pSetupIsLocalSystem(
  281. VOID
  282. );
  283. //
  284. // Registry utility functions
  285. //
  286. DWORD
  287. pSetupRegistryDelnode(
  288. IN HKEY RootKey,
  289. IN PCTSTR SubKeyName
  290. );
  291. DWORD
  292. pSetupRegistryDelnodeEx(
  293. IN HKEY RootKey,
  294. IN PCTSTR SubKeyName,
  295. IN DWORD ExtraFlags
  296. );
  297. //
  298. // Miscellaneous utility functions
  299. //
  300. DWORD
  301. pSetupCaptureAndConvertAnsiArg(
  302. IN PCSTR AnsiString,
  303. OUT PCWSTR *UnicodeString
  304. );
  305. PTSTR
  306. pSetupDuplicateString(
  307. IN PCTSTR String
  308. );
  309. PSTR
  310. pSetupUnicodeToMultiByte(
  311. IN PCWSTR UnicodeString,
  312. IN UINT Codepage
  313. );
  314. PWSTR
  315. pSetupMultiByteToUnicode(
  316. IN PCSTR String,
  317. IN UINT Codepage
  318. );
  319. VOID
  320. pSetupCenterWindowRelativeToParent(
  321. HWND hwnd
  322. );
  323. #define pSetupUnicodeToAnsi(UnicodeString) pSetupUnicodeToMultiByte((UnicodeString),CP_ACP)
  324. #define pSetupUnicodeToOem(UnicodeString) pSetupUnicodeToMultiByte((UnicodeString),CP_OEMCP)
  325. #define pSetupAnsiToUnicode(AnsiString) pSetupMultiByteToUnicode((AnsiString),CP_ACP)
  326. #define pSetupOemToUnicode(OemString) pSetupMultiByteToUnicode((OemString),CP_OEMCP)
  327. BOOL
  328. pSetupConcatenatePaths(
  329. IN OUT PTSTR Target,
  330. IN PCTSTR Path,
  331. IN UINT TargetBufferSize,
  332. OUT PUINT RequiredSize
  333. );
  334. PCTSTR
  335. pSetupGetFileTitle(
  336. IN PCTSTR FilePath
  337. );