mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 20:50:29 +00:00
[SETUPLIB] Introduce and use a UnMapAndCloseFile() macro that calls UnMapFile() and NtClose() on handles returned by the OpenAndMapFile() function.
svn path=/branches/setup_improvements/; revision=75651 svn path=/branches/setup_improvements/; revision=75657
This commit is contained in:
parent
29fe31df1b
commit
a80f803a2a
5 changed files with 18 additions and 12 deletions
|
@ -461,8 +461,9 @@ OpenIniBootLoaderStore(
|
||||||
DPRINT1("IniCacheLoadFromMemory() failed (Status 0x%08lx)\n", Status);
|
DPRINT1("IniCacheLoadFromMemory() failed (Status 0x%08lx)\n", Status);
|
||||||
|
|
||||||
/* Finally, unmap and close the file */
|
/* Finally, unmap and close the file */
|
||||||
UnMapFile(BootStore->SectionHandle, BootStore->ViewBase);
|
UnMapAndCloseFile(BootStore->FileHandle,
|
||||||
NtClose(BootStore->FileHandle);
|
BootStore->SectionHandle,
|
||||||
|
BootStore->ViewBase);
|
||||||
|
|
||||||
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
RtlFreeHeap(ProcessHeap, 0, BootStore);
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -715,8 +716,9 @@ Quit:
|
||||||
if (BootStore->SectionHandle)
|
if (BootStore->SectionHandle)
|
||||||
{
|
{
|
||||||
/* Finally, unmap and close the file */
|
/* Finally, unmap and close the file */
|
||||||
UnMapFile(BootStore->SectionHandle, BootStore->ViewBase);
|
UnMapAndCloseFile(BootStore->FileHandle,
|
||||||
NtClose(BootStore->FileHandle);
|
BootStore->SectionHandle,
|
||||||
|
BootStore->ViewBase);
|
||||||
}
|
}
|
||||||
else // if (BootStore->FileHandle)
|
else // if (BootStore->FileHandle)
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,4 +100,10 @@ UnMapFile(
|
||||||
IN HANDLE SectionHandle,
|
IN HANDLE SectionHandle,
|
||||||
IN PVOID BaseAddress);
|
IN PVOID BaseAddress);
|
||||||
|
|
||||||
|
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress) \
|
||||||
|
do { \
|
||||||
|
UnMapFile((SectionHandle), (BaseAddress)); \
|
||||||
|
NtClose(FileHandle); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -284,7 +284,7 @@ CheckForValidPEAndVendor(
|
||||||
{
|
{
|
||||||
DPRINT1("File '%S' does not seem to be a valid PE, bail out\n", PathNameToFile);
|
DPRINT1("File '%S' does not seem to be a valid PE, bail out\n", PathNameToFile);
|
||||||
Status = STATUS_INVALID_IMAGE_FORMAT;
|
Status = STATUS_INVALID_IMAGE_FORMAT;
|
||||||
goto UnmapFile;
|
goto UnmapCloseFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -295,7 +295,7 @@ CheckForValidPEAndVendor(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed to get version resource for file '%S', Status 0x%08lx\n", PathNameToFile, Status);
|
DPRINT1("Failed to get version resource for file '%S', Status 0x%08lx\n", PathNameToFile, Status);
|
||||||
goto UnmapFile;
|
goto UnmapCloseFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = NtVerQueryValue(VersionBuffer, L"\\VarFileInfo\\Translation", &pvData, &BufLen);
|
Status = NtVerQueryValue(VersionBuffer, L"\\VarFileInfo\\Translation", &pvData, &BufLen);
|
||||||
|
@ -333,10 +333,9 @@ CheckForValidPEAndVendor(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
DPRINT1("No version vendor found for file '%S'\n", PathNameToFile);
|
DPRINT1("No version vendor found for file '%S'\n", PathNameToFile);
|
||||||
|
|
||||||
UnmapFile:
|
UnmapCloseFile:
|
||||||
/* Finally, unmap and close the file */
|
/* Finally, unmap and close the file */
|
||||||
UnMapFile(SectionHandle, ViewBase);
|
UnMapAndCloseFile(FileHandle, SectionHandle, ViewBase);
|
||||||
NtClose(FileHandle);
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -841,7 +841,7 @@ SetDiskSignature(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if the signature already exist */
|
/* Check if the signature already exist */
|
||||||
/* FIXME:
|
/* FIXME:
|
||||||
* Check also signatures from disks, which are
|
* Check also signatures from disks, which are
|
||||||
* not visible (bootable) by the bios.
|
* not visible (bootable) by the bios.
|
||||||
|
|
|
@ -373,8 +373,7 @@ Quit:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, unmap and close the file */
|
/* Finally, unmap and close the file */
|
||||||
UnMapFile(SectionHandle, ViewBase);
|
UnMapAndCloseFile(UnattendFileHandle, SectionHandle, ViewBase);
|
||||||
NtClose(UnattendFileHandle);
|
|
||||||
|
|
||||||
NtClose(FileHandle);
|
NtClose(FileHandle);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue