ReactOS  0.4.13-dev-39-g8b6696f
cabinet.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CAB_SEARCH
 
struct  _CABINET_CONTEXT
 

Macros

#define CAB_STATUS_SUCCESS   0x00000000
 
#define CAB_STATUS_FAILURE   0x00000001
 
#define CAB_STATUS_NOMEMORY   0x00000002
 
#define CAB_STATUS_CANNOT_OPEN   0x00000003
 
#define CAB_STATUS_CANNOT_CREATE   0x00000004
 
#define CAB_STATUS_CANNOT_READ   0x00000005
 
#define CAB_STATUS_CANNOT_WRITE   0x00000006
 
#define CAB_STATUS_FILE_EXISTS   0x00000007
 
#define CAB_STATUS_INVALID_CAB   0x00000008
 
#define CAB_STATUS_NOFILE   0x00000009
 
#define CAB_STATUS_UNSUPPCOMP   0x0000000A
 
#define CS_SUCCESS   0x0000 /* All data consumed */
 
#define CS_NOMEMORY   0x0001 /* Not enough free memory */
 
#define CS_BADSTREAM   0x0002 /* Bad data stream */
 
#define CAB_CODEC_RAW   0x00
 
#define CAB_CODEC_LZX   0x01
 
#define CAB_CODEC_MSZIP   0x02
 

Typedefs

typedef struct _CFHEADERPCFHEADER
 
typedef struct _CFFOLDERPCFFOLDER
 
typedef struct _CFFILEPCFFILE
 
typedef struct _CFDATAPCFDATA
 
typedef struct _CAB_CODECPCAB_CODEC
 
