Author: ion
Date: Sat Sep 5 19:38:20 2015
New Revision: 69039
URL: http://svn.reactos.org/svn/reactos?rev=69039&view=rev
Log:
[BOOTMGFW]:
Add support for converting the EFI file path as well. The first 1000 lines of many have been written. Time to test on Virtual Box.
Modified:
trunk/reactos/boot/environ/app/bootmgr/efiemu.c
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] Sat Sep 5 19:38:20 2015
@@ -72,6 +72,115 @@
}
/*++
+ * @name EfiInitpAppendPathString
+ *
+ * The EfiInitpAppendPathString routine
+ *
+ * @param DestinationPath
+ * UEFI Image Handle for the current loaded application.
+ *
+ * @param RemainingSize
+ * Pointer to the UEFI System Table.
+ *
+ * @param AppendPath
+ * Pointer to the UEFI System Table.
+ *
+ * @param AppendLength
+ * Pointer to the UEFI System Table.
+ *
+ * @param BytesAppended
+ * Pointer to the UEFI System Table.
+ *
+ * @return None
+ *
+ *--*/
+NTSTATUS
+EfiInitpAppendPathString (
+ _In_ PWCHAR PathString,
+ _In_ ULONG MaximumLength,
+ _In_ PWCHAR NewPathString,
+ _In_ ULONG NewPathLength,
+ _Out_ PULONG ResultLength
+ )
+{
+ NTSTATUS Status;
+ ULONG FinalPathLength;
+
+ /* We deal in Unicode, validate the length */
+ if (NewPathLength & 1)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Is the new element at least a character? */
+ Status = STATUS_SUCCESS;
+ if (NewPathLength >= sizeof(WCHAR))
+ {
+ /* Is the last character already a NULL character? */
+ if (NewPathString[(NewPathLength - sizeof(WCHAR)) / sizeof(WCHAR)] ==
+ UNICODE_NULL)
+ {
+ /* Then we won't need to count it */
+ NewPathLength -= sizeof(UNICODE_NULL);
+ }
+
+ /* Was it more than just a NULL character? */
+ if (NewPathLength >= sizeof(WCHAR))
+ {
+ /* Yep -- but does it have a separator? */
+ if (*NewPathString == OBJ_NAME_PATH_SEPARATOR)
+ {
+ /* Skip it, we'll add our own later */
+ NewPathString++;
+ NewPathLength -= sizeof(OBJ_NAME_PATH_SEPARATOR);
+ }
+
+ /* Was it more than just a separator? */
+ if (NewPathLength >= sizeof(WCHAR))
+ {
+ /* Yep -- but does it end with a separator? */
+ if (NewPathString[(NewPathLength - sizeof(WCHAR)) / sizeof(WCHAR)] ==
+ OBJ_NAME_PATH_SEPARATOR)
+ {
+ /* That's something else we won't need for now */
+ NewPathLength -= sizeof(OBJ_NAME_PATH_SEPARATOR);
+ }
+ }
+ }
+ }
+
+ /* Check if anything needs to be appended after all */
+ if (NewPathLength != 0)
+ {
+ /* We will append the length of the new path element, plus a separator */
+ FinalPathLength = NewPathLength + sizeof(OBJ_NAME_PATH_SEPARATOR);
+ if (MaximumLength >= FinalPathLength)
+ {
+ /* Add a separator to the existing path*/
+ *PathString = OBJ_NAME_PATH_SEPARATOR;
+
+ /* Followed by the new path element */
+ RtlCopyMemory(PathString + 1, NewPathString, NewPathLength);
+
+ /* Return the number of bytes appended */
+ *ResultLength = FinalPathLength;
+ }
+ else
+ {
+ /* There's not enough space to do this */
+ Status = STATUS_BUFFER_TOO_SMALL;
+ }
+ }
+ else
+ {
+ /* Nothing to append */
+ *ResultLength = 0;
+ }
+
+ return Status;
+}
+
+/*++
* @name EfiInitpConvertEfiDevicePath
*
* The EfiInitpConvertEfiDevicePath routine
@@ -93,13 +202,97 @@
*--*/
NTSTATUS
EfiInitpConvertEfiFilePath (
- _In_ EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ _In_ EFI_DEVICE_PATH_PROTOCOL *DevicePath,
_In_ ULONG PathType,
_In_ PBL_BCD_OPTION Option,
_In_ ULONG MaximumLength
)
{
- return STATUS_NOT_IMPLEMENTED;
+ ULONG BytesAppended, DataSize, StringLength;
+ PBCDE_STRING StringEntry;
+ PWCHAR PathString;
+ FILEPATH_DEVICE_PATH *FilePath;
+ NTSTATUS Status;
+
+ /* Make sure we have enough space for the option */
+ if (MaximumLength < sizeof(*Option))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Set the initial size of the option, and consume from our buffer */
+ DataSize = sizeof(*Option);
+ MaximumLength -= sizeof(*Option);
+
+ /* Zero out and fill the option header */
+ RtlZeroMemory(Option, DataSize);
+ Option->Type = PathType;
+ Option->DataOffset = sizeof(*Option);
+
+ /* Extract the string option */
+ StringEntry = (PBCDE_STRING)(Option + 1);
+ PathString = StringEntry->String;
+
+ /* Start parsing the device path */
+ FilePath = (FILEPATH_DEVICE_PATH*)DevicePath;
+ while (IsDevicePathEndType(FilePath) == FALSE)
+ {
+ /* Is this a file path? */
+ if ((FilePath->Header.Type == MEDIA_DEVICE_PATH) &&
+ (FilePath->Header.SubType == MEDIA_FILEPATH_DP))
+ {
+ /* Get the length of the file path string, avoiding overflow */
+ StringLength = DevicePathNodeLength(FilePath) -
+ FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName);
+ if (StringLength < FIELD_OFFSET(FILEPATH_DEVICE_PATH, PathName))
+ {
+ Status = STATUS_INTEGER_OVERFLOW;
+ goto Quickie;
+ }
+
+ /* Append this path string to the current path string */
+ Status = EfiInitpAppendPathString(PathString,
+ MaximumLength,
+ FilePath->PathName,
+ StringLength,
+ &BytesAppended);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Increase the size of the data, consume buffer space */
+ DataSize += BytesAppended;
+ MaximumLength -= BytesAppended;
+
+ /* Move to the next path string */
+ PathString = (PWCHAR)((ULONG_PTR)PathString + BytesAppended);
+ }
+
+ /* Move to the next path node */
+ FilePath = (FILEPATH_DEVICE_PATH*)NextDevicePathNode(FilePath);
+ }
+
+ /* Check if we still have space for a NULL-terminator */
+ if (MaximumLength < sizeof(UNICODE_NULL))
+ {
+ Status = STATUS_INVALID_PARAMETER;
+ goto Quickie;
+ }
+
+ /* We do -- NULL-terminate the string */
+ *PathString = UNICODE_NULL;
+ DataSize += sizeof(UNICODE_NULL);
+
+ /* Check if all of this has amounted to a single NULL-char */
+ if (PathString == StringEntry->String)
+ {
+ /* Then this option is empty */
+ Option->Failed = TRUE;
+ }
+
+ /* Set the final size of the option */
+ Option->DataSize = DataSize;
+
+Quickie:
+ return STATUS_SUCCESS;
}
/*++
@@ -264,7 +457,7 @@
/* Set GPT partition ID */
DeviceEntry->Partition.Disk.HardDisk.PartitionType = GptPartition;
- /* Copy the siggnature GUID */
+ /* Copy the signature GUID */
RtlCopyMemory(&DeviceEntry->Partition.Gpt.PartitionGuid,
DiskPath->Signature,
sizeof(GUID));
Author: akhaldi
Date: Sat Sep 5 17:31:51 2015
New Revision: 69034
URL: http://svn.reactos.org/svn/reactos?rev=69034&view=rev
Log:
[CMAKE/MSVC] Temporarily disable C4018 until we fix more of the others. CORE-10113
Modified:
trunk/reactos/cmake/msvc.cmake
Modified: trunk/reactos/cmake/msvc.cmake
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/msvc.cmake?rev=69034…
==============================================================================
--- trunk/reactos/cmake/msvc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/msvc.cmake [iso-8859-1] Sat Sep 5 17:31:51 2015
@@ -50,6 +50,9 @@
# - C4800: forcing value to bool 'true' or 'false' (performance warning)
#add_compile_flags("/wd4244 /wd4290 /wd4800 ")
add_compile_flags("/wd4244 /wd4290 /wd4800")
+
+# FIXME: Temporarily disable C4018 until we fix more of the others. CORE-10113
+add_compile_flags("/wd4018")
# The following warnings are treated as errors:
# - C4013: implicit function declaration
Author: sginsberg
Date: Sat Sep 5 15:20:27 2015
New Revision: 69032
URL: http://svn.reactos.org/svn/reactos?rev=69032&view=rev
Log:
- Don't have two different implementation of KiConvertToGuiThread, first as inlined assembly gcc and second as a function call (for msvc). Always use the function call to be consistent with both compilers.
Modified:
trunk/reactos/ntoskrnl/include/internal/i386/ke.h
trunk/reactos/ntoskrnl/ke/i386/trap.s
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Sat Sep 5 15:20:27 2015
@@ -524,6 +524,12 @@
IN ULONG_PTR Parameter2,
IN ULONG_PTR Parameter3,
IN PKTRAP_FRAME TrapFrame
+);
+
+NTSTATUS
+NTAPI
+KiConvertToGuiThread(
+ VOID
);
//
@@ -777,55 +783,6 @@
}
//
-// Converts a base thread to a GUI thread
-//
-#ifdef __GNUC__
-FORCEINLINE
-NTSTATUS
-KiConvertToGuiThread(VOID)
-{
- NTSTATUS NTAPI PsConvertToGuiThread(VOID);
- NTSTATUS Result;
- PVOID StackFrame;
-
- /*
- * Converting to a GUI thread safely updates ESP in-place as well as the
- * current Thread->TrapFrame and EBP when KeSwitchKernelStack is called.
- *
- * However, PsConvertToGuiThread "helpfully" restores EBP to the original
- * caller's value, since it is considered a nonvolatile register. As such,
- * as soon as we're back after the conversion and we try to store the result
- * which will probably be in some stack variable (EBP-based), we'll crash as
- * we are touching the de-allocated non-expanded stack.
- *
- * Thus we need a way to update our EBP before EBP is touched, and the only
- * way to guarantee this is to do the call itself in assembly, use the EAX
- * register to store the result, fixup EBP, and then let the C code continue
- * on its merry way.
- *
- */
- __asm__ __volatile__
- (
- "movl %%ebp, %1\n\t"
- "subl %%esp, %1\n\t"
- "call _PsConvertToGuiThread@0\n\t"
- "addl %%esp, %1\n\t"
- "movl %1, %%ebp"
- : "=a"(Result), "=r"(StackFrame)
- : "p"(PsConvertToGuiThread)
- : "%esp", "%ecx", "%edx", "memory"
- );
- return Result;
-}
-#elif defined(_MSC_VER)
-NTSTATUS
-NTAPI
-KiConvertToGuiThread(VOID);
-#else
-#error Unknown Compiler
-#endif
-
-//
// Switches from boot loader to initial kernel stack
//
FORCEINLINE
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Sat Sep 5 15:20:27 2015
@@ -177,12 +177,29 @@
KiTrapExitStub KiTrapReturnNoSegments, (KI_RESTORE_VOLATILES OR KI_EXIT_IRET)
KiTrapExitStub KiTrapReturnNoSegmentsRet8,(KI_RESTORE_VOLATILES OR KI_RESTORE_EFLAGS OR KI_EXIT_RET8)
-#ifdef _MSC_VER
EXTERN _PsConvertToGuiThread@0:PROC
PUBLIC _KiConvertToGuiThread@0
_KiConvertToGuiThread@0:
- /* Safe ebx */
+
+ /*
+ * Converting to a GUI thread safely updates ESP in-place as well as the
+ * current Thread->TrapFrame and EBP when KeSwitchKernelStack is called.
+ *
+ * However, PsConvertToGuiThread "helpfully" restores EBP to the original
+ * caller's value, since it is considered a nonvolatile register. As such,
+ * as soon as we're back after the conversion and we try to store the result
+ * which will probably be in some stack variable (EBP-based), we'll crash as
+ * we are touching the de-allocated non-expanded stack.
+ *
+ * Thus we need a way to update our EBP before EBP is touched, and the only
+ * way to guarantee this is to do the call itself in assembly, use the EAX
+ * register to store the result, fixup EBP, and then let the C code continue
+ * on its merry way.
+ *
+ */
+
+ /* Save ebx */
push ebx
/* Calculate the stack frame offset in ebx */
@@ -201,6 +218,5 @@
/* return to the caller */
ret
-#endif
END