Author: hbelusca
Date: Wed Aug 23 12:20:15 2017
New Revision: 75651
URL:
http://svn.reactos.org/svn/reactos?rev=75651&view=rev
Log:
[SETUPLIB]: Introduce and use a UnMapAndCloseFile() macro that calls UnMapFile() and
NtClose() on handles returned by the OpenAndMapFile() function.
Modified:
branches/setup_improvements/base/setup/lib/bldrsup.c
branches/setup_improvements/base/setup/lib/filesup.h
branches/setup_improvements/base/setup/lib/osdetect.c
branches/setup_improvements/base/setup/lib/partlist.c
branches/setup_improvements/base/setup/lib/setuplib.c
Modified: branches/setup_improvements/base/setup/lib/bldrsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] Wed Aug 23 12:20:15
2017
@@ -461,8 +461,9 @@
DPRINT1("IniCacheLoadFromMemory() failed (Status 0x%08lx)\n",
Status);
/* Finally, unmap and close the file */
- UnMapFile(BootStore->SectionHandle, BootStore->ViewBase);
- NtClose(BootStore->FileHandle);
+ UnMapAndCloseFile(BootStore->FileHandle,
+ BootStore->SectionHandle,
+ BootStore->ViewBase);
RtlFreeHeap(ProcessHeap, 0, BootStore);
return Status;
@@ -715,8 +716,9 @@
if (BootStore->SectionHandle)
{
/* Finally, unmap and close the file */
- UnMapFile(BootStore->SectionHandle, BootStore->ViewBase);
- NtClose(BootStore->FileHandle);
+ UnMapAndCloseFile(BootStore->FileHandle,
+ BootStore->SectionHandle,
+ BootStore->ViewBase);
}
else // if (BootStore->FileHandle)
{
Modified: branches/setup_improvements/base/setup/lib/filesup.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/filesup.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/filesup.h [iso-8859-1] Wed Aug 23 12:20:15
2017
@@ -102,4 +102,10 @@
IN HANDLE SectionHandle,
IN PVOID BaseAddress);
+#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress) \
+do { \
+ UnMapFile((SectionHandle), (BaseAddress)); \
+ NtClose(FileHandle); \
+} while (1)
+
/* EOF */
Modified: branches/setup_improvements/base/setup/lib/osdetect.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] Wed Aug 23 12:20:15
2017
@@ -280,7 +280,7 @@
{
DPRINT1("File '%S' does not seem to be a valid PE, bail out\n",
PathNameToFile);
Status = STATUS_INVALID_IMAGE_FORMAT;
- goto UnmapFile;
+ goto UnmapCloseFile;
}
/*
@@ -291,7 +291,7 @@
if (!NT_SUCCESS(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);
@@ -329,10 +329,9 @@
if (!NT_SUCCESS(Status))
DPRINT1("No version vendor found for file '%S'\n",
PathNameToFile);
-UnmapFile:
+UnmapCloseFile:
/* Finally, unmap and close the file */
- UnMapFile(SectionHandle, ViewBase);
- NtClose(FileHandle);
+ UnMapAndCloseFile(FileHandle, SectionHandle, ViewBase);
return Success;
}
Modified: branches/setup_improvements/base/setup/lib/partlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/partlist.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/partlist.c [iso-8859-1] Wed Aug 23 12:20:15
2017
@@ -838,7 +838,7 @@
continue;
}
- /* check if the signature already exist */
+ /* Check if the signature already exist */
/* FIXME:
* Check also signatures from disks, which are
* not visible (bootable) by the bios.
Modified: branches/setup_improvements/base/setup/lib/setuplib.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
==============================================================================
--- branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] Wed Aug 23 12:20:15
2017
@@ -370,8 +370,7 @@
}
/* Finally, unmap and close the file */
- UnMapFile(SectionHandle, ViewBase);
- NtClose(UnattendFileHandle);
+ UnMapAndCloseFile(UnattendFileHandle, SectionHandle, ViewBase);
NtClose(FileHandle);
#endif