typedef BOOL(* PCABINET_OVERWRITE) (IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
 
typedef VOID(* PCABINET_EXTRACT) (IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)
 
typedef VOID(* PCABINET_DISK_CHANGE) (IN struct _CABINET_CONTEXT *CabinetContext, IN PCWSTR CabinetName, IN PCWSTR DiskLabel)
 
typedef struct _CAB_SEARCH CAB_SEARCH
 
typedef struct _CAB_SEARCHPCAB_SEARCH
 
typedef struct _CABINET_CONTEXT CABINET_CONTEXT
 
typedef struct _CABINET_CONTEXTPCABINET_CONTEXT
 

Functions

VOID CabinetInitialize (IN OUT PCABINET_CONTEXT CabinetContext)
 
VOID CabinetCleanup (IN OUT PCABINET_CONTEXT CabinetContext)
 
PCWSTR CabinetGetCabinetName (IN PCABINET_CONTEXT CabinetContext)
 
VOID CabinetSetCabinetName (IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName)
 
VOID CabinetSetDestinationPath (IN PCABINET_CONTEXT CabinetContext, IN PCWSTR DestinationPath)
 
PCWSTR CabinetGetDestinationPath (IN PCABINET_CONTEXT CabinetContext)
 
ULONG CabinetOpen (IN OUT PCABINET_CONTEXT CabinetContext)
 
VOID CabinetClose (IN OUT PCABINET_CONTEXT CabinetContext)
 
ULONG CabinetFindFirst (IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
 
ULONG CabinetFindNext (IN PCABINET_CONTEXT CabinetContext, IN OUT PCAB_SEARCH Search)
 
ULONG CabinetFindNextFileSequential (IN PCABINET_CONTEXT CabinetContext, IN PCWSTR FileName, IN OUT PCAB_SEARCH Search)
 
ULONG CabinetExtractFile (IN PCABINET_CONTEXT CabinetContext, IN PCAB_SEARCH Search)
 
VOID CabinetSelectCodec (IN PCABINET_CONTEXT CabinetContext, IN ULONG Id)
 
VOID CabinetSetEventHandlers (IN PCABINET_CONTEXT CabinetContext, IN PCABINET_OVERWRITE Overwrite, IN PCABINET_EXTRACT Extract, IN PCABINET_DISK_CHANGE DiskChange)
 
PVOID CabinetGetCabinetReservedArea (IN PCABINET_CONTEXT CabinetContext, OUT PULONG Size)
 

Macro Definition Documentation

◆ CAB_CODEC_LZX

#define CAB_CODEC_LZX   0x01

Definition at line 47 of file cabinet.h.

◆ CAB_CODEC_MSZIP

#define CAB_CODEC_MSZIP   0x02

Definition at line 48 of file cabinet.h.

◆ CAB_CODEC_RAW

#define CAB_CODEC_RAW   0x00

Definition at line 46 of file cabinet.h.

◆ CAB_STATUS_CANNOT_CREATE

#define CAB_STATUS_CANNOT_CREATE   0x00000004

Definition at line 27 of file cabinet.h.

◆ CAB_STATUS_CANNOT_OPEN

#define CAB_STATUS_CANNOT_OPEN   0x00000003

Definition at line 26 of file cabinet.h.

◆ CAB_STATUS_CANNOT_READ

#define CAB_STATUS_CANNOT_READ   0x00000005

Definition at line 28 of file cabinet.h.

◆ CAB_STATUS_CANNOT_WRITE

#define CAB_STATUS_CANNOT_WRITE   0x00000006

Definition at line 29 of file cabinet.h.

◆ CAB_STATUS_FAILURE

#define CAB_STATUS_FAILURE   0x00000001

Definition at line 24 of file cabinet.h.

◆ CAB_STATUS_FILE_EXISTS

#define CAB_STATUS_FILE_EXISTS   0x00000007

Definition at line 30 of file cabinet.h.

◆ CAB_STATUS_INVALID_CAB

#define CAB_STATUS_INVALID_CAB   0x00000008

Definition at line 31 of file cabinet.h.

◆ CAB_STATUS_NOFILE

#define CAB_STATUS_NOFILE   0x00000009

Definition at line 32 of file cabinet.h.

◆ CAB_STATUS_NOMEMORY

#define CAB_STATUS_NOMEMORY   0x00000002

Definition at line 25 of file cabinet.h.

◆ CAB_STATUS_SUCCESS

#define CAB_STATUS_SUCCESS   0x00000000

Definition at line 23 of file cabinet.h.

◆ CAB_STATUS_UNSUPPCOMP

#define CAB_STATUS_UNSUPPCOMP   0x0000000A

Definition at line 33 of file cabinet.h.

◆ CS_BADSTREAM

#define CS_BADSTREAM   0x0002 /* Bad data stream */

Definition at line 43 of file cabinet.h.

◆ CS_NOMEMORY

#define CS_NOMEMORY   0x0001 /* Not enough free memory */

Definition at line 42 of file cabinet.h.

◆ CS_SUCCESS

#define CS_SUCCESS   0x0000 /* All data consumed */

Definition at line 41 of file cabinet.h.

Typedef Documentation

◆ CAB_SEARCH

◆ CABINET_CONTEXT

◆ PCAB_CODEC

Definition at line 38 of file cabinet.h.

◆ PCAB_SEARCH

◆ PCABINET_CONTEXT

◆ PCABINET_DISK_CHANGE

typedef VOID(* PCABINET_DISK_CHANGE) (IN struct _CABINET_CONTEXT *CabinetContext, IN PCWSTR CabinetName, IN PCWSTR DiskLabel)

Definition at line 63 of file cabinet.h.

◆ PCABINET_EXTRACT

typedef VOID(* PCABINET_EXTRACT) (IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)

Definition at line 58 of file cabinet.h.

◆ PCABINET_OVERWRITE

typedef BOOL(* PCABINET_OVERWRITE) (IN struct _CABINET_CONTEXT *CabinetContext, IN PCFFILE File, IN PCWSTR FileName)

Definition at line 53 of file cabinet.h.

◆ PCFDATA

Definition at line 15 of file cabinet.h.

◆ PCFFILE

Definition at line 14 of file cabinet.h.

◆ PCFFOLDER

Definition at line 13 of file cabinet.h.

◆ PCFHEADER

Definition at line 12 of file cabinet.h.

Function Documentation

◆ CabinetCleanup()

VOID CabinetCleanup ( IN OUT PCABINET_CONTEXT  CabinetContext)

Definition at line 529 of file cabinet.c.

531 {
532  CabinetClose(CabinetContext);
533 }
VOID CabinetClose(IN OUT PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:794

Referenced by PrepareFileCopy(), and SetupExtractFile().

◆ CabinetClose()

VOID CabinetClose ( IN OUT PCABINET_CONTEXT  CabinetContext)

Definition at line 794 of file cabinet.c.

796 {
797  if (!CabinetContext->FileOpen)
798  return;
799 
800  CloseCabinet(CabinetContext);
801  CabinetContext->FileOpen = FALSE;
802 }
static ULONG CloseCabinet(IN PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:483

Referenced by CabinetCleanup().

◆ CabinetExtractFile()

ULONG CabinetExtractFile ( IN PCABINET_CONTEXT  CabinetContext,
IN PCAB_SEARCH  Search 
)

Definition at line 952 of file cabinet.c.

955 {
956  ULONG Size; // remaining file bytes to decompress
957  ULONG CurrentOffset; // current uncompressed offset within the folder
958  PUCHAR CurrentBuffer; // current pointer to compressed data in the block
959  LONG RemainingBlock; // remaining comp data in the block
960  HANDLE DestFile;
961  HANDLE DestFileSection;
962  PVOID DestFileBuffer; // mapped view of dest file
963  PVOID CurrentDestBuffer; // pointer to the current position in the dest view
964  PCFDATA CFData; // current data block
965  ULONG Status;
966  FILETIME FileTime;
967  WCHAR DestName[MAX_PATH];
968  NTSTATUS NtStatus;
973  FILE_BASIC_INFORMATION FileBasic;
974  PCFFOLDER CurrentFolder;
975  LARGE_INTEGER MaxDestFileSize;
976  LONG InputLength, OutputLength;
977  char Chunk[512];
978 
979  if (wcscmp(Search->Cabinet, CabinetContext->CabinetName) != 0)
980  {
981  /* the file is not in the current cabinet */
982  DPRINT("File is not in this cabinet (%S != %S)\n",
983  Search->Cabinet, CabinetContext->CabinetName);
984  return CAB_STATUS_NOFILE;
985  }
986 
987  /* look up the folder that the file specifies */
988  if (Search->File->FolderIndex == 0xFFFD ||
989  Search->File->FolderIndex == 0xFFFF)
990  {
991  /* folder is continued from previous cabinet,
992  that shouldn't happen here */
993  return CAB_STATUS_NOFILE;
994  }
995  else if (Search->File->FolderIndex == 0xFFFE)
996  {
997  /* folder is the last in this cabinet and continues into next */
998  CurrentFolder = &CabinetContext->CabinetFolders[CabinetContext->PCABHeader->FolderCount - 1];
999  }
1000  else
1001  {
1002  /* folder is completely contained within this cabinet */
1003  CurrentFolder = &CabinetContext->CabinetFolders[Search->File->FolderIndex];
1004  }
1005 
1006  switch (CurrentFolder->CompressionType & CAB_COMP_MASK)
1007  {
1008  case CAB_COMP_NONE:
1009  CabinetSelectCodec(CabinetContext, CAB_CODEC_RAW);
1010  break;
1011  case CAB_COMP_MSZIP:
1012  CabinetSelectCodec(CabinetContext, CAB_CODEC_MSZIP);
1013  break;
1014  default:
1015  return CAB_STATUS_UNSUPPCOMP;
1016  }
1017 
1018  DPRINT("Extracting file at uncompressed offset (0x%X) Size (%d bytes)\n",
1019  (UINT)Search->File->FileOffset, (UINT)Search->File->FileSize);
1020 
1021  RtlInitAnsiString(&AnsiString, Search->File->FileName);
1022  wcscpy(DestName, CabinetContext->DestPath);
1023  UnicodeString.MaximumLength = sizeof(DestName) - wcslen(DestName) * sizeof(WCHAR);
1024  UnicodeString.Buffer = DestName + wcslen(DestName);
1025  UnicodeString.Length = 0;
1027 
1028  /* Create destination file, fail if it already exists */
1029  RtlInitUnicodeString(&UnicodeString, DestName);
1030 
1032  &UnicodeString,
1034  NULL, NULL);
1035 
1036  NtStatus = NtCreateFile(&DestFile,
1039  &IoStatusBlock,
1040  NULL,
1042  0,
1043  FILE_CREATE,
1045  NULL, 0);
1046 
1047  if (!NT_SUCCESS(NtStatus))
1048  {
1049  DPRINT("NtCreateFile() failed (%S) (%x)\n", DestName, NtStatus);
1050 
1051  /* If file exists, ask to overwrite file */
1052  if (CabinetContext->OverwriteHandler == NULL ||
1053  CabinetContext->OverwriteHandler(CabinetContext, Search->File, DestName))
1054  {
1055  /* Create destination file, overwrite if it already exists */
1056  NtStatus = NtCreateFile(&DestFile,
1059  &IoStatusBlock,
1060  NULL,
1062  0,
1065  NULL, 0);
1066 
1067  if (!NT_SUCCESS(NtStatus))
1068  {
1069  DPRINT1("NtCreateFile() failed (%S) (%x)\n", DestName, NtStatus);
1070  return CAB_STATUS_CANNOT_CREATE;
1071  }
1072  }
1073  else
1074  {
1075  DPRINT1("File (%S) exists\n", DestName);
1076  return CAB_STATUS_FILE_EXISTS;
1077  }
1078  }
1079 
1080  MaxDestFileSize.QuadPart = Search->File->FileSize;
1081  NtStatus = NtCreateSection(&DestFileSection,
1083  0,
1084  &MaxDestFileSize,
1086  SEC_COMMIT,
1087  DestFile);
1088 
1089  if (!NT_SUCCESS(NtStatus))
1090  {
1091  DPRINT1("NtCreateSection failed for %ls: %x\n", DestName, NtStatus);
1093  goto CloseDestFile;
1094  }
1095 
1096  DestFileBuffer = 0;
1097  CabinetContext->DestFileSize = 0;
1098  NtStatus = NtMapViewOfSection(DestFileSection,
1099  NtCurrentProcess(),
1100  &DestFileBuffer,
1101  0, 0, 0,
1102  &CabinetContext->DestFileSize,
1103  ViewUnmap,
1104  0,
1105  PAGE_READWRITE);
1106 
1107  if (!NT_SUCCESS(NtStatus))
1108  {
1109  DPRINT1("NtMapViewOfSection failed: %x\n", NtStatus);
1111  goto CloseDestFileSection;
1112  }
1113 
1114  CurrentDestBuffer = DestFileBuffer;
1115  if (!ConvertDosDateTimeToFileTime(Search->File->FileDate,
1116  Search->File->FileTime,
1117  &FileTime))
1118  {
1119  DPRINT1("DosDateTimeToFileTime() failed\n");
1121  goto UnmapDestFile;
1122  }
1123 
1124  NtStatus = NtQueryInformationFile(DestFile,
1125  &IoStatusBlock,
1126  &FileBasic,
1127  sizeof(FILE_BASIC_INFORMATION),
1129  if (!NT_SUCCESS(NtStatus))
1130  {
1131  DPRINT("NtQueryInformationFile() failed (%x)\n", NtStatus);
1132  }
1133  else
1134  {
1135  memcpy(&FileBasic.LastAccessTime, &FileTime, sizeof(FILETIME));
1136 
1137  NtStatus = NtSetInformationFile(DestFile,
1138  &IoStatusBlock,
1139  &FileBasic,
1140  sizeof(FILE_BASIC_INFORMATION),
1142  if (!NT_SUCCESS(NtStatus))
1143  {
1144  DPRINT("NtSetInformationFile() failed (%x)\n", NtStatus);
1145  }
1146  }
1147 
1148  SetAttributesOnFile(Search->File, DestFile);
1149 
1150  /* Call extract event handler */
1151  if (CabinetContext->ExtractHandler != NULL)
1152  CabinetContext->ExtractHandler(CabinetContext, Search->File, DestName);
1153 
1154  if (Search->CFData)
1155  CFData = Search->CFData;
1156  else
1157  CFData = (PCFDATA)(CabinetContext->CabinetFolders[Search->File->FolderIndex].DataOffset + CabinetContext->FileBuffer);
1158 
1159  CurrentOffset = Search->Offset;
1160  while (CurrentOffset + CFData->UncompSize <= Search->File->FileOffset)
1161  {
1162  /* walk the data blocks until we reach
1163  the one containing the start of the file */
1164  CurrentOffset += CFData->UncompSize;
1165  CFData = (PCFDATA)((char *)(CFData + 1) + CabinetContext->DataReserved + CFData->CompSize);
1166  }
1167 
1168  Search->CFData = CFData;
1169  Search->Offset = CurrentOffset;
1170 
1171  /* now decompress and discard any data in
1172  the block before the start of the file */
1173 
1174  /* start of comp data */
1175  CurrentBuffer = ((unsigned char *)(CFData + 1)) + CabinetContext->DataReserved;
1176  RemainingBlock = CFData->CompSize;
1177  InputLength = RemainingBlock;
1178 
1179  while (CurrentOffset < Search->File->FileOffset)
1180  {
1181  /* compute remaining uncomp bytes to start
1182  of file, bounded by size of chunk */
1183  OutputLength = Search->File->FileOffset - CurrentOffset;
1184  if (OutputLength > (LONG)sizeof(Chunk))
1185  OutputLength = sizeof(Chunk);
1186 
1187  /* negate to signal NOT end of block */
1188  OutputLength = -OutputLength;
1189 
1190  CabinetContext->Codec->Uncompress(CabinetContext->Codec,
1191  Chunk,
1192  CurrentBuffer,
1193  &InputLength,
1194  &OutputLength);
1195 
1196  /* add the uncomp bytes extracted to current folder offset */
1197  CurrentOffset += OutputLength;
1198  /* add comp bytes consumed to CurrentBuffer */
1199  CurrentBuffer += InputLength;
1200  /* subtract bytes consumed from bytes remaining in block */
1201  RemainingBlock -= InputLength;
1202  /* neg for resume decompression of the same block */
1203  InputLength = -RemainingBlock;
1204  }
1205 
1206  /* now CurrentBuffer points to the first comp byte
1207  of the file, so we can begin decompressing */
1208 
1209  /* Size = remaining uncomp bytes of the file to decompress */
1210  Size = Search->File->FileSize;
1211  while (Size > 0)
1212  {
1213  OutputLength = Size;
1214  DPRINT("Decompressing block at %x with RemainingBlock = %d, Size = %d\n",
1215  CurrentBuffer, RemainingBlock, Size);
1216 
1217  Status = CabinetContext->Codec->Uncompress(CabinetContext->Codec,
1218  CurrentDestBuffer,
1219  CurrentBuffer,
1220  &InputLength,
1221  &OutputLength);
1222  if (Status != CS_SUCCESS)
1223  {
1224  DPRINT("Cannot uncompress block\n");
1225  if (Status == CS_NOMEMORY)
1228  goto UnmapDestFile;
1229  }
1230 
1231  /* advance dest buffer by bytes produced */
1232  CurrentDestBuffer = (PVOID)((ULONG_PTR)CurrentDestBuffer + OutputLength);
1233  /* advance src buffer by bytes consumed */
1234  CurrentBuffer += InputLength;
1235  /* reduce remaining file bytes by bytes produced */
1236  Size -= OutputLength;
1237  /* reduce remaining block size by bytes consumed */
1238  RemainingBlock -= InputLength;
1239  if (Size > 0 && RemainingBlock == 0)
1240  {
1241  /* used up this block, move on to the next */
1242  DPRINT("Out of block data\n");
1243  CFData = (PCFDATA)CurrentBuffer;
1244  RemainingBlock = CFData->CompSize;
1245  CurrentBuffer = (unsigned char *)(CFData + 1) + CabinetContext->DataReserved;
1246  InputLength = RemainingBlock;
1247  }
1248  }
1249 
1251 
1252 UnmapDestFile:
1253  NtUnmapViewOfSection(NtCurrentProcess(), DestFileBuffer);
1254 
1255 CloseDestFileSection:
1256  NtClose(DestFileSection);
1257 
1258 CloseDestFile:
1259  NtClose(DestFile);
1260 
1261  return Status;
1262 }
#define CAB_STATUS_INVALID_CAB
Definition: cabinet.h:31
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3780
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3371
VOID CabinetSelectCodec(IN PCABINET_CONTEXT CabinetContext, IN ULONG Id)
Definition: cabinet.c:1270
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
#define CAB_CODEC_RAW
Definition: cabinet.h:46
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_CREATE
Definition: from_kernel.h:55
static BOOL ConvertDosDateTimeToFileTime(WORD wFatDate, WORD wFatTime, LPFILETIME lpFileTime)
Definition: cabinet.c:348
#define FILE_OVERWRITE
Definition: from_kernel.h:57
struct _CFDATA * PCFDATA
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
while(1)
Definition: macro.lex.yy.c:740
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define CAB_CODEC_MSZIP
Definition: cabinet.h:48
#define CAB_COMP_MSZIP
Definition: cabinet.c:53
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
#define SEC_COMMIT
Definition: mmtypes.h:99
long LONG
Definition: pedump.c:60
#define GENERIC_WRITE
Definition: nt_native.h:90
#define CAB_STATUS_CANNOT_WRITE
Definition: cabinet.h:29
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3552
USHORT CompSize
Definition: cabinet.c:129
#define CAB_STATUS_NOMEMORY
Definition: cabinet.h:25
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
static BOOL SetAttributesOnFile(PCFFILE File, HANDLE hFile)
Definition: cabinet.c:427
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define CAB_STATUS_UNSUPPCOMP
Definition: cabinet.h:33
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
#define CAB_STATUS_CANNOT_CREATE
Definition: cabinet.h:27
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
USHORT CompressionType
Definition: cabinet.c:108
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GENERIC_READ
Definition: compat.h:124
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define CS_NOMEMORY
Definition: cabinet.h:42
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define CAB_COMP_MASK
Definition: cabinet.c:51
static PVOID CurrentBuffer
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int UINT
Definition: ndis.h:50
USHORT UncompSize
Definition: cabinet.c:130
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define CAB_STATUS_FILE_EXISTS
Definition: cabinet.h:30
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
Definition: File.h:15
#define CAB_COMP_NONE
Definition: cabinet.c:52
#define CS_SUCCESS
Definition: cabinet.h:41
#define CAB_STATUS_NOFILE
Definition: cabinet.h:32
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3042
LONGLONG QuadPart
Definition: typedefs.h:112
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by SetupExtractFile().

◆ CabinetFindFirst()

ULONG CabinetFindFirst ( IN PCABINET_CONTEXT  CabinetContext,
IN PCWSTR  FileName,
IN OUT PCAB_SEARCH  Search 
)

Definition at line 813 of file cabinet.c.

817 {
818  DPRINT("CabinetFindFirst(FileName = %S)\n", FileName);
819  wcsncpy(Search->Search, FileName, MAX_PATH);
820  wcsncpy(Search->Cabinet, CabinetContext->CabinetName, MAX_PATH);
821  Search->File = 0;
822  return CabinetFindNext(CabinetContext, Search);
823 }
ULONG CabinetFindNext(IN PCABINET_CONTEXT CabinetContext, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:833
void DPRINT(...)
Definition: polytest.cpp:61
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)

Referenced by SetupExtractFile().

◆ CabinetFindNext()

ULONG CabinetFindNext ( IN PCABINET_CONTEXT  CabinetContext,
IN OUT PCAB_SEARCH  Search 
)

Definition at line 833 of file cabinet.c.

836 {
837  PCFFILE Prev;
841 
842  if (wcscmp(Search->Cabinet, CabinetContext->CabinetName) != 0)
843  {
844  /* restart search of cabinet has changed since last find */
845  Search->File = 0;
846  }
847 
848  if (!Search->File)
849  {
850  /* starting new search or cabinet */
851  Search->File = (PCFFILE)(CabinetContext->FileBuffer + CabinetContext->PCABHeader->FileTableOffset);
852  Search->Index = 0;
853  Prev = 0;
854  }
855  else
856  Prev = Search->File;
857 
858  while (TRUE)
859  {
860  /* look at each file in the archive and see if we found a match */
861  if (Search->File->FolderIndex == 0xFFFD ||
862  Search->File->FolderIndex == 0xFFFF)
863  {
864  /* skip files continued from previous cab */
865  DPRINT("Skipping file (%s): FileOffset (0x%X), "
866  "LastFileOffset (0x%X)\n", (char *)(Search->File + 1),
867  Search->File->FileOffset, CabinetContext->LastFileOffset);
868  }
869  else
870  {
871  // FIXME: check for match against search criteria
872  if (Search->File != Prev)
873  {
874  if (Prev == NULL || Search->File->FolderIndex != Prev->FolderIndex)
875  {
876  Search->CFData = NULL;
877  Search->Offset = 0;
878  }
879 
880  /* don't match the file we started with */
881  if (wcscmp(Search->Search, L"*") == 0)
882  {
883  /* take any file */
884  break;
885  }
886  else
887  {
888  /* otherwise, try to match the exact file name */
889  RtlInitAnsiString(&AnsiString, Search->File->FileName);
890  UnicodeString.Buffer = FileName;
891  UnicodeString.Buffer[0] = 0;
892  UnicodeString.Length = 0;
893  UnicodeString.MaximumLength = sizeof(FileName);
895  if (wcscmp(Search->Search, UnicodeString.Buffer) == 0)
896  break;
897  }
898  }
899  }
900 
901  /* if we make it here we found no match, so move to the next file */
902  Search->Index++;
903  if (Search->Index >= CabinetContext->PCABHeader->FileCount)
904  {
905  /* we have reached the end of this cabinet */
906  DPRINT("End of cabinet reached\n");
907  return CAB_STATUS_NOFILE;
908  }
909  else
910  Search->File = (PCFFILE)(strchr((char *)(Search->File + 1), 0) + 1);
911  }
912 
913  DPRINT("Found file %s\n", Search->File->FileName);
914  return CAB_STATUS_SUCCESS;
915 }
#define TRUE
Definition: types.h:120
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
struct _CFFILE * PCFFILE
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
static const WCHAR L[]
Definition: oid.c:1250
USHORT FolderIndex
Definition: cabinet.c:118
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
struct _FileName FileName
Definition: fatprocs.h:884
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define CAB_STATUS_NOFILE
Definition: cabinet.h:32

Referenced by CabinetFindFirst(), and CabinetFindNextFileSequential().

◆ CabinetFindNextFileSequential()

ULONG CabinetFindNextFileSequential ( IN PCABINET_CONTEXT  CabinetContext,
IN PCWSTR  FileName,
IN OUT PCAB_SEARCH  Search 
)

Definition at line 926 of file cabinet.c.

930 {
931  DPRINT("CabinetFindNextFileSequential(FileName = %S)\n", FileName);
932  wcsncpy(Search->Search, FileName, MAX_PATH);
933  return CabinetFindNext(CabinetContext, Search);
934 }
ULONG CabinetFindNext(IN PCABINET_CONTEXT CabinetContext, IN OUT PCAB_SEARCH Search)
Definition: cabinet.c:833
void DPRINT(...)
Definition: polytest.cpp:61
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)

Referenced by SetupExtractFile().

◆ CabinetGetCabinetName()

PCWSTR CabinetGetCabinetName ( IN PCABINET_CONTEXT  CabinetContext)

Definition at line 568 of file cabinet.c.

570 {
571  return CabinetContext->CabinetName;
572 }

Referenced by SetupExtractFile().

◆ CabinetGetCabinetReservedArea()

PVOID CabinetGetCabinetReservedArea ( IN PCABINET_CONTEXT  CabinetContext,
OUT PULONG  Size 
)

Definition at line 1330 of file cabinet.c.

1333 {
1334  if (CabinetContext->CabinetReservedArea != NULL)
1335  {
1336  if (Size != NULL)
1337  {
1338  *Size = CabinetContext->CabinetReserved;
1339  }
1340 
1341  return CabinetContext->CabinetReservedArea;
1342  }
1343  else
1344  {
1345  if (Size != NULL)
1346  {
1347  *Size = 0;
1348  }
1349 
1350  return NULL;
1351  }
1352 }
smooth NULL
Definition: ftsmooth.c:416
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359

Referenced by PrepareFileCopy().

◆ CabinetGetDestinationPath()

PCWSTR CabinetGetDestinationPath ( IN PCABINET_CONTEXT  CabinetContext)

Definition at line 609 of file cabinet.c.

611 {
612  return CabinetContext->DestPath;
613 }

◆ CabinetInitialize()

VOID CabinetInitialize ( IN OUT PCABINET_CONTEXT  CabinetContext)

Definition at line 501 of file cabinet.c.

503 {
504  RtlZeroMemory(CabinetContext, sizeof(*CabinetContext));
505 
506  CabinetContext->FileOpen = FALSE;
507  wcscpy(CabinetContext->DestPath, L"");
508 
509  CabinetContext->CodecSelected = FALSE;
510  CabinetSelectCodec(CabinetContext, CAB_CODEC_RAW);
511 
512  CabinetContext->OverwriteHandler = NULL;
513  CabinetContext->ExtractHandler = NULL;
514  CabinetContext->DiskChangeHandler = NULL;
515 
516  CabinetContext->FolderUncompSize = 0;
517  CabinetContext->BytesLeftInBlock = 0;
518  CabinetContext->CabinetReserved = 0;
519  CabinetContext->FolderReserved = 0;
520  CabinetContext->DataReserved = 0;
521  CabinetContext->CabinetReservedArea = NULL;
522  CabinetContext->LastFileOffset = 0;
523 }
VOID CabinetSelectCodec(IN PCABINET_CONTEXT CabinetContext, IN ULONG Id)
Definition: cabinet.c:1270
#define CAB_CODEC_RAW
Definition: cabinet.h:46
smooth NULL
Definition: ftsmooth.c:416
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by PrepareFileCopy(), and SetupExtractFile().

◆ CabinetOpen()

ULONG CabinetOpen ( IN OUT PCABINET_CONTEXT  CabinetContext)

Definition at line 621 of file cabinet.c.

623 {
624  PUCHAR Buffer;
626  ANSI_STRING astring;
627 
631  NTSTATUS NtStatus;
632 
633  if (CabinetContext->FileOpen)
634  {
635  /* Cabinet file already opened */
636  DPRINT("CabinetOpen returning SUCCESS\n");
637  return CAB_STATUS_SUCCESS;
638  }
639 
640  RtlInitUnicodeString(&FileName, CabinetContext->CabinetName);
641 
643  &FileName,
645  NULL, NULL);
646 
647  NtStatus = NtOpenFile(&CabinetContext->FileHandle,
650  &IoStatusBlock,
653 
654  if (!NT_SUCCESS(NtStatus))
655  {
656  DPRINT1("Cannot open file (%S) (%x)\n", CabinetContext->CabinetName, NtStatus);
657  return CAB_STATUS_CANNOT_OPEN;
658  }
659 
660  CabinetContext->FileOpen = TRUE;
661 
662  NtStatus = NtCreateSection(&CabinetContext->FileSectionHandle,
664  0, 0,
666  SEC_COMMIT,
667  CabinetContext->FileHandle);
668 
669  if (!NT_SUCCESS(NtStatus))
670  {
671  DPRINT1("NtCreateSection failed for %ls: %x\n", CabinetContext->CabinetName, NtStatus);
672  return CAB_STATUS_NOMEMORY;
673  }
674 
675  CabinetContext->FileBuffer = 0;
676  CabinetContext->FileSize = 0;
677 
678  NtStatus = NtMapViewOfSection(CabinetContext->FileSectionHandle,
680  (PVOID*)&CabinetContext->FileBuffer,
681  0, 0, 0,
682  &CabinetContext->FileSize,
683  ViewUnmap,
684  0,
685  PAGE_READONLY);
686 
687  if (!NT_SUCCESS(NtStatus))
688  {
689  DPRINT1("NtMapViewOfSection failed: %x\n", NtStatus);
690  return CAB_STATUS_NOMEMORY;
691  }
692 
693  DPRINT("Cabinet file %S opened and mapped to %x\n",
694  CabinetContext->CabinetName, CabinetContext->FileBuffer);
695  CabinetContext->PCABHeader = (PCFHEADER)CabinetContext->FileBuffer;
696 
697  /* Check header */
698  if (CabinetContext->FileSize <= sizeof(CFHEADER) ||
699  CabinetContext->PCABHeader->Signature != CAB_SIGNATURE ||
700  CabinetContext->PCABHeader->Version != CAB_VERSION ||
701  CabinetContext->PCABHeader->FolderCount == 0 ||
702  CabinetContext->PCABHeader->FileCount == 0 ||
703  CabinetContext->PCABHeader->FileTableOffset < sizeof(CFHEADER))
704  {
705  CloseCabinet(CabinetContext);
706  DPRINT1("File has invalid header\n");
707  return CAB_STATUS_INVALID_CAB;
708  }
709 
710  Buffer = (PUCHAR)(CabinetContext->PCABHeader + 1);
711 
712  /* Read/skip any reserved bytes */
713  if (CabinetContext->PCABHeader->Flags & CAB_FLAG_RESERVE)
714  {
715  CabinetContext->CabinetReserved = *(PUSHORT)Buffer;
716  Buffer += 2;
717  CabinetContext->FolderReserved = *Buffer;
718  Buffer++;
719  CabinetContext->DataReserved = *Buffer;
720  Buffer++;
721 
722  if (CabinetContext->CabinetReserved > 0)
723  {
724  CabinetContext->CabinetReservedArea = Buffer;
725  Buffer += CabinetContext->CabinetReserved;
726  }
727  }
728 
729  if (CabinetContext->PCABHeader->Flags & CAB_FLAG_HASPREV)
730  {
731  /* The previous cabinet file is in
732  the same directory as the current */
733  wcscpy(CabinetContext->CabinetPrev, CabinetContext->CabinetName);
734  RemoveFileName(CabinetContext->CabinetPrev);
735  CabinetNormalizePath(CabinetContext->CabinetPrev, 256);
736  RtlInitAnsiString(&astring, (LPSTR)Buffer);
737  ustring.Length = wcslen(CabinetContext->CabinetPrev);
738  ustring.Buffer = CabinetContext->CabinetPrev + ustring.Length;
739  ustring.MaximumLength = sizeof(CabinetContext->CabinetPrev) - ustring.Length;
741  Buffer += astring.Length + 1;
742 
743  /* Read label of prev disk */
744  RtlInitAnsiString(&astring, (LPSTR)Buffer);
745  ustring.Length = 0;
746  ustring.Buffer = CabinetContext->DiskPrev;
747  ustring.MaximumLength = sizeof(CabinetContext->DiskPrev);
749  Buffer += astring.Length + 1;
750  }
751  else
752  {
753  wcscpy(CabinetContext->CabinetPrev, L"");
754  wcscpy(CabinetContext->DiskPrev, L"");
755  }
756 
757  if (CabinetContext->PCABHeader->Flags & CAB_FLAG_HASNEXT)
758  {
759  /* The next cabinet file is in
760  the same directory as the previous */
761  wcscpy(CabinetContext->CabinetNext, CabinetContext->CabinetName);
762  RemoveFileName(CabinetContext->CabinetNext);
763  CabinetNormalizePath(CabinetContext->CabinetNext, 256);
764  RtlInitAnsiString(&astring, (LPSTR)Buffer);
765  ustring.Length = wcslen(CabinetContext->CabinetNext);
766  ustring.Buffer = CabinetContext->CabinetNext + ustring.Length;
767  ustring.MaximumLength = sizeof(CabinetContext->CabinetNext) - ustring.Length;
769  Buffer += astring.Length + 1;
770 
771  /* Read label of next disk */
772  RtlInitAnsiString(&astring, (LPSTR)Buffer);
773  ustring.Length = 0;
774  ustring.Buffer = CabinetContext->DiskNext;
775  ustring.MaximumLength = sizeof(CabinetContext->DiskNext);
777  Buffer += astring.Length + 1;
778  }
779  else
780  {
781  wcscpy(CabinetContext->CabinetNext, L"");
782  wcscpy(CabinetContext->DiskNext, L"");
783  }
784  CabinetContext->CabinetFolders = (PCFFOLDER)Buffer;
785 
786  DPRINT("CabinetOpen returning SUCCESS\n");
787  return CAB_STATUS_SUCCESS;
788 }
#define CAB_STATUS_INVALID_CAB
Definition: cabinet.h:31
struct _CFHEADER CFHEADER
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static ULONG CloseCabinet(IN PCABINET_CONTEXT CabinetContext)
Definition: cabinet.c:483
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3371
unsigned char * PUCHAR
Definition: retypes.h:3
DWORD MaximumLength
Definition: config.c:21
LONG NTSTATUS
Definition: precomp.h:26
char * LPSTR
Definition: xmlstorage.h:182
#define FILE_SHARE_READ
Definition: compat.h:125
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
DWORD Length
Definition: config.c:20
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define SEC_COMMIT
Definition: mmtypes.h:99
#define CAB_VERSION
Definition: cabinet.c:48
#define CAB_FLAG_RESERVE
Definition: cabinet.c:59
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3552
#define CAB_STATUS_NOMEMORY
Definition: cabinet.h:25
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static VOID RemoveFileName(PWCHAR Path)
Definition: cabinet.c:402
#define CAB_FLAG_HASPREV
Definition: cabinet.c:57
#define CAB_SIGNATURE
Definition: cabinet.c:47
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define CAB_STATUS_SUCCESS
Definition: cabinet.h:23
struct _CFHEADER * PCFHEADER
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
#define CAB_FLAG_HASNEXT
Definition: cabinet.c:58
#define SYNCHRONIZE
Definition: nt_native.h:61
struct _FileName FileName
Definition: fatprocs.h:884
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
static BOOL CabinetNormalizePath(PWCHAR Path, ULONG Length)
Definition: cabinet.c:544
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
Definition: config.c:18
#define PAGE_READONLY
Definition: compat.h:127
Definition: fci.c:65
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
struct _CFFOLDER * PCFFOLDER
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define CAB_STATUS_CANNOT_OPEN
Definition: cabinet.h:26
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned short * PUSHORT
Definition: retypes.h:2
unsigned char * Buffer
Definition: config.c:22

Referenced by PrepareFileCopy(), and SetupExtractFile().

◆ CabinetSelectCodec()

VOID CabinetSelectCodec ( IN PCABINET_CONTEXT  CabinetContext,
IN ULONG  Id 
)

Definition at line 1270 of file cabinet.c.

1273 {
1274  if (CabinetContext->CodecSelected)
1275  {
1276  if (Id == CabinetContext->CodecId)
1277  return;
1278 
1279  CabinetContext->CodecSelected = FALSE;
1280  }
1281 
1282  switch (Id)
1283  {
1284  case CAB_CODEC_RAW:
1285  {
1286  CabinetContext->Codec = &RawCodec;
1287  break;
1288  }
1289 
1290  case CAB_CODEC_MSZIP:
1291  {
1292  CabinetContext->Codec = &MSZipCodec;
1293  CabinetContext->Codec->ZStream.zalloc = MSZipAlloc;
1294  CabinetContext->Codec->ZStream.zfree = MSZipFree;
1295  CabinetContext->Codec->ZStream.opaque = (voidpf)0;
1296  break;
1297  }
1298 
1299  default:
1300  return;
1301  }
1302 
1303  CabinetContext->CodecId = Id;
1304  CabinetContext->CodecSelected = TRUE;
1305 }
#define TRUE
Definition: types.h:120
static CAB_CODEC MSZipCodec
Definition: cabinet.c:302
#define CAB_CODEC_RAW
Definition: cabinet.h:46
z_stream ZStream
Definition: cabinet.c:172
DWORD Id
#define CAB_CODEC_MSZIP
Definition: cabinet.h:48
alloc_func zalloc
Definition: zlib.h:98
void MSZipFree(voidpf opaque, voidpf address)
Definition: cabinet.c:317
Byte FAR * voidpf
Definition: zconf.h:413
voidpf MSZipAlloc(voidpf opaque, uInt items, uInt size)
Definition: cabinet.c:311
static CAB_CODEC RawCodec
Definition: cabinet.c:205

Referenced by CabinetExtractFile(), and CabinetInitialize().

◆ CabinetSetCabinetName()

VOID CabinetSetCabinetName ( IN PCABINET_CONTEXT  CabinetContext,
IN PCWSTR  FileName 
)

Definition at line 580 of file cabinet.c.

583 {
584  wcscpy(CabinetContext->CabinetName, FileName);
585 }
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

Referenced by PrepareFileCopy(), and SetupExtractFile().

◆ CabinetSetDestinationPath()

VOID CabinetSetDestinationPath ( IN PCABINET_CONTEXT  CabinetContext,
IN PCWSTR  DestinationPath 
)

Definition at line 593 of file cabinet.c.

596 {
597  wcscpy(CabinetContext->DestPath, DestinationPath);
598 
599  if (wcslen(CabinetContext->DestPath) > 0)
600  CabinetNormalizePath(CabinetContext->DestPath, MAX_PATH);
601 }
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static BOOL CabinetNormalizePath(PWCHAR Path, ULONG Length)
Definition: cabinet.c:544
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by SetupExtractFile().

◆ CabinetSetEventHandlers()

VOID CabinetSetEventHandlers ( IN PCABINET_CONTEXT  CabinetContext,
IN PCABINET_OVERWRITE  Overwrite,
IN PCABINET_EXTRACT  Extract,
IN PCABINET_DISK_CHANGE  DiskChange 
)

Definition at line 1315 of file cabinet.c.

1320 {
1321  CabinetContext->OverwriteHandler = Overwrite;
1322  CabinetContext->ExtractHandler = Extract;
1323  CabinetContext->DiskChangeHandler = DiskChange;
1324 }
HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
Definition: cabinet_main.c:328

Referenced by PrepareFileCopy(), and SetupExtractFile().