mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:42:57 +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",
|
DPRINT("Extracting file at uncompressed offset (0x%X) Size (%d bytes)\n",
|
||||||
(UINT)Search->File->FileOffset, (UINT)Search->File->FileSize);
|
(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);
|
RtlInitAnsiString(&AnsiString, Search->File->FileName);
|
||||||
wcscpy(DestName, CabinetContext->DestPath);
|
wcscpy(DestName, CabinetContext->DestPath);
|
||||||
UnicodeString.MaximumLength = sizeof(DestName) - wcslen(DestName) * sizeof(WCHAR);
|
UnicodeString.MaximumLength = sizeof(DestName) - wcslen(DestName) * sizeof(WCHAR);
|
||||||
|
@ -1146,6 +1158,7 @@ CabinetExtractFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
SetAttributesOnFile(Search->File, DestFile);
|
SetAttributesOnFile(Search->File, DestFile);
|
||||||
|
}
|
||||||
|
|
||||||
/* Call extract event handler */
|
/* Call extract event handler */
|
||||||
if (CabinetContext->ExtractHandler != NULL)
|
if (CabinetContext->ExtractHandler != NULL)
|
||||||
|
@ -1250,12 +1263,15 @@ CabinetExtractFile(
|
||||||
Status = CAB_STATUS_SUCCESS;
|
Status = CAB_STATUS_SUCCESS;
|
||||||
|
|
||||||
UnmapDestFile:
|
UnmapDestFile:
|
||||||
|
if (!CabinetContext->CreateFileHandler)
|
||||||
NtUnmapViewOfSection(NtCurrentProcess(), DestFileBuffer);
|
NtUnmapViewOfSection(NtCurrentProcess(), DestFileBuffer);
|
||||||
|
|
||||||
CloseDestFileSection:
|
CloseDestFileSection:
|
||||||
|
if (!CabinetContext->CreateFileHandler)
|
||||||
NtClose(DestFileSection);
|
NtClose(DestFileSection);
|
||||||
|
|
||||||
CloseDestFile:
|
CloseDestFile:
|
||||||
|
if (!CabinetContext->CreateFileHandler)
|
||||||
NtClose(DestFile);
|
NtClose(DestFile);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -1316,11 +1332,13 @@ CabinetSetEventHandlers(
|
||||||
IN PCABINET_CONTEXT CabinetContext,
|
IN PCABINET_CONTEXT CabinetContext,
|
||||||
IN PCABINET_OVERWRITE Overwrite,
|
IN PCABINET_OVERWRITE Overwrite,
|
||||||
IN PCABINET_EXTRACT Extract,
|
IN PCABINET_EXTRACT Extract,
|
||||||
IN PCABINET_DISK_CHANGE DiskChange)
|
IN PCABINET_DISK_CHANGE DiskChange,
|
||||||
|
IN PCABINET_CREATE_FILE CreateFile)
|
||||||
{
|
{
|
||||||
CabinetContext->OverwriteHandler = Overwrite;
|
CabinetContext->OverwriteHandler = Overwrite;
|
||||||
CabinetContext->ExtractHandler = Extract;
|
CabinetContext->ExtractHandler = Extract;
|
||||||
CabinetContext->DiskChangeHandler = DiskChange;
|
CabinetContext->DiskChangeHandler = DiskChange;
|
||||||
|
CabinetContext->CreateFileHandler = CreateFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -65,6 +65,9 @@ typedef VOID (*PCABINET_DISK_CHANGE)(
|
||||||
IN PCWSTR CabinetName,
|
IN PCWSTR CabinetName,
|
||||||
IN PCWSTR DiskLabel);
|
IN PCWSTR DiskLabel);
|
||||||
|
|
||||||
|
typedef PVOID (*PCABINET_CREATE_FILE)(
|
||||||
|
IN struct _CABINET_CONTEXT* CabinetContext,
|
||||||
|
IN ULONG FileSize);
|
||||||
|
|
||||||
/* Classes */
|
/* Classes */
|
||||||
|
|
||||||
|
@ -106,6 +109,7 @@ typedef struct _CABINET_CONTEXT
|
||||||
PCABINET_OVERWRITE OverwriteHandler;
|
PCABINET_OVERWRITE OverwriteHandler;
|
||||||
PCABINET_EXTRACT ExtractHandler;
|
PCABINET_EXTRACT ExtractHandler;
|
||||||
PCABINET_DISK_CHANGE DiskChangeHandler;
|
PCABINET_DISK_CHANGE DiskChangeHandler;
|
||||||
|
PCABINET_CREATE_FILE CreateFileHandler;
|
||||||
PVOID CabinetReservedArea;
|
PVOID CabinetReservedArea;
|
||||||
} CABINET_CONTEXT, *PCABINET_CONTEXT;
|
} CABINET_CONTEXT, *PCABINET_CONTEXT;
|
||||||
|
|
||||||
|
@ -204,7 +208,8 @@ CabinetSetEventHandlers(
|
||||||
IN PCABINET_CONTEXT CabinetContext,
|
IN PCABINET_CONTEXT CabinetContext,
|
||||||
IN PCABINET_OVERWRITE Overwrite,
|
IN PCABINET_OVERWRITE Overwrite,
|
||||||
IN PCABINET_EXTRACT Extract,
|
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 */
|
/* Get pointer to cabinet reserved area. NULL if none */
|
||||||
PVOID
|
PVOID
|
||||||
|
|
|
@ -117,7 +117,7 @@ SetupExtractFile(
|
||||||
|
|
||||||
CabinetInitialize(&QueueHeader->CabinetContext);
|
CabinetInitialize(&QueueHeader->CabinetContext);
|
||||||
CabinetSetEventHandlers(&QueueHeader->CabinetContext,
|
CabinetSetEventHandlers(&QueueHeader->CabinetContext,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
CabinetSetCabinetName(&QueueHeader->CabinetContext, CabinetFileName);
|
CabinetSetCabinetName(&QueueHeader->CabinetContext, CabinetFileName);
|
||||||
|
|
||||||
CabStatus = CabinetOpen(&QueueHeader->CabinetContext);
|
CabStatus = CabinetOpen(&QueueHeader->CabinetContext);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue