ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
13 participants
192 discussions
Start a n
N
ew thread
[ion] 70629: [BOOTLIB]: Begin PE loader. Works so far. Next up is loading the sections, zeroing out the .bss, and computing checksum.
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 17:00:18 2016 New Revision: 70629 URL:
http://svn.reactos.org/svn/reactos?rev=70629&view=rev
Log: [BOOTLIB]: Begin PE loader. Works so far. Next up is loading the sections, zeroing out the .bss, and computing checksum. Modified: trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/misc/image.c Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Wed Jan 20 17:00:18 2016 @@ -147,6 +147,13 @@ #define BL_LOAD_IMG_UNKNOWN_BUFFER_FLAG 0x08 #define BL_LOAD_IMG_COMPUTE_SIGNATURE 0x10 #define BL_LOAD_IMG_COMPUTE_HASH 0x40000 + +#define BL_LOAD_PE_IMG_VIRTUAL_BUFFER BL_LOAD_IMG_VIRTUAL_BUFFER +#define BL_LOAD_PE_IMG_CHECK_MACHINE 0x02 +#define BL_LOAD_PE_IMG_EXISTING_BUFFER BL_LOAD_IMG_EXISTING_BUFFER +#define BL_LOAD_PE_IMG_COMPUTE_HASH 0x10 +#define BL_LOAD_PE_IMG_CHECK_SUBSYSTEM 0x80 +#define BL_LOAD_PE_IMG_CHECK_FORCED_INTEGRITY 0x200 /* ENUMERATIONS **************************************************************/ Modified: trunk/reactos/boot/environ/lib/misc/image.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/imag…
============================================================================== --- trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] Wed Jan 20 17:00:18 2016 @@ -655,15 +655,240 @@ ImgpLoadPEImage ( _In_ PBL_IMG_FILE ImageFile, _In_ BL_MEMORY_TYPE MemoryType, - _Out_ PVOID* ImageBase, + _Inout_ PVOID* ImageBase, _Out_ PULONG ImageSize, - _Out_ PVOID Hash, + _Inout_opt_ PVOID Hash, _In_ ULONG Flags ) { - /* Micro-PE loader (no imports/exports/etc) */ - EfiPrintf(L"PE not implemented\r\n"); - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + ULONG FileSize, HeaderSize; + PVOID ImageBuffer; + BL_IMG_FILE LocalFileBuffer; + PBL_IMG_FILE LocalFile; + PVOID VirtualAddress; + ULONGLONG VirtualSize; + PHYSICAL_ADDRESS PhysicalAddress; + PIMAGE_NT_HEADERS NtHeaders; + + /* Initialize locals */ + LocalFile = NULL; + ImageBuffer = NULL; + FileSize = 0; + + /* Get the size of the image */ + Status = ImgpGetFileSize(ImageFile, &FileSize); + if (!NT_SUCCESS(Status)) + { + return STATUS_FILE_INVALID; + } + + /* Allocate a flat buffer for it */ + Status = BlImgAllocateImageBuffer(&ImageBuffer, BlLoaderData, FileSize, 0); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Read the whole file flat for now */ + Status = ImgpReadAtFileOffset(ImageFile, FileSize, 0, ImageBuffer, NULL); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Build a local file handle */ + LocalFile = &LocalFileBuffer; + LocalFileBuffer.FileName = ImageFile->FileName; + LocalFileBuffer.Flags = BL_IMG_MEMORY_FILE | BL_IMG_VALID_FILE; + LocalFileBuffer.BaseAddress = ImageBuffer; + LocalFileBuffer.FileSize = FileSize; + + /* Get the NT headers of the file */ + Status = RtlImageNtHeaderEx(0, ImageBuffer, FileSize, &NtHeaders); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Check if we should validate the machine type */ + if (Flags & BL_LOAD_PE_IMG_CHECK_MACHINE) + { + /* Is it different than our current machine type? */ +#if _M_AMD64 + if (NtHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64) +#else + if (NtHeaders->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) +#endif + { + /* Is it x86 (implying we are x64) ? */ + if (NtHeaders->FileHeader.Machine == IMAGE_FILE_MACHINE_I386) + { + /* Return special error code */ + Status = STATUS_INVALID_IMAGE_WIN_32; + } + else if (NtHeaders->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64) + { + /* Otherwise, it's x64 but we are x86 */ + Status = STATUS_INVALID_IMAGE_WIN_64; + } + else + { + /* Or it's ARM or something... */ + Status = STATUS_INVALID_IMAGE_FORMAT; + } + + /* Return with the distinguished error code */ + goto Quickie; + } + } + + /* Check if we should validate the subsystem */ + if (Flags & BL_LOAD_PE_IMG_CHECK_SUBSYSTEM) + { + /* It must be a Windows boot Application */ + if (NtHeaders->OptionalHeader.Subsystem != + IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION) + { + Status = STATUS_INVALID_IMAGE_FORMAT; + goto Quickie; + } + } + + /* Check if we should validate the /INTEGRITYCHECK flag */ + if (Flags & BL_LOAD_PE_IMG_CHECK_FORCED_INTEGRITY) + { + /* Check if it's there */ + if (!(NtHeaders->OptionalHeader.DllCharacteristics & + IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY)) + { + /* Nope, fail otherwise */ + Status = STATUS_INVALID_IMAGE_FORMAT; + goto Quickie; + } + } + + /* Check if we should compute the image hash */ + if ((Flags & BL_LOAD_PE_IMG_COMPUTE_HASH) || (Hash)) + { + EfiPrintf(L"No hash support\r\n"); + } + + /* Read the current base address, if any */ + VirtualAddress = *ImageBase; + + /* Get the virtual size of the image */ + VirtualSize = NtHeaders->OptionalHeader.SizeOfImage; + + /* Safely align the virtual size to a page */ + Status = RtlULongLongAdd(VirtualSize, + PAGE_SIZE - 1, + &VirtualSize); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + VirtualSize = ALIGN_DOWN_BY(VirtualSize, PAGE_SIZE); + + /* Make sure the image isn't larger than 4GB */ + if (VirtualSize > ULONG_MAX) + { + Status = STATUS_INVALID_IMAGE_FORMAT; + goto Quickie; + } + + /* Check if we have a buffer already */ + if (Flags & BL_LOAD_IMG_EXISTING_BUFFER) + { + /* Check if it's too small */ + if (*ImageSize < VirtualSize) + { + /* Fail, letting the caller know how big to make it */ + *ImageSize = VirtualSize; + Status = STATUS_BUFFER_TOO_SMALL; + } + } + else + { + /* Allocate the buffer with the flags and type the caller wants */ + Status = BlImgAllocateImageBuffer(&VirtualAddress, + MemoryType, + VirtualSize, + Flags); + } + + /* Bail out if allocation failed, or existing buffer is too small */ + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Read the size of the headers */ + HeaderSize = NtHeaders->OptionalHeader.SizeOfHeaders; + if (VirtualSize < HeaderSize) + { + /* Bail out if they're bigger than the image! */ + Status = STATUS_INVALID_IMAGE_FORMAT; + goto Quickie; + } + + /* Now read the header into the buffer */ + Status = ImgpReadAtFileOffset(LocalFile, HeaderSize, 0, VirtualAddress, NULL); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Get the NT headers of the file */ + Status = RtlImageNtHeaderEx(0, VirtualAddress, HeaderSize, &NtHeaders); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + EfiPrintf(L"MORE PE TODO: %lx\r\n", NtHeaders->OptionalHeader.AddressOfEntryPoint); + EfiStall(100000000); + +Quickie: + /* Check if we had an image buffer allocated */ + if ((ImageBuffer) && (FileSize)) + { + /* Free it */ + BlImgUnallocateImageBuffer(ImageBuffer, FileSize, 0); + } + + /* Check if we had a local file handle */ + if (LocalFile) + { + /* Close it */ + ImgpCloseFile(LocalFile); + } + + /* Check if this is the failure path */ + if (!NT_SUCCESS(Status)) + { + /* Check if we had started mapping in the image already */ + if ((VirtualAddress) && !(Flags & BL_LOAD_PE_IMG_EXISTING_BUFFER)) + { + /* Into a virtual buffer? */ + if (Flags & BL_LOAD_PE_IMG_VIRTUAL_BUFFER) + { + /* Unmap and free it */ + BlMmUnmapVirtualAddressEx(VirtualAddress, VirtualSize); + PhysicalAddress.QuadPart = (ULONG_PTR)VirtualAddress; + BlMmFreePhysicalPages(PhysicalAddress); + } + else + { + /* Into a physical buffer -- free it */ + EfiPrintf(L"Leaking physical pages\r\n"); + // MmPapFreePages(VirtualAddress, TRUE); + } + } + } + + /* Return back to caller */ + return Status; } NTSTATUS @@ -691,7 +916,7 @@ } /* If we are loading a pre-allocated image, make sure we have it */ - if ((Flags & 4) && (!(*ImageBase) || !(ImageSize))) + if ((Flags & BL_LOAD_IMG_EXISTING_BUFFER) && (!(*ImageBase) || !(ImageSize))) { return STATUS_INVALID_PARAMETER; } @@ -707,11 +932,6 @@ ImageSize, Hash, Flags); - } - else - { - /* For temporary debugging */ - EfiPrintf(L"Couldn't open file: %lx\r\n", Status); } /* Close the image file and return back to caller */ @@ -750,8 +970,6 @@ ImageSize = 0; ImageBase = NULL; - EfiPrintf(L"Loading application %p\r\n", BootEntry); - /* Check for "allowed in-memory settings" */ Status = BlpGetBootOptionIntegerList(BootEntry->BcdData, BcdLibraryIntegerList_AllowedInMemorySettings, @@ -804,12 +1022,10 @@ } /* Open the device */ - EfiPrintf(L"Opening device for path: %s\r\n", Path); Status = BlpDeviceOpen(Device, BL_DEVICE_READ_ACCESS, 0, &DeviceId); - EfiPrintf(L"Device ID: %lx %lx\r\n", Status, DeviceId); if (!NT_SUCCESS(Status)) { goto Quickie;
8 years, 11 months
1
0
0
0
[akhaldi] 70628: [0.4.0] * Merge the missing Italian STRING_EXTENDED_PARTITION fix in r70627. CORE-10809
by akhaldi@svn.reactos.org
Author: akhaldi Date: Wed Jan 20 15:26:48 2016 New Revision: 70628 URL:
http://svn.reactos.org/svn/reactos?rev=70628&view=rev
Log: [0.4.0] * Merge the missing Italian STRING_EXTENDED_PARTITION fix in r70627. CORE-10809 Modified: branches/ros-branch-0_4_0/ (props changed) branches/ros-branch-0_4_0/reactos/ (props changed) branches/ros-branch-0_4_0/reactos/base/setup/usetup/lang/it-IT.h Propchange: branches/ros-branch-0_4_0/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Jan 20 15:26:48 2016 @@ -1 +1 @@ -/trunk:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70482,70485-70487,70497,70499-70501,70507-70510,70512-70513,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606 +/trunk:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70482,70485-70487,70497,70499-70501,70507-70510,70512-70513,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606,70627 Propchange: branches/ros-branch-0_4_0/reactos/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Jan 20 15:26:48 2016 @@ -20,4 +20,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70482,70485-70487,70497,70501,70507-70510,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606 +/trunk/reactos:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70482,70485-70487,70497,70501,70507-70510,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606,70627 Modified: branches/ros-branch-0_4_0/reactos/base/setup/usetup/lang/it-IT.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/base/s…
============================================================================== --- branches/ros-branch-0_4_0/reactos/base/setup/usetup/lang/it-IT.h [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/reactos/base/setup/usetup/lang/it-IT.h [iso-8859-1] Wed Jan 20 15:26:48 2016 @@ -1823,6 +1823,8 @@ " %sSpazio non partizionato%s %6lu %s"}, {STRING_MAXSIZE, "MB (max. %lu MB)"}, + {STRING_EXTENDED_PARTITION, + "Partizione estesa"}, {STRING_UNFORMATTED, "Nuova (Non formattata)"}, {STRING_FORMATUNUSED,
8 years, 11 months
1
0
0
0
[akhaldi] 70627: [USETUP] Add missing Italian STRING_EXTENDED_PARTITION string. CORE-10809
by akhaldi@svn.reactos.org
Author: akhaldi Date: Wed Jan 20 15:20:59 2016 New Revision: 70627 URL:
http://svn.reactos.org/svn/reactos?rev=70627&view=rev
Log: [USETUP] Add missing Italian STRING_EXTENDED_PARTITION string. CORE-10809 Modified: trunk/reactos/base/setup/usetup/lang/it-IT.h Modified: trunk/reactos/base/setup/usetup/lang/it-IT.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/lang/it-…
============================================================================== --- trunk/reactos/base/setup/usetup/lang/it-IT.h [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/lang/it-IT.h [iso-8859-1] Wed Jan 20 15:20:59 2016 @@ -1823,6 +1823,8 @@ " %sSpazio non partizionato%s %6lu %s"}, {STRING_MAXSIZE, "MB (max. %lu MB)"}, + {STRING_EXTENDED_PARTITION, + "Partizione estesa"}, {STRING_UNFORMATTED, "Nuova (Non formattata)"}, {STRING_FORMATUNUSED,
8 years, 11 months
1
0
0
0
[ion] 70626: [ROSLOAD]: Create directory and build rules. rosload.efi is now dropped in system32\boot just like on the Windows Setup DVD. BlImgLoadBootApplication is able to find it. [BOOTMGR/BOOTL...
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 06:59:12 2016 New Revision: 70626 URL:
http://svn.reactos.org/svn/reactos?rev=70626&view=rev
Log: [ROSLOAD]: Create directory and build rules. rosload.efi is now dropped in system32\boot just like on the Windows Setup DVD. BlImgLoadBootApplication is able to find it. [BOOTMGR/BOOTLIB]: Fix factorings that were incorrect but not noticed when bootmgr was the only bootlib user. Now with rosload in the picture, they became obvious. [EFISYS]: BCD should not be on the EFISYS.BIN, only on the boot volume, just like a Windows DVD. Added: trunk/reactos/boot/environ/app/rosload/ (with props) trunk/reactos/boot/environ/app/rosload/rosload.c (with props) trunk/reactos/boot/environ/app/rosload/rosload.h (with props) trunk/reactos/boot/environ/lib/misc/rtlcompat.c - copied, changed from r70605, trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c Removed: trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c Modified: trunk/reactos/boot/CMakeLists.txt trunk/reactos/boot/environ/CMakeLists.txt trunk/reactos/boot/environ/app/bootmgr/bootmgr.c trunk/reactos/boot/environ/app/bootmgr/efiemu.c trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/bootlib.c trunk/reactos/boot/environ/lib/io/etfs.c Modified: trunk/reactos/boot/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/CMakeLists.txt?rev=70…
============================================================================== --- trunk/reactos/boot/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/CMakeLists.txt [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -16,7 +16,7 @@ endif() add_custom_target(efisys - COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $<TARGET_FILE:bootmgfw> EFI/BOOT/boot${EFI_PLATFORM_ID}.efi -add ${CMAKE_BINARY_DIR}/boot/bootdata/BCD EFI/BOOT/BCD + COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $<TARGET_FILE:bootmgfw> EFI/BOOT/boot${EFI_PLATFORM_ID}.efi DEPENDS native-fatten fat bootmgfw bcd_hive VERBATIM) Modified: trunk/reactos/boot/environ/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
============================================================================== --- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -18,6 +18,7 @@ lib/misc/image.c lib/misc/resource.c lib/misc/font.c + lib/misc/rtlcompat.c lib/firmware/fwutil.c lib/firmware/efi/firmware.c lib/mm/mm.c @@ -73,7 +74,6 @@ list(APPEND BOOTMGR_BASE_SOURCE app/bootmgr/efiemu.c app/bootmgr/bootmgr.c - app/bootmgr/rtlcompat.c ) add_executable(bootmgfw ${BOOTMGR_BASE_SOURCE} app/bootmgr/bootmgr.rc) @@ -105,3 +105,37 @@ add_dependencies(bootmgfw asm bugcodes) +list(APPEND ROSLOAD_BASE_SOURCE + app/rosload/rosload.c + ) + +add_executable(rosload ${ROSLOAD_BASE_SOURCE}) +set_target_properties(rosload PROPERTIES SUFFIX ".efi") + +if(MSVC) + add_target_link_flags(rosload "/ignore:4078 /ignore:4254 /DRIVER /FIXED") +else() + add_target_link_flags(rosload "-Wl,--strip-all,--exclude-all-symbols") +endif() + +set_image_base(rosload 0x10000) + +if(MSVC) + set_subsystem(rosload BOOT_APPLICATION) +else() + set_subsystem(rosload 14) +endif() + +set_entrypoint(rosload OslMain@4) + +target_link_libraries(rosload bootlib cportlib cmlib rtl libcntpr) + +if(STACK_PROTECTOR) + target_link_libraries(rosload gcc_ssp) +elseif(RUNTIME_CHECKS) + target_link_libraries(rosload runtmchk) +endif() + +add_dependencies(rosload asm bugcodes) + +add_cd_file(TARGET rosload DESTINATION reactos/system32/boot NO_CAB FOR all) Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -2862,7 +2862,7 @@ goto Failure; } XmlLoaded = TRUE; - EfiStall(100000000); + /* Check if there's an active bitmap visible */ if (!BlDisplayValidOemBitmap()) { Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/e…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -21,8 +21,6 @@ } BOOT_APPLICATION_PARAMETER_BLOCK_SCRATCH; /* DATA VARIABLES ************************************************************/ - -ULONG BlpApplicationFlags; BOOT_APPLICATION_PARAMETER_BLOCK_SCRATCH EfiInitScratch; Removed: trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/r…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c (removed) @@ -1,98 +0,0 @@ -/* -* COPYRIGHT: See COPYING.ARM in the top level directory -* PROJECT: ReactOS UEFI Boot Manager -* FILE: boot/environ/app/bootmgr/rtlcompat.c -* PURPOSE: RTL Library Compatibility Routines -* PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) -*/ - -/* INCLUDES ******************************************************************/ - -#include "bootmgr.h" - -/* FUNCTIONS *****************************************************************/ - -#if DBG -VOID FASTCALL -CHECK_PAGED_CODE_RTL ( - char *file, - int line - ) -{ - // boot-code is always ok -} -#endif - -PVOID MmHighestUserAddress = (PVOID)0xFFFFFFFF; - -PVOID -NTAPI -RtlpAllocateMemory ( - _In_ ULONG Bytes, - _In_ ULONG Tag - ) -{ - UNREFERENCED_PARAMETER(Tag); - return BlMmAllocateHeap(Bytes); -} - -VOID -NTAPI -RtlpFreeMemory ( - _In_ PVOID Mem, - _In_ ULONG Tag - ) -{ - UNREFERENCED_PARAMETER(Tag); - BlMmFreeHeap(Mem); -} - -NTSTATUS -NTAPI -RtlpSafeCopyMemory ( - _Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination, - _In_reads_bytes_(Length) CONST VOID UNALIGNED *Source, - _In_ SIZE_T Length - ) -{ - RtlCopyMemory(Destination, Source, Length); - return STATUS_SUCCESS; -} - -VOID -NTAPI -RtlAssert ( - IN PVOID FailedAssertion, - IN PVOID FileName, - IN ULONG LineNumber, - IN PCHAR Message OPTIONAL - ) -{ - EfiPrintf(L"*** ASSERTION %s FAILED AT %d in %s (%s) ***\r\n", - FailedAssertion, - LineNumber, - FileName, - Message); -} - -ULONG -DbgPrint ( - const char *Format, - ... - ) -{ - EfiPrintf(L"%s\r\n", Format); - return 0; -} - -VOID -NTAPI -KeBugCheckEx( - _In_ ULONG BugCheckCode, - _In_ ULONG_PTR BugCheckParameter1, - _In_ ULONG_PTR BugCheckParameter2, - _In_ ULONG_PTR BugCheckParameter3, - _In_ ULONG_PTR BugCheckParameter4) -{ - __assume(0); -} Propchange: trunk/reactos/boot/environ/app/rosload/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Wed Jan 20 06:59:12 2016 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/boot/environ/app/rosload/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/boot/environ/app/rosload/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/boot/environ/app/rosload/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/boot/environ/app/rosload/rosload.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/rosload/r…
============================================================================== --- trunk/reactos/boot/environ/app/rosload/rosload.c (added) +++ trunk/reactos/boot/environ/app/rosload/rosload.c [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -0,0 +1,39 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI OS Loader + * FILE: boot/environ/app/rosload/rosload.c + * PURPOSE: OS Loader Entrypoint + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "rosload.h" + +/* DATA VARIABLES ************************************************************/ + +/* FUNCTIONS *****************************************************************/ + +/*++ + * @name OslMain + * + * The BmMain function implements the Windows Boot Application entrypoint for + * the OS Loader. + * + * @param BootParameters + * Pointer to the Boot Application Parameter Block. + * + * @return NT_SUCCESS if the image was loaded correctly, relevant error code + * otherwise. + * + *--*/ +NTSTATUS +NTAPI +OslMain ( + _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters + ) +{ + EfiPrintf(L"ReactOS UEFI OS Loader Initializing...\r\n"); + return STATUS_NOT_IMPLEMENTED; +} + Propchange: trunk/reactos/boot/environ/app/rosload/rosload.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/boot/environ/app/rosload/rosload.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/rosload/r…
============================================================================== --- trunk/reactos/boot/environ/app/rosload/rosload.h (added) +++ trunk/reactos/boot/environ/app/rosload/rosload.h [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -0,0 +1,36 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI OS Loader + * FILE: boot/environ/app/rosload/rosload.h + * PURPOSE: Main OS Loader Header + * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) +*/ + +#ifndef _ROSLOAD_H +#define _ROSLOAD_H + +/* INCLUDES ******************************************************************/ + +/* C Headers */ +#include <stdlib.h> +#include <stdio.h> +#include <wchar.h> + +/* NT Base Headers */ +#include <initguid.h> +#include <ntifs.h> + +/* UEFI Headers */ +#include <Uefi.h> + +/* Boot Library Headers */ +#include <bl.h> + +/* BCD Headers */ +#include <bcd.h> + +/* STRUCTURES ****************************************************************/ + +/* FUNCTIONS *****************************************************************/ + +#endif Propchange: trunk/reactos/boot/environ/app/rosload/rosload.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -134,6 +134,9 @@ #define BL_FILE_ENTRY_READ_ACCESS 0x02 #define BL_FILE_ENTRY_WRITE_ACCESS 0x04 #define BL_FILE_ENTRY_UNKNOWN_ACCESS 0x10 +#define BL_FILE_ENTRY_DIRECTORY 0x10000 + +#define BL_ETFS_FILE_ENTRY_DIRECTORY 0x01 #define BL_IMG_VALID_FILE 0x01 #define BL_IMG_MEMORY_FILE 0x02 Modified: trunk/reactos/boot/environ/lib/bootlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
============================================================================== --- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -18,6 +18,7 @@ PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters; BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry; BOOLEAN BlpLibraryParametersInitialized; +ULONG BlpApplicationFlags; ULONG PdPersistAllocations; LIST_ENTRY BlpPdListHead; Modified: trunk/reactos/boot/environ/lib/io/etfs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/etfs.c…
============================================================================== --- trunk/reactos/boot/environ/lib/io/etfs.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/io/etfs.c [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -573,15 +573,18 @@ &FileSize, &IsDirectory); + /* Allocate a file entry */ NewFile = BlMmAllocateHeap(sizeof(*NewFile)); if (!NewFile) { return STATUS_NO_MEMORY; } + + /* Zero it out */ RtlZeroMemory(NewFile, sizeof(*NewFile)); + /* Figure out the size of the path and filename plus a slash and NUL */ Size = wcslen(Directory->FilePath) + wcslen(FileName) + 2; - FilePath = BlMmAllocateHeap(Size * sizeof(WCHAR)); if (!FilePath) { @@ -589,6 +592,7 @@ goto Quickie; } + /* Allocate an ETFS file entry */ EtfsFile = (PBL_ETFS_FILE)BlMmAllocateHeap(sizeof(*EtfsFile)); if (!EtfsFile) { @@ -596,48 +600,63 @@ goto Quickie; } + /* Zero it out */ RtlZeroMemory(NewFile, sizeof(*EtfsFile)); + /* Capture the device ID of the directory */ NewFile->DeviceId = Directory->DeviceId; + + /* Check if this is the root or a filename\directory under */ FormatString = L"%ls%ls"; if (Directory->FilePath[1]) { FormatString = L"%ls\\%ls"; } + /* Combine the paths, and save the final path in the file entry */ _snwprintf(FilePath, Size, FormatString, Directory->FilePath, FileName); NewFile->FilePath = FilePath; + /* Copy the ETFS function callbacks into the file netry */ RtlCopyMemory(&NewFile->Callbacks, &EtfsFunctionTable, sizeof(NewFile->Callbacks)); + + /* Fill out the rest of the details */ EtfsFile->DiskOffset = FileOffset; EtfsFile->DirOffset = DirOffset; EtfsFile->Size = FileSize; EtfsFile->DeviceId = DeviceId; + + /* Check if this is a directory */ if (IsDirectory) { - EtfsFile->Flags |= 1; - NewFile->Flags |= 0x10000; - } + EtfsFile->Flags |= BL_ETFS_FILE_ENTRY_DIRECTORY; + NewFile->Flags |= BL_FILE_ENTRY_DIRECTORY; + } + + /* Write down the name of the filesytem */ EtfsFile->FsName = L"cdfs"; + /* All done, return the file entry, and save the ETFS side */ NewFile->FsSpecificData = EtfsFile; *FileEntry = NewFile; return Status; Quickie: - + /* Failure path -- free the file path if we had one */ if (NewFile->FilePath) { BlMmFreeHeap(NewFile->FilePath); } + /* Free the ETFS file entry if we had one */ if (NewFile->FsSpecificData) { BlMmFreeHeap(NewFile->FsSpecificData); } + /* Free the file entry itself, and return the error code */ BlMmFreeHeap(NewFile); return Status; } Copied: trunk/reactos/boot/environ/lib/misc/rtlcompat.c (from r70605, trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c) URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/rtlc…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/rtlcompat.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/rtlcompat.c [iso-8859-1] Wed Jan 20 06:59:12 2016 @@ -1,14 +1,14 @@ /* * COPYRIGHT: See COPYING.ARM in the top level directory * PROJECT: ReactOS UEFI Boot Manager -* FILE: boot/environ/app/bootmgr/rtlcompat.c +* FILE: boot/environ/lib/misc/rtlcompat.c * PURPOSE: RTL Library Compatibility Routines * PROGRAMMER: Alex Ionescu (alex.ionescu(a)reactos.org) */ /* INCLUDES ******************************************************************/ -#include "bootmgr.h" +#include "bl.h" /* FUNCTIONS *****************************************************************/
8 years, 11 months
1
0
0
0
[ion] 70625: [HIVEBCD/BOOTMGR]: Prep work
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 03:53:59 2016 New Revision: 70625 URL:
http://svn.reactos.org/svn/reactos?rev=70625&view=rev
Log: [HIVEBCD/BOOTMGR]: Prep work Modified: trunk/reactos/boot/bootdata/hivebcd.inf trunk/reactos/boot/environ/app/bootmgr/bootmgr.c Modified: trunk/reactos/boot/bootdata/hivebcd.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivebcd.inf?…
============================================================================== --- trunk/reactos/boot/bootdata/hivebcd.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivebcd.inf [iso-8859-1] Wed Jan 20 03:53:59 2016 @@ -31,34 +31,15 @@ 00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 -BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\12000002","Element",,"\windows\system32\boot\winload.efi" ; path +BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\12000002","Element",,"\reactos\system32\boot\rosload.efi" ; path BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\12000004","Element",,"ReactOS Setup" ; description BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\12000005","Element",,"en-US" ; locale="en-US" BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\14000006","Element",0x10000,"{6efb52bf-1766-41db-a6b3-0ee5eff72bd7}" ; inherit={bootloadersettings} BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\16000060","Element",0x1,0x01 ; isolatedcontext=Yes -BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\22000002","Element",,"\windows" ; systemroot=\Windows +BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\22000002","Element",,"\reactos" ; systemroot=\Windows BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\26000010","Element",0x1,0x01 ; detecthal=Yes BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\26000022","Element",0x1,0x01 ; winpe=Yes BCD,"BCD00000000\Objects\{7619dcc9-fafe-11d9-b411-000476eba25f}\Elements\260000b0","Element",0x1,0x01 ; ems=Yes - -; -; ReactOS Memory Tester -; -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Description","Type",0x00010001,0x10200005 ; identifier={memdiag} -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Elements\11000001","Element",0x1,\ ; device=boot - 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ - 05,00,00,00,\ - 00,00,00,00,\ - 48,00,00,00,\ - 00,00,00,00,\ - 00,00,00,00,\ - 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ - 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Elements\12000002","Element",,"\EFI\BOOT\MEMTEST.EFI" ; path -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Elements\12000004","Element",,"ReactOS Memory Diagnostics" ; description -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Elements\12000005","Element",,"en-US" ; locale="en-US" -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Elements\14000006","Element",0x10000,"{7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}" ; inherit={globalsettings} -BCD,"BCD00000000\Objects\{b2721d73-1db4-4c62-bf78-c548a880142d}\Elements\1600000b","Element",0x1,0x01 ; allowbadmemoryaccess=Yes ; ; Global Settings Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Wed Jan 20 03:53:59 2016 @@ -2862,7 +2862,7 @@ goto Failure; } XmlLoaded = TRUE; - + EfiStall(100000000); /* Check if there's an active bitmap visible */ if (!BlDisplayValidOemBitmap()) { @@ -2951,6 +2951,8 @@ Status = STATUS_NOT_IMPLEMENTED; goto Failure; } + + //BlResourceFindMessage(BM_MSG_TEST); /* At last, enter the boot selection stage */ SequenceId = 0;
8 years, 11 months
1
0
0
0
[ion] 70624: [BOOTLIB]: Cleanups and small fixes.
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 03:43:56 2016 New Revision: 70624 URL:
http://svn.reactos.org/svn/reactos?rev=70624&view=rev
Log: [BOOTLIB]: Cleanups and small fixes. Modified: trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/misc/image.c Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Wed Jan 20 03:43:56 2016 @@ -1324,6 +1324,11 @@ NTSTATUS BlpDisplayInitialize ( _In_ ULONG Flags + ); + +NTSTATUS +BlpDisplayReinitialize ( + VOID ); VOID Modified: trunk/reactos/boot/environ/lib/misc/image.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/imag…
============================================================================== --- trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] Wed Jan 20 03:43:56 2016 @@ -652,6 +652,21 @@ } NTSTATUS +ImgpLoadPEImage ( + _In_ PBL_IMG_FILE ImageFile, + _In_ BL_MEMORY_TYPE MemoryType, + _Out_ PVOID* ImageBase, + _Out_ PULONG ImageSize, + _Out_ PVOID Hash, + _In_ ULONG Flags + ) +{ + /* Micro-PE loader (no imports/exports/etc) */ + EfiPrintf(L"PE not implemented\r\n"); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS BlImgLoadPEImageEx ( _In_ ULONG DeviceId, _In_ BL_MEMORY_TYPE MemoryType, @@ -662,8 +677,46 @@ _In_ ULONG Flags ) { - EfiPrintf(L"PE not implemented\r\n"); - return STATUS_NOT_IMPLEMENTED; + BL_IMG_FILE ImageFile; + NTSTATUS Status; + + /* Initialize the image file structure */ + ImageFile.Flags = 0; + ImageFile.FileName = NULL; + + /* Check if the required parameter are missing */ + if (!(ImageBase) || !(Path)) + { + return STATUS_INVALID_PARAMETER; + } + + /* If we are loading a pre-allocated image, make sure we have it */ + if ((Flags & 4) && (!(*ImageBase) || !(ImageSize))) + { + return STATUS_INVALID_PARAMETER; + } + + /* Load the file from disk */ + Status = ImgpOpenFile(DeviceId, Path, 0, &ImageFile); + if (NT_SUCCESS(Status)) + { + /* If that worked, do the PE parsing */ + Status = ImgpLoadPEImage(&ImageFile, + MemoryType, + ImageBase, + ImageSize, + Hash, + Flags); + } + else + { + /* For temporary debugging */ + EfiPrintf(L"Couldn't open file: %lx\r\n", Status); + } + + /* Close the image file and return back to caller */ + ImgpCloseFile(&ImageFile); + return Status; } NTSTATUS @@ -675,22 +728,18 @@ NTSTATUS Status; PULONGLONG AllowedList; ULONGLONG AllowedCount; - ULONG i; + ULONG i, DeviceId, ImageSize, Flags, ListSize; LARGE_INTEGER Frequency; - PVOID UnlockCode; + PVOID UnlockCode, ImageBase; PBL_DEVICE_DESCRIPTOR Device, BitLockerDevice; - ULONG DeviceId; PWCHAR Path; PBL_APPLICATION_ENTRY AppEntry; PBL_IMG_FILE ImageFile; - PVOID ImageBase; - ULONG ImageSize; BOOLEAN DisableIntegrity, TestSigning; UCHAR Hash[64]; - ULONG Flags; - ULONG ListSize; PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry; + /* Initialize all locals */ BitLockerDevice = NULL; UnlockCode = NULL; ImageFile = NULL; @@ -703,6 +752,7 @@ EfiPrintf(L"Loading application %p\r\n", BootEntry); + /* Check for "allowed in-memory settings" */ Status = BlpGetBootOptionIntegerList(BootEntry->BcdData, BcdLibraryIntegerList_AllowedInMemorySettings, &AllowedList, @@ -710,10 +760,13 @@ TRUE); if (Status == STATUS_SUCCESS) { + /* Loop through the list of allowed setting */ for (i = 0; i < AllowedCount; i++) { + /* Find the super undocumented one */ if (AllowedList[i] == BcdLibraryInteger_UndocumentedMagic) { + /* If it's present, append the current perf frequence to it */ BlTimeQueryPerformanceCounter(&Frequency); BlAppendBootOptionInteger(BootEntry, BcdLibraryInteger_UndocumentedMagic, @@ -723,34 +776,49 @@ } #if BL_BITLOCKER_SUPPORT + /* Do bitlocker stuff */ Status = BlFveSecureBootUnlockBootDevice(BootEntry, &BitLockerDevice, &UnlockCode); -#else - Status = STATUS_SUCCESS; + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } #endif + + /* Get the device on which this application is on*/ + Status = BlGetBootOptionDevice(BootEntry->BcdData, + BcdLibraryDevice_ApplicationDevice, + &Device, + NULL); if (!NT_SUCCESS(Status)) { goto Quickie; } - Status = BlGetBootOptionDevice(BootEntry->BcdData, BcdLibraryDevice_ApplicationDevice, &Device, NULL); + /* Get the path of the application */ + Status = BlGetBootOptionString(BootEntry->BcdData, + BcdLibraryString_ApplicationPath, + &Path); if (!NT_SUCCESS(Status)) { goto Quickie; } - Status = BlGetBootOptionString(BootEntry->BcdData, BcdLibraryString_ApplicationPath, &Path); + /* Open the device */ + EfiPrintf(L"Opening device for path: %s\r\n", Path); + Status = BlpDeviceOpen(Device, + BL_DEVICE_READ_ACCESS, + 0, + &DeviceId); + EfiPrintf(L"Device ID: %lx %lx\r\n", Status, DeviceId); if (!NT_SUCCESS(Status)) { goto Quickie; } - Status = BlpDeviceOpen(Device, BL_DEVICE_READ_ACCESS, 0, &DeviceId); - if (!NT_SUCCESS(Status)) - { - goto Quickie; - } - - BlImgQueryCodeIntegrityBootOptions(BootEntry, &DisableIntegrity, &TestSigning); + /* Check for integrity BCD options */ + BlImgQueryCodeIntegrityBootOptions(BootEntry, + &DisableIntegrity, + &TestSigning); #if BL_TPM_SUPPORT RtlZeroMemory(&Context, sizeof(Context); @@ -758,27 +826,39 @@ BlEnNotifyEvent(0x10000003, &Context); #endif + /* Enable signing and hashing checks if integrity is enabled */ Flags = 0; if (!DisableIntegrity) { Flags = 0x8070; } - Status = BlImgLoadPEImageEx(DeviceId, BlLoaderMemory, Path, &ImageBase, &ImageSize, Hash, Flags); + /* Now call the PE loader to load the image */ + Status = BlImgLoadPEImageEx(DeviceId, + BlLoaderMemory, + Path, + &ImageBase, + &ImageSize, + Hash, + Flags); if (!NT_SUCCESS(Status)) { goto Quickie; } #if BL_KD_SUPPORT + /* Check if we should notify the debugger of load */ if (BdDebugTransitions) { + /* Initialize it */ BdForceDebug = 1; Status = BlBdInitialize(); if (NT_SUCCESS(Status)) { + /* Check if it's enabled */ if (BlBdDebuggerEnabled()) { + /* Send it an image load notification */ BdDebuggerNotPresent = FALSE; RtlInitUnicodeString(&PathString, Path); BlBdLoadImageSymbols(&PathString, ImageBase); @@ -788,27 +868,27 @@ #endif #if BL_BITLOCKER_SUPPORT + /* Do bitlocker stuff */ Status = BlSecureBootCheckPolicyOnFveDevice(BitLockerDevice); -#else - Status = STATUS_SUCCESS; + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } #endif + +#if BL_BITLOCKER_SUPPORT + /* Do bitlocker stuff */ + Status = BlFveSecureBootCheckpointBootApp(BootEntry, BitLockerDevice, Hash, UnlockCode); if (!NT_SUCCESS(Status)) { goto Quickie; } - -#if BL_BITLOCKER_SUPPORT - Status = BlFveSecureBootCheckpointBootApp(BootEntry, BitLockerDevice, Hash, UnlockCode); -#else -Status = STATUS_SUCCESS; #endif - if (!NT_SUCCESS(Status)) - { - goto Quickie; - } - + + /* Get the BCD option size */ ListSize = BlGetBootOptionListSize(BootEntry->BcdData); + /* Allocate an entry with all the BCD options */ AppEntry = BlMmAllocateHeap(ListSize + sizeof(*AppEntry)); if (!AppEntry) { @@ -816,21 +896,34 @@ goto Quickie; } + /* Zero it out */ RtlZeroMemory(AppEntry, sizeof(AppEntry)); + /* Initialize it */ strcpy(AppEntry->Signature, "BTAPENT"); AppEntry->Guid = BootEntry->Guid; AppEntry->Flags = BootEntry->Flags; + + /* Copy the BCD options */ RtlCopyMemory(&AppEntry->BcdData, BootEntry->BcdData, ListSize); - + /* Allocate the image entry */ ImageAppEntry = BlMmAllocateHeap(sizeof(*ImageAppEntry)); + if (!ImageAppEntry) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + /* Initialize it */ ImageAppEntry->ImageBase = ImageBase; ImageAppEntry->ImageSize = ImageSize; ImageAppEntry->AppEntry = AppEntry; + /* Check if this is the first entry */ if (!IapTableEntries) { + /* Allocate two entries */ IapAllocatedTableEntries = 0; IapTableEntries = 2; IapImageTable = BlMmAllocateHeap(IapTableEntries * sizeof(PVOID)); @@ -840,9 +933,11 @@ goto Quickie; } + /* Zero out the entries for now */ RtlZeroMemory(IapImageTable, sizeof(IapTableEntries * sizeof(PVOID))); } + /* Set this entry into the table */ Status = BlTblSetEntry(&IapImageTable, &IapTableEntries, ImageAppEntry, @@ -850,60 +945,75 @@ TblDoNotPurgeEntry); Quickie: + /* Is the device open? Close it if so */ if (DeviceId != 1) { BlDeviceClose(DeviceId); } + /* Is there an allocated device? Free it */ if (Device) { BlMmFreeHeap(Device); } + /* Is there an allocated path? Free it */ if (Path) { BlMmFreeHeap(Path); } + /* Is there a bitlocker device? Free it */ if (BitLockerDevice) { BlMmFreeHeap(BitLockerDevice); } + /* Is there a bitlocker unlock code? Free it */ if (UnlockCode) { BlMmFreeHeap(UnlockCode); } + /* Did we succeed in creating an entry? */ if (NT_SUCCESS(Status)) { + /* Remember there's one more in the table */ IapAllocatedTableEntries++; - } - else - { - if (ImageBase) - { - BlImgUnLoadImage(ImageBase, ImageSize, 0); - } - - if (AppEntry) - { - BlMmFreeHeap(AppEntry); - } - - if (ImageFile) - { - BlMmFreeHeap(ImageFile); - } - - if (!(IapAllocatedTableEntries) && (IapImageTable)) - { - BlMmFreeHeap(IapImageTable); - IapTableEntries = 0; - IapImageTable = NULL; - } - } - + + /* Return success */ + return Status; + } + + /* Did we load an image after all? */ + if (ImageBase) + { + /* Unload it */ + BlImgUnLoadImage(ImageBase, ImageSize, 0); + } + + /* Did we allocate an app entry? Free it */ + if (AppEntry) + { + BlMmFreeHeap(AppEntry); + } + + /* Do we have an image file entry? Free it */ + if (ImageFile) + { + BlMmFreeHeap(ImageFile); + } + + /* Do we no longer have a single entry in the table? */ + if (!(IapAllocatedTableEntries) && (IapImageTable)) + { + /* Free and destroy the table */ + BlMmFreeHeap(IapImageTable); + IapTableEntries = 0; + IapImageTable = NULL; + } + + /* Return the failure code */ return Status; } @@ -912,11 +1022,14 @@ _In_ PBL_RETURN_ARGUMENTS ReturnArguments ) { + /* Check if any custom data was returned */ if (ReturnArguments->DataPage == 0) { + /* Nope, nothing to do */ return STATUS_SUCCESS; } + /* Yes, we have to parse it */ EfiPrintf(L"Return arguments not supported\r\n"); return STATUS_NOT_IMPLEMENTED; } @@ -929,6 +1042,7 @@ _In_ PBL_RETURN_ARGUMENTS ReturnArguments ) { + /* Not yet implemented. This is the last step! */ return STATUS_NOT_IMPLEMENTED; } @@ -944,67 +1058,81 @@ PLIST_ENTRY NextEntry, ListHead; NTSTATUS Status; + /* Check if we don't have an argument structure */ if (!ReturnArguments) { - LocalReturnArgs.Version = 1; + /* Initialize a local copy and use it instead */ + LocalReturnArgs.Version = BL_RETURN_ARGUMENTS_VERSION; LocalReturnArgs.Status = STATUS_SUCCESS; LocalReturnArgs.Flags = 0; LocalReturnArgs.DataPage = 0; LocalReturnArgs.DataSize = 0; - ReturnArguments = &LocalReturnArgs; } - + /* Make sure the handle index is valid */ if (IapTableEntries <= AppHandle) { return STATUS_INVALID_PARAMETER; } + /* Get the entry for this handle, making sure it exists */ ImageAppEntry = IapImageTable[AppHandle]; if (!ImageAppEntry) { return STATUS_INVALID_PARAMETER; } + /* Loop the registered file systems */ ListHead = &RegisteredFileSystems; NextEntry = RegisteredFileSystems.Flink; while (NextEntry != ListHead) { - FileSystem = CONTAINING_RECORD(NextEntry, BL_FILE_SYSTEM_ENTRY, ListEntry); - + /* Get the filesystem entry */ + FileSystem = CONTAINING_RECORD(NextEntry, + BL_FILE_SYSTEM_ENTRY, + ListEntry); + + /* See if it has a purge callback */ if (FileSystem->PurgeCallback) { + /* Call it */ FileSystem->PurgeCallback(); } + /* Move to the next entry */ NextEntry = NextEntry->Flink; } - /* TODO */ + /* TODO -- flush the block I/O cache too */ //BlockIoPurgeCache(); + /* Call into EFI land to start the boot application */ Status = ImgArchEfiStartBootApplication(ImageAppEntry->AppEntry, ImageAppEntry->ImageBase, ImageAppEntry->ImageSize, ReturnArguments); + /* Parse any arguments we got on the way back */ BlpPdParseReturnArguments(ReturnArguments); #if BL_BITLOCKER_SUPPORT + /* Bitlocker stuff */ FvebpCheckAllPartitions(TRUE); #endif #if BL_TPM_SUPPORT + /* Notify a TPM/SI event */ BlEnNotifyEvent(0x10000005, NULL); #endif - /* TODO */ - //BlpDisplayReinitialize(); - - /* TODO */ + /* Reset the display */ + BlpDisplayReinitialize(); + + /* TODO -- reset ETW */ //BlpLogInitialize(); + /* All done */ return Status; } @@ -1013,43 +1141,53 @@ _In_ ULONG AppHandle ) { - PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry; // esi@2 + PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry; NTSTATUS Status; + /* Make sure the handle index is valid */ if (IapTableEntries <= AppHandle) { return STATUS_INVALID_PARAMETER; } + /* Get the entry for this handle, making sure it exists */ ImageAppEntry = IapImageTable[AppHandle]; if (!ImageAppEntry) { return STATUS_INVALID_PARAMETER; } + /* Unload the image */ Status = BlImgUnLoadImage(ImageAppEntry->ImageBase, ImageAppEntry->ImageSize, 0); if (NT_SUCCESS(Status)) { + /* Normalize the success code */ Status = STATUS_SUCCESS; } else { + /* Normalize the failure code */ Status = STATUS_MEMORY_NOT_ALLOCATED; } + /* Free the entry and the image entry as well */ BlMmFreeHeap(ImageAppEntry->AppEntry); BlMmFreeHeap(ImageAppEntry); + /* Clear the handle */ IapImageTable[AppHandle] = NULL; + /* Free one entry */ if (!(--IapAllocatedTableEntries)) { + /* There are no more, so get rid of the table itself */ BlMmFreeHeap(IapImageTable); IapImageTable = NULL; IapTableEntries = 0; } + /* All good */ return Status; }
8 years, 11 months
1
0
0
0
[ion] 70623: [BOOTMGR]: Cleanup, less magic, one bug fix.
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 02:58:39 2016 New Revision: 70623 URL:
http://svn.reactos.org/svn/reactos?rev=70623&view=rev
Log: [BOOTMGR]: Cleanup, less magic, one bug fix. Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c trunk/reactos/boot/environ/app/bootmgr/bootmgr.h trunk/reactos/boot/environ/include/bl.h Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Wed Jan 20 02:58:39 2016 @@ -2005,533 +2005,708 @@ return Status; } +NTSTATUS +BmLaunchRecoverySequence ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, + _In_ ULONG LaunchCode + ) +{ + NTSTATUS Status; + PBL_LOADED_APPLICATION_ENTRY RecoveryEntry; + HANDLE BcdHandle; + PGUID RecoverySequence; + ULONG Count, i, RecoveryIndex, SequenceCount; + PBL_LOADED_APPLICATION_ENTRY* Sequence; + + /* Initialize locals */ + RecoveryIndex = 0; + Sequence = NULL; + RecoverySequence = NULL; + Count = 0; + BcdHandle = NULL; + + /* Open the BCD*/ + Status = BmOpenDataStore(&BcdHandle); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Get the recovery sequence list */ + Status = BlGetBootOptionGuidList(BootEntry->BcdData, + BcdLibraryObjectList_RecoverySequence, + &RecoverySequence, + &SequenceCount); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Get the sequence of boot entries out of it */ + Status = BmGetBootSequence(BcdHandle, + RecoverySequence, + SequenceCount, + BL_APPLICATION_ENTRY_RECOVERY, + &Sequence, + &Count); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + /* Was the BCD open? */ + if (BcdHandle) + { + /* Close it */ + BmCloseDataStore(BcdHandle); + } + + /* Now go over every entry in the sequence */ + for (i = 0; i < Count; ++i) + { + /* Check the code for this recovery launch */ + if (LaunchCode == 2 || LaunchCode == 5) + { + /* Remove the override if there is one, and set it to 4 */ + BlRemoveBootOption(Sequence[i]->BcdData, BcdLibraryInteger_DisplayMessageOverride); + BlAppendBootOptionInteger(Sequence[i], + BcdLibraryInteger_DisplayMessageOverride, + 4); + } + else if (LaunchCode == 3) + { + /* Remove the override if there is one, and set it to 10 */ + BlRemoveBootOption(Sequence[i]->BcdData, BcdLibraryInteger_DisplayMessageOverride); + BlAppendBootOptionInteger(Sequence[i], + BcdLibraryInteger_DisplayMessageOverride, + 10); + } + + /* Launch the boot entry for this part of the recovery sequence */ + Status = BmpLaunchBootEntry(Sequence[i], NULL, LaunchCode, FALSE); + if (!NT_SUCCESS(Status)) + { + break; + } + } + +Quickie: + /* Did we have a sequence of entries? */ + if (Sequence) + { + /* Loop through each one */ + for (RecoveryIndex = 0; RecoveryIndex < Count; RecoveryIndex++) + { + /* Does this index have an allocated boot entry? */ + RecoveryEntry = Sequence[RecoveryIndex]; + if (RecoveryEntry) + { + /* Destroy it */ + BlDestroyBootEntry(RecoveryEntry); + } + } + + /* Free the sequence itself */ + BlMmFreeHeap(Sequence); + } + + /* Was there a sequence list? */ + if (RecoverySequence) + { + /* Free it */ + BlMmFreeHeap(RecoverySequence); + } + + /* Return back to caller */ + return Status; +} + +ULONG +BmDisplayDumpError ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, + _In_ ULONG LaunchCode + ) +{ + ULONG BootError; + NTSTATUS Status; + BOOLEAN Restart, NoError; + + /* Assume we'll just reboot */ + BootError = Reboot; + + /* Should we reboot? */ + Status = BlGetBootOptionBoolean(BlpApplicationEntry.BcdData, + BcdLibraryBoolean_RestartOnFailure, + &Restart); + if ((NT_SUCCESS(Status)) && (Restart)) + { + return BootError; + } + + /* Should we not show errors, and thus, reboot? */ + Status = BlGetBootOptionBoolean(BlpApplicationEntry.BcdData, + BcdBootMgrBoolean_NoErrorDisplay, + &NoError); + if ((NT_SUCCESS(Status)) && (NoError)) + { + return BootError; + } + + /* Is there an internal boot error? */ + if (BmpInternalBootError) + { + /* Return it -- but it's a pointer? */ + return (ULONG)BmpInternalBootError; // ??? + } + + /* Otherwise, show the menu to see what to do */ + EfiPrintf(L"Error menu not yet implemented\r\n"); + return BootError; +} + +NTSTATUS +BmpCreateDevices ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry + ) +{ + ULONG NextOffset, DataOffset, ListOffset; + PBL_BCD_OPTION Option, ListOption; + BcdElementType ElementType; + PBCD_DEVICE_OPTION BcdDevice; + + /* Starting at offset 0, loop every BCD option */ + NextOffset = 0; + do + { + /* Get the current option, and its offset */ + Option = (PBL_BCD_OPTION)((ULONG_PTR)BootEntry->BcdData + NextOffset); + NextOffset = Option->NextEntryOffset; + + /* If it's empty, ignore it */ + if (Option->Empty) + { + continue; + } + + /* If it's not a device option, ignore it */ + ElementType.PackedValue = Option->Type; + if (ElementType.Format != BCD_TYPE_DEVICE) + { + continue; + } + + /* Get the data offset */ + DataOffset = Option->DataOffset; + + /* Extract the device out of it */ + BcdDevice = (PBCD_DEVICE_OPTION)((ULONG_PTR)BootEntry->BcdData + DataOffset); + + /* If the device is already fully specified, no need to build it */ + if (!(BcdDevice->DeviceDescriptor.Flags & 1)) + { + continue; + } + + /* Otherwise, check if there's any list options as well */ + ListOption = NULL; + ListOffset = Option->ListOffset; + if (Option->ListOffset) + { + ListOption = (PBL_BCD_OPTION)((ULONG_PTR)BootEntry->BcdData + ListOffset); + } + + /* And now call BlCreateDevice to build the full device descriptor */ + EfiPrintf(L"Unspecified devices not yet supported: %p\r\n", ListOption); + return STATUS_NOT_SUPPORTED; + } while (NextOffset != 0); + + /* Devices created successfully */ + return STATUS_SUCCESS; +} + +NTSTATUS +BmpTransferExecution ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, + _Out_ PULONG LaunchCode, + _Out_ PBOOLEAN Recover + ) +{ + PWCHAR AppPath; + NTSTATUS Status; + PBL_DEVICE_DESCRIPTOR AppDevice; + BL_RETURN_ARGUMENTS ReturnArgs; + BOOLEAN AdvancedOptions; + ULONG AppHandle; + + /* Get the application path */ + Status = BlGetBootOptionString(BootEntry->BcdData, + BcdLibraryString_ApplicationPath, + &AppPath); + if (!NT_SUCCESS(Status)) + { + /* If we couldn't find one, set this to NULL */ + AppPath = NULL; + } + + /* Check if this is a PXE
startup.com
*/ + if (BootEntry->Flags & BL_APPLICATION_ENTRY_STARTUP) + { +#if BL_NET_SUPPORT + /* Do soft reboot to launch it */ + Status = BlNetSoftReboot(BootEntry); +#else + EfiPrintf(L"Net boot not supported\r\n"); + Status = STATUS_NOT_SUPPORTED; +#endif + /* Nothing else for us to do */ + goto Quickie; + } + + /* Loop as long as boot was not cancelled */ + do + { + /* Load the boot application */ + Status = BlImgLoadBootApplication(BootEntry, &AppHandle); + + /* Did we not find it? */ + if (Status == STATUS_NOT_FOUND) + { + /* Get the device for the boot application */ + Status = BlGetBootOptionDevice(BootEntry->BcdData, + BcdLibraryDevice_ApplicationDevice, + &AppDevice, + NULL); + if (NT_SUCCESS(Status)) + { + /* Force re-enumeration */ + Status = BlFwEnumerateDevice(AppDevice); + } + + /* Did re-enumeration work? */ + if (!NT_SUCCESS(Status)) + { + /* Nope, raise a fatal error */ + BmFatalErrorEx(BL_FATAL_ERROR_APP_LOAD, + (ULONG_PTR)AppPath, + Status, + 0, + 0); + goto Quickie; + } + + /* Yes, try booting it again */ + Status = BlImgLoadBootApplication(BootEntry, &AppHandle); + } + + /* Was boot cancelled?*/ + if (Status == STATUS_CANCELLED) + { + /* Should we display the menu, or is there no launch sequence? */ + if ((BmGetBootMenuPolicy(BootEntry) != MenuPolicyStandard) || + !(MiscGetBootOption(BootEntry->BcdData, + BcdLibraryObjectList_RecoverySequence))) + { + /* Bail out, the menu will take care of it */ + goto Quickie; + } + + /* No menu and there's a sequence, launch it */ + *LaunchCode = 4; + *Recover = TRUE; + goto Quickie; + } + + /* STATUS_FVE_LOCKED_VOLUME -- bitlocker volume is locked */ + if (Status == 0xC0210000) + { + /* Launch recovery mode */ + *LaunchCode = 4; + *Recover = TRUE; + goto Quickie; + } + + /* Was there some other error launching the boot application? */ + if (!NT_SUCCESS(Status)) + { + /* Raise a fatal error */ + BmFatalErrorEx(BL_FATAL_ERROR_APP_LOAD, + (ULONG_PTR)AppPath, + Status, + 0, + 0); + goto Quickie; + } + + /* Zero out the return arguments */ + RtlZeroMemory(&ReturnArgs, sizeof(ReturnArgs)); + + /* Log to ETW this launch */ + //BmpLogApplicationLaunchEvent(&BootEntry->Guid, AppPath); + + /* Launch the boot application*/ + Status = BlImgStartBootApplication(AppHandle, &ReturnArgs); + +#if BL_BITLOCKER_SUPPORT + /* Bitlocker stuff */ + BlFveSecureBootCheckpointAppReturn(BootEntry, &ReturnArgs); +#endif + + /* Log in the boot status log the launch */ + //BlBsdLogEntry(1, 0x12, &BootEntry->Guid, 0x14); + + /* Unloac the boot application if we've returned */ + BlImgUnloadBootApplication(AppHandle); + + /* Keep going unless STATUS_RESTART_BOOT_APPLICATION */ + } while (Status != 0xC0000453); + + /* We've come back. Assume we need to launch the recovery sequence */ + *Recover = TRUE; + + /* Why did we get back? */ + if (ReturnArgs.Flags & 1) + { + /* Flag 1 -- should we display advanced options? */ + Status = BlGetBootOptionBoolean(BootEntry->BcdData, + BcdLibraryBoolean_DisplayAdvancedOptions, + &AdvancedOptions); + if ((NT_SUCCESS(Status)) && (AdvancedOptions)) + { + /* Yes, so return with code 2 */ + *LaunchCode = 2; + } + else + { + /* No, return with code 1 */ + *LaunchCode = 1; + } + } + else if (ReturnArgs.Flags & 4) + { + /* Flag 4 -- unkown */ + *LaunchCode = 1; + } + else if (ReturnArgs.Flags & 8) + { + /* Flag 5 -- unkown */ + *LaunchCode = 5; + } + else if (ReturnArgs.Flags & 0x10) + { + /* Flag 6 -- unkown */ + *LaunchCode = 6; + } + else if (ReturnArgs.Flags & 0x20) + { + /* Flag 7 -- unkown */ + *LaunchCode = 7; + } + else if (ReturnArgs.Flags & BL_RETURN_ARGUMENTS_NO_PAE_FLAG) + { + /* PAE is not supported -- refuse to boot */ + *Recover = FALSE; + BmFatalErrorEx(BL_FATAL_ERROR_NO_PAE, Status, 0, 0, 0); + } + +Quickie: + /* All done, did we have an application path? */ + if (AppPath) + { + /* Free it */ + BlMmFreeHeap(AppPath); + } + + /* Back to the caller now */ + return Status; +} + NTSTATUS BmpLaunchBootEntry ( _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, _Out_ PULONG EntryIndex, _In_ ULONG LaunchCode, _In_ BOOLEAN LaunchWinRe - ); - -NTSTATUS -BmLaunchRecoverySequence ( - _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, - _In_ ULONG LaunchCode - ) -{ - NTSTATUS Status; - PBL_LOADED_APPLICATION_ENTRY RecoveryEntry; - HANDLE BcdHandle; - PGUID RecoverySequence; - ULONG Count, i, RecoveryIndex, SequenceCount; - PBL_LOADED_APPLICATION_ENTRY* Sequence; - - RecoveryIndex = 0; - Sequence = NULL; - RecoverySequence = NULL; - Count = 0; - BcdHandle = NULL; - - Status = BmOpenDataStore(&BcdHandle); - if (NT_SUCCESS(Status)) - { - Status = BlGetBootOptionGuidList(BootEntry->BcdData, - BcdLibraryObjectList_RecoverySequence, - &RecoverySequence, - &SequenceCount); - if (NT_SUCCESS(Status)) - { - Status = BmGetBootSequence(BcdHandle, - RecoverySequence, - SequenceCount, - BL_APPLICATION_ENTRY_RECOVERY, - &Sequence, - &Count); - if (NT_SUCCESS(Status)) - { - if (BcdHandle) - { - BmCloseDataStore(BcdHandle); - } - - for (i = 0; i < Count; ++i) - { - if (LaunchCode == 2 || LaunchCode == 5) - { - BlRemoveBootOption(Sequence[i]->BcdData, BcdLibraryInteger_DisplayMessageOverride); - BlAppendBootOptionInteger(Sequence[i], - BcdLibraryInteger_DisplayMessageOverride, - 4); - } - else if (LaunchCode == 3) - { - BlRemoveBootOption(Sequence[i]->BcdData, BcdLibraryInteger_DisplayMessageOverride); - BlAppendBootOptionInteger(Sequence[i], - BcdLibraryInteger_DisplayMessageOverride, - 10); - } - - Status = BmpLaunchBootEntry(Sequence[i], NULL, LaunchCode, FALSE); - if (!NT_SUCCESS(Status)) - { - break; - } - } - } - - if (Sequence) - { - for (RecoveryIndex = 0; RecoveryIndex < Count; RecoveryIndex++) - { - RecoveryEntry = Sequence[RecoveryIndex]; - if (RecoveryEntry) - { - BlDestroyBootEntry(RecoveryEntry); - } - } - BlMmFreeHeap(Sequence); - } - } - - if (RecoverySequence) - { - BlMmFreeHeap(RecoverySequence); - } - } - - return Status; -} - -ULONG -BmDisplayDumpError ( - _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, - _In_ ULONG LaunchCode - ) -{ - ULONG BootError; - NTSTATUS Status; - BOOLEAN Restart, NoError; - - BootError = 1; - - Status = BlGetBootOptionBoolean(BlpApplicationEntry.BcdData, - BcdLibraryBoolean_RestartOnFailure, - &Restart); - if ((NT_SUCCESS(Status)) && (Restart)) - { - return BootError; - } - - Status = BlGetBootOptionBoolean(BlpApplicationEntry.BcdData, - BcdBootMgrBoolean_NoErrorDisplay, - &NoError); - if ((NT_SUCCESS(Status)) && (NoError)) - { - return BootError; - } - - if (BmpInternalBootError) - { - return (ULONG)BmpInternalBootError; // ??? - } - - EfiPrintf(L"Error menu not yet implemented\r\n"); - return BootError; -} - -NTSTATUS -BmpCreateDevices ( - _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry - ) -{ - ULONG NextOffset, DataOffset, ListOffset; - PBL_BCD_OPTION Option, ListOption; - BcdElementType ElementType; - PBCD_DEVICE_OPTION BcdDevice; - - NextOffset = 0; - do - { - Option = (PBL_BCD_OPTION)((ULONG_PTR)BootEntry->BcdData + NextOffset); - NextOffset = Option->NextEntryOffset; - - if (Option->Empty) - { - continue; - } - - ElementType.PackedValue = Option->Type; - if (ElementType.Format != BCD_TYPE_DEVICE) - { - continue; - } - - DataOffset = Option->DataOffset; - - BcdDevice = (PBCD_DEVICE_OPTION)((ULONG_PTR)BootEntry->BcdData + DataOffset); - if (!(BcdDevice->DeviceDescriptor.Flags & 1)) - { - continue; - } - - ListOption = NULL; - ListOffset = Option->ListOffset; - if (Option->ListOffset) - { - ListOption = (PBL_BCD_OPTION)((ULONG_PTR)BootEntry->BcdData + ListOffset); - } - - EfiPrintf(L"Unspecified devices not yet supported: %p\r\n", ListOption); - return STATUS_NOT_SUPPORTED; - } while (NextOffset != 0); - - return STATUS_SUCCESS; -} - - -NTSTATUS -BmpTransferExecution ( - _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, - _Out_ PULONG LaunchCode, - _Out_ PBOOLEAN Recover - ) -{ - PWCHAR AppPath; - NTSTATUS Status; - PBL_DEVICE_DESCRIPTOR AppDevice; - BL_RETURN_ARGUMENTS ReturnArgs; - BOOLEAN AdvancedOptions; - ULONG AppHandle; - - Status = BlGetBootOptionString(BootEntry->BcdData, - BcdLibraryString_ApplicationPath, - &AppPath); - if (!NT_SUCCESS(Status)) - { - AppPath = NULL; - } - - if (BootEntry->Flags & BL_APPLICATION_ENTRY_STARTUP) - { -#if BL_NET_SUPPORT - Status = BlNetSoftReboot(BootEntry); -#else - EfiPrintf(L"Net boot not supported\r\n"); - Status = STATUS_NOT_SUPPORTED; -#endif - goto Quickie; - } - - do - { - Status = BlImgLoadBootApplication(BootEntry, &AppHandle); - if (Status == STATUS_NOT_FOUND) - { - Status = BlGetBootOptionDevice(BootEntry->BcdData, - BcdLibraryDevice_ApplicationDevice, - &AppDevice, - NULL); - if (NT_SUCCESS(Status)) - { - Status = BlFwEnumerateDevice(AppDevice); - } - - if (!NT_SUCCESS(Status)) - { - BmFatalErrorEx(2, (ULONG_PTR)AppPath, Status, 0, 0); - goto Quickie; - } - - Status = BlImgLoadBootApplication(BootEntry, &AppHandle); - } - - if (Status == STATUS_CANCELLED) - { - if ((BmGetBootMenuPolicy(BootEntry) != MenuPolicyStandard) || - !(MiscGetBootOption(BootEntry->BcdData, - BcdLibraryObjectList_RecoverySequence))) - { - goto Quickie; - } - - *LaunchCode = 4; - *Recover = TRUE; - goto Quickie; - } - - if (Status == 0xC0210000) - { - *LaunchCode = 4; - *Recover = TRUE; - goto Quickie; - } - - if (!NT_SUCCESS(Status)) - { - BmFatalErrorEx(2, (ULONG_PTR)AppPath, Status, 0, 0); - goto Quickie; - } - - RtlZeroMemory(&ReturnArgs, sizeof(ReturnArgs)); - //BmpLogApplicationLaunchEvent(&BootEntry->Guid, AppPath); - - Status = BlImgStartBootApplication(AppHandle, &ReturnArgs); - -#if BL_BITLOCKER_SUPPORT - BlFveSecureBootCheckpointAppReturn(BootEntry, &ReturnArgs); -#endif - - //BlBsdLogEntry(1, 0x12, &BootEntry->Guid, 0x14); - - BlImgUnloadBootApplication(AppHandle); - - } while (Status != 0xC0000453); - - *Recover = TRUE; - if (ReturnArgs.Flags & 1) - { - Status = BlGetBootOptionBoolean(BootEntry->BcdData, - BcdLibraryBoolean_DisplayAdvancedOptions, - &AdvancedOptions); - if ((NT_SUCCESS(Status)) && (AdvancedOptions)) - { - *LaunchCode = 2; - } - else - { - *LaunchCode = 1; - } - } - else if (ReturnArgs.Flags & 4) - { - *LaunchCode = 1; - } - else if (ReturnArgs.Flags & 8) - { - *LaunchCode = 5; - } - else if (ReturnArgs.Flags & 0x10) - { - *LaunchCode = 6; - } - else if (ReturnArgs.Flags & 0x20) - { - *LaunchCode = 7; - } - else if (ReturnArgs.Flags & 0x40) - { - *Recover = FALSE; - BmFatalErrorEx(11, Status, 0, 0, 0); - } - -Quickie: - if (AppPath) - { - BlMmFreeHeap(AppPath); - } - - return Status; -} - -NTSTATUS -BmpLaunchBootEntry ( - _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, - _Out_ PULONG EntryIndex, - _In_ ULONG LaunchCode, - _In_ BOOLEAN LaunchWinRe ) { HANDLE BcdHandle; NTSTATUS Status; GUID ObjectId; - BOOLEAN DoRecovery, AutoRecovery, DoRestart, RestartOnFailure; + BOOLEAN DoRecovery, AutoRecovery, DoSequence, RestartOnFailure; ULONG ErrorCode; - BOOLEAN AdvancedOneTime, EditOneTime, Recover; - + BOOLEAN AdvancedOneTime, EditOneTime; + + /* Check if this is the OS loader */ if (BootEntry->Flags & BL_APPLICATION_ENTRY_WINLOAD) { - if (MiscGetBootOption(BootEntry->BcdData, BcdOSLoaderBoolean_AdvancedOptionsOneTime)) - { + /* Check if one-time advanced options should be shown */ + if (MiscGetBootOption(BootEntry->BcdData, + BcdOSLoaderBoolean_AdvancedOptionsOneTime)) + { + /* Open the BCD */ BcdHandle = NULL; Status = BmOpenDataStore(BcdHandle); if (NT_SUCCESS(Status)) { + /* Delete the option from the BCD, so it doesn't happen again */ ObjectId = BootEntry->Guid; - BmPurgeOption(BcdHandle, &ObjectId, BcdOSLoaderBoolean_AdvancedOptionsOneTime); + BmPurgeOption(BcdHandle, + &ObjectId, + BcdOSLoaderBoolean_AdvancedOptionsOneTime); BmCloseDataStore(BcdHandle); } } - if (MiscGetBootOption(BootEntry->BcdData, BcdOSLoaderBoolean_OptionsEditOneTime)) - { + + /* Check if one-time options editor should be shown */ + if (MiscGetBootOption(BootEntry->BcdData, + BcdOSLoaderBoolean_OptionsEditOneTime)) + { + /* Open the BCD */ BcdHandle = NULL; Status = BmOpenDataStore(BcdHandle); if (NT_SUCCESS(Status)) { + /* Delete the option from the BCD, so it doesn't happen again */ ObjectId = BootEntry->Guid; - BmPurgeOption(BcdHandle, &ObjectId, BcdOSLoaderBoolean_OptionsEditOneTime); + BmPurgeOption(BcdHandle, + &ObjectId, + BcdOSLoaderBoolean_OptionsEditOneTime); BmCloseDataStore(BcdHandle); } } } TryAgain: + /* Disable recovery mode */ DoRecovery = FALSE; - Recover = FALSE; + + /* Store globally which entry we are trying to boot */ BmpSelectedBootEntry = BootEntry; + /* Create any devices that aren't yet fully defined for this boot entry */ Status = BmpCreateDevices(BootEntry); if (!NT_SUCCESS(Status)) { + /* That failed -- can we launch the recovery environment? */ if (!LaunchWinRe) { return Status; } + /* Yes, so return with the WinRe launch code */ LaunchCode = 2; goto Quickie; } + /* Is this an OS loader/ */ if (BootEntry->Flags & BL_APPLICATION_ENTRY_WINLOAD) { - Status = BlGetBootOptionBoolean(BootEntry->BcdData, BcdOSLoaderBoolean_AdvancedOptionsOneTime, &AdvancedOneTime); + /* Is the one-time advanced options menu option present? */ + Status = BlGetBootOptionBoolean(BootEntry->BcdData, + BcdOSLoaderBoolean_AdvancedOptionsOneTime, + &AdvancedOneTime); if (NT_SUCCESS(Status)) { + /* Is it turned on? */ if (AdvancedOneTime) { - BlAppendBootOptionBoolean(BootEntry, BcdLibraryBoolean_DisplayAdvancedOptions); + /* Set the option this once */ + BlAppendBootOptionBoolean(BootEntry, + BcdLibraryBoolean_DisplayAdvancedOptions); } else { - BlRemoveBootOption(BootEntry->BcdData, BcdLibraryBoolean_DisplayAdvancedOptions); - } - - BlRemoveBootOption(BootEntry->BcdData, BcdOSLoaderBoolean_AdvancedOptionsOneTime); - } - - Status = BlGetBootOptionBoolean(BootEntry->BcdData, BcdOSLoaderBoolean_OptionsEditOneTime, &EditOneTime); + /* It's not, so disable the option if active */ + BlRemoveBootOption(BootEntry->BcdData, + BcdLibraryBoolean_DisplayAdvancedOptions); + } + + /* Remove the one-time option. We've already purged it earlier */ + BlRemoveBootOption(BootEntry->BcdData, + BcdOSLoaderBoolean_AdvancedOptionsOneTime); + } + + /* Is the one-time options editor menu option present? */ + Status = BlGetBootOptionBoolean(BootEntry->BcdData, + BcdOSLoaderBoolean_OptionsEditOneTime, + &EditOneTime); if (NT_SUCCESS(Status)) { - if (AdvancedOneTime) - { - BlAppendBootOptionBoolean(BootEntry, BcdLibraryBoolean_DisplayOptionsEdit); + /* Is it turned on? */ + if (EditOneTime) + { + /* Set the option this once */ + BlAppendBootOptionBoolean(BootEntry, + BcdLibraryBoolean_DisplayOptionsEdit); } else { - BlRemoveBootOption(BootEntry->BcdData, BcdLibraryBoolean_DisplayOptionsEdit); - } - - BlRemoveBootOption(BootEntry->BcdData, BcdOSLoaderBoolean_OptionsEditOneTime); - } - } - - Status = BmpTransferExecution(BootEntry, &LaunchCode, &Recover); + /* It's not, so disable the option if active */ + BlRemoveBootOption(BootEntry->BcdData, + BcdLibraryBoolean_DisplayOptionsEdit); + } + + /* Remove the one-time option. We've already purged it earlier */ + BlRemoveBootOption(BootEntry->BcdData, + BcdOSLoaderBoolean_OptionsEditOneTime); + } + } + + /* BCD handling done, transfer execution to this entry */ + Status = BmpTransferExecution(BootEntry, &LaunchCode, &DoRecovery); if (!LaunchWinRe) { return Status; } - DoRecovery = Recover; - - if (((NT_SUCCESS(Status)) || (Status == STATUS_CANCELLED)) && !(Recover)) + /* Check if boot was successfull, or cancelled and we're not doing WinRE */ + if (((NT_SUCCESS(Status)) || (Status == STATUS_CANCELLED)) && !(DoRecovery)) { return Status; } - if (!Recover) - { + /* Boot failed -- are we doing recovery? */ + if (!DoRecovery) + { + /* Nope, bail out */ LaunchCode = 2; goto Quickie; } Quickie: + /* Get the recovery sequence */ if (MiscGetBootOption(BootEntry->BcdData, BcdLibraryObjectList_RecoverySequence)) { + /* Check if the launch depends on auto-recovery being enabled or not */ if ((LaunchCode == 3) || (LaunchCode == 5) || (LaunchCode == 6)) { - Status = BlGetBootOptionBoolean(BootEntry->BcdData, BcdLibraryBoolean_AutoRecoveryEnabled, &AutoRecovery); + Status = BlGetBootOptionBoolean(BootEntry->BcdData, + BcdLibraryBoolean_AutoRecoveryEnabled, + &AutoRecovery); if (NT_SUCCESS(Status)) { + /* Override the setting */ DoRecovery = AutoRecovery; } } } else { + /* There's no recovery setting */ DoRecovery = FALSE; } + /* Check if we should restart on failure */ RestartOnFailure = FALSE; - BlGetBootOptionBoolean(BlpApplicationEntry.BcdData, BcdLibraryBoolean_RestartOnFailure, &RestartOnFailure); - DoRestart = RestartOnFailure ? FALSE : DoRecovery; + BlGetBootOptionBoolean(BlpApplicationEntry.BcdData, + BcdLibraryBoolean_RestartOnFailure, + &RestartOnFailure); + + /* Do the sequence if recovery is on, unless we should restart instead */ + DoSequence = RestartOnFailure ? FALSE : DoRecovery; while (1) { - if (DoRestart) - { + /* Are we doing the recovery sequence? */ + if (DoSequence) + { + /* Because of automatic recovery? */ if (AutoRecovery) { - //BlFveRegisterBootEntryForTrustedWimBoot(BootEntry, TRUE); - } - +#if BL_BITLOCKER_SUPPORT + /* Do bitlocker stuff */ + BlFveRegisterBootEntryForTrustedWimBoot(BootEntry, TRUE); +#endif + } + + /* Launch the recovery sequence*/ Status = BmLaunchRecoverySequence(BootEntry, LaunchCode); + /* Was it launched automatically? */ if (AutoRecovery) { - //BlFveRegisterBootEntryForTrustedWimBoot(BootEntry, FALSE); +#if BL_BITLOCKER_SUPPORT + /* Do bitlocker stuff */ + BlFveRegisterBootEntryForTrustedWimBoot(BootEntry, FALSE); +#endif + + /* No need to do this again */ AutoRecovery = FALSE; } + /* Did the recovery sequence work? */ if (NT_SUCCESS(Status)) { + /* All good */ return STATUS_SUCCESS; } + /* Remove the sequence, don't do it again */ BlRemoveBootOption(BootEntry->BcdData, BcdLibraryObjectList_RecoverySequence); } + /* Recovery sequence also failed, show fatal error */ if (!BmpInternalBootError) { - BmFatalErrorEx(4, Status, 0, 0, 0); - } - + BmFatalErrorEx(BL_FATAL_ERROR_GENERIC, Status, 0, 0, 0); + } + + /* Display the error menu */ ErrorCode = BmDisplayDumpError(BootEntry, LaunchCode); BmErrorPurge(); + /* See what the user wants to do */ switch (ErrorCode) { - case 6: + case TryAgain: + /* Try again */ goto TryAgain; - case 5: + + case NextOs: + /* Boot the next entry*/ break; - case 4: + + case OsSelection: + /* Cancel the boot*/ return STATUS_CANCELLED; - case 3: + + case RecoverOem: + /* Custom OEM recovery -- open the BCD */ Status = BmOpenDataStore(BcdHandle); if (NT_SUCCESS(Status)) { + /* See what the custom sequence is */ Status = BmProcessCustomAction(BcdHandle, NULL); } + + /* All done, close the BCD */ if (BcdHandle) { BmCloseDataStore(BcdHandle); } return Status; - case 7: + + case AdvancedOptions: + /* Show the advanced options next iteration */ BlAppendBootOptionBoolean(BootEntry, BcdOSLoaderBoolean_AdvancedOptionsOneTime); goto TryAgain; - case 8: + + case BootOptions: + /* Show the options editor next iteration */ BlAppendBootOptionBoolean(BootEntry, BcdOSLoaderBoolean_OptionsEditOneTime); goto TryAgain; - case 2: - DoRestart = TRUE; + + case Recover: + /* Try the recovery sequence next time*/ + DoSequence = TRUE; LaunchCode = 1; goto TryAgain; + default: + /* Something unknown */ return STATUS_CANCELLED; } } - - + /* We are booting the next OS, so return success as to not kill the boot */ return STATUS_SUCCESS; } Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/bootmgr.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.h [iso-8859-1] Wed Jan 20 02:58:39 2016 @@ -53,9 +53,11 @@ } BL_PACKED_BOOT_ERROR, *PBL_PACKED_BOOT_ERROR; #define BL_FATAL_ERROR_BCD_READ 0x01 +#define BL_FATAL_ERROR_APP_LOAD 0x02 #define BL_FATAL_ERROR_BCD_ENTRIES 0x03 #define BL_FATAL_ERROR_GENERIC 0x04 #define BL_FATAL_ERROR_BCD_PARSE 0x07 +#define BL_FATAL_ERROR_NO_PAE 0x0B /* FUNCTIONS *****************************************************************/ @@ -64,4 +66,12 @@ _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters ); +NTSTATUS +BmpLaunchBootEntry ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, + _Out_ PULONG EntryIndex, + _In_ ULONG LaunchCode, + _In_ BOOLEAN LaunchWinRe + ); + #endif Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Wed Jan 20 02:58:39 2016 @@ -63,6 +63,8 @@ #define BL_MEMORY_DATA_VERSION 1 #define BL_RETURN_ARGUMENTS_VERSION 1 #define BL_FIRMWARE_DESCRIPTOR_VERSION 2 + +#define BL_RETURN_ARGUMENTS_NO_PAE_FLAG 0x40 #define BL_APPLICATION_ENTRY_FLAG_NO_GUID 0x01 #define BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL 0x02 @@ -758,6 +760,18 @@ ULONG BootIndex; WCHAR KeyValue; } BL_MENU_STATUS, *PL_MENU_STATUS; + +typedef enum _BL_BOOT_ERROR_STATUS +{ + Reboot = 1, + Recover = 2, + RecoverOem = 3, + OsSelection = 4, + NextOs = 5, + TryAgain = 6, + AdvancedOptions = 7, + BootOptions = 8 +} BL_BOOT_ERROR_STATUS; typedef struct _BL_HARDDISK_DEVICE {
8 years, 11 months
1
0
0
0
[ion] 70622: [BOOTLIB]: Fix build
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 01:29:59 2016 New Revision: 70622 URL:
http://svn.reactos.org/svn/reactos?rev=70622&view=rev
Log: [BOOTLIB]: Fix build Modified: trunk/reactos/boot/environ/lib/misc/image.c Modified: trunk/reactos/boot/environ/lib/misc/image.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/imag…
============================================================================== --- trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] Wed Jan 20 01:29:59 2016 @@ -922,6 +922,17 @@ } NTSTATUS +ImgArchEfiStartBootApplication ( + _In_ PBL_APPLICATION_ENTRY AppEntry, + _In_ PVOID ImageBase, + _In_ ULONG ImageSize, + _In_ PBL_RETURN_ARGUMENTS ReturnArguments + ) +{ + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS BlImgStartBootApplication ( _In_ ULONG AppHandle, _Inout_opt_ PBL_RETURN_ARGUMENTS ReturnArguments
8 years, 11 months
1
0
0
0
[ion] 70621: [BOOTLIB]: Rough sketches of BlImgLoadBootApplication, BlImgStartBootApplication, BlImgUnLoadBootApplication.
by ion@svn.reactos.org
Author: ion Date: Wed Jan 20 01:28:50 2016 New Revision: 70621 URL:
http://svn.reactos.org/svn/reactos?rev=70621&view=rev
Log: [BOOTLIB]: Rough sketches of BlImgLoadBootApplication, BlImgStartBootApplication, BlImgUnLoadBootApplication. Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c trunk/reactos/boot/environ/include/bcd.h trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/bootlib.c trunk/reactos/boot/environ/lib/misc/image.c trunk/reactos/boot/environ/lib/platform/time.c Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
============================================================================== --- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Wed Jan 20 01:28:50 2016 @@ -1083,30 +1083,6 @@ return STATUS_SUCCESS; } -VOID -BlImgQueryCodeIntegrityBootOptions ( - _In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry, - _Out_ PBOOLEAN IntegrityChecksDisabled, - _Out_ PBOOLEAN TestSigningEnabled - ) -{ - - NTSTATUS Status; - BOOLEAN Value; - - /* Check if /DISABLEINTEGRITYCHECKS is on */ - Status = BlGetBootOptionBoolean(ApplicationEntry->BcdData, - BcdLibraryBoolean_DisableIntegrityChecks, - &Value); - *IntegrityChecksDisabled = NT_SUCCESS(Status) && (Value); - - /* Check if /TESTSIGNING is on */ - Status = BlGetBootOptionBoolean(ApplicationEntry->BcdData, - BcdLibraryBoolean_AllowPrereleaseSignatures, - &Value); - *TestSigningEnabled = NT_SUCCESS(Status) && (Value); -} - NTSTATUS BmFwVerifySelfIntegrity ( VOID @@ -2212,38 +2188,6 @@ return STATUS_SUCCESS; } -/* MOVE TO IMAGe.C */ -NTSTATUS -BlImgLoadBootApplication ( - _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, - _Out_ PHANDLE AppHandle - ) -{ - EfiPrintf(L"Loading application %p\r\n", BootEntry); - - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -BlImgStartBootApplication ( - _In_ HANDLE AppHandle, - _Inout_ PBL_RETURN_ARGUMENTS ReturnArguments - ) -{ - EfiPrintf(L"Starting application %p\r\n", AppHandle); - - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS -BlImgUnloadBootApplication ( - _In_ HANDLE AppHandle - ) -{ - EfiPrintf(L"Unloading application %p\r\n", AppHandle); - - return STATUS_NOT_IMPLEMENTED; -} NTSTATUS BmpTransferExecution ( @@ -2257,7 +2201,7 @@ PBL_DEVICE_DESCRIPTOR AppDevice; BL_RETURN_ARGUMENTS ReturnArgs; BOOLEAN AdvancedOptions; - HANDLE AppHandle; + ULONG AppHandle; Status = BlGetBootOptionString(BootEntry->BcdData, BcdLibraryString_ApplicationPath, Modified: trunk/reactos/boot/environ/include/bcd.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bcd.h…
============================================================================== --- trunk/reactos/boot/environ/include/bcd.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bcd.h [iso-8859-1] Wed Jan 20 01:28:50 2016 @@ -94,6 +94,7 @@ BcdLibraryInteger_GraphicsResolution = 0x15000052, BcdLibraryInteger_DisplayMessage = 0x15000065, /* Undocumented */ BcdLibraryInteger_DisplayMessageOverride = 0x15000066, /* Undocumented */ + BcdLibraryInteger_UndocumentedMagic = 0x15000075, /* Undocumented magic */ BcdLibraryBoolean_RestartOnFailure = 0x16000053, BcdLibraryBoolean_GraphicsForceHighestMode = 0x16000054, BcdLibraryBoolean_IsolatedExecutionContext = 0x16000060, Modified: trunk/reactos/boot/environ/include/bl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Wed Jan 20 01:28:50 2016 @@ -1139,6 +1139,13 @@ PWCHAR FileName; } BL_IMG_FILE, *PBL_IMG_FILE; +typedef struct _BL_IMAGE_APPLICATION_ENTRY +{ + PBL_APPLICATION_ENTRY AppEntry; + PVOID ImageBase; + ULONG ImageSize; +} BL_IMAGE_APPLICATION_ENTRY, *PBL_IMAGE_APPLICATION_ENTRY; + typedef struct _BL_DEFERRED_FONT_FILE { LIST_ENTRY ListEntry; @@ -1464,6 +1471,11 @@ VOID ); +ULONGLONG +BlTimeQueryPerformanceCounter ( + _Out_opt_ PLARGE_INTEGER Frequency + ); + /* RESOURCE LOCALE INTERNATIONALIZATION ROUTINES *****************************/ NTSTATUS @@ -2134,6 +2146,30 @@ BlImgFindSection ( _In_ PVOID ImageBase, _In_ ULONG ImageSize + ); + +NTSTATUS +BlImgLoadBootApplication ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, + _Out_ PULONG AppHandle + ); + +NTSTATUS +BlImgStartBootApplication ( + _In_ ULONG AppHandle, + _Inout_ PBL_RETURN_ARGUMENTS ReturnArguments + ); + +NTSTATUS +BlImgUnloadBootApplication ( + _In_ ULONG AppHandle + ); + +VOID +BlImgQueryCodeIntegrityBootOptions ( + _In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry, + _Out_ PBOOLEAN IntegrityChecksDisabled, + _Out_ PBOOLEAN TestSigning ); /* FILE I/O ROUTINES *********************************************************/ @@ -2453,4 +2489,7 @@ extern PVOID DspLocalInputConsole; extern WCHAR BlScratchBuffer[8192]; extern BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated; +extern ULONGLONG BlpTimePerformanceFrequency; +extern LIST_ENTRY RegisteredFileSystems; + #endif Modified: trunk/reactos/boot/environ/lib/bootlib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/bootlib.c…
============================================================================== --- trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/bootlib.c [iso-8859-1] Wed Jan 20 01:28:50 2016 @@ -49,9 +49,11 @@ PBL_MEMORY_DATA MemoryData; PBL_APPLICATION_ENTRY AppEntry; PBL_FIRMWARE_DESCRIPTOR FirmwareDescriptor; - ULONG_PTR ParamPointer = (ULONG_PTR)BootAppParameters; + LARGE_INTEGER BootFrequency; + ULONG_PTR ParamPointer; /* Validate correct Boot Application data */ + ParamPointer = (ULONG_PTR)BootAppParameters; if (!(BootAppParameters) || (BootAppParameters->Signature[0] != BOOT_APPLICATION_SIGNATURE_1) || (BootAppParameters->Signature[1] != BOOT_APPLICATION_SIGNATURE_2) || @@ -131,18 +133,16 @@ return Status; } -#if 0 /* Modern systems have an undocumented BCD system for the boot frequency */ Status = BlGetBootOptionInteger(BlpApplicationEntry.BcdData, 0x15000075, - &BootFrequency); - if (NT_SUCCESS(Status) && (BootFrequency)) + (PULONGLONG)&BootFrequency.QuadPart); + if (NT_SUCCESS(Status) && (BootFrequency.QuadPart)) { /* Use it if present */ - BlpTimePerformanceFrequency = BootFrequency; + BlpTimePerformanceFrequency = BootFrequency.QuadPart; } else -#endif { /* Use the TSC for calibration */ Status = BlpTimeCalibratePerformanceCounter(); Modified: trunk/reactos/boot/environ/lib/misc/image.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/imag…
============================================================================== --- trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] Wed Jan 20 01:28:50 2016 @@ -9,6 +9,13 @@ /* INCLUDES ******************************************************************/ #include "bl.h" +#include <bcd.h> + +/* DATA VARIABLES ************************************************************/ + +ULONG IapAllocatedTableEntries; +ULONG IapTableEntries; +PVOID* IapImageTable; /* FUNCTIONS *****************************************************************/ @@ -186,6 +193,17 @@ /* Return the final status */ return Status; +} + +NTSTATUS +BlImgUnallocateImageBuffer ( + _In_ PVOID ImageBase, + _In_ ULONG ImageSize, + _In_ ULONG ImageFlags + ) +{ + EfiPrintf(L"leaking the shit out of %p\r\n", ImageBase); + return STATUS_NOT_IMPLEMENTED; } NTSTATUS @@ -591,3 +609,436 @@ return FoundSection; } +VOID +BlImgQueryCodeIntegrityBootOptions ( + _In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry, + _Out_ PBOOLEAN IntegrityChecksDisabled, + _Out_ PBOOLEAN TestSigning + ) +{ + + NTSTATUS Status; + BOOLEAN Value; + + /* Check if /DISABLEINTEGRITYCHECKS is on */ + Status = BlGetBootOptionBoolean(ApplicationEntry->BcdData, + BcdLibraryBoolean_DisableIntegrityChecks, + &Value); + *IntegrityChecksDisabled = NT_SUCCESS(Status) && (Value); + + /* Check if /TESTSIGNING is on */ + Status = BlGetBootOptionBoolean(ApplicationEntry->BcdData, + BcdLibraryBoolean_AllowPrereleaseSignatures, + &Value); + *TestSigning = NT_SUCCESS(Status) && (Value); +} + +NTSTATUS +BlImgUnLoadImage ( + _In_ PVOID ImageBase, + _In_ ULONG ImageSize, + _In_ ULONG ImageFlags + ) +{ + /* Check for missing parameters */ + if (!(ImageSize) || !(ImageBase)) + { + /* Bail out */ + return STATUS_INVALID_PARAMETER; + } + + /* Unallocate the image buffer */ + return BlImgUnallocateImageBuffer(ImageBase, ImageSize, ImageFlags); +} + +NTSTATUS +BlImgLoadPEImageEx ( + _In_ ULONG DeviceId, + _In_ BL_MEMORY_TYPE MemoryType, + _In_ PWCHAR Path, + _Out_ PVOID* ImageBase, + _Out_ PULONG ImageSize, + _Out_ PVOID Hash, + _In_ ULONG Flags + ) +{ + EfiPrintf(L"PE not implemented\r\n"); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +BlImgLoadBootApplication ( + _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, + _Out_ PULONG AppHandle + ) +{ + NTSTATUS Status; + PULONGLONG AllowedList; + ULONGLONG AllowedCount; + ULONG i; + LARGE_INTEGER Frequency; + PVOID UnlockCode; + PBL_DEVICE_DESCRIPTOR Device, BitLockerDevice; + ULONG DeviceId; + PWCHAR Path; + PBL_APPLICATION_ENTRY AppEntry; + PBL_IMG_FILE ImageFile; + PVOID ImageBase; + ULONG ImageSize; + BOOLEAN DisableIntegrity, TestSigning; + UCHAR Hash[64]; + ULONG Flags; + ULONG ListSize; + PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry; + + BitLockerDevice = NULL; + UnlockCode = NULL; + ImageFile = NULL; + DeviceId = -1; + Device = NULL; + ImageAppEntry = NULL; + Path = NULL; + ImageSize = 0; + ImageBase = NULL; + + EfiPrintf(L"Loading application %p\r\n", BootEntry); + + Status = BlpGetBootOptionIntegerList(BootEntry->BcdData, + BcdLibraryIntegerList_AllowedInMemorySettings, + &AllowedList, + &AllowedCount, + TRUE); + if (Status == STATUS_SUCCESS) + { + for (i = 0; i < AllowedCount; i++) + { + if (AllowedList[i] == BcdLibraryInteger_UndocumentedMagic) + { + BlTimeQueryPerformanceCounter(&Frequency); + BlAppendBootOptionInteger(BootEntry, + BcdLibraryInteger_UndocumentedMagic, + Frequency.QuadPart); + } + } + } + +#if BL_BITLOCKER_SUPPORT + Status = BlFveSecureBootUnlockBootDevice(BootEntry, &BitLockerDevice, &UnlockCode); +#else + Status = STATUS_SUCCESS; +#endif + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + Status = BlGetBootOptionDevice(BootEntry->BcdData, BcdLibraryDevice_ApplicationDevice, &Device, NULL); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + Status = BlGetBootOptionString(BootEntry->BcdData, BcdLibraryString_ApplicationPath, &Path); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + Status = BlpDeviceOpen(Device, BL_DEVICE_READ_ACCESS, 0, &DeviceId); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + BlImgQueryCodeIntegrityBootOptions(BootEntry, &DisableIntegrity, &TestSigning); + +#if BL_TPM_SUPPORT + RtlZeroMemory(&Context, sizeof(Context); + Context.BootEntry = BootEntry; + BlEnNotifyEvent(0x10000003, &Context); +#endif + + Flags = 0; + if (!DisableIntegrity) + { + Flags = 0x8070; + } + + Status = BlImgLoadPEImageEx(DeviceId, BlLoaderMemory, Path, &ImageBase, &ImageSize, Hash, Flags); + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + +#if BL_KD_SUPPORT + if (BdDebugTransitions) + { + BdForceDebug = 1; + Status = BlBdInitialize(); + if (NT_SUCCESS(Status)) + { + if (BlBdDebuggerEnabled()) + { + BdDebuggerNotPresent = FALSE; + RtlInitUnicodeString(&PathString, Path); + BlBdLoadImageSymbols(&PathString, ImageBase); + } + } + } +#endif + +#if BL_BITLOCKER_SUPPORT + Status = BlSecureBootCheckPolicyOnFveDevice(BitLockerDevice); +#else + Status = STATUS_SUCCESS; +#endif + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + +#if BL_BITLOCKER_SUPPORT + Status = BlFveSecureBootCheckpointBootApp(BootEntry, BitLockerDevice, Hash, UnlockCode); +#else +Status = STATUS_SUCCESS; +#endif + if (!NT_SUCCESS(Status)) + { + goto Quickie; + } + + ListSize = BlGetBootOptionListSize(BootEntry->BcdData); + + AppEntry = BlMmAllocateHeap(ListSize + sizeof(*AppEntry)); + if (!AppEntry) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + RtlZeroMemory(AppEntry, sizeof(AppEntry)); + + strcpy(AppEntry->Signature, "BTAPENT"); + AppEntry->Guid = BootEntry->Guid; + AppEntry->Flags = BootEntry->Flags; + RtlCopyMemory(&AppEntry->BcdData, BootEntry->BcdData, ListSize); + + + ImageAppEntry = BlMmAllocateHeap(sizeof(*ImageAppEntry)); + ImageAppEntry->ImageBase = ImageBase; + ImageAppEntry->ImageSize = ImageSize; + ImageAppEntry->AppEntry = AppEntry; + + if (!IapTableEntries) + { + IapAllocatedTableEntries = 0; + IapTableEntries = 2; + IapImageTable = BlMmAllocateHeap(IapTableEntries * sizeof(PVOID)); + if (!IapImageTable) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + RtlZeroMemory(IapImageTable, sizeof(IapTableEntries * sizeof(PVOID))); + } + + Status = BlTblSetEntry(&IapImageTable, + &IapTableEntries, + ImageAppEntry, + AppHandle, + TblDoNotPurgeEntry); + +Quickie: + if (DeviceId != 1) + { + BlDeviceClose(DeviceId); + } + + if (Device) + { + BlMmFreeHeap(Device); + } + + if (Path) + { + BlMmFreeHeap(Path); + } + + if (BitLockerDevice) + { + BlMmFreeHeap(BitLockerDevice); + } + + if (UnlockCode) + { + BlMmFreeHeap(UnlockCode); + } + + if (NT_SUCCESS(Status)) + { + IapAllocatedTableEntries++; + } + else + { + if (ImageBase) + { + BlImgUnLoadImage(ImageBase, ImageSize, 0); + } + + if (AppEntry) + { + BlMmFreeHeap(AppEntry); + } + + if (ImageFile) + { + BlMmFreeHeap(ImageFile); + } + + if (!(IapAllocatedTableEntries) && (IapImageTable)) + { + BlMmFreeHeap(IapImageTable); + IapTableEntries = 0; + IapImageTable = NULL; + } + } + + return Status; +} + +NTSTATUS +BlpPdParseReturnArguments ( + _In_ PBL_RETURN_ARGUMENTS ReturnArguments + ) +{ + if (ReturnArguments->DataPage == 0) + { + return STATUS_SUCCESS; + } + + EfiPrintf(L"Return arguments not supported\r\n"); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +BlImgStartBootApplication ( + _In_ ULONG AppHandle, + _Inout_opt_ PBL_RETURN_ARGUMENTS ReturnArguments + ) +{ + PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry; + BL_RETURN_ARGUMENTS LocalReturnArgs; + PBL_FILE_SYSTEM_ENTRY FileSystem; + PLIST_ENTRY NextEntry, ListHead; + NTSTATUS Status; + + if (!ReturnArguments) + { + LocalReturnArgs.Version = 1; + LocalReturnArgs.Status = STATUS_SUCCESS; + LocalReturnArgs.Flags = 0; + LocalReturnArgs.DataPage = 0; + LocalReturnArgs.DataSize = 0; + + ReturnArguments = &LocalReturnArgs; + } + + + if (IapTableEntries <= AppHandle) + { + return STATUS_INVALID_PARAMETER; + } + + ImageAppEntry = IapImageTable[AppHandle]; + if (!ImageAppEntry) + { + return STATUS_INVALID_PARAMETER; + } + + ListHead = &RegisteredFileSystems; + NextEntry = RegisteredFileSystems.Flink; + while (NextEntry != ListHead) + { + FileSystem = CONTAINING_RECORD(NextEntry, BL_FILE_SYSTEM_ENTRY, ListEntry); + + if (FileSystem->PurgeCallback) + { + FileSystem->PurgeCallback(); + } + + NextEntry = NextEntry->Flink; + } + + /* TODO */ + //BlockIoPurgeCache(); + + Status = ImgArchEfiStartBootApplication(ImageAppEntry->AppEntry, + ImageAppEntry->ImageBase, + ImageAppEntry->ImageSize, + ReturnArguments); + + BlpPdParseReturnArguments(ReturnArguments); + +#if BL_BITLOCKER_SUPPORT + FvebpCheckAllPartitions(TRUE); +#endif + +#if BL_TPM_SUPPORT + BlEnNotifyEvent(0x10000005, NULL); +#endif + + /* TODO */ + //BlpDisplayReinitialize(); + + /* TODO */ + //BlpLogInitialize(); + + return Status; +} + +NTSTATUS +BlImgUnloadBootApplication ( + _In_ ULONG AppHandle + ) +{ + PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry; // esi@2 + NTSTATUS Status; + + if (IapTableEntries <= AppHandle) + { + return STATUS_INVALID_PARAMETER; + } + + ImageAppEntry = IapImageTable[AppHandle]; + if (!ImageAppEntry) + { + return STATUS_INVALID_PARAMETER; + } + + Status = BlImgUnLoadImage(ImageAppEntry->ImageBase, + ImageAppEntry->ImageSize, + 0); + if (NT_SUCCESS(Status)) + { + Status = STATUS_SUCCESS; + } + else + { + Status = STATUS_MEMORY_NOT_ALLOCATED; + } + + BlMmFreeHeap(ImageAppEntry->AppEntry); + BlMmFreeHeap(ImageAppEntry); + + IapImageTable[AppHandle] = NULL; + + if (!(--IapAllocatedTableEntries)) + { + BlMmFreeHeap(IapImageTable); + IapImageTable = NULL; + IapTableEntries = 0; + } + + return Status; +} Modified: trunk/reactos/boot/environ/lib/platform/time.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/platform/…
============================================================================== --- trunk/reactos/boot/environ/lib/platform/time.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/platform/time.c [iso-8859-1] Wed Jan 20 01:28:50 2016 @@ -87,3 +87,19 @@ /* On other systems, compute it */ return BlpTimeMeasureTscFrequency(); } + +ULONGLONG +BlTimeQueryPerformanceCounter ( + _Out_opt_ PLARGE_INTEGER Frequency + ) +{ + /* Check if caller wants frequency */ + if (Frequency) + { + /* Return it */ + Frequency->QuadPart = BlpTimePerformanceFrequency; + } + + /* Return the TSC value */ + return __rdtsc(); +};
8 years, 11 months
1
0
0
0
[akhaldi] 70620: [0.4.0] * Merge the win32k fixes by Timo in revisions 70482, 70485, 70486 and 70487. CORE-10807
by akhaldi@svn.reactos.org
Author: akhaldi Date: Tue Jan 19 21:57:30 2016 New Revision: 70620 URL:
http://svn.reactos.org/svn/reactos?rev=70620&view=rev
Log: [0.4.0] * Merge the win32k fixes by Timo in revisions 70482, 70485, 70486 and 70487. CORE-10807 Modified: branches/ros-branch-0_4_0/ (props changed) branches/ros-branch-0_4_0/reactos/ (props changed) branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.c branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.h branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/dibobj.c branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/palette.c Propchange: branches/ros-branch-0_4_0/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jan 19 21:57:30 2016 @@ -1 +1 @@ -/trunk:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70497,70499-70501,70507-70510,70512-70513,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606 +/trunk:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70482,70485-70487,70497,70499-70501,70507-70510,70512-70513,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606 Propchange: branches/ros-branch-0_4_0/reactos/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jan 19 21:57:30 2016 @@ -20,4 +20,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70497,70501,70507-70510,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606 +/trunk/reactos:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70433-70437,70443,70445-70449,70454,70464,70468,70470,70477,70480,70482,70485-70487,70497,70501,70507-70510,70523,70527-70530,70536-70537,70545-70548,70552-70554,70557-70558,70576-70578,70583,70597,70606 Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
============================================================================== --- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.c [iso-8859-1] Tue Jan 19 21:57:30 2016 @@ -42,15 +42,15 @@ return GreSetObjectOwner(hbmp, ulOwner); } -static -int +BOOL NTAPI UnsafeSetBitmapBits( - PSURFACE psurf, - IN ULONG cjBits, - IN PVOID pvBits) -{ - PUCHAR pjDst, pjSrc; + _Inout_ PSURFACE psurf, + _In_ ULONG cjBits, + _In_ const VOID *pvBits) +{ + PUCHAR pjDst; + const UCHAR *pjSrc; LONG lDeltaDst, lDeltaSrc; ULONG nWidth, nHeight, cBitsPixel; NT_ASSERT(psurf->flags & API_BITMAP); @@ -69,7 +69,7 @@ /* Make sure the buffer is large enough*/ if (cjBits < (lDeltaSrc * nHeight)) - return 0; + return FALSE; while (nHeight--) { @@ -79,7 +79,7 @@ pjDst += lDeltaDst; } - return 1; + return TRUE; } HBITMAP Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
============================================================================== --- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.h [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/bitmaps.h [iso-8859-1] Tue Jan 19 21:57:30 2016 @@ -43,3 +43,10 @@ IN FLONG fl, IN UINT cjMaxBits, IN HANDLE hcmXform); + +BOOL +NTAPI +UnsafeSetBitmapBits( + _Inout_ PSURFACE psurf, + _In_ ULONG cjBits, + _In_ const VOID *pvBits); Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/dibobj.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
============================================================================== --- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] Tue Jan 19 21:57:30 2016 @@ -261,16 +261,10 @@ PPALETTE ppalDIB = 0; ULONG cjSizeImage; - if (!bmi) return 0; - - /* Check if the header provided an image size */ - if (bmi->bmiHeader.biSizeImage != 0) - { - /* Use the given size */ - cjSizeImage = bmi->bmiHeader.biSizeImage; - } - /* Otherwise check for uncompressed formats */ - else if ((bmi->bmiHeader.biCompression == BI_RGB) || + if (!bmi || !Bits) return 0; + + /* Check for uncompressed formats */ + if ((bmi->bmiHeader.biCompression == BI_RGB) || (bmi->bmiHeader.biCompression == BI_BITFIELDS)) { /* Calculate the image size */ @@ -278,6 +272,12 @@ ScanLines, bmi->bmiHeader.biBitCount); } + /* Check if the header provided an image size */ + else if (bmi->bmiHeader.biSizeImage != 0) + { + /* Use the given size */ + cjSizeImage = bmi->bmiHeader.biSizeImage; + } else { /* Compressed format without a size. This is invalid. */ @@ -286,9 +286,9 @@ } /* Check if the size that we have is ok */ - if (cjSizeImage > cjMaxBits) - { - DPRINT1("Size too large! cjSizeImage = %lu, cjMaxBits = %lu\n", + if ((cjSizeImage > cjMaxBits) || (cjSizeImage == 0)) + { + DPRINT1("Invalid bitmap size! cjSizeImage = %lu, cjMaxBits = %lu\n", cjSizeImage, cjMaxBits); return 0; } @@ -340,8 +340,6 @@ rcDst.right = psurfDst->SurfObj.sizlBitmap.cx; ptSrc.x = 0; ptSrc.y = 0; - - NT_ASSERT(psurfSrc->SurfObj.cjBits <= cjMaxBits); result = IntEngCopyBits(&psurfDst->SurfObj, &psurfSrc->SurfObj, @@ -1456,6 +1454,11 @@ PBYTE safeBits = NULL; HBITMAP hbmResult = NULL; + if (pjInit == NULL) + { + fInit &= ~CBM_INIT; + } + if(pjInit && (fInit & CBM_INIT)) { if (cjMaxBits == 0) return NULL; Modified: branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/palette.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/win32s…
============================================================================== --- branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/palette.c [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/reactos/win32ss/gdi/ntgdi/palette.c [iso-8859-1] Tue Jan 19 21:57:30 2016 @@ -786,9 +786,6 @@ { PPALETTE palPtr; UINT pal_entries; - HDC hDC; - PDC dc; - PWND Wnd; const PALETTEENTRY *pptr = PaletteColors; palPtr = PALETTE_ShareLockPalette(hPal); @@ -816,6 +813,16 @@ PALETTE_ShareUnlockPalette(palPtr); +#if 0 +/* FIXME: This is completely broken! We cannot call UserGetDesktopWindow + without first acquiring the USER lock. But the whole process here is + screwed anyway. Instead of messing with the desktop DC, we need to + check, whether the palette is associated with a PDEV and whether that + PDEV supports palette operations. Then we need to call pfnDrvSetPalette. + But since IntGdiRealizePalette() is not even implemented for direct DCs, + we can as well just do nothing, that will at least not ASSERT! + I leave the whole thing here, to scare people away, who want to "fix" it. */ + /* Immediately apply the new palette if current window uses it */ Wnd = UserGetDesktopWindow(); hDC = UserGetWindowDC(Wnd); @@ -831,6 +838,7 @@ DC_UnlockDc(dc); } UserReleaseDC(Wnd,hDC, FALSE); +#endif // 0 } return ret; }
8 years, 11 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
20
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Results per page:
10
25
50
100
200