ReactOS  0.4.15-dev-1150-g593bcce
cabinet.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS cabinet manager
4  * FILE: base/setup/usetup/cabinet.h
5  * PURPOSE: Cabinet definitions
6  */
7 #pragma once
8 
9 /* Cabinet structures */
10 
11 // Shadow types, implementation-specific
12 typedef struct _CFHEADER *PCFHEADER;
13 typedef struct _CFFOLDER *PCFFOLDER;
14 typedef struct _CFFILE *PCFFILE;
15 typedef struct _CFDATA *PCFDATA;
16 
17 struct _CABINET_CONTEXT;
18 
19 
20 /* Constants */
21 
22 /* Status codes */
23 #define CAB_STATUS_SUCCESS 0x00000000
24 #define CAB_STATUS_FAILURE 0x00000001
25 #define CAB_STATUS_NOMEMORY 0x00000002
26 #define CAB_STATUS_CANNOT_OPEN 0x00000003
27 #define CAB_STATUS_CANNOT_CREATE 0x00000004
28 #define CAB_STATUS_CANNOT_READ 0x00000005
29 #define CAB_STATUS_CANNOT_WRITE 0x00000006
30 #define CAB_STATUS_FILE_EXISTS 0x00000007
31 #define CAB_STATUS_INVALID_CAB 0x00000008
32 #define CAB_STATUS_NOFILE 0x00000009
33 #define CAB_STATUS_UNSUPPCOMP 0x0000000A
34 
35 
36 /* Codecs */
37 
38 typedef struct _CAB_CODEC *PCAB_CODEC;
39 
40 /* Codec status codes */
41 #define CS_SUCCESS 0x0000 /* All data consumed */
42 #define CS_NOMEMORY 0x0001 /* Not enough free memory */
43 #define CS_BADSTREAM 0x0002 /* Bad data stream */
44 
45 /* Codec identifiers */
46 #define CAB_CODEC_RAW 0x00
47 #define CAB_CODEC_LZX 0x01
48 #define CAB_CODEC_MSZIP 0x02
49 
50 
51 /* Event handler prototypes */
52 
54  IN struct _CABINET_CONTEXT* CabinetContext,
55  IN PCFFILE File,
57 
59  IN struct _CABINET_CONTEXT* CabinetContext,
60  IN PCFFILE File,
62 
64  IN struct _CABINET_CONTEXT* CabinetContext,
66  IN PCWSTR DiskLabel);
67 
69  IN struct _CABINET_CONTEXT* CabinetContext,
70  IN ULONG FileSize);
71 
72 /* Classes */
73 
74 typedef struct _CAB_SEARCH
75 {
76  WCHAR Search[MAX_PATH]; // Search criteria
79  PCFFILE File; // Pointer to current CFFILE
83 
84 typedef struct _CABINET_CONTEXT
85 {
86  WCHAR CabinetName[256]; // Filename of current cabinet
87  WCHAR CabinetPrev[256]; // Filename of previous cabinet
88  WCHAR DiskPrev[256]; // Label of cabinet in file CabinetPrev
89  WCHAR CabinetNext[256]; // Filename of next cabinet
90  WCHAR DiskNext[256]; // Label of cabinet in file CabinetNext
91  ULONG FolderUncompSize; // Uncompressed size of folder
92  ULONG BytesLeftInBlock; // Number of bytes left in current block
108  ULONG LastFileOffset; // Uncompressed offset of last extracted file
115 
116 
117 /* Default constructor */
118 VOID
120  IN OUT PCABINET_CONTEXT CabinetContext);
121 
122 /* Default destructor */
123 VOID
125  IN OUT PCABINET_CONTEXT CabinetContext);
126 
127 #if 0
128 /* Returns a pointer to the filename part of a fully qualified filename */
129 PWCHAR CabinetGetFileName(PWCHAR Path);
130 /* Removes a filename from a fully qualified filename */
131 VOID CabinetRemoveFileName(PWCHAR Path);
132 /* Normalizes a path */
134 #endif
135 
136 /* Returns name of cabinet file */
137 PCWSTR
139  IN PCABINET_CONTEXT CabinetContext);
140 
141 /* Sets the name of the cabinet file */
142 VOID
144  IN PCABINET_CONTEXT CabinetContext,
145  IN PCWSTR FileName);
146 
147 /* Sets destination path for extracted files */
148 VOID
150  IN PCABINET_CONTEXT CabinetContext,
151  IN PCWSTR DestinationPath);
152 
153 /* Returns destination path */
154 PCWSTR
156  IN PCABINET_CONTEXT CabinetContext);
157 
158 #if 0
159 /* Returns zero-based current disk number */
160 ULONG CabinetGetCurrentDiskNumber(VOID);
161 #endif
162 
163 /* Opens the current cabinet file */
164 ULONG
166  IN OUT PCABINET_CONTEXT CabinetContext);
167 
168 /* Closes the current open cabinet file */
169 VOID
171  IN OUT PCABINET_CONTEXT CabinetContext);
172 
173 /* Locates the first file in the current cabinet file that matches a search criteria */
174 ULONG
176  IN PCABINET_CONTEXT CabinetContext,
178  IN OUT PCAB_SEARCH Search);
179 
180 /* Locates the next file that matches the current search criteria */
181 ULONG
183  IN PCABINET_CONTEXT CabinetContext,
184  IN OUT PCAB_SEARCH Search);
185 
186 /* Locates the next file in the current cabinet file sequentially */
187 ULONG
189  IN PCABINET_CONTEXT CabinetContext,
191  IN OUT PCAB_SEARCH Search);
192 
193 /* Extracts a file from the current cabinet file */
194 ULONG
196  IN PCABINET_CONTEXT CabinetContext,
197  IN PCAB_SEARCH Search);
198 
199 /* Select codec engine to use */
200 VOID
202  IN PCABINET_CONTEXT CabinetContext,
203  IN ULONG Id);
204 
205 /* Set event handlers */
206 VOID
208  IN PCABINET_CONTEXT CabinetContext,
209  IN PCABINET_OVERWRITE Overwrite,
211  IN PCABINET_DISK_CHANGE DiskChange,
213 
214 /* Get pointer to cabinet reserved area. NULL if none */
215 PVOID
217  IN PCABINET_CONTEXT CabinetContext,
218  OUT PULONG Size);
PCWSTR CabinetGetCabinetName(IN PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:568
struct _CFFOLDER * PCFFOLDER
Definition: cabinet.h:13
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
VOID(* PCABINET_EXTRACT)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
Definition: cabinet.h:58
WCHAR Search[MAX_PATH]
Definition: cabinet.h:76
ULONG LastFileOffset
Definition: cabinet.h:108
PVOID CabinetReservedArea
Definition: cabinet.h:113
WCHAR Cabinet[MAX_PATH]
Definition: cabinet.h:77
struct _CFHEADER * PCFHEADER
Definition: cabinet.h:12
WCHAR DestPath[MAX_PATH]
Definition: cabinet.h:93
PCABINET_OVERWRITE OverwriteHandler
Definition: cabinet.h:109
unsigned char * PUCHAR
Definition: retypes.h:3
VOID(* PCABINET_DISK_CHANGE)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCWSTR CabinetName, IN PCWSTR DiskLabel)
Definition: cabinet.h:63
VOID CabinetSetEventHandlers(IN PCABINET_CONTEXT CabinetContext, IN PCABINET_OVERWRITE Overwrite, IN PCABINET_EXTRACT Extract, IN PCABINET_DISK_CHANGE DiskChange, IN PCABINET_CREATE_FILE CreateFile)
Definition: cabinet.c:1331
struct _CAB_SEARCH * PCAB_SEARCH
HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
Definition: cabinet_main.c:328
ULONG Offset
Definition: cabinet.h:81
VOID CabinetSetCabinetName(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName)
Definition: cabinet.c:580
struct _CFDATA * PCFDATA
Definition: cabinet.h:15
uint16_t * PWCHAR
Definition: typedefs.h:56
PVOID(* PCABINET_CREATE_FILE)(IN struct _CABINET_CONTEXT *CabinetContext, IN ULONG FileSize)
Definition: cabinet.h:68
SIZE_T DestFileSize
Definition: cabinet.h:97
#define BOOL
Definition: nt_native.h:43
WCHAR DiskNext[256]
Definition: cabinet.h:90
DWORD Id
PCABINET_CREATE_FILE CreateFileHandler
Definition: cabinet.h:112
SIZE_T FileSize
Definition: cabinet.h:98
ULONG FolderReserved
Definition: cabinet.h:103
struct _CABINET_CONTEXT CABINET_CONTEXT
PCWSTR CabinetGetDestinationPath(IN PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:609
unsigned int BOOL
Definition: ntddk_ex.h:94
PUCHAR FileBuffer
Definition: cabinet.h:96
_In_opt_ PVOID _In_ PCSTR File
Definition: iofuncs.h:615
ULONG DataReserved
Definition: cabinet.h:104
ULONG BytesLeftInBlock
Definition: cabinet.h:92
ULONG CabinetFindNextFileSequential(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:926
VOID CabinetClose(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:794
struct _CABINET_CONTEXT * PCABINET_CONTEXT
struct _CAB_SEARCH CAB_SEARCH
void * PVOID
Definition: retypes.h:9
ULONG CabinetExtractFile(IN PCABINET_CONTEXT CabinetContext, IN PCAB_SEARCH Search)
Definition: cabinet.c:952
VOID CabinetSetDestinationPath(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR DestinationPath)
Definition: cabinet.c:593
WCHAR CabinetPrev[256]
Definition: cabinet.h:87
PCABINET_EXTRACT ExtractHandler
Definition: cabinet.h:110
PCFFOLDER CabinetFolders
Definition: cabinet.h:101
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID CabinetCleanup(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:529
#define MAX_PATH
Definition: compat.h:34
struct _CFFILE * PCFFILE
Definition: cabinet.h:14
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG CabinetOpen(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:621
#define VOID
Definition: acefi.h:82
ULONG FolderUncompSize
Definition: cabinet.h:91
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
PVOID CabinetGetCabinetReservedArea(IN PCABINET_CONTEXT CabinetContext, OUT PULONG Size)
Definition: cabinet.c:1348
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
VOID CabinetInitialize(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:501
HANDLE FileHandle
Definition: cabinet.h:94
ULONG_PTR SIZE_T
Definition: typedefs.h:80
struct _FileName FileName
Definition: fatprocs.h:893
PCAB_CODEC Codec
Definition: cabinet.h:105
USHORT Index
Definition: cabinet.h:78
PCFHEADER PCABHeader
Definition: cabinet.h:100
PRTL_UNICODE_STRING_BUFFER Path
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
ULONG CabinetReserved
Definition: cabinet.h:102
unsigned short USHORT
Definition: pedump.c:61
BOOL CodecSelected
Definition: cabinet.h:107
struct _CAB_CODEC * PCAB_CODEC
Definition: cabinet.h:38
WCHAR CabinetNext[256]
Definition: cabinet.h:89
static BOOL CabinetNormalizePath(PWCHAR Path, ULONG Length)
Definition: cabinet.c:544
unsigned int * PULONG
Definition: retypes.h:1
PCFFILE File
Definition: cabinet.h:79
WCHAR CabinetName[256]
Definition: cabinet.h:86
ULONG CabinetFindNext(IN PCABINET_CONTEXT CabinetContext, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:833
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
VOID CabinetSelectCodec(IN PCABINET_CONTEXT CabinetContext, IN ULONG Id)
Definition: cabinet.c:1286
PCABINET_DISK_CHANGE DiskChangeHandler
Definition: cabinet.h:111
BOOL(* PCABINET_OVERWRITE)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
Definition: cabinet.h:53
PCFDATA CFData
Definition: cabinet.h:80
WCHAR DiskPrev[256]
Definition: cabinet.h:88
ULONG CabinetFindFirst(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:813
HANDLE FileSectionHandle
Definition: cabinet.h:95