[FREELDR]

- Move cleaning the shared user data to after WinLdrSetProcessorContext, as we need the new page tables to be active
- Fix indentation/coding style in registry.c
- Fix a few 64 bit warnings
- delete <arch>/ntsetup.c and rename <arch>/wlmemory.c to <arch>/winldr.c

svn path=/trunk/; revision=53526
This commit is contained in:
Timo Kreuzer 2011-09-01 19:01:19 +00:00
parent e6fe154eef
commit 6d62252f5a
19 changed files with 547 additions and 761 deletions

View file

@ -112,8 +112,7 @@ if(ARCH MATCHES i386)
arch/i386/xboxmem.c
arch/i386/xboxrtc.c
arch/i386/xboxvideo.c
arch/i386/ntsetup.c
arch/i386/wlmemory.c
arch/i386/winldr.c
windows/headless.c
disk/scsiport.c)
if(NOT MSVC)
@ -141,8 +140,7 @@ elseif(ARCH MATCHES amd64)
arch/i386/pcmem.c
arch/i386/pcrtc.c
arch/i386/pcvideo.c
arch/amd64/ntsetup.c
arch/amd64/wlmemory.c)
arch/amd64/winldr.c)
else()
#TBD
endif()

View file

@ -1,84 +0,0 @@
/*
* PROJECT: EFI Windows Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: freeldr/windows/i386/ntsetup.c
* PURPOSE: i386-specific setup for Windows boot
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
*/
/* INCLUDES ***************************************************************/
#include <freeldr.h>
#include <debug.h>
// this is needed for new IDT filling
#if 0
extern ULONG_PTR i386DivideByZero;
extern ULONG_PTR i386DebugException;
extern ULONG_PTR i386NMIException;
extern ULONG_PTR i386Breakpoint;
extern ULONG_PTR i386Overflow;
extern ULONG_PTR i386BoundException;
extern ULONG_PTR i386InvalidOpcode;
extern ULONG_PTR i386FPUNotAvailable;
extern ULONG_PTR i386DoubleFault;
extern ULONG_PTR i386CoprocessorSegment;
extern ULONG_PTR i386InvalidTSS;
extern ULONG_PTR i386SegmentNotPresent;
extern ULONG_PTR i386StackException;
extern ULONG_PTR i386GeneralProtectionFault;
extern ULONG_PTR i386PageFault; // exc 14
extern ULONG_PTR i386CoprocessorError; // exc 16
extern ULONG_PTR i386AlignmentCheck; // exc 17
#endif
/* FUNCTIONS **************************************************************/
// Last step before going virtual
void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID *GdtIdt,
ULONG *PcrBasePage,
ULONG *TssBasePage)
{
ULONG TssSize;
ULONG TssPages;
ULONG_PTR Pcr = 0;
ULONG_PTR Tss = 0;
ULONG BlockSize, NumPages;
LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
/* Allocate 2 pages for PCR */
Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
*PcrBasePage = Pcr >> MM_PAGE_SHIFT;
RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE);
if (Pcr == 0)
{
UiMessageBox("Can't allocate PCR\n");
return;
}
/* Allocate TSS */
TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
TssPages = TssSize / MM_PAGE_SIZE;
Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData);
*TssBasePage = Tss >> MM_PAGE_SHIFT;
/* Allocate space for new GDT + IDT */
BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here?
NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
*GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (*GdtIdt == NULL)
{
UiMessageBox("Can't allocate pages for GDT+IDT!\n");
return;
}
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
}

View file

