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
October 2006
----- 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
17 participants
357 discussions
Start a n
N
ew thread
[greatlrd] 24430: Fixed control apps windows, Let me known if it create any regress.
by greatlrd@svn.reactos.org
Author: greatlrd Date: Sat Oct 7 01:59:42 2006 New Revision: 24430 URL:
http://svn.reactos.org/svn/reactos?rev=24430&view=rev
Log: Fixed control apps windows, Let me known if it create any regress. Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c Sat Oct 7 01:59:42 2006 @@ -1221,7 +1221,7 @@ } if (RgnType != ERROR && RgnType != NULLREGION) { - if (Window->Parent) + if ((Window->Parent == UserGetDesktopWindow()) && (Window->Style & WS_VISIBLE)) { NtGdiOffsetRgn(DirtyRgn, Window->WindowRect.left - Window->Parent->ClientRect.left, @@ -1229,7 +1229,7 @@ co_UserRedrawWindow(Window->Parent, NULL, DirtyRgn, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } - else + else { NtGdiOffsetRgn(DirtyRgn, Window->WindowRect.left - Window->ClientRect.left,
18 years, 2 months
1
0
0
0
[fireball] 24429: - Load and initialize in-memory registry - Query NLS file names from registry instead of hardcoding - Move loading of NLS data to WinLdrLoadAndScanSystemHive()
by fireball@svn.reactos.org
Author: fireball Date: Sat Oct 7 01:20:36 2006 New Revision: 24429 URL:
http://svn.reactos.org/svn/reactos?rev=24429&view=rev
Log: - Load and initialize in-memory registry - Query NLS file names from registry instead of hardcoding - Move loading of NLS data to WinLdrLoadAndScanSystemHive() Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c Sat Oct 7 01:20:36 2006 @@ -29,162 +29,6 @@ VOID DumpMemoryAllocMap(VOID); VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); -BOOLEAN -WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN LPCSTR DirectoryPath, - IN LPCSTR AnsiFileName, - IN LPCSTR OemFileName, - IN LPCSTR LanguageFileName) -{ - CHAR FileName[255]; - PFILE AnsiFileHandle; - PFILE OemFileHandle; - PFILE LanguageFileHandle; - ULONG AnsiFileSize, OemFileSize, LanguageFileSize; - ULONG TotalSize; - ULONG_PTR NlsDataBase; - PVOID NlsVirtual; - BOOLEAN Status, AnsiEqualsOem = FALSE; - - /* There may be a case, when OEM and ANSI page coincide */ - if (!strcmp(AnsiFileName, OemFileName)) - AnsiEqualsOem = TRUE; - - /* Open file with ANSI and store its size */ - //Print(L"Loading %s...\n", Filename); - strcpy(FileName, DirectoryPath); - strcat(FileName, AnsiFileName); - AnsiFileHandle = FsOpenFile(FileName); - - if (AnsiFileHandle == NULL) - goto Failure; - - AnsiFileSize = FsGetFileSize(AnsiFileHandle); - DbgPrint((DPRINT_WINDOWS, "AnsiFileSize: %d\n", AnsiFileSize)); - FsCloseFile(AnsiFileHandle); - - /* Open OEM file and store its length */ - if (AnsiEqualsOem) - { - OemFileSize = 0; - } - else - { - //Print(L"Loading %s...\n", Filename); - strcpy(FileName, DirectoryPath); - strcat(FileName, OemFileName); - OemFileHandle = FsOpenFile(FileName); - - if (OemFileHandle == NULL) - goto Failure; - - OemFileSize = FsGetFileSize(OemFileHandle); - FsCloseFile(OemFileHandle); - } - DbgPrint((DPRINT_WINDOWS, "OemFileSize: %d\n", OemFileSize)); - - /* And finally open the language codepage file and store its length */ - //Print(L"Loading %s...\n", Filename); - strcpy(FileName, DirectoryPath); - strcat(FileName, LanguageFileName); - LanguageFileHandle = FsOpenFile(FileName); - - if (LanguageFileHandle == NULL) - goto Failure; - - LanguageFileSize = FsGetFileSize(LanguageFileHandle); - FsCloseFile(LanguageFileHandle); - DbgPrint((DPRINT_WINDOWS, "LanguageFileSize: %d\n", LanguageFileSize)); - - /* Sum up all three length, having in mind that every one of them - must start at a page boundary => thus round up each file to a page */ - TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) + - MM_SIZE_TO_PAGES(OemFileSize) + - MM_SIZE_TO_PAGES(LanguageFileSize); - - NlsDataBase = (ULONG_PTR)MmAllocateMemory(TotalSize*MM_PAGE_SIZE); - - if (NlsDataBase == 0) - goto Failure; - - NlsVirtual = (PVOID)(KSEG0_BASE | NlsDataBase); - LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual; - LoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)NlsVirtual + - (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT)); - LoaderBlock->NlsData->UnicodeCodePageData = (PVOID)((PUCHAR)NlsVirtual + - (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) + - (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT)); - - /* Ansi and OEM data are the same - just set pointers to the same area */ - if (AnsiEqualsOem) - LoaderBlock->NlsData->OemCodePageData = LoaderBlock->NlsData->AnsiCodePageData; - - - /* Now actually read the data into memory, starting with Ansi file */ - strcpy(FileName, DirectoryPath); - strcat(FileName, AnsiFileName); - AnsiFileHandle = FsOpenFile(FileName); - - if (AnsiFileHandle == NULL) - goto Failure; - - Status = FsReadFile(AnsiFileHandle, AnsiFileSize, NULL, VaToPa(LoaderBlock->NlsData->AnsiCodePageData)); - - if (!Status) - goto Failure; - - FsCloseFile(AnsiFileHandle); - - /* OEM now, if it doesn't equal Ansi of course */ - if (!AnsiEqualsOem) - { - strcpy(FileName, DirectoryPath); - strcat(FileName, OemFileName); - OemFileHandle = FsOpenFile(FileName); - - if (OemFileHandle == NULL) - goto Failure; - - Status = FsReadFile(OemFileHandle, OemFileSize, NULL, VaToPa(LoaderBlock->NlsData->OemCodePageData)); - - if (!Status) - goto Failure; - - FsCloseFile(AnsiFileHandle); - } - - /* finally the language file */ - strcpy(FileName, DirectoryPath); - strcat(FileName, LanguageFileName); - LanguageFileHandle = FsOpenFile(FileName); - - if (LanguageFileHandle == NULL) - goto Failure; - - Status = FsReadFile(LanguageFileHandle, LanguageFileSize, NULL, VaToPa(LoaderBlock->NlsData->UnicodeCodePageData)); - - if (!Status) - goto Failure; - - FsCloseFile(LanguageFileHandle); - - // - // THIS IS HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACK - // Should go to WinLdrLoadOemHalFont(), when it will be implemented - // - LoaderBlock->OemFontFile = VaToPa(LoaderBlock->NlsData->UnicodeCodePageData); - - /* Convert NlsTables address to VA */ - LoaderBlock->NlsData = PaToVa(LoaderBlock->NlsData); - - return TRUE; - -Failure: - //UiMessageBox("Error reading NLS file %s\n", Filename); - UiMessageBox("Error reading NLS file!"); - return FALSE; -} - void InitializeHWConfig(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock) { PCONFIGURATION_COMPONENT_DATA ConfigurationRoot; @@ -393,7 +237,7 @@ ULONG BootDevice; PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA; KERNEL_ENTRY_POINT KiSystemStartup; - PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE; + PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE = NULL; // Mm-related things PVOID GdtIdt; ULONG PcrBasePage=0; @@ -494,13 +338,6 @@ Status = WinLdrLoadAndScanSystemHive(LoaderBlock, BootPath); DbgPrint((DPRINT_WINDOWS, "SYSTEM hive loaded and scanned with status %d\n", Status)); - /* FIXME: Load NLS data, should be moved to WinLdrLoadAndScanSystemHive() */ - strcpy(SearchPath, BootPath); - strcat(SearchPath, "SYSTEM32\\"); - Status = WinLdrLoadNLSData(LoaderBlock, SearchPath, - "c_1252.nls", "c_437.nls", "l_intl.nls"); - DbgPrint((DPRINT_WINDOWS, "NLS data loaded with status %d\n", Status)); - /* FIXME: Load OEM HAL font, should be moved to WinLdrLoadAndScanSystemHive() */ /* Load boot drivers */ Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c Sat Oct 7 01:20:36 2006 @@ -12,6 +12,14 @@ #define NDEBUG #include <debug.h> + +BOOLEAN +WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN LPCSTR DirectoryPath, + IN LPCSTR AnsiFileName, + IN LPCSTR OemFileName, + IN LPCSTR LanguageFileName); + /* FUNCTIONS **************************************************************/ @@ -79,11 +87,99 @@ return TRUE; } +// Queries registry for those three file names +BOOLEAN WinLdrGetNLSNames(LPSTR AnsiName, + LPSTR OemName, + LPSTR LangName) +{ + LONG rc = ERROR_SUCCESS; + FRLDRHKEY hKey; + WCHAR szIdBuffer[80]; + WCHAR NameBuffer[80]; + ULONG BufferSize; + + /* open the codepage key */ + rc = RegOpenKey(NULL, + L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage", + &hKey); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "Couldn't open CodePage registry key"); + return FALSE; + } + + /* get ANSI codepage */ + BufferSize = sizeof(szIdBuffer); + rc = RegQueryValue(hKey, L"ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "Couldn't get ACP NLS setting"); + return FALSE; + } + + BufferSize = sizeof(NameBuffer); + rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)NameBuffer, &BufferSize); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "ACP NLS Setting exists, but isn't readable"); + return FALSE; + } + sprintf(AnsiName, "%S", NameBuffer); + + /* get OEM codepage */ + BufferSize = sizeof(szIdBuffer); + rc = RegQueryValue(hKey, L"OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "Couldn't get OEMCP NLS setting"); + return FALSE; + } + + BufferSize = sizeof(NameBuffer); + rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)NameBuffer, &BufferSize); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "OEMCP NLS setting exists, but isn't readable"); + return FALSE; + } + sprintf(OemName, "%S", NameBuffer); + + /* open the language key */ + rc = RegOpenKey(NULL, + L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language", + &hKey); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "Couldn't open Language registry key"); + return FALSE; + } + + /* get the Unicode case table */ + BufferSize = sizeof(szIdBuffer); + rc = RegQueryValue(hKey, L"Default", NULL, (PUCHAR)szIdBuffer, &BufferSize); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "Couldn't get Language Default setting"); + return FALSE; + } + + BufferSize = sizeof(NameBuffer); + rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)NameBuffer, &BufferSize); + if (rc != ERROR_SUCCESS) + { + //strcpy(szErrorOut, "Language Default setting exists, but isn't readable"); + return FALSE; + } + sprintf(LangName, "%S", NameBuffer); + + return TRUE; +} BOOLEAN WinLdrLoadAndScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN LPCSTR DirectoryPath) { CHAR SearchPath[1024]; + CHAR AnsiName[256], OemName[256], LangName[256]; BOOLEAN Status; // There is a simple logic here: try to load usual hive (system), if it @@ -98,7 +194,197 @@ if (!Status) return FALSE; - + // Initialize in-memory registry + RegInitializeRegistry(); + + // Import what was loaded + Status = RegImportBinaryHive((PCHAR)VaToPa(LoaderBlock->RegistryBase), LoaderBlock->RegistryLength); + if (!Status) + { + UiMessageBox("Importing binary hive failed!"); + return FALSE; + } + + // Initialize the 'CurrentControlSet' link + if (RegInitCurrentControlSet(FALSE) != ERROR_SUCCESS) + { + UiMessageBox("Initializing CurrentControlSet link failed!"); + return FALSE; + } + + Status = WinLdrGetNLSNames(AnsiName, OemName, LangName); + if (!Status) + { + UiMessageBox("Getting NLS names from registry failed!"); + return FALSE; + } + + DbgPrint((DPRINT_WINDOWS, "NLS data %s %s %s\n", AnsiName, OemName, LangName)); + + /* Load NLS data, should be moved to WinLdrLoadAndScanSystemHive() */ + strcpy(SearchPath, DirectoryPath); + strcat(SearchPath, "SYSTEM32\\"); + Status = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName); + DbgPrint((DPRINT_WINDOWS, "NLS data loaded with status %d\n", Status)); return TRUE; } + + +/* PRIVATE FUNCTIONS ******************************************************/ + +BOOLEAN +WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN LPCSTR DirectoryPath, + IN LPCSTR AnsiFileName, + IN LPCSTR OemFileName, + IN LPCSTR LanguageFileName) +{ + CHAR FileName[255]; + PFILE AnsiFileHandle; + PFILE OemFileHandle; + PFILE LanguageFileHandle; + ULONG AnsiFileSize, OemFileSize, LanguageFileSize; + ULONG TotalSize; + ULONG_PTR NlsDataBase; + PVOID NlsVirtual; + BOOLEAN Status, AnsiEqualsOem = FALSE; + + /* There may be a case, when OEM and ANSI page coincide */ + if (!strcmp(AnsiFileName, OemFileName)) + AnsiEqualsOem = TRUE; + + /* Open file with ANSI and store its size */ + //Print(L"Loading %s...\n", Filename); + strcpy(FileName, DirectoryPath); + strcat(FileName, AnsiFileName); + AnsiFileHandle = FsOpenFile(FileName); + + if (AnsiFileHandle == NULL) + goto Failure; + + AnsiFileSize = FsGetFileSize(AnsiFileHandle); + DbgPrint((DPRINT_WINDOWS, "AnsiFileSize: %d\n", AnsiFileSize)); + FsCloseFile(AnsiFileHandle); + + /* Open OEM file and store its length */ + if (AnsiEqualsOem) + { + OemFileSize = 0; + } + else + { + //Print(L"Loading %s...\n", Filename); + strcpy(FileName, DirectoryPath); + strcat(FileName, OemFileName); + OemFileHandle = FsOpenFile(FileName); + + if (OemFileHandle == NULL) + goto Failure; + + OemFileSize = FsGetFileSize(OemFileHandle); + FsCloseFile(OemFileHandle); + } + DbgPrint((DPRINT_WINDOWS, "OemFileSize: %d\n", OemFileSize)); + + /* And finally open the language codepage file and store its length */ + //Print(L"Loading %s...\n", Filename); + strcpy(FileName, DirectoryPath); + strcat(FileName, LanguageFileName); + LanguageFileHandle = FsOpenFile(FileName); + + if (LanguageFileHandle == NULL) + goto Failure; + + LanguageFileSize = FsGetFileSize(LanguageFileHandle); + FsCloseFile(LanguageFileHandle); + DbgPrint((DPRINT_WINDOWS, "LanguageFileSize: %d\n", LanguageFileSize)); + + /* Sum up all three length, having in mind that every one of them + must start at a page boundary => thus round up each file to a page */ + TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) + + MM_SIZE_TO_PAGES(OemFileSize) + + MM_SIZE_TO_PAGES(LanguageFileSize); + + NlsDataBase = (ULONG_PTR)MmAllocateMemory(TotalSize*MM_PAGE_SIZE); + + if (NlsDataBase == 0) + goto Failure; + + NlsVirtual = (PVOID)(KSEG0_BASE | NlsDataBase); + LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual; + LoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)NlsVirtual + + (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT)); + LoaderBlock->NlsData->UnicodeCodePageData = (PVOID)((PUCHAR)NlsVirtual + + (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) + + (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT)); + + /* Ansi and OEM data are the same - just set pointers to the same area */ + if (AnsiEqualsOem) + LoaderBlock->NlsData->OemCodePageData = LoaderBlock->NlsData->AnsiCodePageData; + + + /* Now actually read the data into memory, starting with Ansi file */ + strcpy(FileName, DirectoryPath); + strcat(FileName, AnsiFileName); + AnsiFileHandle = FsOpenFile(FileName); + + if (AnsiFileHandle == NULL) + goto Failure; + + Status = FsReadFile(AnsiFileHandle, AnsiFileSize, NULL, VaToPa(LoaderBlock->NlsData->AnsiCodePageData)); + + if (!Status) + goto Failure; + + FsCloseFile(AnsiFileHandle); + + /* OEM now, if it doesn't equal Ansi of course */ + if (!AnsiEqualsOem) + { + strcpy(FileName, DirectoryPath); + strcat(FileName, OemFileName); + OemFileHandle = FsOpenFile(FileName); + + if (OemFileHandle == NULL) + goto Failure; + + Status = FsReadFile(OemFileHandle, OemFileSize, NULL, VaToPa(LoaderBlock->NlsData->OemCodePageData)); + + if (!Status) + goto Failure; + + FsCloseFile(AnsiFileHandle); + } + + /* finally the language file */ + strcpy(FileName, DirectoryPath); + strcat(FileName, LanguageFileName); + LanguageFileHandle = FsOpenFile(FileName); + + if (LanguageFileHandle == NULL) + goto Failure; + + Status = FsReadFile(LanguageFileHandle, LanguageFileSize, NULL, VaToPa(LoaderBlock->NlsData->UnicodeCodePageData)); + + if (!Status) + goto Failure; + + FsCloseFile(LanguageFileHandle); + + // + // THIS IS HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACK + // Should go to WinLdrLoadOemHalFont(), when it will be implemented + // + LoaderBlock->OemFontFile = VaToPa(LoaderBlock->NlsData->UnicodeCodePageData); + + /* Convert NlsTables address to VA */ + LoaderBlock->NlsData = PaToVa(LoaderBlock->NlsData); + + return TRUE; + +Failure: + //UiMessageBox("Error reading NLS file %s\n", Filename); + UiMessageBox("Error reading NLS file!"); + return FALSE; +}
18 years, 2 months
1
0
0
0
[ion] 24428: - Fix calls to HvInitializeHive due to my last patch. Proof that Fireball doesn't properly test his commits... I broke Freeldr building before his commit, yet he commited it anyway even though freeldr couldn't build ; ). Just kidding.
by ion@svn.reactos.org
Author: ion Date: Sat Oct 7 00:52:50 2006 New Revision: 24428 URL:
http://svn.reactos.org/svn/reactos?rev=24428&view=rev
Log: - Fix calls to HvInitializeHive due to my last patch. Proof that Fireball doesn't properly test his commits... I broke Freeldr building before his commit, yet he commited it anyway even though freeldr couldn't build ;). Just kidding. Modified: trunk/reactos/boot/freeldr/freeldr/reactos/binhive.c Modified: trunk/reactos/boot/freeldr/freeldr/reactos/binhive.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/reactos/binhive.c (original) +++ trunk/reactos/boot/freeldr/freeldr/reactos/binhive.c Sat Oct 7 00:52:50 2006 @@ -28,6 +28,7 @@ /* FUNCTIONS ****************************************************************/ static PVOID +NTAPI CmpAllocate (ULONG Size, BOOLEAN Paged) { return MmAllocateMemory(Size); @@ -35,6 +36,7 @@ static VOID +NTAPI CmpFree (PVOID Ptr) { return MmFreeMemory(Ptr); @@ -714,7 +716,7 @@ DbgPrint((DPRINT_REGISTRY, "RegImportBinaryHive(%x, %u) called\n",ChunkBase,ChunkSize)); CmHive = CmpAllocate(sizeof(EREGISTRY_HIVE), TRUE); - Status = HvInitialize (&CmHive->Hive, HV_OPERATION_MEMORY_INPLACE, + Status = HvInitialize (&CmHive->Hive, HV_OPERATION_MEMORY_INPLACE, 0, 0, (ULONG_PTR)ChunkBase, 0, CmpAllocate, CmpFree, NULL, NULL, NULL, NULL, NULL); @@ -813,7 +815,7 @@ DbgPrint((DPRINT_REGISTRY, "Creating binary hardware hive\n")); CmHive = CmpAllocate(sizeof(EREGISTRY_HIVE), TRUE); - Status = HvInitialize (&CmHive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, + Status = HvInitialize (&CmHive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, 0, 0, CmpAllocate, CmpFree, NULL, NULL, NULL, NULL, NULL); Hive = &CmHive->Hive;
18 years, 2 months
1
0
0
0
[fireball] 24427: - Make arc-path passed to the kernel look a bit more correct (still a hack of course) - Add KdCom.dll loading along with ntoskrnl.exe and hal.dll - Move registry-related code to a new file wlregistry.c - WinLdrLoadAndScanSystemHive() is going to combine loading, initializing and parsing registry. NLS / OEM font data loading is marked with FIXMEs now, since it needs going into that routine (because registry tells the file names, not hardcoding them)
by fireball@svn.reactos.org
Author: fireball Date: Sat Oct 7 00:28:55 2006 New Revision: 24427 URL:
http://svn.reactos.org/svn/reactos?rev=24427&view=rev
Log: - Make arc-path passed to the kernel look a bit more correct (still a hack of course) - Add KdCom.dll loading along with ntoskrnl.exe and hal.dll - Move registry-related code to a new file wlregistry.c - WinLdrLoadAndScanSystemHive() is going to combine loading, initializing and parsing registry. NLS / OEM font data loading is marked with FIXMEs now, since it needs going into that routine (because registry tells the file names, not hardcoding them) Added: trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c (with props) Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild trunk/reactos/boot/freeldr/freeldr/include/winldr.h trunk/reactos/boot/freeldr/freeldr/windows/conversion.c (contents, props changed) trunk/reactos/boot/freeldr/freeldr/windows/winldr.c (contents, props changed) Modified: trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/freel…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild (original) +++ trunk/reactos/boot/freeldr/freeldr/freeldr_base.rbuild Sat Oct 7 00:28:55 2006 @@ -72,6 +72,7 @@ <file>peloader.c</file> <file>winldr.c</file> <file>wlmemory.c</file> + <file>wlregistry.c</file> </directory> <file>freeldr.c</file> <file>debug.c</file> Modified: trunk/reactos/boot/freeldr/freeldr/include/winldr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/winldr.h (original) +++ trunk/reactos/boot/freeldr/freeldr/include/winldr.h Sat Oct 7 00:28:55 2006 @@ -74,4 +74,9 @@ ULONG TssBasePage, PVOID GdtIdt); +// wlregistry.c +BOOLEAN WinLdrLoadAndScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN LPCSTR DirectoryPath); + + #endif // defined __WINLDR_H Modified: trunk/reactos/boot/freeldr/freeldr/windows/conversion.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/conversion.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/conversion.c Sat Oct 7 00:28:55 2006 @@ -1,123 +1,123 @@ -/* - * PROJECT: EFI Windows Loader - * LICENSE: GPL - See COPYING in the top level directory - * FILE: freeldr/winldr/conversion.c - * PURPOSE: Physical <-> Virtual addressing mode conversions - * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.org) - */ - -/* INCLUDES ***************************************************************/ - -#include <freeldr.h> - -//#include <ndk/ldrtypes.h> - -#define NDEBUG -#include <debug.h> - -/* FUNCTIONS **************************************************************/ - -/* Arch-specific addresses translation implementation */ -PVOID -VaToPa(PVOID Va) -{ - return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE); -} - -PVOID -PaToVa(PVOID Pa) -{ - return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE); -} - -VOID -List_PaToVa(LIST_ENTRY *ListEntry) -{ - LIST_ENTRY *ListHead = ListEntry; - LIST_ENTRY *Next = ListEntry->Flink; - LIST_ENTRY *NextPA; - - //Print(L"\n\nList_Entry: %X, First Next: %X\n", ListEntry, Next); - // - // Walk through the whole list - // - if (Next != NULL) - { - while (Next != PaToVa(ListHead)) - { - NextPA = VaToPa(Next); - //Print(L"Current: %X, Flink: %X, Blink: %X\n", Next, NextPA->Flink, NextPA->Blink); - - NextPA->Flink = PaToVa((PVOID)NextPA->Flink); - NextPA->Blink = PaToVa((PVOID)NextPA->Blink); - - //Print(L"After converting Flink: %X, Blink: %X\n", NextPA->Flink, NextPA->Blink); - - Next = NextPA->Flink; - } - - // - // Finally convert first Flink/Blink - // - ListEntry->Flink = PaToVa((PVOID)ListEntry->Flink); - if (ListEntry->Blink) - ListEntry->Blink = PaToVa((PVOID)ListEntry->Blink); - } -} - -// This function converts only Child->Child, and calls itself for each Sibling -VOID -ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start) -{ - PCONFIGURATION_COMPONENT_DATA Child; - PCONFIGURATION_COMPONENT_DATA Sibling; - - DbgPrint((DPRINT_WINDOWS, "ConvertConfigToVA(Start 0x%X)", Start)); - Child = Start; - - while (Child != NULL) - { - if (Child->ConfigurationData) - Child->ConfigurationData = PaToVa(Child->ConfigurationData); - - if (Child->Child) - Child->Child = PaToVa(Child->Child); - - if (Child->Parent) - Child->Parent = PaToVa(Child->Parent); - - if (Child->Sibling) - Child->Sibling = PaToVa(Child->Sibling); - - DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Child, Child->ComponentEntry.Class)); - - // If the child has a sibling list, then search the sibling list - // for an entry that matches the specified class, type, and key. - Sibling = Child->Sibling; - while (Sibling != NULL) - { - if (Sibling->ConfigurationData) - Sibling->ConfigurationData = PaToVa(Sibling->ConfigurationData); - - if (Sibling->Child) - Sibling->Child = PaToVa(Sibling->Child); - - if (Sibling->Parent) - Sibling->Parent = PaToVa(Sibling->Parent); - - if (Sibling->Sibling) - Sibling->Sibling = PaToVa(Sibling->Sibling); - - DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Sibling, Sibling->ComponentEntry.Class)); - - // If the sibling has a child tree, then search the child tree - // for an entry that matches the specified class, type, and key. - if (VaToPa(Sibling->Child) != NULL) - ConvertConfigToVA(VaToPa(Sibling->Child)); - - Sibling = VaToPa(Sibling->Sibling); - } - - Child = VaToPa(Child->Child); - } -} +/* + * PROJECT: EFI Windows Loader + * LICENSE: GPL - See COPYING in the top level directory + * FILE: freeldr/winldr/conversion.c + * PURPOSE: Physical <-> Virtual addressing mode conversions + * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.org) + */ + +/* INCLUDES ***************************************************************/ + +#include <freeldr.h> + +//#include <ndk/ldrtypes.h> + +#define NDEBUG +#include <debug.h> + +/* FUNCTIONS **************************************************************/ + +/* Arch-specific addresses translation implementation */ +PVOID +VaToPa(PVOID Va) +{ + return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE); +} + +PVOID +PaToVa(PVOID Pa) +{ + return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE); +} + +VOID +List_PaToVa(LIST_ENTRY *ListEntry) +{ + LIST_ENTRY *ListHead = ListEntry; + LIST_ENTRY *Next = ListEntry->Flink; + LIST_ENTRY *NextPA; + + //Print(L"\n\nList_Entry: %X, First Next: %X\n", ListEntry, Next); + // + // Walk through the whole list + // + if (Next != NULL) + { + while (Next != PaToVa(ListHead)) + { + NextPA = VaToPa(Next); + //Print(L"Current: %X, Flink: %X, Blink: %X\n", Next, NextPA->Flink, NextPA->Blink); + + NextPA->Flink = PaToVa((PVOID)NextPA->Flink); + NextPA->Blink = PaToVa((PVOID)NextPA->Blink); + + //Print(L"After converting Flink: %X, Blink: %X\n", NextPA->Flink, NextPA->Blink); + + Next = NextPA->Flink; + } + + // + // Finally convert first Flink/Blink + // + ListEntry->Flink = PaToVa((PVOID)ListEntry->Flink); + if (ListEntry->Blink) + ListEntry->Blink = PaToVa((PVOID)ListEntry->Blink); + } +} + +// This function converts only Child->Child, and calls itself for each Sibling +VOID +ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start) +{ + PCONFIGURATION_COMPONENT_DATA Child; + PCONFIGURATION_COMPONENT_DATA Sibling; + + DbgPrint((DPRINT_WINDOWS, "ConvertConfigToVA(Start 0x%X)", Start)); + Child = Start; + + while (Child != NULL) + { + if (Child->ConfigurationData) + Child->ConfigurationData = PaToVa(Child->ConfigurationData); + + if (Child->Child) + Child->Child = PaToVa(Child->Child); + + if (Child->Parent) + Child->Parent = PaToVa(Child->Parent); + + if (Child->Sibling) + Child->Sibling = PaToVa(Child->Sibling); + + DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Child, Child->ComponentEntry.Class)); + + // If the child has a sibling list, then search the sibling list + // for an entry that matches the specified class, type, and key. + Sibling = Child->Sibling; + while (Sibling != NULL) + { + if (Sibling->ConfigurationData) + Sibling->ConfigurationData = PaToVa(Sibling->ConfigurationData); + + if (Sibling->Child) + Sibling->Child = PaToVa(Sibling->Child); + + if (Sibling->Parent) + Sibling->Parent = PaToVa(Sibling->Parent); + + if (Sibling->Sibling) + Sibling->Sibling = PaToVa(Sibling->Sibling); + + DbgPrint((DPRINT_WINDOWS, "Device 0x%X class %d", Sibling, Sibling->ComponentEntry.Class)); + + // If the sibling has a child tree, then search the child tree + // for an entry that matches the specified class, type, and key. + if (VaToPa(Sibling->Child) != NULL) + ConvertConfigToVA(VaToPa(Sibling->Child)); + + Sibling = VaToPa(Sibling->Sibling); + } + + Child = VaToPa(Child->Child); + } +} Propchange: trunk/reactos/boot/freeldr/freeldr/windows/conversion.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c Sat Oct 7 00:28:55 2006 @@ -1,615 +1,559 @@ -/* - * FreeLoader - * - * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com> - * Copyright (C) 2006 Aleksey Bragin <aleksey(a)reactos.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <freeldr.h> - -#include <ndk/ldrtypes.h> - -//#define NDEBUG -#include <debug.h> - -VOID DumpMemoryAllocMap(VOID); -VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); - -BOOLEAN -WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN LPCSTR DirectoryPath, - IN LPCSTR AnsiFileName, - IN LPCSTR OemFileName, - IN LPCSTR LanguageFileName) -{ - CHAR FileName[255]; - PFILE AnsiFileHandle; - PFILE OemFileHandle; - PFILE LanguageFileHandle; - ULONG AnsiFileSize, OemFileSize, LanguageFileSize; - ULONG TotalSize; - ULONG_PTR NlsDataBase; - PVOID NlsVirtual; - BOOLEAN Status, AnsiEqualsOem = FALSE; - - /* There may be a case, when OEM and ANSI page coincide */ - if (!strcmp(AnsiFileName, OemFileName)) - AnsiEqualsOem = TRUE; - - /* Open file with ANSI and store its size */ - //Print(L"Loading %s...\n", Filename); - strcpy(FileName, DirectoryPath); - strcat(FileName, AnsiFileName); - AnsiFileHandle = FsOpenFile(FileName); - - if (AnsiFileHandle == NULL) - goto Failure; - - AnsiFileSize = FsGetFileSize(AnsiFileHandle); - DbgPrint((DPRINT_WINDOWS, "AnsiFileSize: %d\n", AnsiFileSize)); - FsCloseFile(AnsiFileHandle); - - /* Open OEM file and store its length */ - if (AnsiEqualsOem) - { - OemFileSize = 0; - } - else - { - //Print(L"Loading %s...\n", Filename); - strcpy(FileName, DirectoryPath); - strcat(FileName, OemFileName); - OemFileHandle = FsOpenFile(FileName); - - if (OemFileHandle == NULL) - goto Failure; - - OemFileSize = FsGetFileSize(OemFileHandle); - FsCloseFile(OemFileHandle); - } - DbgPrint((DPRINT_WINDOWS, "OemFileSize: %d\n", OemFileSize)); - - /* And finally open the language codepage file and store its length */ - //Print(L"Loading %s...\n", Filename); - strcpy(FileName, DirectoryPath); - strcat(FileName, LanguageFileName); - LanguageFileHandle = FsOpenFile(FileName); - - if (LanguageFileHandle == NULL) - goto Failure; - - LanguageFileSize = FsGetFileSize(LanguageFileHandle); - FsCloseFile(LanguageFileHandle); - DbgPrint((DPRINT_WINDOWS, "LanguageFileSize: %d\n", LanguageFileSize)); - - /* Sum up all three length, having in mind that every one of them - must start at a page boundary => thus round up each file to a page */ - TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) + - MM_SIZE_TO_PAGES(OemFileSize) + - MM_SIZE_TO_PAGES(LanguageFileSize); - - NlsDataBase = (ULONG_PTR)MmAllocateMemory(TotalSize*MM_PAGE_SIZE); - - if (NlsDataBase == 0) - goto Failure; - - NlsVirtual = (PVOID)(KSEG0_BASE | NlsDataBase); - LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual; - LoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)NlsVirtual + - (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT)); - LoaderBlock->NlsData->UnicodeCodePageData = (PVOID)((PUCHAR)NlsVirtual + - (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) + - (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT)); - - /* Ansi and OEM data are the same - just set pointers to the same area */ - if (AnsiEqualsOem) - LoaderBlock->NlsData->OemCodePageData = LoaderBlock->NlsData->AnsiCodePageData; - - - /* Now actually read the data into memory, starting with Ansi file */ - strcpy(FileName, DirectoryPath); - strcat(FileName, AnsiFileName); - AnsiFileHandle = FsOpenFile(FileName); - - if (AnsiFileHandle == NULL) - goto Failure; - - Status = FsReadFile(AnsiFileHandle, AnsiFileSize, NULL, VaToPa(LoaderBlock->NlsData->AnsiCodePageData)); - - if (!Status) - goto Failure; - - FsCloseFile(AnsiFileHandle); - - /* OEM now, if it doesn't equal Ansi of course */ - if (!AnsiEqualsOem) - { - strcpy(FileName, DirectoryPath); - strcat(FileName, OemFileName); - OemFileHandle = FsOpenFile(FileName); - - if (OemFileHandle == NULL) - goto Failure; - - Status = FsReadFile(OemFileHandle, OemFileSize, NULL, VaToPa(LoaderBlock->NlsData->OemCodePageData)); - - if (!Status) - goto Failure; - - FsCloseFile(AnsiFileHandle); - } - - /* finally the language file */ - strcpy(FileName, DirectoryPath); - strcat(FileName, LanguageFileName); - LanguageFileHandle = FsOpenFile(FileName); - - if (LanguageFileHandle == NULL) - goto Failure; - - Status = FsReadFile(LanguageFileHandle, LanguageFileSize, NULL, VaToPa(LoaderBlock->NlsData->UnicodeCodePageData)); - - if (!Status) - goto Failure; - - FsCloseFile(LanguageFileHandle); - - // - // THIS IS HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACK - // Should go to WinLdrLoadOemHalFont(), when it will be implemented - // - LoaderBlock->OemFontFile = VaToPa(LoaderBlock->NlsData->UnicodeCodePageData); - - /* Convert NlsTables address to VA */ - LoaderBlock->NlsData = PaToVa(LoaderBlock->NlsData); - - return TRUE; - -Failure: - //UiMessageBox("Error reading NLS file %s\n", Filename); - UiMessageBox("Error reading NLS file!"); - return FALSE; -} - -BOOLEAN -WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, - IN LPCSTR DirectoryPath, - IN LPCSTR HiveName) -{ - PFILE FileHandle; - CHAR FullHiveName[256]; - BOOLEAN Status; - ULONG HiveFileSize; - ULONG_PTR HiveDataPhysical; - PVOID HiveDataVirtual; - - /* Concatenate path and filename to get the full name */ - strcpy(FullHiveName, DirectoryPath); - strcat(FullHiveName, HiveName); - //Print(L"Loading %s...\n", FullHiveName); - FileHandle = FsOpenFile(FullHiveName); - - if (FileHandle == NULL) - { - UiMessageBox("Opening hive file failed!"); - return FALSE; - } - - /* Get the file length */ - HiveFileSize = FsGetFileSize(FileHandle); - - if (HiveFileSize == 0) - { - FsCloseFile(FileHandle); - UiMessageBox("Hive file has 0 size!"); - return FALSE; - } - - /* Round up the size to page boundary and alloc memory */ - HiveDataPhysical = (ULONG_PTR)MmAllocateMemory( - MM_SIZE_TO_PAGES(HiveFileSize + MM_PAGE_SIZE - 1) << MM_PAGE_SHIFT); - - if (HiveDataPhysical == 0) - { - FsCloseFile(FileHandle); - UiMessageBox("Unable to alloc memory for a hive!"); - return FALSE; - } - - /* Convert address to virtual */ - HiveDataVirtual = (PVOID)(KSEG0_BASE | HiveDataPhysical); - - /* Fill LoaderBlock's entries */ - LoaderBlock->RegistryLength = HiveFileSize; - LoaderBlock->RegistryBase = HiveDataVirtual; - - /* Finally read from file to the memory */ - Status = FsReadFile(FileHandle, HiveFileSize, NULL, (PVOID)HiveDataPhysical); - FsCloseFile(FileHandle); - if (!Status) - { - UiMessageBox("Unable to read from hive file!"); - return FALSE; - } - - return TRUE; -} - -void InitializeHWConfig(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - PCONFIGURATION_COMPONENT_DATA ConfigurationRoot; - PCONFIGURATION_COMPONENT Component; - PCONFIGURATION_COMPONENT_DATA /*CurrentEntry,*/ PreviousEntry, AdapterEntry; - BOOLEAN IsNextEntryChild; - - DbgPrint((DPRINT_WINDOWS, "InitializeHWConfig()\n")); - - LoaderBlock->ConfigurationRoot = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA)); - RtlZeroMemory(LoaderBlock->ConfigurationRoot, sizeof(CONFIGURATION_COMPONENT_DATA)); - - /* Fill root == SystemClass */ - ConfigurationRoot = LoaderBlock->ConfigurationRoot; - Component = &LoaderBlock->ConfigurationRoot->ComponentEntry; - - Component->Class = SystemClass; - Component->Type = MaximumType; - Component->Version = 0; // FIXME: ? - Component->Key = 0; - Component->AffinityMask = 0; - - IsNextEntryChild = TRUE; - PreviousEntry = ConfigurationRoot; - - /* Enumerate all PCI buses */ - AdapterEntry = ConfigurationRoot; - - /* TODO: Disk Geometry */ - /* TODO: Keyboard */ - - /* TODO: Serial port */ - - //Config->ConfigurationData = alloc(sizeof(CONFIGURATION_COMPONENT_DATA), EfiLoaderData); - - /* Convert everything to VA */ - ConvertConfigToVA(LoaderBlock->ConfigurationRoot); - LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot); -} - - -// Init "phase 0" -VOID -AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock) -{ - PLOADER_PARAMETER_BLOCK LoaderBlock; - - /* Allocate and zero-init the LPB */ - LoaderBlock = MmAllocateMemory(sizeof(LOADER_PARAMETER_BLOCK)); - RtlZeroMemory(LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK)); - - /* Init three critical lists, used right away */ - InitializeListHead(&LoaderBlock->LoadOrderListHead); - InitializeListHead(&LoaderBlock->MemoryDescriptorListHead); - InitializeListHead(&LoaderBlock->BootDriverListHead); - - - *OutLoaderBlock = LoaderBlock; -} - -// Init "phase 1" -VOID -WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - //CHAR Options[] = "/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200"; - CHAR Options[] = "/NODEBUG"; - CHAR SystemRoot[] = "\\WINNT"; - CHAR HalPath[] = "\\"; - CHAR ArcBoot[] = "multi(0)"; - CHAR ArcHal[] = "multi(0)"; - - PLOADER_PARAMETER_EXTENSION Extension; - - LoaderBlock->u.I386.CommonDataArea = NULL; // Force No ABIOS support - - /* Fill Arc BootDevice */ - LoaderBlock->ArcBootDeviceName = MmAllocateMemory(strlen(ArcBoot)+1); - strcpy(LoaderBlock->ArcBootDeviceName, ArcBoot); - LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName); - - /* Fill Arc HalDevice */ - LoaderBlock->ArcHalDeviceName = MmAllocateMemory(strlen(ArcHal)+1); - strcpy(LoaderBlock->ArcHalDeviceName, ArcHal); - LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName); - - /* Fill SystemRoot */ - LoaderBlock->NtBootPathName = MmAllocateMemory(strlen(SystemRoot)+1); - strcpy(LoaderBlock->NtBootPathName, SystemRoot); - LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName); - - /* Fill NtHalPathName */ - LoaderBlock->NtHalPathName = MmAllocateMemory(strlen(HalPath)+1); - strcpy(LoaderBlock->NtHalPathName, HalPath); - LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName); - - /* Fill load options */ - LoaderBlock->LoadOptions = MmAllocateMemory(strlen(Options)+1); - strcpy(LoaderBlock->LoadOptions, Options); - LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions); - - /* Arc devices */ - LoaderBlock->ArcDiskInformation = (PARC_DISK_INFORMATION)MmAllocateMemory(sizeof(ARC_DISK_INFORMATION)); - InitializeListHead(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead); - List_PaToVa(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead); - LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation); - - /* Alloc space for NLS (it will be converted to VA in WinLdrLoadNLS) */ - LoaderBlock->NlsData = MmAllocateMemory(sizeof(NLS_DATA_BLOCK)); - if (LoaderBlock->NlsData == NULL) - { - UiMessageBox("Failed to allocate memory for NLS table data!"); - return; - } - RtlZeroMemory(LoaderBlock->NlsData, sizeof(NLS_DATA_BLOCK)); - - /* Create configuration entries */ - InitializeHWConfig(LoaderBlock); - - /* Convert all DTE into virtual addresses */ - //TODO: !!! - - /* Convert all list's to Virtual address */ - List_PaToVa(&LoaderBlock->LoadOrderListHead); - - /* this one will be converted right before switching to - virtual paging mode */ - //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead); - - List_PaToVa(&LoaderBlock->BootDriverListHead); - - /* Initialize Extension now */ - Extension = MmAllocateMemory(sizeof(LOADER_PARAMETER_EXTENSION)); - if (Extension == NULL) - { - UiMessageBox("Failed to allocate LPB Extension!"); - return; - } - RtlZeroMemory(Extension, sizeof(LOADER_PARAMETER_EXTENSION)); - - Extension->Size = sizeof(LOADER_PARAMETER_EXTENSION); - Extension->MajorVersion = 4; - Extension->MinorVersion = 0; - - - LoaderBlock->Extension = PaToVa(Extension); -} - -// 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;//CommonDataArea; - //LoaderBlock->u.I386.MachineType = MachineType; //FIXME: MachineType? - - /* Allocate 2 pages for PCR */ - Pcr = (ULONG_PTR)MmAllocateMemory(2 * MM_PAGE_SIZE); - *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)MmAllocateMemory(TssSize); - - *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)MmAllocateMemory(NumPages * MM_PAGE_SIZE); - - if (*GdtIdt == NULL) - { - UiMessageBox("Can't allocate pages for GDT+IDT!\n"); - return; - } - - /* Zero newly prepared GDT+IDT */ - RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT); -} - -VOID -LoadAndBootWindows(PCSTR OperatingSystemName, WORD OperatingSystemVersion) -{ - CHAR MsgBuffer[256]; - CHAR SystemPath[1024], SearchPath[1024]; - CHAR FileName[1024]; - CHAR BootPath[256]; - PVOID NtosBase = NULL, HalBase = NULL; - BOOLEAN Status; - ULONG SectionId; - ULONG BootDevice; - PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA; - KERNEL_ENTRY_POINT KiSystemStartup; - PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE; - // Mm-related things - PVOID GdtIdt; - ULONG PcrBasePage=0; - ULONG TssBasePage=0; - - - - //sprintf(MsgBuffer,"Booting Microsoft(R) Windows(R) OS version '%04x' is not implemented yet", OperatingSystemVersion); - //UiMessageBox(MsgBuffer); - - // - // Open the operating system section - // specified in the .ini file - // - if (!IniOpenSection(OperatingSystemName, &SectionId)) - { - sprintf(MsgBuffer,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName); - UiMessageBox(MsgBuffer); - return; - } - - /* - * Make sure the system path is set in the .ini file - */ - if (!IniReadSettingByName(SectionId, "SystemPath", SystemPath, sizeof(SystemPath))) - { - UiMessageBox("System path not specified for selected operating system."); - return; - } - - if (!MachDiskNormalizeSystemPath(SystemPath, - sizeof(SystemPath))) - { - UiMessageBox("Invalid system path"); - return; - } - - UiDrawStatusText("Loading..."); - - /* - * Try to open system drive - */ - BootDevice = 0xffffffff; - if (!FsOpenSystemVolume(SystemPath, BootPath, &BootDevice)) - { - UiMessageBox("Failed to open boot drive."); - return; - } - - /* append a backslash */ - if ((strlen(BootPath)==0) || - BootPath[strlen(BootPath)] != '\\') - strcat(BootPath, "\\"); - - DbgPrint((DPRINT_WINDOWS,"SystemRoot: '%s'\n", BootPath)); - - /* Allocate and minimalistic-initialize LPB */ - AllocateAndInitLPB(&LoaderBlock); - - // Load kernel - strcpy(FileName, BootPath); - strcat(FileName, "SYSTEM32\\NTOSKRNL.EXE"); - Status = WinLdrLoadImage(FileName, &NtosBase); - DbgPrint((DPRINT_WINDOWS, "Ntos loaded with status %d\n", Status)); - - // Load HAL - strcpy(FileName, BootPath); - strcat(FileName, "SYSTEM32\\HAL.DLL"); - Status = WinLdrLoadImage(FileName, &HalBase); - DbgPrint((DPRINT_WINDOWS, "HAL loaded with status %d\n", Status)); - - WinLdrAllocateDataTableEntry(LoaderBlock, "ntoskrnl.exe", - "WINNT\\SYSTEM32\\NTOSKRNL.EXE", NtosBase, &KernelDTE); - WinLdrAllocateDataTableEntry(LoaderBlock, "hal.dll", - "WINNT\\SYSTEM32\\HAL.EXE", HalBase, &HalDTE); - - /* Load all referenced DLLs for kernel and HAL */ - strcpy(SearchPath, BootPath); - strcat(SearchPath, "SYSTEM32\\"); - WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, KernelDTE); - WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, HalDTE); - - /* Initialize Phase 1 - before NLS */ - WinLdrInitializePhase1(LoaderBlock); - - /* Load SYSTEM hive and its LOG file */ - strcpy(SearchPath, BootPath); - strcat(SearchPath, "SYSTEM32\\CONFIG\\"); - Status = WinLdrLoadSystemHive(LoaderBlock, SearchPath, "SYSTEM"); - DbgPrint((DPRINT_WINDOWS, "SYSTEM hive loaded with status %d\n", Status)); - - /* Load NLS data */ - strcpy(SearchPath, BootPath); - strcat(SearchPath, "SYSTEM32\\"); - Status = WinLdrLoadNLSData(LoaderBlock, SearchPath, - "c_1252.nls", "c_437.nls", "l_intl.nls"); - DbgPrint((DPRINT_WINDOWS, "NLS data loaded with status %d\n", Status)); - - /* Load OEM HAL font */ - - /* Load boot drivers */ - - /* Alloc PCR, TSS, do magic things with the GDT/IDT */ - WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage); - - /* Save entry-point pointer (VA) */ - KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint; - - LoaderBlockVA = PaToVa(LoaderBlock); - - /* Debugging... */ - //DumpMemoryAllocMap(); - - /* Turn on paging mode of CPU*/ - WinLdrTurnOnPaging(LoaderBlock, PcrBasePage, TssBasePage, GdtIdt); - - DbgPrint((DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n", - KiSystemStartup, LoaderBlockVA)); - - WinLdrpDumpMemoryDescriptors(LoaderBlockVA); - - // temp: offset C9000 - - //FIXME: If I substitute this debugging checkpoint, GCC will "optimize away" the code below - //while (1) {}; - asm(".intel_syntax noprefix\n"); - asm("test1:\n"); - asm("jmp test1\n"); - asm(".att_syntax\n"); - - - (*KiSystemStartup)(LoaderBlockVA); - - return; -} - -VOID -WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - PLIST_ENTRY NextMd; - PMEMORY_ALLOCATION_DESCRIPTOR MemoryDescriptor; - - NextMd = LoaderBlock->MemoryDescriptorListHead.Flink; - - while (NextMd != &LoaderBlock->MemoryDescriptorListHead) - { - MemoryDescriptor = CONTAINING_RECORD(NextMd, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry); - - - DbgPrint((DPRINT_WINDOWS, "BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage, - MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType)); - - NextMd = MemoryDescriptor->ListEntry.Flink; - } -} +/* + * FreeLoader + * + * Copyright (C) 1998-2003 Brian Palmer <brianp(a)sginet.com> + * Copyright (C) 2006 Aleksey Bragin <aleksey(a)reactos.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <freeldr.h> + +#include <ndk/ldrtypes.h> + +//#define NDEBUG +#include <debug.h> + +VOID DumpMemoryAllocMap(VOID); +VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); + +BOOLEAN +WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN LPCSTR DirectoryPath, + IN LPCSTR AnsiFileName, + IN LPCSTR OemFileName, + IN LPCSTR LanguageFileName) +{ + CHAR FileName[255]; + PFILE AnsiFileHandle; + PFILE OemFileHandle; + PFILE LanguageFileHandle; + ULONG AnsiFileSize, OemFileSize, LanguageFileSize; + ULONG TotalSize; + ULONG_PTR NlsDataBase; + PVOID NlsVirtual; + BOOLEAN Status, AnsiEqualsOem = FALSE; + + /* There may be a case, when OEM and ANSI page coincide */ + if (!strcmp(AnsiFileName, OemFileName)) + AnsiEqualsOem = TRUE; + + /* Open file with ANSI and store its size */ + //Print(L"Loading %s...\n", Filename); + strcpy(FileName, DirectoryPath); + strcat(FileName, AnsiFileName); + AnsiFileHandle = FsOpenFile(FileName); + + if (AnsiFileHandle == NULL) + goto Failure; + + AnsiFileSize = FsGetFileSize(AnsiFileHandle); + DbgPrint((DPRINT_WINDOWS, "AnsiFileSize: %d\n", AnsiFileSize)); + FsCloseFile(AnsiFileHandle); + + /* Open OEM file and store its length */ + if (AnsiEqualsOem) + { + OemFileSize = 0; + } + else + { + //Print(L"Loading %s...\n", Filename); + strcpy(FileName, DirectoryPath); + strcat(FileName, OemFileName); + OemFileHandle = FsOpenFile(FileName); + + if (OemFileHandle == NULL) + goto Failure; + + OemFileSize = FsGetFileSize(OemFileHandle); + FsCloseFile(OemFileHandle); + } + DbgPrint((DPRINT_WINDOWS, "OemFileSize: %d\n", OemFileSize)); + + /* And finally open the language codepage file and store its length */ + //Print(L"Loading %s...\n", Filename); + strcpy(FileName, DirectoryPath); + strcat(FileName, LanguageFileName); + LanguageFileHandle = FsOpenFile(FileName); + + if (LanguageFileHandle == NULL) + goto Failure; + + LanguageFileSize = FsGetFileSize(LanguageFileHandle); + FsCloseFile(LanguageFileHandle); + DbgPrint((DPRINT_WINDOWS, "LanguageFileSize: %d\n", LanguageFileSize)); + + /* Sum up all three length, having in mind that every one of them + must start at a page boundary => thus round up each file to a page */ + TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) + + MM_SIZE_TO_PAGES(OemFileSize) + + MM_SIZE_TO_PAGES(LanguageFileSize); + + NlsDataBase = (ULONG_PTR)MmAllocateMemory(TotalSize*MM_PAGE_SIZE); + + if (NlsDataBase == 0) + goto Failure; + + NlsVirtual = (PVOID)(KSEG0_BASE | NlsDataBase); + LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual; + LoaderBlock->NlsData->OemCodePageData = (PVOID)((PUCHAR)NlsVirtual + + (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT)); + LoaderBlock->NlsData->UnicodeCodePageData = (PVOID)((PUCHAR)NlsVirtual + + (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) + + (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT)); + + /* Ansi and OEM data are the same - just set pointers to the same area */ + if (AnsiEqualsOem) + LoaderBlock->NlsData->OemCodePageData = LoaderBlock->NlsData->AnsiCodePageData; + + + /* Now actually read the data into memory, starting with Ansi file */ + strcpy(FileName, DirectoryPath); + strcat(FileName, AnsiFileName); + AnsiFileHandle = FsOpenFile(FileName); + + if (AnsiFileHandle == NULL) + goto Failure; + + Status = FsReadFile(AnsiFileHandle, AnsiFileSize, NULL, VaToPa(LoaderBlock->NlsData->AnsiCodePageData)); + + if (!Status) + goto Failure; + + FsCloseFile(AnsiFileHandle); + + /* OEM now, if it doesn't equal Ansi of course */ + if (!AnsiEqualsOem) + { + strcpy(FileName, DirectoryPath); + strcat(FileName, OemFileName); + OemFileHandle = FsOpenFile(FileName); + + if (OemFileHandle == NULL) + goto Failure; + + Status = FsReadFile(OemFileHandle, OemFileSize, NULL, VaToPa(LoaderBlock->NlsData->OemCodePageData)); + + if (!Status) + goto Failure; + + FsCloseFile(AnsiFileHandle); + } + + /* finally the language file */ + strcpy(FileName, DirectoryPath); + strcat(FileName, LanguageFileName); + LanguageFileHandle = FsOpenFile(FileName); + + if (LanguageFileHandle == NULL) + goto Failure; + + Status = FsReadFile(LanguageFileHandle, LanguageFileSize, NULL, VaToPa(LoaderBlock->NlsData->UnicodeCodePageData)); + + if (!Status) + goto Failure; + + FsCloseFile(LanguageFileHandle); + + // + // THIS IS HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACK + // Should go to WinLdrLoadOemHalFont(), when it will be implemented + // + LoaderBlock->OemFontFile = VaToPa(LoaderBlock->NlsData->UnicodeCodePageData); + + /* Convert NlsTables address to VA */ + LoaderBlock->NlsData = PaToVa(LoaderBlock->NlsData); + + return TRUE; + +Failure: + //UiMessageBox("Error reading NLS file %s\n", Filename); + UiMessageBox("Error reading NLS file!"); + return FALSE; +} + +void InitializeHWConfig(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PCONFIGURATION_COMPONENT_DATA ConfigurationRoot; + PCONFIGURATION_COMPONENT Component; + PCONFIGURATION_COMPONENT_DATA /*CurrentEntry,*/ PreviousEntry, AdapterEntry; + BOOLEAN IsNextEntryChild; + + DbgPrint((DPRINT_WINDOWS, "InitializeHWConfig()\n")); + + LoaderBlock->ConfigurationRoot = MmAllocateMemory(sizeof(CONFIGURATION_COMPONENT_DATA)); + RtlZeroMemory(LoaderBlock->ConfigurationRoot, sizeof(CONFIGURATION_COMPONENT_DATA)); + + /* Fill root == SystemClass */ + ConfigurationRoot = LoaderBlock->ConfigurationRoot; + Component = &LoaderBlock->ConfigurationRoot->ComponentEntry; + + Component->Class = SystemClass; + Component->Type = MaximumType; + Component->Version = 0; // FIXME: ? + Component->Key = 0; + Component->AffinityMask = 0; + + IsNextEntryChild = TRUE; + PreviousEntry = ConfigurationRoot; + + /* Enumerate all PCI buses */ + AdapterEntry = ConfigurationRoot; + + /* TODO: Disk Geometry */ + /* TODO: Keyboard */ + + /* TODO: Serial port */ + + //Config->ConfigurationData = alloc(sizeof(CONFIGURATION_COMPONENT_DATA), EfiLoaderData); + + /* Convert everything to VA */ + ConvertConfigToVA(LoaderBlock->ConfigurationRoot); + LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot); +} + + +// Init "phase 0" +VOID +AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock) +{ + PLOADER_PARAMETER_BLOCK LoaderBlock; + + /* Allocate and zero-init the LPB */ + LoaderBlock = MmAllocateMemory(sizeof(LOADER_PARAMETER_BLOCK)); + RtlZeroMemory(LoaderBlock, sizeof(LOADER_PARAMETER_BLOCK)); + + /* Init three critical lists, used right away */ + InitializeListHead(&LoaderBlock->LoadOrderListHead); + InitializeListHead(&LoaderBlock->MemoryDescriptorListHead); + InitializeListHead(&LoaderBlock->BootDriverListHead); + + + *OutLoaderBlock = LoaderBlock; +} + +// Init "phase 1" +VOID +WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + //CHAR Options[] = "/CRASHDEBUG /DEBUGPORT=COM1 /BAUDRATE=115200"; + CHAR Options[] = "/NODEBUG"; + CHAR SystemRoot[] = "\\WINNT"; + CHAR HalPath[] = "\\"; + CHAR ArcBoot[] = "multi(0)disk(0)rdisk(1)partition(1)"; + CHAR ArcHal[] = "multi(0)disk(0)rdisk(1)partition(1)"; + + PLOADER_PARAMETER_EXTENSION Extension; + + LoaderBlock->u.I386.CommonDataArea = NULL; // Force No ABIOS support + + /* Fill Arc BootDevice */ + LoaderBlock->ArcBootDeviceName = MmAllocateMemory(strlen(ArcBoot)+1); + strcpy(LoaderBlock->ArcBootDeviceName, ArcBoot); + LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName); + + /* Fill Arc HalDevice */ + LoaderBlock->ArcHalDeviceName = MmAllocateMemory(strlen(ArcHal)+1); + strcpy(LoaderBlock->ArcHalDeviceName, ArcHal); + LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName); + + /* Fill SystemRoot */ + LoaderBlock->NtBootPathName = MmAllocateMemory(strlen(SystemRoot)+1); + strcpy(LoaderBlock->NtBootPathName, SystemRoot); + LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName); + + /* Fill NtHalPathName */ + LoaderBlock->NtHalPathName = MmAllocateMemory(strlen(HalPath)+1); + strcpy(LoaderBlock->NtHalPathName, HalPath); + LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName); + + /* Fill load options */ + LoaderBlock->LoadOptions = MmAllocateMemory(strlen(Options)+1); + strcpy(LoaderBlock->LoadOptions, Options); + LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions); + + /* Arc devices */ + LoaderBlock->ArcDiskInformation = (PARC_DISK_INFORMATION)MmAllocateMemory(sizeof(ARC_DISK_INFORMATION)); + InitializeListHead(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead); + List_PaToVa(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead); + LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation); + + /* Alloc space for NLS (it will be converted to VA in WinLdrLoadNLS) */ + LoaderBlock->NlsData = MmAllocateMemory(sizeof(NLS_DATA_BLOCK)); + if (LoaderBlock->NlsData == NULL) + { + UiMessageBox("Failed to allocate memory for NLS table data!"); + return; + } + RtlZeroMemory(LoaderBlock->NlsData, sizeof(NLS_DATA_BLOCK)); + + /* Create configuration entries */ + InitializeHWConfig(LoaderBlock); + + /* Convert all DTE into virtual addresses */ + //TODO: !!! + + /* Convert all list's to Virtual address */ + List_PaToVa(&LoaderBlock->LoadOrderListHead); + + /* this one will be converted right before switching to + virtual paging mode */ + //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead); + + List_PaToVa(&LoaderBlock->BootDriverListHead); + + /* Initialize Extension now */ + Extension = MmAllocateMemory(sizeof(LOADER_PARAMETER_EXTENSION)); + if (Extension == NULL) + { + UiMessageBox("Failed to allocate LPB Extension!"); + return; + } + RtlZeroMemory(Extension, sizeof(LOADER_PARAMETER_EXTENSION)); + + Extension->Size = sizeof(LOADER_PARAMETER_EXTENSION); + Extension->MajorVersion = 4; + Extension->MinorVersion = 0; + + + LoaderBlock->Extension = PaToVa(Extension); +} + +// 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;//CommonDataArea; + //LoaderBlock->u.I386.MachineType = MachineType; //FIXME: MachineType? + + /* Allocate 2 pages for PCR */ + Pcr = (ULONG_PTR)MmAllocateMemory(2 * MM_PAGE_SIZE); + *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)MmAllocateMemory(TssSize); + + *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)MmAllocateMemory(NumPages * MM_PAGE_SIZE); + + if (*GdtIdt == NULL) + { + UiMessageBox("Can't allocate pages for GDT+IDT!\n"); + return; + } + + /* Zero newly prepared GDT+IDT */ + RtlZeroMemory(*GdtIdt, NumPages << MM_PAGE_SHIFT); +} + +VOID +LoadAndBootWindows(PCSTR OperatingSystemName, WORD OperatingSystemVersion) +{ + CHAR MsgBuffer[256]; + CHAR SystemPath[1024], SearchPath[1024]; + CHAR FileName[1024]; + CHAR BootPath[256]; + PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL; + BOOLEAN Status; + ULONG SectionId; + ULONG BootDevice; + PLOADER_PARAMETER_BLOCK LoaderBlock, LoaderBlockVA; + KERNEL_ENTRY_POINT KiSystemStartup; + PLDR_DATA_TABLE_ENTRY KernelDTE, HalDTE, KdComDTE; + // Mm-related things + PVOID GdtIdt; + ULONG PcrBasePage=0; + ULONG TssBasePage=0; + + + + //sprintf(MsgBuffer,"Booting Microsoft(R) Windows(R) OS version '%04x' is not implemented yet", OperatingSystemVersion); + //UiMessageBox(MsgBuffer); + + // Open the operating system section + // specified in the .ini file + if (!IniOpenSection(OperatingSystemName, &SectionId)) + { + sprintf(MsgBuffer,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName); + UiMessageBox(MsgBuffer); + return; + } + + /* Make sure the system path is set in the .ini file */ + if (!IniReadSettingByName(SectionId, "SystemPath", SystemPath, sizeof(SystemPath))) + { + UiMessageBox("System path not specified for selected operating system."); + return; + } + + if (!MachDiskNormalizeSystemPath(SystemPath, + sizeof(SystemPath))) + { + UiMessageBox("Invalid system path"); + return; + } + + UiDrawStatusText("Loading..."); + + /* Try to open system drive */ + BootDevice = 0xffffffff; + if (!FsOpenSystemVolume(SystemPath, BootPath, &BootDevice)) + { + UiMessageBox("Failed to open boot drive."); + return; + } + + /* append a backslash */ + if ((strlen(BootPath)==0) || + BootPath[strlen(BootPath)] != '\\') + strcat(BootPath, "\\"); + + DbgPrint((DPRINT_WINDOWS,"SystemRoot: '%s'\n", BootPath)); + + // Allocate and minimalistic-initialize LPB + AllocateAndInitLPB(&LoaderBlock); + + // Load kernel + strcpy(FileName, BootPath); + strcat(FileName, "SYSTEM32\\NTOSKRNL.EXE"); + Status = WinLdrLoadImage(FileName, &NtosBase); + DbgPrint((DPRINT_WINDOWS, "Ntos loaded with status %d at %p\n", Status, NtosBase)); + + // Load HAL + strcpy(FileName, BootPath); + strcat(FileName, "SYSTEM32\\HAL.DLL"); + Status = WinLdrLoadImage(FileName, &HalBase); + DbgPrint((DPRINT_WINDOWS, "HAL loaded with status %d at %p\n", Status, HalBase)); + + // Load kernel-debugger support dll + if (OperatingSystemVersion > _WIN32_WINNT_NT4) + { + strcpy(FileName, BootPath); + strcat(FileName, "SYSTEM32\\KDCOM.DLL"); + Status = WinLdrLoadImage(FileName, &KdComBase); + DbgPrint((DPRINT_WINDOWS, "KdCom loaded with status %d at %p\n", Status, KdComBase)); + } + + // Allocate data table entries for above-loaded modules + WinLdrAllocateDataTableEntry(LoaderBlock, "ntoskrnl.exe", + "WINNT\\SYSTEM32\\NTOSKRNL.EXE", NtosBase, &KernelDTE); + WinLdrAllocateDataTableEntry(LoaderBlock, "hal.dll", + "WINNT\\SYSTEM32\\HAL.DLL", HalBase, &HalDTE); + if (OperatingSystemVersion > _WIN32_WINNT_NT4) + { + WinLdrAllocateDataTableEntry(LoaderBlock, "kdcom.dll", + "WINNT\\SYSTEM32\\KDCOM.DLL", KdComBase, &KdComDTE); + } + + /* Load all referenced DLLs for kernel, HAL and kdcom.dll */ + strcpy(SearchPath, BootPath); + strcat(SearchPath, "SYSTEM32\\"); + WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, KernelDTE); + WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, HalDTE); + if (KdComDTE) + WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, KdComDTE); + + /* Initialize Phase 1 - before NLS */ + WinLdrInitializePhase1(LoaderBlock); + + /* Load Hive, and then NLS data, OEM font, and prepare boot drivers list */ + Status = WinLdrLoadAndScanSystemHive(LoaderBlock, BootPath); + DbgPrint((DPRINT_WINDOWS, "SYSTEM hive loaded and scanned with status %d\n", Status)); + + /* FIXME: Load NLS data, should be moved to WinLdrLoadAndScanSystemHive() */ + strcpy(SearchPath, BootPath); + strcat(SearchPath, "SYSTEM32\\"); + Status = WinLdrLoadNLSData(LoaderBlock, SearchPath, + "c_1252.nls", "c_437.nls", "l_intl.nls"); + DbgPrint((DPRINT_WINDOWS, "NLS data loaded with status %d\n", Status)); + + /* FIXME: Load OEM HAL font, should be moved to WinLdrLoadAndScanSystemHive() */ + + /* Load boot drivers */ + //WinLdrLoadBootDrivers(); + + /* Alloc PCR, TSS, do magic things with the GDT/IDT */ + WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage); + + /* Save entry-point pointer (VA) */ + KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint; + + LoaderBlockVA = PaToVa(LoaderBlock); + + /* Debugging... */ + //DumpMemoryAllocMap(); + + /* Turn on paging mode of CPU*/ + WinLdrTurnOnPaging(LoaderBlock, PcrBasePage, TssBasePage, GdtIdt); + + DbgPrint((DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n", + KiSystemStartup, LoaderBlockVA)); + + WinLdrpDumpMemoryDescriptors(LoaderBlockVA); + + //FIXME: If I substitute this debugging checkpoint, GCC will "optimize away" the code below + //while (1) {}; + /*asm(".intel_syntax noprefix\n"); + asm("test1:\n"); + asm("jmp test1\n"); + asm(".att_syntax\n");*/ + + + (*KiSystemStartup)(LoaderBlockVA); + + return; +} + +VOID +WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PLIST_ENTRY NextMd; + PMEMORY_ALLOCATION_DESCRIPTOR MemoryDescriptor; + + NextMd = LoaderBlock->MemoryDescriptorListHead.Flink; + + while (NextMd != &LoaderBlock->MemoryDescriptorListHead) + { + MemoryDescriptor = CONTAINING_RECORD(NextMd, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry); + + + DbgPrint((DPRINT_WINDOWS, "BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage, + MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType)); + + NextMd = MemoryDescriptor->ListEntry.Flink; + } +} Propchange: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c (added) +++ trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c Sat Oct 7 00:28:55 2006 @@ -1,0 +1,104 @@ +/* + * PROJECT: EFI Windows Loader + * LICENSE: GPL - See COPYING in the top level directory + * FILE: freeldr/winldr/wlregistry.c + * PURPOSE: Registry support functions + * PROGRAMMERS: Aleksey Bragin (aleksey(a)reactos.org) + */ + +/* INCLUDES ***************************************************************/ + +#include <freeldr.h> + +#define NDEBUG +#include <debug.h> + +/* FUNCTIONS **************************************************************/ + +BOOLEAN +WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN LPCSTR DirectoryPath, + IN LPCSTR HiveName) +{ + PFILE FileHandle; + CHAR FullHiveName[256]; + BOOLEAN Status; + ULONG HiveFileSize; + ULONG_PTR HiveDataPhysical; + PVOID HiveDataVirtual; + + /* Concatenate path and filename to get the full name */ + strcpy(FullHiveName, DirectoryPath); + strcat(FullHiveName, HiveName); + //Print(L"Loading %s...\n", FullHiveName); + FileHandle = FsOpenFile(FullHiveName); + + if (FileHandle == NULL) + { + UiMessageBox("Opening hive file failed!"); + return FALSE; + } + + /* Get the file length */ + HiveFileSize = FsGetFileSize(FileHandle); + + if (HiveFileSize == 0) + { + FsCloseFile(FileHandle); + UiMessageBox("Hive file has 0 size!"); + return FALSE; + } + + /* Round up the size to page boundary and alloc memory */ + HiveDataPhysical = (ULONG_PTR)MmAllocateMemory( + MM_SIZE_TO_PAGES(HiveFileSize + MM_PAGE_SIZE - 1) << MM_PAGE_SHIFT); + + if (HiveDataPhysical == 0) + { + FsCloseFile(FileHandle); + UiMessageBox("Unable to alloc memory for a hive!"); + return FALSE; + } + + /* Convert address to virtual */ + HiveDataVirtual = (PVOID)(KSEG0_BASE | HiveDataPhysical); + + /* Fill LoaderBlock's entries */ + LoaderBlock->RegistryLength = HiveFileSize; + LoaderBlock->RegistryBase = HiveDataVirtual; + + /* Finally read from file to the memory */ + Status = FsReadFile(FileHandle, HiveFileSize, NULL, (PVOID)HiveDataPhysical); + FsCloseFile(FileHandle); + if (!Status) + { + UiMessageBox("Unable to read from hive file!"); + return FALSE; + } + + return TRUE; +} + + +BOOLEAN WinLdrLoadAndScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN LPCSTR DirectoryPath) +{ + CHAR SearchPath[1024]; + BOOLEAN Status; + + // There is a simple logic here: try to load usual hive (system), if it + // fails, then give system.alt a try, and finally try a system.sav + + // FIXME: For now we only try system + strcpy(SearchPath, DirectoryPath); + strcat(SearchPath, "SYSTEM32\\CONFIG\\"); + Status = WinLdrLoadSystemHive(LoaderBlock, SearchPath, "SYSTEM"); + + // Fail if failed... + if (!Status) + return FALSE; + + + + return TRUE; +} Propchange: trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c ------------------------------------------------------------------------------ svn:eol-style = native
18 years, 2 months
1
0
0
0
[ion] 24426: - Add PROFILE_ACPI_DOCKING_STATE. - Fix HvInitialize definition to match more closely NT's since I need some of the extra parameters for the cm rewrite. - Implement ExInitializePushLock and ExConvertPushLockSharedToExclusive macros.
by ion@svn.reactos.org
Author: ion Date: Fri Oct 6 23:29:25 2006 New Revision: 24426 URL:
http://svn.reactos.org/svn/reactos?rev=24426&view=rev
Log: - Add PROFILE_ACPI_DOCKING_STATE. - Fix HvInitialize definition to match more closely NT's since I need some of the extra parameters for the cm rewrite. - Implement ExInitializePushLock and ExConvertPushLockSharedToExclusive macros. Modified: trunk/reactos/include/reactos/arc/arc.h trunk/reactos/lib/cmlib/cmlib.h trunk/reactos/lib/cmlib/hiveinit.c trunk/reactos/ntoskrnl/cm/import.c trunk/reactos/ntoskrnl/cm/regfile.c trunk/reactos/ntoskrnl/include/internal/ex.h Modified: trunk/reactos/include/reactos/arc/arc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/arc/arc.h?…
============================================================================== --- trunk/reactos/include/reactos/arc/arc.h (original) +++ trunk/reactos/include/reactos/arc/arc.h Fri Oct 6 23:29:25 2006 @@ -151,6 +151,16 @@ } NLS_DATA_BLOCK, *PNLS_DATA_BLOCK; // +// ACPI Docking State +// +typedef struct _PROFILE_ACPI_DOCKING_STATE +{ + USHORT DockingState; + USHORT SerialLength; + WCHAR SerialNumber[1]; +} PROFILE_ACPI_DOCKING_STATE, *PPROFILE_ACPI_DOCKING_STATE; + +// // Subsystem Specific Loader Blocks // typedef struct _PROFILE_PARAMETER_BLOCK Modified: trunk/reactos/lib/cmlib/cmlib.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/cmlib.h?rev=2442…
============================================================================== --- trunk/reactos/lib/cmlib/cmlib.h (original) +++ trunk/reactos/lib/cmlib/cmlib.h Fri Oct 6 23:29:25 2006 @@ -18,7 +18,7 @@ #define ROUND_DOWN(a,b) (((a)/(b))*(b)) #endif -#define CMAPI +#define CMAPI NTAPI struct _HHIVE; @@ -110,6 +110,10 @@ BOOLEAN ReadOnly; BOOLEAN Log; BOOLEAN DirtyFlag; + ULONG HvBinHeadersUse; + ULONG HvFreeCellsUse; + ULONG HvUsedcellsUse; + ULONG CmUsedCellsUse; ULONG HiveFlags; ULONG LogSize; ULONG RefreshCount; @@ -146,6 +150,8 @@ ULONG Operation, ULONG_PTR HiveData OPTIONAL, ULONG Cluster OPTIONAL, + ULONG Flags, + ULONG FileType, PALLOCATE_ROUTINE Allocate, PFREE_ROUTINE Free, PFILE_READ_ROUTINE FileRead, @@ -163,6 +169,9 @@ PHHIVE RegistryHive, HCELL_INDEX CellOffset); +#define HvReleaseCell(h, c) \ + if (h->ReleaseCellRoutine) h->ReleaseCellRoutine(h, c) + LONG CMAPI HvGetCellSize( PHHIVE RegistryHive, Modified: trunk/reactos/lib/cmlib/hiveinit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hiveinit.c?rev=2…
============================================================================== --- trunk/reactos/lib/cmlib/hiveinit.c (original) +++ trunk/reactos/lib/cmlib/hiveinit.c Fri Oct 6 23:29:25 2006 @@ -306,6 +306,8 @@ HvInitialize( PHHIVE RegistryHive, ULONG Operation, + ULONG HiveType, + ULONG HiveFlags, ULONG_PTR HiveData OPTIONAL, ULONG Cluster OPTIONAL, PALLOCATE_ROUTINE Allocate, Modified: trunk/reactos/ntoskrnl/cm/import.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/import.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/cm/import.c (original) +++ trunk/reactos/ntoskrnl/cm/import.c Fri Oct 6 23:29:25 2006 @@ -52,7 +52,7 @@ /* Allocate hive header */ ((PHBASE_BLOCK)ChunkBase)->Length = ChunkSize; - Status = HvInitialize(&Hive->Hive, HV_OPERATION_MEMORY, + Status = HvInitialize(&Hive->Hive, HV_OPERATION_MEMORY, 0, 0, (ULONG_PTR)ChunkBase, 0, CmpAllocate, CmpFree, CmpFileRead, CmpFileWrite, CmpFileSetSize, Modified: trunk/reactos/ntoskrnl/cm/regfile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/regfile.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/cm/regfile.c (original) +++ trunk/reactos/ntoskrnl/cm/regfile.c Fri Oct 6 23:29:25 2006 @@ -141,7 +141,7 @@ CmHive = CmpAllocate(sizeof(EREGISTRY_HIVE), TRUE); CmHive->HiveHandle = FileHandle; - Status = HvInitialize(&CmHive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, + Status = HvInitialize(&CmHive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, 0, 0, CmpAllocate, CmpFree, CmpFileRead, CmpFileWrite, CmpFileSetSize, CmpFileFlush, NULL); @@ -570,7 +570,7 @@ DPRINT("ViewBase %p ViewSize %lx\n", ViewBase, ViewSize); ((PHBASE_BLOCK)ViewBase)->Length = ViewSize; - Status = HvInitialize(&RegistryHive->Hive, HV_OPERATION_MEMORY, + Status = HvInitialize(&RegistryHive->Hive, HV_OPERATION_MEMORY, 0, 0, (ULONG_PTR)ViewBase, 0, CmpAllocate, CmpFree, CmpFileRead, CmpFileWrite, CmpFileSetSize, @@ -622,7 +622,7 @@ DPRINT("Hive 0x%p\n", Hive); - Status = HvInitialize(&Hive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, + Status = HvInitialize(&Hive->Hive, HV_OPERATION_CREATE_HIVE, 0, 0, 0, 0, CmpAllocate, CmpFree, CmpFileRead, CmpFileWrite, CmpFileSetSize, CmpFileFlush, NULL); Modified: trunk/reactos/ntoskrnl/include/internal/ex.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ex.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ex.h Fri Oct 6 23:29:25 2006 @@ -14,6 +14,7 @@ extern FAST_MUTEX ExpEnvironmentLock; extern ERESOURCE ExpFirmwareTableResource; extern LIST_ENTRY ExpFirmwareTableProviderListHead; +extern BOOLEAN ExpIsWinPEMode; ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset; ULONG ExpUnicodeCaseTableDataOffset; PVOID ExpNlsSectionPointer; @@ -139,6 +140,14 @@ NTAPI ExInitPoolLookasidePointers(VOID); +/* Callback Functions ********************************************************/ + +VOID +NTAPI +ExInitializeCallBack( + IN PEX_CALLBACK Callback +); + /* Rundown Functions ********************************************************/ VOID @@ -312,6 +321,7 @@ #define ExpSetRundown(x, y) InterlockedExchange64((PLONGLONG)x, y) #else #define ExpChangeRundown(x, y, z) InterlockedCompareExchange((PLONG)x, PtrToLong(y), PtrToLong(z)) +#define ExpChangePushlock(x, y, z) LongToPtr(InterlockedCompareExchange((PLONG)x, PtrToLong(y), PtrToLong(z))) #define ExpSetRundown(x, y) InterlockedExchange((PLONG)x, y) #endif @@ -484,6 +494,28 @@ /* PUSHLOCKS *****************************************************************/ /*++ + * @name ExInitializePushLock + * INTERNAL MACRO + * + * The ExInitializePushLock macro initializes a PushLock. + * + * @params PushLock + * Pointer to the pushlock which is to be initialized. + * + * @return None. + * + * @remarks None. + * + *--*/ +VOID +FORCEINLINE +ExInitializePushLock(IN PEX_PUSH_LOCK PushLock) +{ + /* Set the value to 0 */ + PushLock->Value = 0; +} + +/*++ * @name ExAcquirePushLockExclusive * INTERNAL MACRO * @@ -545,7 +577,7 @@ /* Try acquiring the lock */ NewValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_SHARE_INC; - if (InterlockedCompareExchangePointer(PushLock, NewValue.Ptr, 0)) + if (ExpChangePushlock(PushLock, NewValue.Ptr, 0)) { /* Someone changed it, use the slow path */ DbgPrint("%s - Contention!\n", __FUNCTION__); @@ -558,6 +590,44 @@ } /*++ + * @name ExConvertPushLockSharedToExclusive + * INTERNAL MACRO + * + * The ExConvertPushLockSharedToExclusive macro converts an exclusive + * pushlock to a shared pushlock. + * + * @params PushLock + * Pointer to the pushlock which is to be converted. + * + * @return FALSE if conversion failed, TRUE otherwise. + * + * @remarks The function attempts the quickest route to convert the lock, which is + * to simply set the lock bit and remove any other bits. + * + *--*/ +BOOLEAN +FORCEINLINE +ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock) +{ + EX_PUSH_LOCK OldValue; + + /* Set the expected old value */ + OldValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_SHARE_INC; + + /* Try converting the lock */ + if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) != + OldValue.Ptr) + { + /* Conversion failed */ + return FALSE; + } + + /* Sanity check */ + ASSERT(PushLock->Locked); + return TRUE; +} + +/*++ * @name ExWaitOnPushLock * INTERNAL MACRO * @@ -617,8 +687,7 @@ /* Try to clear the pushlock */ OldValue.Value = EX_PUSH_LOCK_LOCK | EX_PUSH_LOCK_SHARE_INC; - if (InterlockedCompareExchangePointer(PushLock, 0, OldValue.Ptr) != - OldValue.Ptr) + if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr) { /* There are still other people waiting on it */ DbgPrint("%s - Contention!\n", __FUNCTION__); @@ -716,7 +785,7 @@ /* Check if nobody is waiting on us and try clearing the lock here */ if ((OldValue.Waiting) || - (InterlockedCompareExchangePointer(PushLock, NewValue.Ptr, OldValue.Ptr) == + (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) == OldValue.Ptr)) { /* We have waiters, use the long path */
18 years, 2 months
1
0
0
0
[gedmurphy] 24425: fix a TCHAR brain lapse...
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Fri Oct 6 21:10:57 2006 New Revision: 24425 URL:
http://svn.reactos.org/svn/reactos?rev=24425&view=rev
Log: fix a TCHAR brain lapse... Modified: trunk/reactos/dll/win32/devmgr/advprop.c Modified: trunk/reactos/dll/win32/devmgr/advprop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/advprop.c…
============================================================================== --- trunk/reactos/dll/win32/devmgr/advprop.c (original) +++ trunk/reactos/dll/win32/devmgr/advprop.c Fri Oct 6 21:10:57 2006 @@ -1906,7 +1906,7 @@ { WCHAR szDeviceID[MAX_DEVICE_ID_LEN+1]; WCHAR szMachineName[MAX_COMPUTERNAME_LENGTH+1]; - LPTSTR lpString = (LPTSTR)lpDeviceCmd; + LPWSTR lpString = (LPWSTR)lpDeviceCmd; szDeviceID[0] = L'\0'; szMachineName[0] = L'\0';
18 years, 2 months
1
0
0
0
[gedmurphy] 24424: implemented DeviceProperties_RunDLLW and DeviceProperties_RunDLLA
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Fri Oct 6 20:08:54 2006 New Revision: 24424 URL:
http://svn.reactos.org/svn/reactos?rev=24424&view=rev
Log: implemented DeviceProperties_RunDLLW and DeviceProperties_RunDLLA Modified: trunk/reactos/dll/win32/devmgr/advprop.c trunk/reactos/dll/win32/devmgr/stubs.c Modified: trunk/reactos/dll/win32/devmgr/advprop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/advprop.c…
============================================================================== --- trunk/reactos/dll/win32/devmgr/advprop.c (original) +++ trunk/reactos/dll/win32/devmgr/advprop.c Fri Oct 6 20:08:54 2006 @@ -16,12 +16,13 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: hwpage.c 19599 2005-11-26 02:12:58Z weiden $ +/* * * PROJECT: ReactOS devmgr.dll * FILE: lib/devmgr/advprop.c * PURPOSE: ReactOS Device Manager * PROGRAMMER: Thomas Weidenmueller <w3seek(a)reactos.com> + * Ged Murphy <gedmurphy(a)reactos.org> * UPDATE HISTORY: * 04-04-2004 Created */ @@ -1742,7 +1743,7 @@ * 1: if bShowDevMgr is non-zero and no error occured * -1: a call to GetLastError returns 0 if successful * - * @unimplemented + * @implemented */ INT_PTR WINAPI @@ -1814,3 +1815,153 @@ return Ret; } + + +/*************************************************************************** + * NAME EXPORTED + * DeviceProperties_RunDLLA + * + * DESCRIPTION + * Invokes the device properties dialog + * + * ARGUMENTS + * hWndParent: Handle to the parent window + * hInst: Handle to the application instance + * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown, + * also see NOTEs + * nCmdShow: Specifies how the window should be shown + * + * RETURN VALUE + * + * REVISIONS + * + * NOTE + * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH" + * (/MachineName is optional). This function only parses this string and eventually + * calls DeviceProperties(). + * + * @implemented + */ +VOID +WINAPI +DeviceProperties_RunDLLA(HWND hWndParent, + HINSTANCE hInst, + LPCSTR lpDeviceCmd, + int nCmdShow) +{ + LPWSTR lpDeviceCmdW = NULL; + + if (lpDeviceCmd != NULL) + { + if ((lpDeviceCmdW = ConvertMultiByteToUnicode(lpDeviceCmd, + CP_ACP))) + { + DeviceProperties_RunDLLW(hWndParent, + hInst, + lpDeviceCmdW, + nCmdShow); + } + } + + if (lpDeviceCmdW != NULL) + { + HeapFree(GetProcessHeap(), + 0, + lpDeviceCmdW); + } +} + + +/*************************************************************************** + * NAME EXPORTED + * DeviceProperties_RunDLLW + * + * DESCRIPTION + * Invokes the device properties dialog + * + * ARGUMENTS + * hWndParent: Handle to the parent window + * hInst: Handle to the application instance + * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown, + * also see NOTEs + * nCmdShow: Specifies how the window should be shown + * + * RETURN VALUE + * + * REVISIONS + * + * NOTE + * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH" + * (/MachineName is optional). This function only parses this string and eventually + * calls DeviceProperties(). + * + * @implemented + */ +VOID +WINAPI +DeviceProperties_RunDLLW(HWND hWndParent, + HINSTANCE hInst, + LPCWSTR lpDeviceCmd, + int nCmdShow) +{ + WCHAR szDeviceID[MAX_DEVICE_ID_LEN+1]; + WCHAR szMachineName[MAX_COMPUTERNAME_LENGTH+1]; + LPTSTR lpString = (LPTSTR)lpDeviceCmd; + + szDeviceID[0] = L'\0'; + szMachineName[0] = L'\0'; + + while (*lpString != L'\0') + { + if (*lpString == L'/') + { + lpString++; + if(!wcsnicmp(lpString, L"DeviceID", 8)) + { + lpString += 9; + if (*lpString != L'\0') + { + int i = 0; + while ((*lpString != L' ') && + (*lpString != L'\0') && + (i <= MAX_DEVICE_ID_LEN)) + { + szDeviceID[i++] = *lpString++; + } + szDeviceID[i] = L'\0'; + } + } + else if (!wcsnicmp(lpString, L"MachineName", 11)) + { + lpString += 12; + if (*lpString != L'\0') + { + int i = 0; + while ((*lpString != L' ') && + (*lpString != L'\0') && + (i <= MAX_COMPUTERNAME_LENGTH)) + { + szMachineName[i++] = *lpString++; + } + szMachineName[i] = L'\0'; + } + } + /* knock the pointer back one and let the next + * pointer deal with incrementing, otherwise we + * go past the end of the string */ + lpString--; + } + lpString++; + } + + //DPRINT("DeviceID: %S, MachineName: %S\n", szDeviceID, szMachineName); + + if (szDeviceID == L'\0') + return; + + DevicePropertiesW(hWndParent, + hInst, + szMachineName, + szDeviceID, + 0); +} Modified: trunk/reactos/dll/win32/devmgr/stubs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/stubs.c?r…
============================================================================== --- trunk/reactos/dll/win32/devmgr/stubs.c (original) +++ trunk/reactos/dll/win32/devmgr/stubs.c Fri Oct 6 20:08:54 2006 @@ -1,4 +1,4 @@ -/* $Id$ +/* * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS devmgr.dll @@ -91,78 +91,6 @@ { UNIMPLEMENTED; return FALSE; -} - - -/*************************************************************************** - * NAME EXPORTED - * DeviceProperties_RunDLLA - * - * DESCRIPTION - * Invokes the device properties dialog - * - * ARGUMENTS - * hWndParent: Handle to the parent window - * hInst: Handle to the application instance - * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown, - * also see NOTEs - * nCmdShow: Specifies how the window should be shown - * - * RETURN VALUE - * - * REVISIONS - * - * NOTE - * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH" - * (/MachineName is optional). This function only parses this string and eventually - * calls DeviceProperties(). - * - * @unimplemented - */ -VOID -WINAPI -DeviceProperties_RunDLLA(HWND hWndParent, - HINSTANCE hInst, - LPCSTR lpDeviceCmd, - int nCmdShow) -{ - UNIMPLEMENTED; -} - - -/*************************************************************************** - * NAME EXPORTED - * DeviceProperties_RunDLLW - * - * DESCRIPTION - * Invokes the device properties dialog - * - * ARGUMENTS - * hWndParent: Handle to the parent window - * hInst: Handle to the application instance - * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown, - * also see NOTEs - * nCmdShow: Specifies how the window should be shown - * - * RETURN VALUE - * - * REVISIONS - * - * NOTE - * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH" - * (/MachineName is optional). This function only parses this string and eventually - * calls DeviceProperties(). - * - * @unimplemented - */ -VOID -WINAPI -DeviceProperties_RunDLLW(HWND hWndParent, - HINSTANCE hInst, - LPCWSTR lpDeviceCmd, - int nCmdShow) -{ - UNIMPLEMENTED; }
18 years, 2 months
1
0
0
0
[ion] 24423: - Implement CmpHwProfileDefaultSelect, CmpAddDockingInfo, CmpAddAliasEntry, CmpCreateCurrentControlSetLink. - Stub CmpCloneHwProfile, CmpSetAcpiHwProfile since there are more complex to handle and shouldn't occur while testing.
by ion@svn.reactos.org
Author: ion Date: Fri Oct 6 18:47:19 2006 New Revision: 24423 URL:
http://svn.reactos.org/svn/reactos?rev=24423&view=rev
Log: - Implement CmpHwProfileDefaultSelect, CmpAddDockingInfo, CmpAddAliasEntry, CmpCreateCurrentControlSetLink. - Stub CmpCloneHwProfile, CmpSetAcpiHwProfile since there are more complex to handle and shouldn't occur while testing. Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c URL:
http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl…
============================================================================== --- branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c (original) +++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cminit.c Fri Oct 6 18:47:19 2006 @@ -16,6 +16,8 @@ RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM"); UNICODE_STRING CmpSystemFileName = RTL_CONSTANT_STRING(L"SYSTEM"); +UNICODE_STRING CmSymbolicLinkValueName = + RTL_CONSTANT_STRING(L"SymbolicLinkValue"); BOOLEAN CmpMiniNTBoot; BOOLEAN CmpShareSystemHives; @@ -354,6 +356,570 @@ return TRUE; } +NTSTATUS +NTAPI +CmpHwProfileDefaultSelect(IN PVOID ProfileList, + OUT PULONG ProfileIndexToUse, + IN PVOID Context) +{ + /* Clear the index and return success */ + *ProfileIndexToUse = 0; + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmpAddDockingInfo(IN HANDLE Key, + IN PPROFILE_PARAMETER_BLOCK ProfileBlock) +{ + NTSTATUS Status = STATUS_SUCCESS; + UNICODE_STRING KeyName; + ULONG Value; + PAGED_CODE (); + + /* Get the Value from the profile block, create a Name for it and set it */ + Value = ProfileBlock->DockingState; + RtlInitUnicodeString(&KeyName, L"DockingState"); + Status = NtSetValueKey(Key, + &KeyName, + 0, + REG_DWORD, + &Value, + sizeof(Value)); + if (!NT_SUCCESS(Status)) return Status; + + /* Get the Value from the profile block, create a Name for it and set it */ + Value = ProfileBlock->Capabilities; + RtlInitUnicodeString(&KeyName, L"Capabilities"); + Status = NtSetValueKey(Key, + &KeyName, + 0, + REG_DWORD, + &Value, + sizeof(Value)); + if (!NT_SUCCESS(Status)) return Status; + + /* Get the Value from the profile block, create a Name for it and set it */ + Value = ProfileBlock->DockID; + RtlInitUnicodeString(&KeyName, L"DockID"); + Status = NtSetValueKey(Key, + &KeyName, + 0, + REG_DWORD, + &Value, + sizeof(Value)); + if (!NT_SUCCESS(Status)) return Status; + + /* Get the Value from the profile block, create a Name for it and set it */ + Value = ProfileBlock->SerialNumber; + RtlInitUnicodeString(&KeyName, L"SerialNumber"); + Status = NtSetValueKey(Key, + &KeyName, + 0, + REG_DWORD, + &Value, + sizeof(Value)); + + /* Return Status */ + return Status; +} + +NTSTATUS +NTAPI +CmpAddAliasEntry(IN HANDLE IDConfigDB, + IN PPROFILE_PARAMETER_BLOCK ProfileBlock, + IN ULONG ProfileNumber) +{ + UNICODE_STRING KeyName; + OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status = STATUS_SUCCESS; + CHAR Buffer[128]; + WCHAR UnicodeBuffer[128]; + ANSI_STRING TempString; + HANDLE AliasHandle = NULL, AliasIdHandle = NULL; + ULONG Value; + ULONG Disposition; + ULONG AliasId = 0; + PAGED_CODE (); + + /* Open the alias key */ + RtlInitUnicodeString(&KeyName, L"Alias"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + IDConfigDB, + NULL); + Status = NtOpenKey(&AliasHandle, KEY_READ | KEY_WRITE, &ObjectAttributes); + + /* Check if we failed to open it */ + if (Status == STATUS_OBJECT_NAME_NOT_FOUND) + { + /* Create it instead */ + Status = NtCreateKey(&AliasHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + 0, + &Disposition); + } + + /* Check if we failed */ + if (!NT_SUCCESS (Status)) + { + /* Cleanup and exit */ + AliasHandle = NULL; + goto Exit; + } + + /* Loop every alias ID */ + while (AliasId++ < 200) + { + /* Build the KeyName */ + sprintf(Buffer, "%04d", AliasId); + RtlInitAnsiString(&TempString, Buffer); + + /* Convert it to Unicode */ + KeyName.MaximumLength = sizeof(UnicodeBuffer); + KeyName.Buffer = UnicodeBuffer; + Status = RtlAnsiStringToUnicodeString(&KeyName, + &TempString, + FALSE); + ASSERT (STATUS_SUCCESS == Status); + + /* Open the key */ + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + AliasHandle, + NULL); + Status = NtOpenKey(&AliasIdHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes); + if (NT_SUCCESS (Status)) + { + /* We opened it, close and keep looping */ + NtClose(AliasIdHandle); + } + else if (Status == STATUS_OBJECT_NAME_NOT_FOUND) + { + /* We couldn't find it, change Status and break out */ + Status = STATUS_SUCCESS; + break; + } + else + { + /* Any other error, break out */ + break; + } + } + + /* Check if we failed in the alias loop */ + if (!NT_SUCCESS(Status)) + { + /* Cleanup and exit */ + AliasIdHandle = 0; + goto Exit; + } + + /* Otherwise, create the alias key */ + Status = NtCreateKey(&AliasIdHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + 0, + &Disposition); + if (!NT_SUCCESS(Status)) + { + /* Cleanup and exit */ + AliasIdHandle = 0; + goto Exit; + } + + /* Add docking information */ + CmpAddDockingInfo(AliasIdHandle, ProfileBlock); + + /* Set the profile number */ + Value = ProfileNumber; + RtlInitUnicodeString(&KeyName, L"ProfileNumber"); + Status = NtSetValueKey(AliasIdHandle, + &KeyName, + 0, + REG_DWORD, + &Value, + sizeof(Value)); + +Exit: + /* Close every opened key */ + if (AliasHandle) NtClose(AliasHandle); + if (AliasIdHandle) NtClose(AliasIdHandle); + + /* Return Status */ + return Status; +} + +NTSTATUS +NTAPI +CmSetAcpiHwProfile(IN PPROFILE_ACPI_DOCKING_STATE NewDockState, + IN PVOID Select, + IN PVOID Context, + OUT PHANDLE NewProfile, + OUT PBOOLEAN ProfileChanged) +{ + /* FIXME: TODO */ + *ProfileChanged = FALSE; + *NewProfile = NULL; + ASSERT(FALSE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmpCloneHwProfile(IN HANDLE ConfigHandle, + IN HANDLE Parent, + IN HANDLE OldProfile, + IN ULONG OldProfileNumber, + IN USHORT DockingState, + OUT PHANDLE NewProfile, + OUT PULONG NewProfileNumber) +{ + /* FIXME: TODO */ + *NewProfileNumber = FALSE; + *NewProfile = NULL; + ASSERT(FALSE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmpCreateCurrentControlSetLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + UNICODE_STRING ConfigName = RTL_CONSTANT_STRING(L"Control\\ConfigHandle"); + UNICODE_STRING SelectName = + RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\Select"); + UNICODE_STRING KeyName; + OBJECT_ATTRIBUTES ObjectAttributes; + CHAR ValueInfoBuffer[128]; + PKEY_VALUE_FULL_INFORMATION ValueInfo; + CHAR Buffer[128]; + WCHAR UnicodeBuffer[128]; + HANDLE SelectHandle, KeyHandle, ConfigHandle = NULL, ProfileHandle = NULL; + HANDLE ParentHandle = NULL, AcpiHandle; + ULONG ControlSet, HwProfile; + ANSI_STRING TempString; + NTSTATUS Status; + ULONG ResultLength, Disposition; + BOOLEAN AcpiProfile = FALSE; + PLOADER_PARAMETER_EXTENSION LoaderExtension; + PROFILE_ACPI_DOCKING_STATE AcpiDockState; + BOOLEAN Active; + PAGED_CODE(); + + /* Open the select key */ + InitializeObjectAttributes(&ObjectAttributes, + &SelectName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenKey(&SelectHandle, KEY_READ, &ObjectAttributes); + if (!NT_SUCCESS(Status))return(Status); + + /* Open the current value */ + RtlInitUnicodeString(&KeyName, L"Current"); + Status = NtQueryValueKey(SelectHandle, + &KeyName, + KeyValueFullInformation, + ValueInfoBuffer, + sizeof(ValueInfoBuffer), + &ResultLength); + NtClose(SelectHandle); + if (!NT_SUCCESS(Status)) return Status; + + /* Get the actual value pointer, and get the control set ID */ + ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer; + ControlSet = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset); + + /* Create the current control set key */ + RtlInitUnicodeString(&KeyName, + L"\\Registry\\Machine\\System\\CurrentControlSet"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtCreateKey(&KeyHandle, + KEY_CREATE_LINK, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, + &Disposition); + if (!NT_SUCCESS(Status)) return Status; + + /* Sanity check */ + ASSERT(Disposition == REG_CREATED_NEW_KEY); + + /* Initialize the symbolic link name */ + sprintf(Buffer, + "\\Registry\\Machine\\System\\ControlSet%03d", + ControlSet); + RtlInitAnsiString(&TempString, Buffer); + + /* Create a Unicode string out of it */ + KeyName.MaximumLength = sizeof(UnicodeBuffer); + KeyName.Buffer = UnicodeBuffer; + Status = RtlAnsiStringToUnicodeString(&KeyName, &TempString, FALSE); + + /* Set the value */ + Status = NtSetValueKey(KeyHandle, + &CmSymbolicLinkValueName, + 0, + REG_LINK, + KeyName.Buffer, + KeyName.Length); + if (!NT_SUCCESS(Status)) return Status; + + /* Get the configuration database key */ + InitializeObjectAttributes(&ObjectAttributes, + &ConfigName, + OBJ_CASE_INSENSITIVE, + KeyHandle, + NULL); + Status = NtOpenKey(&ConfigHandle, KEY_READ, &ObjectAttributes); + NtClose(KeyHandle); + + /* Check if we don't have one */ + if (!NT_SUCCESS(Status)) + { + /* Cleanup and exit */ + ConfigHandle = 0; + goto Cleanup; + } + + /* Now get the current config */ + RtlInitUnicodeString(&KeyName, L"CurrentConfig"); + Status = NtQueryValueKey(ConfigHandle, + &KeyName, + KeyValueFullInformation, + ValueInfoBuffer, + sizeof(ValueInfoBuffer), + &ResultLength); + + /* Set pointer to buffer */ + ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer; + + /* Check if we failed or got a non DWORD-value */ + if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD)) goto Cleanup; + + /* Get the hadware profile */ + HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset); + + /* Open the hardware profile key */ + RtlInitUnicodeString(&KeyName, + L"\\Registry\\Machine\\System\\CurrentControlSet" + L"\\Hardware Profiles"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenKey(&ParentHandle, KEY_READ, &ObjectAttributes); + + /* Check if there is no hardware profile key */ + if (!NT_SUCCESS (Status)) + { + /* Exit and clean up */ + ParentHandle = 0; + goto Cleanup; + } + + /* Build the profile name */ + sprintf(Buffer, "%04d",HwProfile); + RtlInitAnsiString(&TempString, Buffer); + + /* Convert it to Unicode */ + KeyName.MaximumLength = sizeof(UnicodeBuffer); + KeyName.Buffer = UnicodeBuffer; + Status = RtlAnsiStringToUnicodeString(&KeyName, + &TempString, + FALSE); + ASSERT(Status == STATUS_SUCCESS); + + /* Open the associated key */ + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ParentHandle, + NULL); + Status = NtOpenKey(&ProfileHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes); + + /* Check if there's no such key */ + if (!NT_SUCCESS (Status)) + { + /* Cleanup and exit */ + ProfileHandle = 0; + goto Cleanup; + } + + /* Check if we have a loader block extension */ + LoaderExtension = LoaderBlock->Extension; + if (LoaderExtension) + { + /* Check the hardware profile status */ + switch (LoaderExtension->Profile.Status) + { + /* Cloned status */ + case 3: + + /* Clone it */ + Status = CmpCloneHwProfile(ConfigHandle, + ParentHandle, + ProfileHandle, + HwProfile, + LoaderExtension-> + Profile.DockingState, + &ProfileHandle, + &HwProfile); + if (!NT_SUCCESS(Status)) + { + /* Cloning failed, cleanup and exit */ + ProfileHandle = 0; + goto Cleanup; + } + + /* Set the current config key */ + RtlInitUnicodeString(&KeyName, L"CurrentConfig"); + Status = NtSetValueKey(ConfigHandle, + &KeyName, + 0, + REG_DWORD, + &HwProfile, + sizeof (HwProfile)); + if (!NT_SUCCESS (Status)) goto Cleanup; + + /* Alias status */ + case 1: + + /* Create an alias entry */ + Status = CmpAddAliasEntry(ConfigHandle, + &LoaderExtension->Profile, + HwProfile); + + /* Docking status */ + case 2: + + /* Create the current dock info key */ + RtlInitUnicodeString(&KeyName, + L"CurrentDockInfo"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + ConfigHandle, + NULL); + Status = NtCreateKey(&KeyHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + ASSERT (STATUS_SUCCESS == Status); + + /* Add the docking information */ + Status = CmpAddDockingInfo(KeyHandle, + &LoaderExtension->Profile); + break; + + /* Other cases */ + case 0: + case 0xC001: + break; + + /* Unknown status */ + default: + ASSERT(FALSE); + } + } + + /* Create the current hardware profile key */ + RtlInitUnicodeString(&KeyName, + L"\\Registry\\Machine\\System\\CurrentControlSet\\" + L"Hardware Profiles\\Current"); + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtCreateKey(&KeyHandle, + KEY_CREATE_LINK, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, + &Disposition); + if (NT_SUCCESS(Status)) + { + /* Sanity check */ + ASSERT(Disposition == REG_CREATED_NEW_KEY); + + /* Create the profile name */ + sprintf(Buffer, + "\\Registry\\Machine\\System\\CurrentControlSet\\" + "Hardware Profiles\\%04d", + HwProfile); + RtlInitAnsiString(&TempString, Buffer); + + /* Convert it to Unicode */ + KeyName.MaximumLength = sizeof(UnicodeBuffer); + KeyName.Buffer = UnicodeBuffer; + Status = RtlAnsiStringToUnicodeString(&KeyName, + &TempString, + FALSE); + ASSERT (STATUS_SUCCESS == Status); + + /* Set it */ + Status = NtSetValueKey(KeyHandle, + &CmSymbolicLinkValueName, + 0, + REG_LINK, + KeyName.Buffer, + KeyName.Length); + NtClose(KeyHandle); + } + + /* Check if we have to set the ACPI Profile */ + if (AcpiProfile) + { + /* Setup the docking state to undocked */ + AcpiDockState.DockingState = 1; + AcpiDockState.SerialLength = 2; + AcpiDockState.SerialNumber[0] = L'\0'; + + /* Set the ACPI profile */ + Status = CmSetAcpiHwProfile(&AcpiDockState, + CmpHwProfileDefaultSelect, + NULL, + &AcpiHandle, + &Active); + ASSERT(NT_SUCCESS(Status)); + + /* Close the key */ + NtClose(AcpiHandle); + } + + /* Close every opened handle */ +Cleanup: + if (ConfigHandle) NtClose(ConfigHandle); + if (ProfileHandle) NtClose(ProfileHandle); + if (ParentHandle) NtClose(ParentHandle); + + /* Return success */ + return STATUS_SUCCESS; +} + VOID NTAPI CmInitSystem1(IN PLOADER_PARAMETER_BLOCK LoaderBlock) @@ -487,41 +1053,3 @@ CmpSetSystemBootValues(LoaderBlock); } -#if 0 -VOID -INIT_FUNCTION -STDCALL -CmInitHives(BOOLEAN SetupBoot) -{ - PCHAR BaseAddress; - - /* Load Registry Hives. This one can be missing. */ - if (CachedModules[SystemRegistry]) { - BaseAddress = (PCHAR)CachedModules[SystemRegistry]->ModStart; - CmImportSystemHive(BaseAddress, - CachedModules[SystemRegistry]->ModEnd - (ULONG_PTR)BaseAddress); - } - - BaseAddress = (PCHAR)CachedModules[HardwareRegistry]->ModStart; - CmImportHardwareHive(BaseAddress, - CachedModules[HardwareRegistry]->ModEnd - (ULONG_PTR)BaseAddress); - - - /* Create dummy keys if no hardware hive was found */ - CmImportHardwareHive (NULL, 0); - - /* Initialize volatile registry settings */ - if (SetupBoot == FALSE) CmInit2((PCHAR)KeLoaderBlock.CommandLine); -} - - /* - * Create a CurrentControlSet\Control\MiniNT key that is used - * to detect WinPE/MiniNT systems. - */ - if (MiniNT) - { - Status = RtlCreateRegistryKey(RTL_REGISTRY_CONTROL, L"MiniNT"); - if (!NT_SUCCESS(Status)) - KEBUGCHECK(CONFIG_INITIALIZATION_FAILED); - } -#endif
18 years, 2 months
1
0
0
0
[gedmurphy] 24434: move the string parsing routine into it's own function so it can be used with DeviceProblemWizard_RunDLL when required.
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Sat Oct 7 19:02:43 2006 New Revision: 24434 URL:
http://svn.reactos.org/svn/reactos?rev=24434&view=rev
Log: move the string parsing routine into it's own function so it can be used with DeviceProblemWizard_RunDLL when required. Modified: trunk/reactos/dll/win32/devmgr/advprop.c Modified: trunk/reactos/dll/win32/devmgr/advprop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/advprop.c…
============================================================================== --- trunk/reactos/dll/win32/devmgr/advprop.c (original) +++ trunk/reactos/dll/win32/devmgr/advprop.c Sat Oct 7 19:02:43 2006 @@ -1502,6 +1502,64 @@ } +static BOOL +GetDeviceAndComputerName(LPWSTR lpString, + WCHAR szDeviceID[], + WCHAR szMachineName[]) +{ + BOOL ret = FALSE; + + szDeviceID[0] = L'\0'; + szMachineName[0] = L'\0'; + + while (*lpString != L'\0') + { + if (*lpString == L'/') + { + lpString++; + if(!wcsnicmp(lpString, L"DeviceID", 8)) + { + lpString += 9; + if (*lpString != L'\0') + { + int i = 0; + while ((*lpString != L' ') && + (*lpString != L'\0') && + (i <= MAX_DEVICE_ID_LEN)) + { + szDeviceID[i++] = *lpString++; + } + szDeviceID[i] = L'\0'; + ret = TRUE; + } + } + else if (!wcsnicmp(lpString, L"MachineName", 11)) + { + lpString += 12; + if (*lpString != L'\0') + { + int i = 0; + while ((*lpString != L' ') && + (*lpString != L'\0') && + (i <= MAX_COMPUTERNAME_LENGTH)) + { + szMachineName[i++] = *lpString++; + } + szMachineName[i] = L'\0'; + } + } + /* knock the pointer back one and let the next + * pointer deal with incrementing, otherwise we + * go past the end of the string */ + lpString--; + } + lpString++; + } + + return ret; +} + + /*************************************************************************** * NAME EXPORTED * DeviceAdvancedPropertiesW @@ -1908,56 +1966,13 @@ WCHAR szMachineName[MAX_COMPUTERNAME_LENGTH+1]; LPWSTR lpString = (LPWSTR)lpDeviceCmd; - szDeviceID[0] = L'\0'; - szMachineName[0] = L'\0'; - - while (*lpString != L'\0') - { - if (*lpString == L'/') - { - lpString++; - if(!wcsnicmp(lpString, L"DeviceID", 8)) - { - lpString += 9; - if (*lpString != L'\0') - { - int i = 0; - while ((*lpString != L' ') && - (*lpString != L'\0') && - (i <= MAX_DEVICE_ID_LEN)) - { - szDeviceID[i++] = *lpString++; - } - szDeviceID[i] = L'\0'; - } - } - else if (!wcsnicmp(lpString, L"MachineName", 11)) - { - lpString += 12; - if (*lpString != L'\0') - { - int i = 0; - while ((*lpString != L' ') && - (*lpString != L'\0') && - (i <= MAX_COMPUTERNAME_LENGTH)) - { - szMachineName[i++] = *lpString++; - } - szMachineName[i] = L'\0'; - } - } - /* knock the pointer back one and let the next - * pointer deal with incrementing, otherwise we - * go past the end of the string */ - lpString--; - } - lpString++; - } - - //DPRINT("DeviceID: %S, MachineName: %S\n", szDeviceID, szMachineName); - - if (szDeviceID == L'\0') + if (!GetDeviceAndComputerName(lpString, + szDeviceID, + szMachineName)) + { + DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID, szMachineName); return; + } DevicePropertiesW(hWndParent, hInst,
18 years, 2 months
1
0
0
0
[gedmurphy] 24433: testing ros-diffs
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Sat Oct 7 18:35:22 2006 New Revision: 24433 URL:
http://svn.reactos.org/svn/reactos?rev=24433&view=rev
Log: testing ros-diffs Modified: trunk/reactos/base/applications/sc/sc.rc trunk/reactos/base/applications/sc/start.c Modified: trunk/reactos/base/applications/sc/sc.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.rc…
============================================================================== --- trunk/reactos/base/applications/sc/sc.rc (original) +++ trunk/reactos/base/applications/sc/sc.rc Sat Oct 7 18:35:22 2006 @@ -2,9 +2,9 @@ #include <commctrl.h> #include "resource.h" -#define REACTOS_STR_FILE_DESCRIPTION "Services control application\0" -#define REACTOS_STR_INTERNAL_NAME "sc\0" -#define REACTOS_STR_ORIGINAL_FILENAME "sc.exe\0" +#define REACTOS_STR_FILE_DESCRIPTION "Services control application\0" +#define REACTOS_STR_INTERNAL_NAME "sc\0" +#define REACTOS_STR_ORIGINAL_FILENAME "sc.exe\0" #include <reactos/version.rc> //#include "En.rc" Modified: trunk/reactos/base/applications/sc/start.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/start…
============================================================================== --- trunk/reactos/base/applications/sc/start.c (original) +++ trunk/reactos/base/applications/sc/start.c Sat Oct 7 18:35:22 2006 @@ -49,7 +49,7 @@ ArgCount, ServiceArgs)) { - _tprintf(_T("[SC] StartService FAILED %lu:\n\n"), GetLastError()); + _tprintf(_T("[SC] StartService FAILED %lu:\n\n"), GetLastError()); goto fail; }
18 years, 2 months
1
0
0
0
← Newer
1
...
23
24
25
26
27
28
29
...
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200