ReactOS 0.4.16-dev-297-gc569aee
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
12typedef struct _CFHEADER *PCFHEADER;
13typedef struct _CFFOLDER *PCFFOLDER;
14typedef struct _CFFILE *PCFFILE;
15typedef struct _CFDATA *PCFDATA;
16
17struct _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
38typedef 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,
57
59 IN struct _CABINET_CONTEXT* CabinetContext,
62
64 IN struct _CABINET_CONTEXT* CabinetContext,
66 IN PCWSTR DiskLabel);
67
69 IN struct _CABINET_CONTEXT* CabinetContext,
71
72/* Classes */
73
74typedef struct _CAB_SEARCH
75{
76 WCHAR Search[MAX_PATH]; // Search criteria
79 PCFFILE File; // Pointer to current CFFILE
83
84typedef 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 */
118VOID
120 IN OUT PCABINET_CONTEXT CabinetContext);
121
122/* Default destructor */
123VOID
125 IN OUT PCABINET_CONTEXT CabinetContext);
126
127#if 0
128/* Returns a pointer to the filename part of a fully qualified filename */
129PWCHAR CabinetGetFileName(PWCHAR Path);
130/* Removes a filename from a fully qualified filename */
131VOID CabinetRemoveFileName(PWCHAR Path);
132/* Normalizes a path */
134#endif
135
136/* Returns name of cabinet file */
137PCWSTR
139 IN PCABINET_CONTEXT CabinetContext);
140
141/* Sets the name of the cabinet file */
142VOID
144 IN PCABINET_CONTEXT CabinetContext,
146
147/* Sets destination path for extracted files */
148VOID
150 IN PCABINET_CONTEXT CabinetContext,
151 IN PCWSTR DestinationPath);
152
153/* Returns destination path */
154PCWSTR
156 IN PCABINET_CONTEXT CabinetContext);
157
158#if 0
159/* Returns zero-based current disk number */
160ULONG CabinetGetCurrentDiskNumber(VOID);
161#endif
162
163/* Opens the current cabinet file */
164ULONG
166 IN OUT PCABINET_CONTEXT CabinetContext);
167
168/* Closes the current open cabinet file */
169VOID
171 IN OUT PCABINET_CONTEXT CabinetContext);
172
173/* Locates the first file in the current cabinet file that matches a search criteria */
174ULONG
176 IN PCABINET_CONTEXT CabinetContext,
178 IN OUT PCAB_SEARCH Search);
179
180/* Locates the next file that matches the current search criteria */
181ULONG
183 IN PCABINET_CONTEXT CabinetContext,
184 IN OUT PCAB_SEARCH Search);
185
186/* Locates the next file in the current cabinet file sequentially */
187ULONG
189 IN PCABINET_CONTEXT CabinetContext,
191 IN OUT PCAB_SEARCH Search);
192
193/* Extracts a file from the current cabinet file */
194ULONG
196 IN PCABINET_CONTEXT CabinetContext,
197 IN PCAB_SEARCH Search);
198
199/* Select codec engine to use */
200VOID
202 IN PCABINET_CONTEXT CabinetContext,
203 IN ULONG Id);
204
205/* Set event handlers */
206VOID
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 */
215PVOID
217 IN PCABINET_CONTEXT CabinetContext,
218 OUT PULONG Size);
DWORD Id
PRTL_UNICODE_STRING_BUFFER Path
#define VOID
Definition: acefi.h:82
ULONG CabinetOpen(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:627
struct _CAB_CODEC * PCAB_CODEC
Definition: cabinet.h:38
struct _CFDATA * PCFDATA
Definition: cabinet.h:15
PCWSTR CabinetGetDestinationPath(IN PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:615
VOID(* PCABINET_DISK_CHANGE)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCWSTR CabinetName, IN PCWSTR DiskLabel)
Definition: cabinet.h:63
ULONG CabinetFindFirst(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:826
struct _CAB_SEARCH * PCAB_SEARCH
VOID CabinetClose(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:807
struct _CFHEADER * PCFHEADER
Definition: cabinet.h:12
ULONG CabinetFindNext(IN PCABINET_CONTEXT CabinetContext, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:846
VOID(* PCABINET_EXTRACT)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
Definition: cabinet.h:58
struct _CAB_SEARCH CAB_SEARCH
PCWSTR CabinetGetCabinetName(IN PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:574
struct _CABINET_CONTEXT CABINET_CONTEXT
VOID CabinetSelectCodec(IN PCABINET_CONTEXT CabinetContext, IN ULONG Id)
Definition: cabinet.c:1310
PVOID CabinetGetCabinetReservedArea(IN PCABINET_CONTEXT CabinetContext, OUT PULONG Size)
Definition: cabinet.c:1372
ULONG CabinetExtractFile(IN PCABINET_CONTEXT CabinetContext, IN PCAB_SEARCH Search)
Definition: cabinet.c:965
struct _CFFILE * PCFFILE
Definition: cabinet.h:14
BOOL(* PCABINET_OVERWRITE)(IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
Definition: cabinet.h:53
struct _CFFOLDER * PCFFOLDER
Definition: cabinet.h:13
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:1355
VOID CabinetInitialize(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:507
VOID CabinetCleanup(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:535
VOID CabinetSetCabinetName(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName)
Definition: cabinet.c:586
VOID CabinetSetDestinationPath(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR DestinationPath)
Definition: cabinet.c:599
struct _CABINET_CONTEXT * PCABINET_CONTEXT
PVOID(* PCABINET_CREATE_FILE)(IN struct _CABINET_CONTEXT *CabinetContext, IN ULONG FileSize)
Definition: cabinet.h:68
ULONG CabinetFindNextFileSequential(IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:939
static BOOL CabinetNormalizePath(PWCHAR Path, ULONG Length)
Definition: cabinet.c:550
HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
Definition: cabinet_main.c:328
Definition: File.h:16
#define MAX_PATH
Definition: compat.h:34
struct _FileName FileName
Definition: fatprocs.h:897
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
#define BOOL
Definition: nt_native.h:43
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
unsigned short USHORT
Definition: pedump.c:61
HANDLE FileSectionHandle
Definition: cabinet.h:95
WCHAR CabinetName[256]
Definition: cabinet.h:86
PCABINET_OVERWRITE OverwriteHandler
Definition: cabinet.h:109
PCFFOLDER CabinetFolders
Definition: cabinet.h:101
WCHAR DestPath[MAX_PATH]
Definition: cabinet.h:93
WCHAR DiskPrev[256]
Definition: cabinet.h:88
ULONG CabinetReserved
Definition: cabinet.h:102
PCFHEADER PCABHeader
Definition: cabinet.h:100
ULONG FolderReserved
Definition: cabinet.h:103
PVOID CabinetReservedArea
Definition: cabinet.h:113
ULONG FolderUncompSize
Definition: cabinet.h:91
ULONG DataReserved
Definition: cabinet.h:104
PCABINET_DISK_CHANGE DiskChangeHandler
Definition: cabinet.h:111
PCAB_CODEC Codec
Definition: cabinet.h:105
BOOL CodecSelected
Definition: cabinet.h:107
SIZE_T FileSize
Definition: cabinet.h:98
SIZE_T DestFileSize
Definition: cabinet.h:97
HANDLE FileHandle
Definition: cabinet.h:94
ULONG BytesLeftInBlock
Definition: cabinet.h:92
PCABINET_EXTRACT ExtractHandler
Definition: cabinet.h:110
PCABINET_CREATE_FILE CreateFileHandler
Definition: cabinet.h:112
PUCHAR FileBuffer
Definition: cabinet.h:96
WCHAR DiskNext[256]
Definition: cabinet.h:90
WCHAR CabinetNext[256]
Definition: cabinet.h:89
WCHAR CabinetPrev[256]
Definition: cabinet.h:87
ULONG LastFileOffset
Definition: cabinet.h:108
ULONG Offset
Definition: cabinet.h:81
USHORT Index
Definition: cabinet.h:78
WCHAR Search[MAX_PATH]
Definition: cabinet.h:76
PCFDATA CFData
Definition: cabinet.h:80
WCHAR Cabinet[MAX_PATH]
Definition: cabinet.h:77
PCFFILE File
Definition: cabinet.h:79
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define CreateFile
Definition: winbase.h:3774
__wchar_t WCHAR
Definition: xmlstorage.h:180