mirror of
https://github.com/reactos/reactos.git
synced 2025-06-05 17:30:32 +00:00
[USETUP] Support a custom way to extract files for cabinet files
This will be used to extract files from cabinet to memory, instead of writing them to disk.
This commit is contained in:
parent
0d51c71ed7
commit
04ec14e23e
3 changed files with 147 additions and 124 deletions
|
@ -1018,6 +1018,18 @@ CabinetExtractFile(
|
|||
DPRINT("Extracting file at uncompressed offset (0x%X) Size (%d bytes)\n",
|
||||
(UINT)Search->File->FileOffset, (UINT)Search->File->FileSize);
|
||||
|
||||
if (CabinetContext->CreateFileHandler)
|
||||
{
|
||||
/* Call create context */
|
||||
CurrentDestBuffer = CabinetContext->CreateFileHandler(CabinetContext, Search->File->FileSize);
|
||||
if (!CurrentDestBuffer)
|
||||
{
|
||||
DPRINT1("CreateFileHandler() failed\n");
|
||||
return CAB_STATUS_CANNOT_CREATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlInitAnsiString(&AnsiString, Search->File->FileName);
|
||||
wcscpy(DestName, CabinetContext->DestPath);
|
||||
UnicodeString.MaximumLength = sizeof(DestName) - wcslen(DestName) * sizeof(WCHAR);
|
||||
|
@ -1146,6 +1158,7 @@ CabinetExtractFile(
|
|||
}
|
||||
|
||||
SetAttributesOnFile(Search->File, DestFile);
|
||||
}
|
||||
|
||||
/* Call extract event handler */
|
||||
if (CabinetContext->ExtractHandler != NULL)
|
||||
|
@ -1250,12 +1263,15 @@ CabinetExtractFile(
|
|||
Status = CAB_STATUS_SUCCESS;
|
||||
|
||||
UnmapDestFile:
|
||||
if (!CabinetContext->CreateFileHandler)
|
||||
NtUnmapViewOfSection(NtCurrentProcess(), DestFileBuffer);
|
||||
|
||||
CloseDestFileSection:
|
||||
if (!CabinetContext->CreateFileHandler)
|
||||
NtClose(DestFileSection);
|
||||
|
||||
CloseDestFile:
|
||||
if (!CabinetContext->CreateFileHandler)
|
||||
NtClose(DestFile);
|
||||
|
||||
return Status;
|
||||
|
@ -1316,11 +1332,13 @@ CabinetSetEventHandlers(
|
|||
IN PCABINET_CONTEXT CabinetContext,
|
||||
IN PCABINET_OVERWRITE Overwrite,
|
||||
IN PCABINET_EXTRACT Extract,
|
||||
IN PCABINET_DISK_CHANGE DiskChange)
|
||||
IN PCABINET_DISK_CHANGE DiskChange,
|
||||
IN PCABINET_CREATE_FILE CreateFile)
|
||||
{
|
||||
CabinetContext->OverwriteHandler = Overwrite;
|
||||
CabinetContext->ExtractHandler = Extract;
|
||||
CabinetContext->DiskChangeHandler = DiskChange;
|
||||
CabinetContext->CreateFileHandler = CreateFile;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -65,6 +65,9 @@ typedef VOID (*PCABINET_DISK_CHANGE)(
|
|||
IN PCWSTR CabinetName,
|
||||
IN PCWSTR DiskLabel);
|
||||
|
||||
typedef PVOID (*PCABINET_CREATE_FILE)(
|
||||
IN struct _CABINET_CONTEXT* CabinetContext,
|
||||
IN ULONG FileSize);
|
||||
|
||||
/* Classes */
|
||||
|
||||
|
@ -106,6 +109,7 @@ typedef struct _CABINET_CONTEXT
|
|||
PCABINET_OVERWRITE OverwriteHandler;
|
||||
PCABINET_EXTRACT ExtractHandler;
|
||||
PCABINET_DISK_CHANGE DiskChangeHandler;
|
||||
PCABINET_CREATE_FILE CreateFileHandler;
|
||||
PVOID CabinetReservedArea;
|
||||
} CABINET_CONTEXT, *PCABINET_CONTEXT;
|
||||
|
||||
|
@ -204,7 +208,8 @@ CabinetSetEventHandlers(
|
|||
IN PCABINET_CONTEXT CabinetContext,
|
||||
IN PCABINET_OVERWRITE Overwrite,
|
||||
IN PCABINET_EXTRACT Extract,
|
||||
IN PCABINET_DISK_CHANGE DiskChange);
|
||||
IN PCABINET_DISK_CHANGE DiskChange,
|
||||
IN PCABINET_CREATE_FILE CreateFile);
|
||||
|
||||
/* Get pointer to cabinet reserved area. NULL if none */
|
||||
PVOID
|
||||
|
|
|
@ -117,7 +117,7 @@ SetupExtractFile(
|
|||
|
||||
CabinetInitialize(&QueueHeader->CabinetContext);
|
||||
CabinetSetEventHandlers(&QueueHeader->CabinetContext,
|
||||
NULL, NULL, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
CabinetSetCabinetName(&QueueHeader->CabinetContext, CabinetFileName);
|
||||
|
||||
CabStatus = CabinetOpen(&QueueHeader->CabinetContext);
|
||||
|
|
Loading…
Reference in a new issue