@ -23,8 +23,8 @@ PHARDWARE_PTE PxeBase;
//PHARDWARE_PTE HalPageTable;
PVOID GdtIdt;
ULONG PcrBasePage;
ULONG TssBasePage;
ULONG_PTR PcrBasePage;
ULONG_PTR TssBasePage;
/* FUNCTIONS **************************************************************/
@ -152,6 +152,8 @@ MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, ULONG cPage
{
if (!MempMapSinglePage(VirtualAddress, PhysicalAddress))
{
DPRINTM(DPRINT_WINDOWS, "Failed to map page %ld from %p to %p\n",
i, (PVOID)VirtualAddress, (PVOID)PhysicalAddress);
return i;
}
VirtualAddress += PAGE_SIZE;
@ -172,7 +174,8 @@ MempSetupPaging(IN ULONG StartPage,
StartPage * PAGE_SIZE,
NumberOfPages) != NumberOfPages)
{
DPRINTM(DPRINT_WINDOWS,"Failed to map pages 1\n");
DPRINTM(DPRINT_WINDOWS,"Failed to map pages %ld, %ld\n",
StartPage, NumberOfPages);
return FALSE;
}
@ -181,7 +184,8 @@ MempSetupPaging(IN ULONG StartPage,
StartPage * PAGE_SIZE,
NumberOfPages) != NumberOfPages)
{
DPRINTM(DPRINT_WINDOWS,"Failed to map pages 2\n");
DPRINTM(DPRINT_WINDOWS,"Failed to map pages %ld, %ld\n",
StartPage, NumberOfPages);
return FALSE;
}
@ -227,7 +231,7 @@ WinLdrpMapApic()
}
BOOLEAN
WinLdrMapSpecialPages(ULONG PcrBasePage)
WinLdrMapSpecialPages()
{
/* Map the PCR page */
if (!MempMapSinglePage(KIP0PCRADDRESS, PcrBasePage * PAGE_SIZE))
@ -350,10 +354,8 @@ WinLdrSetProcessorContext(void)
DPRINTM(DPRINT_WINDOWS, "leave WinLdrSetProcessorContext\n");
}
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG TssSize;
ULONG_PTR KernelStack;
ULONG_PTR Pcr = 0;
ULONG_PTR Tss = 0;
ULONG BlockSize, NumPages;
@ -382,24 +384,25 @@ WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
/* Allocate space for new GDT + IDT */
BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here?
NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
*GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (*GdtIdt == NULL)
GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (GdtIdt == NULL)
{
UiMessageBox("Can't allocate pages for GDT+IDT!\n");
return;
}
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
RtlZeroMemory(GdtIdt, NumPages << MM_PAGE_SHIFT);
/* Write initial context information */
LoaderBlock->KernelStack = (ULONG_PTR)KernelStack;
LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
LoaderBlock->Prcb = (ULONG_PTR)&Pcr->Prcb;
LoaderBlock->Process = (ULONG_PTR)PdrPage->InitialProcess;
LoaderBlock->Thread = (ULONG_PTR)PdrPage->InitialThread;
// Before we start mapping pages, create a block of memory, which will contain
// PDE and PTEs
if (MempAllocatePageTables() == FALSE)
{
// FIXME: bugcheck
}
/* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
WinLdrMapSpecialPages();
}

View file

@ -1,84 +0,0 @@
/*
* PROJECT: EFI Windows Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: freeldr/windows/i386/ntsetup.c
* PURPOSE: i386-specific setup for Windows boot
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
*/
/* INCLUDES ***************************************************************/
#include <freeldr.h>
#include <debug.h>
// this is needed for new IDT filling
#if 0
extern ULONG_PTR i386DivideByZero;
extern ULONG_PTR i386DebugException;
extern ULONG_PTR i386NMIException;
extern ULONG_PTR i386Breakpoint;
extern ULONG_PTR i386Overflow;
extern ULONG_PTR i386BoundException;
extern ULONG_PTR i386InvalidOpcode;
extern ULONG_PTR i386FPUNotAvailable;
extern ULONG_PTR i386DoubleFault;
extern ULONG_PTR i386CoprocessorSegment;
extern ULONG_PTR i386InvalidTSS;
extern ULONG_PTR i386SegmentNotPresent;
extern ULONG_PTR i386StackException;
extern ULONG_PTR i386GeneralProtectionFault;
extern ULONG_PTR i386PageFault; // exc 14
extern ULONG_PTR i386CoprocessorError; // exc 16
extern ULONG_PTR i386AlignmentCheck; // exc 17
#endif
/* FUNCTIONS **************************************************************/
#if 0
// Last step before going virtual
void WinLdrSetupForNt(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID *GdtIdt,
ULONG *PcrBasePage,
ULONG *TssBasePage)
{
ULONG TssSize;
//ULONG TssPages;
ULONG_PTR Pcr = 0;
ULONG_PTR Tss = 0;
ULONG BlockSize, NumPages;
LoaderBlock->u.I386.CommonDataArea = NULL; // Force No ABIOS support
LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
/* Allocate 2 pages for PCR */
Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
*PcrBasePage = Pcr >> MM_PAGE_SHIFT;
if (Pcr == 0)
{
UiMessageBox("Can't allocate PCR\n");
return;
}
/* Allocate TSS */
TssSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
//TssPages = TssSize / MM_PAGE_SIZE;
Tss = (ULONG_PTR)MmAllocateMemoryWithType(TssSize, LoaderMemoryData);
*TssBasePage = Tss >> MM_PAGE_SHIFT;
/* Allocate space for new GDT + IDT */
BlockSize = NUM_GDT*sizeof(KGDTENTRY) + NUM_IDT*sizeof(KIDTENTRY);//FIXME: Use GDT/IDT limits here?
NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
*GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
if (*GdtIdt == NULL)
{
UiMessageBox("Can't allocate pages for GDT+IDT!\n");
return;
}
/* Zero newly prepared GDT+IDT */
RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT);
}
#endif

