Author: ion Date: Sun Feb 5 00:05:19 2017 New Revision: 73689
URL: http://svn.reactos.org/svn/reactos?rev=73689&view=rev Log: [BOOTLIB]: Fix from hermes for BlReplaceBootOptions [BOOTLIB]: More WIP transfer code.
Modified: trunk/reactos/boot/environ/include/bl.h trunk/reactos/boot/environ/lib/misc/bcdopt.c trunk/reactos/boot/environ/lib/misc/image.c trunk/reactos/boot/environ/lib/misc/util.c
Modified: trunk/reactos/boot/environ/include/bl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?r... ============================================================================== --- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original) +++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Sun Feb 5 00:05:19 2017 @@ -92,6 +92,16 @@ #define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG 0x10 #define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG 0x20 #define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG 0x2000 + +#define BL_MM_INCLUDE_MAPPED_ALLOCATED 0x01 +#define BL_MM_INCLUDE_MAPPED_UNALLOCATED 0x02 +#define BL_MM_INCLUDE_UNMAPPED_ALLOCATED 0x04 +#define BL_MM_INCLUDE_UNMAPPED_UNALLOCATED 0x08 +#define BL_MM_INCLUDE_RESERVED_ALLOCATED 0x10 +#define BL_MM_INCLUDE_BAD_MEMORY 0x20 +#define BL_MM_INCLUDE_FIRMWARE_MEMORY 0x40 +#define BL_MM_INCLUDE_TRUNCATED_MEMORY 0x80 +#define BL_MM_INCLUDE_PERSISTEND_MEMORY 0x100
#define BL_MM_REQUEST_DEFAULT_TYPE 1 #define BL_MM_REQUEST_TOP_DOWN_TYPE 2
Modified: trunk/reactos/boot/environ/lib/misc/bcdopt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/bcdop... ============================================================================== --- trunk/reactos/boot/environ/lib/misc/bcdopt.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/bcdopt.c [iso-8859-1] Sun Feb 5 00:05:19 2017 @@ -821,14 +821,15 @@ NTSTATUS BlReplaceBootOptions ( _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, - _In_ PBL_BCD_OPTION NewOptions - ) -{ - NTSTATUS Status; - ULONG Size; + _In_ PBL_BCD_OPTION OldOptions + ) +{ + NTSTATUS Status; + ULONG OptionSize; + PBL_BCD_OPTION NewOptions;
/* Make sure there's something to replace with */ - if (!NewOptions) + if (!OldOptions) { return STATUS_INVALID_PARAMETER; } @@ -849,17 +850,17 @@ AppEntry->BcdData = NULL;
/* Get the size of the new list of options */ - Size = BlGetBootOptionListSize(NewOptions); + OptionSize = BlGetBootOptionListSize(OldOptions);
/* Allocate a copy of the new list */ - NewOptions = BlMmAllocateHeap(Size); + NewOptions = BlMmAllocateHeap(OptionSize); if (!NewOptions) { return STATUS_NO_MEMORY; }
/* Copy it in */ - RtlCopyMemory(NewOptions, NewOptions, Size); + RtlCopyMemory(NewOptions, OldOptions, OptionSize);
/* Set it as the new set of options and return */ AppEntry->Flags |= BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL;
Modified: trunk/reactos/boot/environ/lib/misc/image.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/image... ============================================================================== --- trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/image.c [iso-8859-1] Sun Feb 5 00:05:19 2017 @@ -1605,6 +1605,17 @@ }
NTSTATUS +BlMmGetMemoryMap ( + _In_ PLIST_ENTRY MemoryMap, + _In_ PBL_IMAGE_PARAMETERS ImageParameters, + _In_ ULONG WhichTypes, + _In_ ULONG Flags + ) +{ + return STATUS_SUCCESS; +} + +NTSTATUS ImgpInitializeBootApplicationParameters ( _In_ PBL_IMAGE_PARAMETERS ImageParameters, _In_ PBL_APPLICATION_ENTRY AppEntry, @@ -1612,6 +1623,32 @@ _In_ ULONG ImageSize ) { + NTSTATUS Status; + PIMAGE_NT_HEADERS NtHeaders; + BL_IMAGE_PARAMETERS MemoryParameters; + LIST_ENTRY MemoryList; + + Status = RtlImageNtHeaderEx(0, ImageBase, ImageSize, &NtHeaders); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + MemoryParameters.BufferSize = 0; + + Status = BlMmGetMemoryMap(&MemoryList, + &MemoryParameters, + BL_MM_INCLUDE_FIRMWARE_MEMORY | + BL_MM_INCLUDE_MAPPED_ALLOCATED | + BL_MM_INCLUDE_MAPPED_UNALLOCATED | + BL_MM_INCLUDE_UNMAPPED_ALLOCATED | + BL_MM_INCLUDE_RESERVED_ALLOCATED, + 0); + if ((Status != STATUS_BUFFER_TOO_SMALL) && (Status != STATUS_SUCCESS)) + { + return Status; + } + return STATUS_SUCCESS; }
@@ -1649,28 +1686,34 @@ goto Quickie; }
+ /* Zero the boot data */ RtlZeroMemory(BootData, BootSizeNeeded);
+ /* Set the new stack, GDT and IDT */ NewStack = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE) - 8); NewGdt = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE)); NewIdt = (PVOID)((ULONG_PTR)BootData + (24 * PAGE_SIZE) + Gdt.Limit + 1);
+ /* Copy the current (firmware) GDT and IDT */ RtlCopyMemory(NewGdt, (PVOID)Gdt.Base, Gdt.Limit + 1); RtlCopyMemory(NewIdt, (PVOID)Idt.Base, Idt.Limit + 1);
+ /* Read the NT headers so that we can get the entrypoint later on */ RtlImageNtHeaderEx(0, ImageBase, ImageSize, &NtHeaders);
+ /* Prepare the application parameters */ RtlZeroMemory(&Parameters, sizeof(Parameters)); - Status = ImgpInitializeBootApplicationParameters(&Parameters, AppEntry, ImageBase, ImageSize); if (NT_SUCCESS(Status)) { + /* Set the firmware GDT/IDT as the one the application will use */ BootAppGdtRegister = Gdt; BootAppIdtRegister = Idt;
+ /* Set the entrypoint, parameters, and stack */ BootApp32EntryRoutine = (PVOID)((ULONG_PTR)ImageBase + NtHeaders->OptionalHeader. AddressOfEntryPoint); @@ -1678,11 +1721,11 @@ BootApp32Stack = NewStack;
#if BL_KD_SUPPORT + /* Disable the kernel debugger */ BlBdStop(); #endif /* Not yet implemented. This is the last step! */ EfiPrintf(L"EFI APPLICATION START!!!\r\n"); - EfiStall(100000000);
/* Make it so */ Archx86TransferTo32BitApplicationAsm(); @@ -1690,17 +1733,22 @@ /* Not yet implemented. This is the last step! */ EfiPrintf(L"EFI APPLICATION RETURNED!!!\r\n"); EfiStall(100000000); + #if BL_KD_SUPPORT + /* Re-enable the kernel debugger */ BlBdStart(); #endif }
Quickie: + /* Check if we had boot data allocated */ if (BootData) { + /* Free it */ //MmPapFreePages(bootData, TRUE); }
+ /* All done */ return STATUS_NOT_IMPLEMENTED; }
Modified: trunk/reactos/boot/environ/lib/misc/util.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/util.... ============================================================================== --- trunk/reactos/boot/environ/lib/misc/util.c [iso-8859-1] (original) +++ trunk/reactos/boot/environ/lib/misc/util.c [iso-8859-1] Sun Feb 5 00:05:19 2017 @@ -27,8 +27,6 @@ ULONG UtlNextUpdatePercentage; BOOLEAN UtlProgressNeedsInfoUpdate; PVOID UtlProgressInfo; - -
/* FUNCTIONS *****************************************************************/