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.

293 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. spcab.h
  5. Abstract:
  6. Kernel mode support for cabbing files, esp. for Win9x uninstall.
  7. Author:
  8. 20-Oct-1999 Ovidiu Temereanca (ovidiut) - File creation.
  9. Revision History:
  10. November 2000 Jay Krell (a-JayK)
  11. ported from windows\winstate\cobra\utils\inc\cablib.h
  12. --*/
  13. #pragma once
  14. #include "spmemory.h"
  15. // this is a bit of an interface boundary crossing hack, but only experimental at the moment
  16. #define sptcompTYPE_MSZIP_BIG_FILES_NONE_SMALL_FILES 0x0004
  17. //
  18. // Types
  19. //
  20. typedef BOOL(NTAPI CABGETCABINETNAMESA)(
  21. IN PCSTR CabPath,
  22. IN UINT CabPathChars,
  23. IN PCSTR CabFileName,
  24. IN UINT CabFileNameChars,
  25. IN PCSTR CabDiskName,
  26. IN UINT CabDiskNameChars,
  27. IN INT CabFileNr,
  28. IN OUT PINT CabDiskNr
  29. );
  30. typedef CABGETCABINETNAMESA *PCABGETCABINETNAMESA;
  31. typedef BOOL(NTAPI CABGETCABINETNAMESW)(
  32. IN PCWSTR CabPath,
  33. IN UINT CabPathChars,
  34. IN PCWSTR CabFileName,
  35. IN UINT CabFileNameChars,
  36. IN PCWSTR CabDiskName,
  37. IN UINT CabDiskNameChars,
  38. IN INT CabFileNr,
  39. IN OUT PINT CabDiskNr
  40. );
  41. typedef CABGETCABINETNAMESW *PCABGETCABINETNAMESW;
  42. typedef BOOL(NTAPI CABNOTIFICATIONA)(
  43. IN PCSTR FileName
  44. );
  45. typedef CABNOTIFICATIONA *PCABNOTIFICATIONA;
  46. typedef BOOL(NTAPI CABNOTIFICATIONW)(
  47. IN PCWSTR FileName
  48. );
  49. typedef CABNOTIFICATIONW *PCABNOTIFICATIONW;
  50. typedef PVOID OCABHANDLE;
  51. struct _FCI_CAB_HANDLE;
  52. typedef struct _FCI_CAB_HANDLE* PFCI_CAB_HANDLE;
  53. typedef PFCI_CAB_HANDLE CCABHANDLE;
  54. //
  55. // API
  56. //
  57. CCABHANDLE
  58. SpCabCreateCabinetA(
  59. IN PCSTR CabPath,
  60. IN PCSTR CabFileFormat,
  61. IN PCSTR CabDiskFormat,
  62. IN LONG MaxFileSize
  63. );
  64. CCABHANDLE
  65. SpCabCreateCabinetW(
  66. IN PCWSTR CabPath,
  67. IN PCWSTR CabFileFormat,
  68. IN PCWSTR CabDiskFormat,
  69. IN LONG MaxFileSize
  70. );
  71. CCABHANDLE
  72. SpCabCreateCabinetExA(
  73. IN PCABGETCABINETNAMESA CabGetCabinetNames,
  74. IN LONG MaxFileSize
  75. );
  76. CCABHANDLE
  77. SpCabCreateCabinetExW(
  78. IN PCABGETCABINETNAMESW CabGetCabinetNames,
  79. IN LONG MaxFileSize
  80. );
  81. NTSTATUS
  82. SpCabAddFileToCabinetW(
  83. IN CCABHANDLE CabHandle,
  84. IN PCWSTR FileName,
  85. IN PCWSTR StoredName
  86. );
  87. BOOL
  88. SpCabFlushAndCloseCabinetEx(
  89. IN CCABHANDLE CabHandle,
  90. OUT PUINT FileCount, OPTIONAL
  91. OUT PLONGLONG FileSize, OPTIONAL
  92. OUT PUINT CabFileCount, OPTIONAL
  93. OUT PLONGLONG CabFileSize OPTIONAL
  94. );
  95. BOOL
  96. SpCabFlushAndCloseCabinet(
  97. IN CCABHANDLE CabHandle
  98. );
  99. OCABHANDLE
  100. SpCabOpenCabinetA(
  101. IN PCSTR FileName
  102. );
  103. OCABHANDLE
  104. SpCabOpenCabinetW(
  105. IN PCWSTR FileName
  106. );
  107. BOOL
  108. SpCabExtractAllFilesExA(
  109. IN OCABHANDLE CabHandle,
  110. IN PCSTR ExtractPath,
  111. IN PCABNOTIFICATIONA CabNotification OPTIONAL
  112. );
  113. BOOL
  114. SpCabExtractAllFilesA(
  115. IN OCABHANDLE CabHandle,
  116. IN PCSTR ExtractPath
  117. );
  118. BOOL
  119. SpCabExtractAllFilesExW(
  120. IN OCABHANDLE CabHandle,
  121. IN PCWSTR ExtractPath,
  122. IN PCABNOTIFICATIONW CabNotification OPTIONAL
  123. );
  124. BOOL
  125. SpCabExtractAllFilesW(
  126. IN OCABHANDLE CabHandle,
  127. IN PCWSTR ExtractPath
  128. );
  129. BOOL
  130. SpCabCloseCabinet(
  131. IN OCABHANDLE CabHandle
  132. );
  133. VOID
  134. SpFreeStringW(
  135. PUNICODE_STRING String
  136. );
  137. VOID
  138. SpFreeStringA(
  139. PANSI_STRING String
  140. );
  141. NTSTATUS
  142. SpConvertToNulTerminatedNtStringsA(
  143. PCSTR Ansi,
  144. PANSI_STRING AnsiString OPTIONAL,
  145. PUNICODE_STRING UnicodeString OPTIONAL
  146. );
  147. NTSTATUS
  148. SpConvertToNulTerminatedNtStringsW(
  149. PCWSTR Unicode,
  150. PANSI_STRING AnsiString OPTIONAL,
  151. PUNICODE_STRING UnicodeString OPTIONAL
  152. );
  153. VOID
  154. SpStringCopyNA(
  155. PSTR Dest,
  156. PCSTR Source,
  157. SIZE_T Max
  158. );
  159. VOID
  160. SpStringCopyNW(
  161. PWSTR Dest,
  162. PCWSTR Source,
  163. SIZE_T Max
  164. );
  165. VOID
  166. SpMoveStringA(
  167. PANSI_STRING Dest,
  168. PANSI_STRING Source
  169. );
  170. VOID
  171. SpMoveStringW(
  172. PUNICODE_STRING Dest,
  173. PUNICODE_STRING Source
  174. );
  175. BOOL
  176. SpCabFlushAndCloseCabinet(
  177. IN CCABHANDLE CabHandle
  178. );
  179. BOOL
  180. SpCabCloseCabinet(
  181. IN OCABHANDLE CabHandle
  182. );
  183. NTSTATUS
  184. SpCreateDirectoryForFileA(
  185. IN PCSTR FilePathA,
  186. IN ULONG CreateFlags
  187. );
  188. #define SpBoolToDbgPrintLevel(f) ((f) ? DPFLTR_TRACE_LEVEL : DPFLTR_ERROR_LEVEL)
  189. #define SpBoolToStringA(f) ((f) ? "true" : "false")
  190. #define SpPointerToDbgPrintLevel(p) DPFLTR_TRACE_LEVEL/*(((p) != NULL && (p) != LongToPtr(-1)) ? DPFLTR_TRACE_LEVEL : DPFLTR_ERROR_LEVEL)*/
  191. #define SpHandleToDbgPrintLevel(h) DPFLTR_TRACE_LEVEL/*(((h) != NULL && (h) != LongToPtr(-1)) ? DPFLTR_TRACE_LEVEL : DPFLTR_ERROR_LEVEL)*/
  192. #define SpNtStatusToDbgPrintLevel(s) \
  193. ((NT_SUCCESS(s) \
  194. || (s) == STATUS_NO_SUCH_FILE \
  195. || (s) == STATUS_OBJECT_PATH_NOT_FOUND \
  196. || (s) == STATUS_OBJECT_NAME_NOT_FOUND \
  197. || (s) == STATUS_NOT_FOUND \
  198. ) ? DPFLTR_TRACE_LEVEL : DPFLTR_ERROR_LEVEL)
  199. #define SpBooleanToStringA(x) ((x) ? "True" : "False")
  200. #define SpBooleanToStringW(x) ((x) ? L"True" : L"False")
  201. NTSTATUS
  202. SpAnsiStringToUnicodeString(
  203. PUNICODE_STRING DestinationStringW,
  204. PCANSI_STRING SourceStringA,
  205. BOOL Allocate
  206. );
  207. NTSTATUS
  208. SpUnicodeStringToAnsiString(
  209. PANSI_STRING DestinationStringA,
  210. PCUNICODE_STRING SourceStringW,
  211. BOOL Allocate
  212. );
  213. NTSTATUS
  214. SpKnownSizeUnicodeToDbcsN(
  215. OUT PSTR Ansi,
  216. IN PCWSTR Unicode,
  217. IN SIZE_T AnsiSize
  218. );
  219. VOID
  220. SpEnsureTrailingBackSlashA(
  221. IN PSTR str
  222. );
  223. PCWSTR
  224. SpGetFileNameFromPathW(
  225. IN PCWSTR PathSpec
  226. );
  227. PSTR
  228. SpJoinPathsA(
  229. PCSTR a,
  230. PCSTR b
  231. );
  232. HANDLE
  233. SpOpenFile1W(
  234. IN PCWSTR FileName
  235. );
  236. HANDLE
  237. SpCreateFile1A(
  238. IN PCSTR FileName
  239. );