ReactOS  0.4.13-dev-247-g0f29b3f
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 
68 
69 /* Classes */
70 
71 typedef struct _CAB_SEARCH
72 {
73  WCHAR Search[MAX_PATH]; // Search criteria
76  PCFFILE File; // Pointer to current CFFILE
80 
81 typedef struct _CABINET_CONTEXT
82 {
83  WCHAR CabinetName[256]; // Filename of current cabinet
84  WCHAR CabinetPrev[256]; // Filename of previous cabinet
85  WCHAR DiskPrev[256]; // Label of cabinet in file CabinetPrev
86  WCHAR CabinetNext[256]; // Filename of next cabinet
87  WCHAR DiskNext[256]; // Label of cabinet in file CabinetNext
88  ULONG FolderUncompSize; // Uncompressed size of folder
89  ULONG BytesLeftInBlock; // Number of bytes left in current block
105  ULONG LastFileOffset; // Uncompressed offset of last extracted file
111 
112 
113 /* Default constructor */
114 VOID
116  IN OUT PCABINET_CONTEXT CabinetContext);
117 
118 /* Default destructor */
119 VOID
121  IN OUT PCABINET_CONTEXT CabinetContext);
122 
123 #if 0
124 /* Returns a pointer to the filename part of a fully qualified filename */
125 PWCHAR CabinetGetFileName(PWCHAR Path);
126 /* Removes a filename from a fully qualified filename */
127 VOID CabinetRemoveFileName(PWCHAR Path);
128 /* Normalizes a path */
130 #endif
131 
132 /* Returns name of cabinet file */
133 PCWSTR
135  IN PCABINET_CONTEXT CabinetContext);
136 
137 /* Sets the name of the cabinet file */
138 VOID
140  IN PCABINET_CONTEXT CabinetContext,
141  IN PCWSTR FileName);
142 
143 /* Sets destination path for extracted files */
144 VOID
146  IN PCABINET_CONTEXT CabinetContext,
147  IN PCWSTR DestinationPath);
148 
149 /* Returns destination path */
150 PCWSTR
152  IN PCABINET_CONTEXT CabinetContext);
153 
154 #if 0
155 /* Returns zero-based current disk number */
156 ULONG CabinetGetCurrentDiskNumber(VOID);
157 #endif
158 
159 /* Opens the current cabinet file */
160 ULONG
162  IN OUT PCABINET_CONTEXT CabinetContext);
163 
164 /* Closes the current open cabinet file */
165 VOID
167  IN OUT PCABINET_CONTEXT CabinetContext);
168 
169 /* Locates the first file in the current cabinet file that matches a search criteria */
170 ULONG
172  IN PCABINET_CONTEXT CabinetContext,
174  IN OUT PCAB_SEARCH Search);
175 
176 /* Locates the next file that matches the current search criteria */
177 ULONG
179  IN PCABINET_CONTEXT CabinetContext,
180  IN OUT PCAB_SEARCH Search);
181 
182 /* Locates the next file in the current cabinet file sequentially */
183 ULONG
185  IN PCABINET_CONTEXT CabinetContext,
187  IN OUT PCAB_SEARCH Search);
188 
189 /* Extracts a file from the current cabinet file */
190 ULONG
192  IN PCABINET_CONTEXT CabinetContext,
193  IN PCAB_SEARCH Search);
194 
195 /* Select codec engine to use */
196 VOID
198  IN PCABINET_CONTEXT CabinetContext,
199  IN ULONG Id);
200 
201 /* Set event handlers */
202 VOID
204  IN PCABINET_CONTEXT CabinetContext,
205  IN PCABINET_OVERWRITE Overwrite,
207  IN PCABINET_DISK_CHANGE DiskChange);
208 
209 /* Get pointer to cabinet reserved area. NULL if none */
210 PVOID
212  IN PCABINET_CONTEXT CabinetContext,
213  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:55
#define IN
Definition: typedefs.h:38
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:73
ULONG LastFileOffset
Definition: cabinet.h:105
PVOID CabinetReservedArea
Definition: cabinet.h:109
WCHAR Cabinet[MAX_PATH]
Definition: cabinet.h:74
struct _CFHEADER * PCFHEADER
Definition: cabinet.h:12
WCHAR DestPath[MAX_PATH]
Definition: cabinet.h:90
PCABINET_OVERWRITE OverwriteHandler
Definition: cabinet.h:106
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
struct _CAB_SEARCH * PCAB_SEARCH
HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
Definition: cabinet_main.c:328
ULONG Offset
Definition: cabinet.h:78
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:54
SIZE_T DestFileSize
Definition: cabinet.h:94
#define BOOL
Definition: nt_native.h:43
WCHAR DiskNext[256]
Definition: cabinet.h:87
DWORD Id
SIZE_T FileSize
Definition: cabinet.h:95
ULONG FolderReserved
Definition: cabinet.h:100
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:93
_In_opt_ PVOID _In_ PCSTR File
Definition: iofuncs.h:615
ULONG DataReserved
Definition: cabinet.h:101
ULONG BytesLeftInBlock
Definition: cabinet.h:89
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
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:84
PCABINET_EXTRACT ExtractHandler
Definition: cabinet.h:107
PCFFOLDER CabinetFolders
Definition: cabinet.h:98
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID CabinetCleanup(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:529
#define MAX_PATH
Definition: compat.h:26
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:88
PVOID CabinetGetCabinetReservedArea(IN PCABINET_CONTEXT CabinetContext, OUT PULONG Size)
Definition: cabinet.c:1330
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
VOID CabinetInitialize(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:501
HANDLE FileHandle
Definition: cabinet.h:91
ULONG_PTR SIZE_T
Definition: typedefs.h:78
struct _FileName FileName
Definition: fatprocs.h:884
PCAB_CODEC Codec
Definition: cabinet.h:102
USHORT Index
Definition: cabinet.h:75
PCFHEADER PCABHeader
Definition: cabinet.h:97
PRTL_UNICODE_STRING_BUFFER Path
ULONG CabinetReserved
Definition: cabinet.h:99
unsigned short USHORT
Definition: pedump.c:61
BOOL CodecSelected
Definition: cabinet.h:104
struct _CAB_CODEC * PCAB_CODEC
Definition: cabinet.h:38
WCHAR CabinetNext[256]
Definition: cabinet.h:86
static BOOL CabinetNormalizePath(PWCHAR Path, ULONG Length)
Definition: cabinet.c:544
VOID CabinetSetEventHandlers(IN PCABINET_CONTEXT CabinetContext, IN PCABINET_OVERWRITE Overwrite, IN PCABINET_EXTRACT Extract, IN PCABINET_DISK_CHANGE DiskChange)
Definition: cabinet.c:1315
unsigned int * PULONG
Definition: retypes.h:1
PCFFILE File
Definition: cabinet.h:76
WCHAR CabinetName[256]
Definition: cabinet.h:83
ULONG CabinetFindNext(IN PCABINET_CONTEXT CabinetContext, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:833
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
VOID CabinetSelectCodec(IN PCABINET_CONTEXT CabinetContext, IN ULONG Id)
Definition: cabinet.c:1270
PCABINET_DISK_CHANGE DiskChangeHandler
Definition: cabinet.h:108
BOOL(* PCABINET_OVERWRITE)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
Definition: cabinet.h:53
PCFDATA CFData
Definition: cabinet.h:77
WCHAR DiskPrev[256]
Definition: cabinet.h:85
ULONG CabinetFindFirst(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:813
HANDLE FileSectionHandle
Definition: cabinet.h:92