View file

@ -21,7 +21,7 @@ VOID
CmdLineParse(IN PCHAR CmdLine)
{
PCHAR End, Setting;
ULONG Length, Offset = 0;
ULONG_PTR Length, Offset = 0;
//
// Set defaults

View file

@ -32,15 +32,13 @@
#if defined (DEBUG_ALL)
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_MEMORY | DPRINT_FILESYSTEM |
DPRINT_UI | DPRINT_DISK | DPRINT_CACHE | DPRINT_REACTOS |
DPRINT_LINUX | DPRINT_HWDETECT | DPRINT_PELOADER;
DPRINT_LINUX | DPRINT_HWDETECT | DPRINT_PELOADER | DPRINT_WINDOWS;
#elif defined (DEBUG_INIFILE)
ULONG DebugPrintMask = DPRINT_INIFILE;
#elif defined (DEBUG_REACTOS)
ULONG DebugPrintMask = DPRINT_REACTOS | DPRINT_REGISTRY;
#elif defined (DEBUG_CUSTOM)
ULONG DebugPrintMask = DPRINT_WARNING |
DPRINT_UI | DPRINT_CACHE | DPRINT_REACTOS |
DPRINT_LINUX;
ULONG DebugPrintMask = DPRINT_WARNING | DPRINT_WINDOWS;
#else //#elif defined (DEBUG_NONE)
ULONG DebugPrintMask = 0;
#endif

View file

@ -41,8 +41,7 @@
<file>xboxmem.c</file>
<file>xboxrtc.c</file>
<file>xboxvideo.c</file>
<file>ntsetup.c</file>
<file>wlmemory.c</file>
<file>winldr.c</file>
</if>
</directory>
<directory name="powerpc">
@ -71,8 +70,7 @@
<if property="ARCH" value="amd64">
<directory name="amd64">
<file>loader.c</file>
<file>ntsetup.c</file>
<file>wlmemory.c</file>
<file>winldr.c</file>
</directory>
<directory name="i386">
<file>hardware.c</file>
@ -93,7 +91,7 @@
<if property="ARCH" value="arm">
<directory name="arm">
<file>wlmemory.c</file>
<file>winldr.c</file>
</directory>
</if>
</directory>

View file

@ -118,7 +118,7 @@ PEXT2_FILE_INFO Ext2OpenFile(PCSTR FileName)
PEXT2_FILE_INFO FileHandle;
CHAR SymLinkPath[EXT2_NAME_LEN];
CHAR FullPath[EXT2_NAME_LEN * 2];
ULONG Index;
ULONG_PTR Index;
DPRINTM(DPRINT_FILESYSTEM, "Ext2OpenFile() FileName = %s\n", FileName);

View file

@ -650,7 +650,7 @@ static BOOLEAN FatXSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID D
{
ULONG EntryCount;
ULONG CurrentEntry;
ULONG FileNameLen;
SIZE_T FileNameLen;
FATX_DIRENTRY OurDirEntry;
PFATX_DIRENTRY DirEntry = &OurDirEntry;

View file

@ -183,7 +183,7 @@ typedef struct ext2_dirent EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
#define LOG2_BLOCK_SIZE(sb) (sb->log2_block_size + 10)
/* The size of an ext2 block in bytes. */
#define EXT2_BLOCK_SIZE(sb) (1 << LOG2_BLOCK_SIZE(sb))
#define EXT2_BLOCK_SIZE(sb) (((SIZE_T)1) << LOG2_BLOCK_SIZE(sb))
/* The revision level. */
#define EXT2_REVISION(sb) (sb->revision_level)

View file

@ -117,7 +117,7 @@ VOID MmFreeMemory(PVOID MemoryPointer);
PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
PVOID MmHeapAlloc(ULONG MemorySize);
PVOID MmHeapAlloc(SIZE_T MemorySize);
VOID MmHeapFree(PVOID MemoryPointer);
#define ExAllocatePool(pool, size) MmHeapAlloc(size)

View file

@ -320,7 +320,7 @@ InfpAddKeyToLine (PINFCACHELINE Line,
if (Line->Key != NULL)
return NULL;
Line->Key = (PCHAR)MmHeapAlloc (strlen (Key) + 1);
Line->Key = MmHeapAlloc(strlen(Key) + 1);
if (Line->Key == NULL)
return NULL;
@ -431,7 +431,7 @@ __inline static int is_eol( struct parser *parser, const CHAR *ptr )
/* push data from current token start up to pos into the current token */
static int push_token( struct parser *parser, const CHAR *pos )
{
unsigned int len = pos - parser->start;
SIZE_T len = pos - parser->start;
const CHAR *src = parser->start;
CHAR *dst = parser->token + parser->token_len;

View file

@ -93,7 +93,7 @@ ULONG IniGetSectionSettingNameSize(ULONG_PTR SectionId, ULONG SettingIndex)
return 0;
// Return the size of the string plus 1 for the null-terminator
return (strlen(SectionItem->ItemName) + 1);
return (ULONG)(strlen(SectionItem->ItemName) + 1);
}
ULONG IniGetSectionSettingValueSize(ULONG_PTR SectionId, ULONG SettingIndex)
@ -106,7 +106,7 @@ ULONG IniGetSectionSettingValueSize(ULONG_PTR SectionId, ULONG SettingIndex)
return 0;
// Return the size of the string plus 1 for the null-terminator
return (strlen(SectionItem->ItemValue) + 1);
return (ULONG)(strlen(SectionItem->ItemValue) + 1);
}
BOOLEAN IniReadSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber, PCHAR SettingName, ULONG NameSize, PCHAR SettingValue, ULONG ValueSize)

View file

@ -28,17 +28,17 @@ VOID
RegInitializeRegistry (VOID)
{
/* Create root key */
RootKey = (FRLDRHKEY) MmHeapAlloc (sizeof(KEY));
RootKey = MmHeapAlloc(sizeof(KEY));
InitializeListHead (&RootKey->SubKeyList);
InitializeListHead (&RootKey->ValueList);
InitializeListHead (&RootKey->KeyList);
InitializeListHead(&RootKey->SubKeyList);
InitializeListHead(&RootKey->ValueList);
InitializeListHead(&RootKey->KeyList);
RootKey->SubKeyCount = 0;
RootKey->ValueCount = 0;
RootKey->NameSize = 4;
RootKey->Name = MmHeapAlloc (4);
RootKey->Name = MmHeapAlloc(4);
wcscpy (RootKey->Name, L"\\");
RootKey->DataType = 0;
@ -72,7 +72,7 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegOpenKey() failed (Error %u)\n", (int)Error);
return(Error);
return Error;
}
DataSize = sizeof(ULONG);
@ -84,7 +84,7 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegQueryValue('Default') failed (Error %u)\n", (int)Error);
return(Error);
return Error;
}
DataSize = sizeof(ULONG);
@ -96,7 +96,7 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegQueryValue('Default') failed (Error %u)\n", (int)Error);
return(Error);
return Error;
}
CurrentSet = (LastKnownGood == TRUE) ? LastKnownGoodSet : DefaultSet;
@ -125,8 +125,8 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
&SystemKey);
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegOpenKey(SystemKey) failed (Error %u)\n", (int)Error);
return(Error);
DPRINTM(DPRINT_REGISTRY, "RegOpenKey(SystemKey) failed (Error %lu)\n", Error);
return Error;
}
Error = RegOpenKey(SystemKey,
@ -134,8 +134,8 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
&ControlSetKey);
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegOpenKey(ControlSetKey) failed (Error %u)\n", (int)Error);
return(Error);
DPRINTM(DPRINT_REGISTRY, "RegOpenKey(ControlSetKey) failed (Error %lu)\n", Error);
return Error;
}
Error = RegCreateKey(SystemKey,
@ -143,8 +143,8 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
&LinkKey);
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegCreateKey(LinkKey) failed (Error %u)\n", (int)Error);
return(Error);
DPRINTM(DPRINT_REGISTRY, "RegCreateKey(LinkKey) failed (Error %lu)\n", Error);
return Error;
}
Error = RegSetValue(LinkKey,
@ -154,11 +154,11 @@ RegInitCurrentControlSet(BOOLEAN LastKnownGood)
sizeof(PVOID));
if (Error != ERROR_SUCCESS)
{
DPRINTM(DPRINT_REGISTRY, "RegSetValue(LinkKey) failed (Error %u)\n", (int)Error);
return(Error);
DPRINTM(DPRINT_REGISTRY, "RegSetValue(LinkKey) failed (Error %lu)\n", Error);
return Error;
}
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -227,16 +227,13 @@ RegCreateKey(FRLDRHKEY ParentKey,
{
DPRINTM(DPRINT_REGISTRY, "Ptr 0x%x\n", Ptr);
SearchKey = CONTAINING_RECORD(Ptr,
KEY,
KeyList);
SearchKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
DPRINTM(DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey);
DPRINTM(DPRINT_REGISTRY, "Searching '%S'\n", SearchKey->Name);
CmpResult = _wcsnicmp(SearchKey->Name, name, subkeyLength);
if (CmpResult == 0 && SearchKey->NameSize == NameSize)
break;
else if (CmpResult == -1)
break;
if (CmpResult == 0 && SearchKey->NameSize == NameSize) break;
else if (CmpResult == -1) break;
Ptr = Ptr->Flink;
}
@ -244,9 +241,8 @@ RegCreateKey(FRLDRHKEY ParentKey,
if (CmpResult != 0)
{
/* no key found -> create new subkey */
NewKey = (FRLDRHKEY)MmHeapAlloc(sizeof(KEY));
if (NewKey == NULL)
return(ERROR_OUTOFMEMORY);
NewKey = MmHeapAlloc(sizeof(KEY));
if (NewKey == NULL) return ERROR_OUTOFMEMORY;
InitializeListHead(&NewKey->SubKeyList);
InitializeListHead(&NewKey->ValueList);
@ -263,8 +259,8 @@ RegCreateKey(FRLDRHKEY ParentKey,
NewKey->NameSize = NameSize;
NewKey->Name = (PWCHAR)MmHeapAlloc(NewKey->NameSize);
if (NewKey->Name == NULL)
return(ERROR_OUTOFMEMORY);
if (NewKey->Name == NULL) return ERROR_OUTOFMEMORY;
memcpy(NewKey->Name, name, NewKey->NameSize - sizeof(WCHAR));
NewKey->Name[subkeyLength] = 0;
@ -287,10 +283,9 @@ RegCreateKey(FRLDRHKEY ParentKey,
KeyName = KeyName + stringLength;
}
if (Key != NULL)
*Key = CurrentKey;
if (Key != NULL) *Key = CurrentKey;
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -299,13 +294,9 @@ RegDeleteKey(FRLDRHKEY Key,
PCWSTR Name)
{
if (wcschr(Name, L'\\') != NULL) return ERROR_INVALID_PARAMETER;
if (wcschr(Name, L'\\') != NULL)
return(ERROR_INVALID_PARAMETER);
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -323,19 +314,15 @@ RegEnumKey(FRLDRHKEY Key,
Ptr = Key->SubKeyList.Flink;
while (Ptr != &Key->SubKeyList)
{
if (Index == Count)
break;
if (Index == Count) break;
Count++;
Ptr = Ptr->Flink;
}
if (Ptr == &Key->SubKeyList)
return(ERROR_NO_MORE_ITEMS);
if (Ptr == &Key->SubKeyList) return ERROR_NO_MORE_ITEMS;
SearchKey = CONTAINING_RECORD(Ptr,
KEY,
KeyList);
SearchKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
DPRINTM(DPRINT_REGISTRY, "Name '%S' Length %d\n", SearchKey->Name, SearchKey->NameSize);
@ -343,7 +330,7 @@ RegEnumKey(FRLDRHKEY Key,
*NameSize = Size;
memcpy(Name, SearchKey->Name, Size);
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -389,8 +376,7 @@ RegOpenKey(FRLDRHKEY ParentKey,
{
DPRINTM(DPRINT_REGISTRY, "KeyName '%S'\n", KeyName);
if (*KeyName == L'\\')
KeyName++;
if (*KeyName == L'\\') KeyName++;
p = wcschr(KeyName, L'\\');
if ((p != NULL) && (p != KeyName))
{
@ -411,23 +397,20 @@ RegOpenKey(FRLDRHKEY ParentKey,
{
DPRINTM(DPRINT_REGISTRY, "Ptr 0x%x\n", Ptr);
SearchKey = CONTAINING_RECORD(Ptr,
KEY,
KeyList);
SearchKey = CONTAINING_RECORD(Ptr, KEY, KeyList);
DPRINTM(DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey);
DPRINTM(DPRINT_REGISTRY, "Searching '%S'\n", SearchKey->Name);
if (SearchKey->NameSize == NameSize &&
_wcsnicmp(SearchKey->Name, name, subkeyLength) == 0)
break;
_wcsnicmp(SearchKey->Name, name, subkeyLength) == 0) break;
Ptr = Ptr->Flink;
}
if (Ptr == &CurrentKey->SubKeyList)
{
return(ERROR_PATH_NOT_FOUND);
return ERROR_PATH_NOT_FOUND;
}
else
{
@ -446,7 +429,7 @@ RegOpenKey(FRLDRHKEY ParentKey,
if (Key != NULL)
*Key = CurrentKey;
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -491,14 +474,11 @@ RegSetValue(FRLDRHKEY Key,
Ptr = Key->ValueList.Flink;
while (Ptr != &Key->ValueList)
{
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
Value = CONTAINING_RECORD(Ptr, VALUE, ValueList);
DPRINTM(DPRINT_REGISTRY, "Value->Name '%S'\n", Value->Name);
if (_wcsicmp(Value->Name, ValueName) == 0)
break;
if (_wcsicmp(Value->Name, ValueName) == 0) break;
Ptr = Ptr->Flink;
}
@ -509,16 +489,14 @@ RegSetValue(FRLDRHKEY Key,
DPRINTM(DPRINT_REGISTRY, "No value found - adding new value\n");
Value = (PVALUE)MmHeapAlloc(sizeof(VALUE));
if (Value == NULL)
return(ERROR_OUTOFMEMORY);
if (Value == NULL) return ERROR_OUTOFMEMORY;
InsertTailList(&Key->ValueList, &Value->ValueList);
Key->ValueCount++;
Value->NameSize = (wcslen(ValueName)+1)*sizeof(WCHAR);
Value->Name = (PWCHAR)MmHeapAlloc(Value->NameSize);
if (Value->Name == NULL)
return(ERROR_OUTOFMEMORY);
Value->NameSize = (wcslen(ValueName)+1) * sizeof(WCHAR);
Value->Name = MmHeapAlloc(Value->NameSize);
if (Value->Name == NULL) return ERROR_OUTOFMEMORY;
wcscpy(Value->Name, ValueName);
Value->DataType = REG_NONE;
Value->DataSize = 0;
@ -540,8 +518,7 @@ RegSetValue(FRLDRHKEY Key,
else
{
Value->Data = MmHeapAlloc(DataSize);
if (Value->Data == NULL)
return(ERROR_OUTOFMEMORY);
if (Value->Data == NULL) return ERROR_OUTOFMEMORY;
Value->DataType = Type;
Value->DataSize = DataSize;
memcpy(Value->Data, Data, DataSize);
@ -565,8 +542,7 @@ RegQueryValue(FRLDRHKEY Key,
if ((ValueName == NULL) || (*ValueName == 0))
{
/* query default value */
if (Key->Data == NULL)
return(ERROR_INVALID_PARAMETER);
if (Key->Data == NULL) return ERROR_INVALID_PARAMETER;
if (Type != NULL)
*Type = Key->DataType;
@ -596,23 +572,18 @@ RegQueryValue(FRLDRHKEY Key,
Ptr = Key->ValueList.Flink;
while (Ptr != &Key->ValueList)
{
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
Value = CONTAINING_RECORD(Ptr, VALUE, ValueList);
DPRINTM(DPRINT_REGISTRY, "Searching for '%S'. Value name '%S'\n", ValueName, Value->Name);
if (_wcsicmp(Value->Name, ValueName) == 0)
break;
if (_wcsicmp(Value->Name, ValueName) == 0) break;
Ptr = Ptr->Flink;
}
if (Ptr == &Key->ValueList)
return(ERROR_INVALID_PARAMETER);
if (Ptr == &Key->ValueList) return ERROR_INVALID_PARAMETER;
if (Type != NULL)
*Type = Value->DataType;
if (Type != NULL) *Type = Value->DataType;
if ((Data != NULL) && (DataSize != NULL))
{
if (Value->DataSize <= sizeof(PUCHAR))
@ -634,7 +605,7 @@ RegQueryValue(FRLDRHKEY Key,
}
}
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -648,8 +619,7 @@ RegDeleteValue(FRLDRHKEY Key,
if ((ValueName == NULL) || (*ValueName == 0))
{
/* delete default value */
if (Key->Data != NULL)
MmFreeMemory(Key->Data);
if (Key->Data != NULL) MmFreeMemory(Key->Data);
Key->Data = NULL;
Key->DataSize = 0;
Key->DataType = 0;
@ -660,29 +630,23 @@ RegDeleteValue(FRLDRHKEY Key,
Ptr = Key->ValueList.Flink;
while (Ptr != &Key->ValueList)
{
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
if (_wcsicmp(Value->Name, ValueName) == 0)
break;
Value = CONTAINING_RECORD(Ptr, VALUE, ValueList);
if (_wcsicmp(Value->Name, ValueName) == 0) break;
Ptr = Ptr->Flink;
}
if (Ptr == &Key->ValueList)
return(ERROR_INVALID_PARAMETER);
if (Ptr == &Key->ValueList) return ERROR_INVALID_PARAMETER;
/* delete value */
Key->ValueCount--;
if (Value->Name != NULL)
MmFreeMemory(Value->Name);
if (Value->Name != NULL) MmFreeMemory(Value->Name);
Value->Name = NULL;
Value->NameSize = 0;
if (Value->DataSize > sizeof(PUCHAR))
{
if (Value->Data != NULL)
MmFreeMemory(Value->Data);
if (Value->Data != NULL) MmFreeMemory(Value->Data);
}
Value->Data = NULL;
Value->DataSize = 0;
@ -691,7 +655,7 @@ RegDeleteValue(FRLDRHKEY Key,
RemoveEntryList(&Value->ValueList);
MmFreeMemory(Value);
}
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -717,10 +681,8 @@ RegEnumValue(FRLDRHKEY Key,
else
{
/* enumerate default value */
if (ValueName != NULL)
*ValueName = 0;
if (Type != NULL)
*Type = Key->DataType;
if (ValueName != NULL) *ValueName = 0;
if (Type != NULL) *Type = Key->DataType;
if (Data != NULL)
{
if (Key->DataSize <= sizeof(PUCHAR))
@ -732,35 +694,32 @@ RegEnumValue(FRLDRHKEY Key,
memcpy(Data, Key->Data, min(Key->DataSize, *DataSize));
}
}
if (DataSize != NULL)
*DataSize = min(Key->DataSize, *DataSize);
return(ERROR_SUCCESS);
if (DataSize != NULL) *DataSize = min(Key->DataSize, *DataSize);
return ERROR_SUCCESS;
}
}
Ptr = Key->ValueList.Flink;
while (Ptr != &Key->ValueList)
{
if (Index == Count)
break;
if (Index == Count) break;
Count++;
Ptr = Ptr->Flink;
}
if (Ptr == &Key->ValueList)
return(ERROR_NO_MORE_ITEMS);
if (Ptr == &Key->ValueList) return ERROR_NO_MORE_ITEMS;
Value = CONTAINING_RECORD(Ptr,
VALUE,
ValueList);
Value = CONTAINING_RECORD(Ptr, VALUE, ValueList);
/* enumerate non-default value */
if (ValueName != NULL)
{
memcpy(ValueName, Value->Name, min(Value->NameSize, *NameSize));
if (Type != NULL)
*Type = Value->DataType;
}
if (Type != NULL) *Type = Value->DataType;
if (Data != NULL)
{
@ -774,10 +733,9 @@ RegEnumValue(FRLDRHKEY Key,
}
}
if (DataSize != NULL)
*DataSize = min(Value->DataSize, *DataSize);
if (DataSize != NULL) *DataSize = min(Value->DataSize, *DataSize);
return(ERROR_SUCCESS);
return ERROR_SUCCESS;
}
@ -791,8 +749,7 @@ RegGetSubKeyCount (FRLDRHKEY Key)
ULONG
RegGetValueCount (FRLDRHKEY Key)
{
if (Key->DataSize != 0)
return Key->ValueCount + 1;
if (Key->DataSize != 0) return Key->ValueCount + 1;
return Key->ValueCount;
}

View file

@ -628,7 +628,7 @@ LoadAndBootWindowsCommon(
/* Do the machine specific initialization */
WinLdrSetupMachineDependent(LoaderBlock);
/* Turn on paging mode of CPU */
/* Map pages and create memory descriptors */
WinLdrSetupMemoryLayout(LoaderBlock);
/* Save final value of LoaderPagesSpanned */
@ -640,6 +640,9 @@ LoadAndBootWindowsCommon(
DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
KiSystemStartup, LoaderBlockVA);
// Zero KI_USER_SHARED_DATA page
memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE);
WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
WinLdrpDumpBootDriver(LoaderBlockVA);
WinLdrpDumpArcDisks(LoaderBlockVA);

View file

@ -324,9 +324,6 @@ WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
MempDump();
#endif
// Zero KI_USER_SHARED_DATA page
memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE);
return TRUE;
}

View file

@ -11,7 +11,7 @@
#include <freeldr.h>
#include <debug.h>
// The only global var here, used to mark mem pages as NLS in WinLdrTurnOnPaging()
// The only global var here, used to mark mem pages as NLS in WinLdrSetupMemoryLayout()
ULONG TotalNLSSize = 0;
BOOLEAN WinLdrGetNLSNames(LPSTR AnsiName,