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
[ion] 24413: - Get rid of the completely convoluted way that Phase 1 initialization was being ended, with umpteen events and waits and timeouts all synchronized from user-mode and do a simple 5-second wait to determine if smss started OK or not. - Promote the Phase 1 initialization thread by jumping directly into the zero-page thread, and remove manual zero-page thread initialization code since we simply jump into its main routine. - 100 less lines of code :)
by ion@svn.reactos.org
Author: ion Date: Thu Oct 5 20:14:28 2006 New Revision: 24413 URL:
http://svn.reactos.org/svn/reactos?rev=24413&view=rev
Log: - Get rid of the completely convoluted way that Phase 1 initialization was being ended, with umpteen events and waits and timeouts all synchronized from user-mode and do a simple 5-second wait to determine if smss started OK or not. - Promote the Phase 1 initialization thread by jumping directly into the zero-page thread, and remove manual zero-page thread initialization code since we simply jump into its main routine. - 100 less lines of code :) Modified: trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/mm.h trunk/reactos/ntoskrnl/mm/freelist.c trunk/reactos/ntoskrnl/mm/mminit.c Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Oct 5 20:14:28 2006 @@ -853,9 +853,6 @@ NTAPI ExPhase2Init(PVOID Context) { - UNICODE_STRING EventName; - HANDLE InitDoneEventHandle; - OBJECT_ATTRIBUTES ObjectAttributes; LARGE_INTEGER Timeout; HANDLE ProcessHandle; HANDLE ThreadHandle; @@ -949,113 +946,37 @@ /* Initialize shared user page. Set dos system path, dos device map, etc. */ InitSystemSharedUserPage(KeLoaderBlock); - /* Create 'ReactOSInitDone' event */ - RtlInitUnicodeString(&EventName, L"\\ReactOSInitDone"); - InitializeObjectAttributes(&ObjectAttributes, - &EventName, - 0, - NULL, - NULL); - Status = ZwCreateEvent(&InitDoneEventHandle, - EVENT_ALL_ACCESS, - &ObjectAttributes, - SynchronizationEvent, - FALSE); - - /* Check for Success */ - if (!NT_SUCCESS(Status)) { - - DPRINT1("Failed to create 'ReactOSInitDone' event (Status 0x%x)\n", Status); - InitDoneEventHandle = INVALID_HANDLE_VALUE; - } - /* Launch initial process */ Status = ExpLoadInitialProcess(&ProcessHandle, &ThreadHandle); - /* Check for success, Bugcheck if we failed */ - if (!NT_SUCCESS(Status)) { - - KEBUGCHECKEX(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0); - } - - /* Wait on the Completion Event */ - if (InitDoneEventHandle != INVALID_HANDLE_VALUE) { - - HANDLE Handles[2]; /* Init event, Initial process */ - - /* Setup the Handles to wait on */ - Handles[0] = InitDoneEventHandle; - Handles[1] = ProcessHandle; - - /* Wait for the system to be initialized */ - Timeout.QuadPart = (LONGLONG)-1200000000; /* 120 second timeout */ - Status = ZwWaitForMultipleObjects(2, - Handles, - WaitAny, - FALSE, - &Timeout); - if (!NT_SUCCESS(Status)) { - - DPRINT1("NtWaitForMultipleObjects failed with status 0x%x!\n", Status); - - } else if (Status == STATUS_TIMEOUT) { - - DPRINT1("WARNING: System not initialized after 120 seconds.\n"); - - } else if (Status == STATUS_WAIT_0 + 1) { - - /* Crash the system if the initial process was terminated. */ - KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 0, 0, 0); - } + /* Wait 5 seconds for it to initialize */ + Timeout.QuadPart = Int32x32To64(5, -10000000); + Status = ZwWaitForSingleObject(ProcessHandle, FALSE, &Timeout); + if (Status == STATUS_SUCCESS) + { + /* Bugcheck the system if SMSS couldn't initialize */ + KeBugCheck(SESSION5_INITIALIZATION_FAILED); + } + else + { + /* Close process handles */ + ZwClose(ThreadHandle); + ZwClose(ProcessHandle); /* - * FIXME: FILIP! - * Disable the Boot Logo - */ + * FIXME: FILIP! + * Disable the Boot Logo + */ if (!NoGuiBoot) InbvEnableBootDriver(FALSE); - /* Signal the Event and close the handle */ - ZwSetEvent(InitDoneEventHandle, NULL); - ZwClose(InitDoneEventHandle); - - } else { - - /* On failure to create 'ReactOSInitDone' event, go to text mode ASAP */ - if (!NoGuiBoot) InbvEnableBootDriver(FALSE); - - /* Crash the system if the initial process terminates within 5 seconds. */ - Timeout.QuadPart = (LONGLONG)-50000000; /* 5 second timeout */ - Status = ZwWaitForSingleObject(ProcessHandle, - FALSE, - &Timeout); - - /* Check for timeout, crash if the initial process didn't initalize */ - if (Status != STATUS_TIMEOUT) KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 1, 0, 0); - } - - /* Enable the Clock, close remaining handles */ - ZwClose(ThreadHandle); - ZwClose(ProcessHandle); - - DPRINT1("System initialization complete\n"); - { - /* FIXME: We should instead jump to zero-page thread */ - /* Free initial kernel memory */ - MiFreeInitMemory(); - - /* Set our priority to 0 */ - KeGetCurrentThread()->BasePriority = 0; - KeSetPriorityThread(KeGetCurrentThread(), 0); - - /* Wait ad-infinitum */ - for (;;) - { - LARGE_INTEGER Timeout; - Timeout.QuadPart = 0x7fffffffffffffffLL; - KeDelayExecutionThread(KernelMode, FALSE, &Timeout); - } - } -} - + /* FIXME: We should free the initial process' memory!*/ + + /* Increase init phase */ + ExpInitializationPhase += 1; + + /* Jump into zero page thread */ + MmZeroPageThreadMain(NULL); + } +} /* EOF */ Modified: trunk/reactos/ntoskrnl/include/internal/mm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/mm.h (original) +++ trunk/reactos/ntoskrnl/include/internal/mm.h Thu Oct 5 20:14:28 2006 @@ -974,7 +974,9 @@ NTSTATUS NTAPI -MmInitZeroPageThread(VOID); +MmZeroPageThreadMain( + PVOID Context +); /* i386/page.c *********************************************************/ Modified: trunk/reactos/ntoskrnl/mm/freelist.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/mm/freelist.c (original) +++ trunk/reactos/ntoskrnl/mm/freelist.c Thu Oct 5 20:14:28 2006 @@ -17,7 +17,6 @@ #if defined (ALLOC_PRAGMA) #pragma alloc_text(INIT, MmInitializePageList) -#pragma alloc_text(INIT, MmInitZeroPageThread) #endif @@ -62,8 +61,6 @@ static LIST_ENTRY FreeUnzeroedPageListHead; static LIST_ENTRY BiosPageListHead; -static PETHREAD ZeroPageThread; -static CLIENT_ID ZeroPageThreadId; static KEVENT ZeroPageThreadEvent; static BOOLEAN ZeroPageThreadShouldTerminate = FALSE; @@ -1139,7 +1136,8 @@ return NumberOfPagesFound; } -VOID STDCALL +NTSTATUS +NTAPI MmZeroPageThreadMain(PVOID Ignored) { NTSTATUS Status; @@ -1148,6 +1146,13 @@ PPHYSICAL_PAGE PageDescriptor; PFN_TYPE Pfn; ULONG Count; + + /* Free initial kernel memory */ + MiFreeInitMemory(); + + /* Set our priority to 0 */ + KeGetCurrentThread()->BasePriority = 0; + KeSetPriorityThread(KeGetCurrentThread(), 0); while(1) { @@ -1160,13 +1165,12 @@ { DbgPrint("ZeroPageThread: Wait failed\n"); KEBUGCHECK(0); - return; } if (ZeroPageThreadShouldTerminate) { DbgPrint("ZeroPageThread: Terminating\n"); - return; + return STATUS_SUCCESS; } Count = 0; KeAcquireSpinLock(&PageListLock, &oldIrql); @@ -1201,46 +1205,11 @@ } } - DPRINT("Zeroed %d pages.\n", Count); + DPRINT1("Zeroed %d pages.\n", Count); KeResetEvent(&ZeroPageThreadEvent); KeReleaseSpinLock(&PageListLock, oldIrql); } -} - -NTSTATUS -INIT_FUNCTION -NTAPI -MmInitZeroPageThread(VOID) -{ - NTSTATUS Status; - HANDLE ThreadHandle; - - ZeroPageThreadShouldTerminate = FALSE; - Status = PsCreateSystemThread(&ThreadHandle, - THREAD_ALL_ACCESS, - NULL, - NULL, - &ZeroPageThreadId, - MmZeroPageThreadMain, - NULL); - if (!NT_SUCCESS(Status)) - { - KEBUGCHECK(0); - } - - Status = ObReferenceObjectByHandle(ThreadHandle, - THREAD_ALL_ACCESS, - PsThreadType, - KernelMode, - (PVOID*)&ZeroPageThread, - NULL); - if (!NT_SUCCESS(Status)) - { - KEBUGCHECK(0); - } - - KeSetPriorityThread(&ZeroPageThread->Tcb, LOW_PRIORITY); - NtClose(ThreadHandle); + return STATUS_SUCCESS; } Modified: trunk/reactos/ntoskrnl/mm/mminit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=2…
============================================================================== --- trunk/reactos/ntoskrnl/mm/mminit.c (original) +++ trunk/reactos/ntoskrnl/mm/mminit.c Thu Oct 5 20:14:28 2006 @@ -455,7 +455,6 @@ MmDeletePageTable(NULL, 0); #endif - MmInitZeroPageThread(); MmCreatePhysicalMemorySection(); MiInitBalancerThread();
18 years, 2 months
1
0
0
0
[ion] 24412: - Put all Phase 1 Ex* Initialization in ExpInitSystemPhase1 and clean up associated deprecated calls. - Call ExpInitializePushLocks since we weren't doing this before.
by ion@svn.reactos.org
Author: ion Date: Thu Oct 5 19:13:59 2006 New Revision: 24412 URL:
http://svn.reactos.org/svn/reactos?rev=24412&view=rev
Log: - Put all Phase 1 Ex* Initialization in ExpInitSystemPhase1 and clean up associated deprecated calls. - Call ExpInitializePushLocks since we weren't doing this before. Modified: trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ex.h Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Oct 5 19:13:59 2006 @@ -327,10 +327,10 @@ } -INIT_FUNCTION NTSTATUS -ExpLoadInitialProcess(PHANDLE ProcessHandle, - PHANDLE ThreadHandle) +NTAPI +ExpLoadInitialProcess(IN PHANDLE ProcessHandle, + IN PHANDLE ThreadHandle) { PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; NTSTATUS Status; @@ -469,21 +469,6 @@ return STATUS_SUCCESS; } -VOID -NTAPI -ExInit3(VOID) -{ - ExpInitializeEventImplementation(); - ExpInitializeEventPairImplementation(); - ExpInitializeMutantImplementation(); - ExpInitializeSemaphoreImplementation(); - ExpInitializeTimerImplementation(); - LpcpInitSystem(); - ExpInitializeProfileImplementation(); - ExpWin32kInit(); - ExpInitUuids(); -} - ULONG NTAPI ExComputeTickCountMultiplier(IN ULONG ClockIncrement) @@ -542,8 +527,37 @@ NTAPI ExpInitSystemPhase1(VOID) { - /* Not yet done */ - return FALSE; + /* Initialize worker threads */ + ExpInitializeWorkerThreads(); + + /* Initialize pushlocks */ + ExpInitializePushLocks(); + + /* Initialize events and event pairs */ + ExpInitializeEventImplementation(); + ExpInitializeEventPairImplementation(); + + /* Initialize callbacks */ + ExpInitializeCallbacks(); + + /* Initialize mutants */ + ExpInitializeMutantImplementation(); + + /* Initialize semaphores */ + ExpInitializeSemaphoreImplementation(); + + /* Initialize timers */ + ExpInitializeTimerImplementation(); + + /* Initialize profiling */ + ExpInitializeProfileImplementation(); + + /* Initialize UUIDs */ + ExpInitUuids(); + + /* Initialize Win32K */ + ExpWin32kInit(); + return TRUE; } BOOLEAN @@ -847,6 +861,9 @@ HANDLE ThreadHandle; NTSTATUS Status; + /* Set to phase 1 */ + ExpInitializationPhase = 1; + /* Set us at maximum priority */ KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY); @@ -860,13 +877,7 @@ HalInitSystem(1, KeLoaderBlock); /* Initialize Basic System Objects and Worker Threads */ - ExInit3(); - - /* initialize the worker threads */ - ExpInitializeWorkerThreads(); - - /* initialize callbacks */ - ExpInitializeCallbacks(); + ExInitSystem(); /* Call KD Providers at Phase 1 */ KdInitSystem(1, KeLoaderBlock); @@ -906,6 +917,9 @@ /* Create NLS section */ ExpInitNls(); + + /* Initialize LPC */ + LpcpInitSystem(); /* Import and Load Registry Hives */ CmInitHives(ExpInTextModeSetup); 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 Thu Oct 5 19:13:59 2006 @@ -63,6 +63,10 @@ VOID NTAPI +ExpInitializePushLocks(VOID); + +VOID +NTAPI ExpInitTimeZoneInfo(VOID); VOID
18 years, 2 months
1
0
0
0
[ion] 24411: - Rewrite ExpLoadInitialProcess by inlining and simplifying what the call to RtlCreateProcsesParameters should do, and also create our own custom environment with the same arguments that NT's smss gets. - This optimizes booting as well as gets use the differnet SESSIONY_INITIALIZATION_FAILED, where Y is a number representing which step of the process parameter/envieonment creation failed.
by ion@svn.reactos.org
Author: ion Date: Thu Oct 5 18:49:20 2006 New Revision: 24411 URL:
http://svn.reactos.org/svn/reactos?rev=24411&view=rev
Log: - Rewrite ExpLoadInitialProcess by inlining and simplifying what the call to RtlCreateProcsesParameters should do, and also create our own custom environment with the same arguments that NT's smss gets. - This optimizes booting as well as gets use the differnet SESSIONY_INITIALIZATION_FAILED, where Y is a number representing which step of the process parameter/envieonment creation failed. Modified: trunk/reactos/ntoskrnl/ex/init.c Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Oct 5 18:49:20 2006 @@ -332,60 +332,140 @@ ExpLoadInitialProcess(PHANDLE ProcessHandle, PHANDLE ThreadHandle) { - UNICODE_STRING CurrentDirectory; - UNICODE_STRING ImagePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\smss.exe"); + PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; NTSTATUS Status; - PRTL_USER_PROCESS_PARAMETERS Params=NULL; - RTL_USER_PROCESS_INFORMATION Info; - - RtlInitUnicodeString(&CurrentDirectory, - SharedUserData->NtSystemRoot); - - /* Create the Parameters */ - Status = RtlCreateProcessParameters(&Params, - &ImagePath, - NULL, - &CurrentDirectory, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - if(!NT_SUCCESS(Status)) - { - DPRINT1("Failed to create ppb!\n"); - return Status; - } - - DPRINT("Creating process\n"); - Status = RtlCreateUserProcess(&ImagePath, + ULONG Size; + RTL_USER_PROCESS_INFORMATION ProcessInformation; + PWSTR p; + UNICODE_STRING NullString = RTL_CONSTANT_STRING(L""); + UNICODE_STRING SmssName, Environment, SystemDriveString; + + /* Allocate memory for the process parameters */ + Size = sizeof(RTL_USER_PROCESS_PARAMETERS) + + ((MAX_PATH * 4) * sizeof(WCHAR)); + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&ProcessParameters, + 0, + &Size, + MEM_COMMIT, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(SESSION1_INITIALIZATION_FAILED, Status, 0, 0, 0); + } + + /* Setup the basic header, and give the process the low 1MB to itself */ + ProcessParameters->Length = Size; + ProcessParameters->MaximumLength = Size; + ProcessParameters->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED | + RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB; + + /* Allocate a page for the environment */ + Size = PAGE_SIZE; + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + (PVOID)&ProcessParameters->Environment, + 0, + &Size, + MEM_COMMIT, + PAGE_READWRITE + ); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0); + } + + /* Make a buffer for the DOS path */ + p = (PWSTR)(ProcessParameters + 1); + ProcessParameters->CurrentDirectory.DosPath.Buffer = p; + ProcessParameters-> + CurrentDirectory.DosPath.MaximumLength = MAX_PATH * sizeof(WCHAR); + + /* Copy the DOS path */ + RtlCopyUnicodeString(&ProcessParameters->CurrentDirectory.DosPath, + &NtSystemRoot); + + /* Make a buffer for the DLL Path */ + p = (PWSTR)((PCHAR)ProcessParameters->CurrentDirectory.DosPath.Buffer + + ProcessParameters->CurrentDirectory.DosPath.MaximumLength); + ProcessParameters->DllPath.Buffer = p; + ProcessParameters->DllPath.MaximumLength = MAX_PATH * sizeof(WCHAR); + + /* Copy the DLL path and append the system32 directory */ + RtlCopyUnicodeString(&ProcessParameters->DllPath, + &ProcessParameters->CurrentDirectory.DosPath); + RtlAppendUnicodeToString(&ProcessParameters->DllPath, L"\\System32"); + + /* Make a buffer for the image name */ + p = (PWSTR)((PCHAR)ProcessParameters->DllPath.Buffer + + ProcessParameters->DllPath.MaximumLength); + ProcessParameters->ImagePathName.Buffer = p; + ProcessParameters->ImagePathName.MaximumLength = MAX_PATH * sizeof(WCHAR); + + /* Append the system path and session manager name */ + RtlAppendUnicodeToString(&ProcessParameters->ImagePathName, + L"\\SystemRoot\\System32"); + RtlAppendUnicodeToString(&ProcessParameters->ImagePathName, + L"\\smss.exe"); + + /* Create the environment string */ + RtlInitEmptyUnicodeString(&Environment, + ProcessParameters->Environment, + Size); + + /* Append the DLL path to it */ + RtlAppendUnicodeToString(&Environment, L"Path=" ); + RtlAppendUnicodeStringToString(&Environment, &ProcessParameters->DllPath); + RtlAppendUnicodeStringToString(&Environment, &NullString ); + + /* Create the system drive string */ + SystemDriveString = NtSystemRoot; + SystemDriveString.Length = 2 * sizeof(WCHAR); + + /* Append it to the environment */ + RtlAppendUnicodeToString(&Environment, L"SystemDrive="); + RtlAppendUnicodeStringToString(&Environment, &SystemDriveString); + RtlAppendUnicodeStringToString(&Environment, &NullString); + + /* Append the system root to the environment */ + RtlAppendUnicodeToString(&Environment, L"SystemRoot="); + RtlAppendUnicodeStringToString(&Environment, &NtSystemRoot); + RtlAppendUnicodeStringToString(&Environment, &NullString); + + /* Get and set the command line equal to the image path */ + ProcessParameters->CommandLine = ProcessParameters->ImagePathName; + SmssName = ProcessParameters->ImagePathName; + + /* Create SMSS process */ + Status = RtlCreateUserProcess(&SmssName, OBJ_CASE_INSENSITIVE, - Params, + RtlDeNormalizeProcessParams( + ProcessParameters), NULL, NULL, NULL, FALSE, NULL, NULL, - &Info); - - /* Close the handle and free the params */ - RtlDestroyProcessParameters(Params); - + &ProcessInformation); if (!NT_SUCCESS(Status)) { - DPRINT1("NtCreateProcess() failed (Status %lx)\n", Status); - return(Status); - } - - /* Start it up */ - ZwResumeThread(Info.ThreadHandle, NULL); + /* Failed */ + KeBugCheckEx(SESSION3_INITIALIZATION_FAILED, Status, 0, 0, 0); + } + + /* Resume the thread */ + Status = ZwResumeThread(ProcessInformation.ThreadHandle, NULL); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0); + } /* Return Handles */ - *ProcessHandle = Info.ProcessHandle; - *ThreadHandle = Info.ThreadHandle; - DPRINT("Process created successfully\n"); + *ProcessHandle = ProcessInformation.ProcessHandle; + *ThreadHandle = ProcessInformation.ThreadHandle; return STATUS_SUCCESS; }
18 years, 2 months
1
0
0
0
[fireball] 24410: - Add #ifdef DEBUG / #endif to fix compile. FreeLdr's debug macros needs some improvement in the future...
by fireball@svn.reactos.org
Author: fireball Date: Thu Oct 5 13:15:44 2006 New Revision: 24410 URL:
http://svn.reactos.org/svn/reactos?rev=24410&view=rev
Log: - Add #ifdef DEBUG / #endif to fix compile. FreeLdr's debug macros needs some improvement in the future... Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c Thu Oct 5 13:15:44 2006 @@ -491,6 +491,7 @@ DbgPrint((DPRINT_WINDOWS, "Memory Descriptor List prepared, printing PDE\n")); List_PaToVa(&LoaderBlock->MemoryDescriptorListHead); + #if DEBUG { ULONG *PDE_Addr=(ULONG *)PDE;//0xC0300000; int j; @@ -509,6 +510,7 @@ DbgPrint((DPRINT_WINDOWS, "\n")); } } + #endif // Enable paging
18 years, 2 months
1
0
0
0
[ion] 24409: - Use KeLoaderBlock for registry hive loading. - Get rid of the CACHED_MODULE array and associated structures and stop using them, get rid of ParseAndCacheLoadedModules. Stop using KeLoadedModules and KeLoadedModuleCount outside of freeldr.c. - Except for MmInit1, the kernel should now be totally isolated from FreeLDR-specific data.
by ion@svn.reactos.org
Author: ion Date: Thu Oct 5 06:02:27 2006 New Revision: 24409 URL:
http://svn.reactos.org/svn/reactos?rev=24409&view=rev
Log: - Use KeLoaderBlock for registry hive loading. - Get rid of the CACHED_MODULE array and associated structures and stop using them, get rid of ParseAndCacheLoadedModules. Stop using KeLoadedModules and KeLoadedModuleCount outside of freeldr.c. - Except for MmInit1, the kernel should now be totally isolated from FreeLDR-specific data. Modified: trunk/reactos/ntoskrnl/KrnlFun.c trunk/reactos/ntoskrnl/cm/registry.c trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/ke/freeldr.c Modified: trunk/reactos/ntoskrnl/KrnlFun.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/KrnlFun.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/KrnlFun.c (original) +++ trunk/reactos/ntoskrnl/KrnlFun.c Thu Oct 5 06:02:27 2006 @@ -27,10 +27,9 @@ // Ke: // // - FIXES: -// * Stop using CachedModules. -// * Try to make MmInit1 NTLDR compatible. // * Sanitize some context fields during conversions. // * Figure out why the DPC stack doesn't really work. +// * Try to make MmInit1 NTLDR compatible. // * Add DR macro/save and VM macro/save. // - FEATURES: // * New optimized table-based tick-hashed timer implementation. Modified: trunk/reactos/ntoskrnl/cm/registry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/registry.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/cm/registry.c (original) +++ trunk/reactos/ntoskrnl/cm/registry.c Thu Oct 5 06:02:27 2006 @@ -136,18 +136,48 @@ CmInitHives(BOOLEAN SetupBoot) { PCHAR BaseAddress; + PLIST_ENTRY ListHead, NextEntry; + PMEMORY_ALLOCATION_DESCRIPTOR MdBlock = NULL; /* Load Registry Hives. This one can be missing. */ - if (CachedModules[SystemRegistry]) { - BaseAddress = (PCHAR)CachedModules[SystemRegistry]->ModStart; + BaseAddress = KeLoaderBlock->RegistryBase; + if (BaseAddress) + { CmImportSystemHive(BaseAddress, - CachedModules[SystemRegistry]->ModEnd - (ULONG_PTR)BaseAddress); - } - - BaseAddress = (PCHAR)CachedModules[HardwareRegistry]->ModStart; + KeLoaderBlock->RegistryLength); + } + + /* Loop the memory descriptors */ + ListHead = &KeLoaderBlock->MemoryDescriptorListHead; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Get the current block */ + MdBlock = CONTAINING_RECORD(NextEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* Check if this is an registry block */ + if (MdBlock->MemoryType == LoaderRegistryData) + { + /* Check if it's not the SYSTEM hive that we already initialized */ + if ((MdBlock->BasePage) != ((ULONG_PTR)BaseAddress >> PAGE_SHIFT)) + { + /* Hardware hive break out */ + break; + } + } + + /* Go to the next block */ + NextEntry = MdBlock->ListEntry.Flink; + } + + /* We need a hardware hive */ + ASSERT(MdBlock); + + BaseAddress = (PCHAR)(MdBlock->BasePage << PAGE_SHIFT); CmImportHardwareHive(BaseAddress, - CachedModules[HardwareRegistry]->ModEnd - (ULONG_PTR)BaseAddress); - + MdBlock->PageCount << PAGE_SHIFT); /* Create dummy keys if no hardware hive was found */ CmImportHardwareHive (NULL, 0); Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Oct 5 06:02:27 2006 @@ -25,16 +25,13 @@ ULONG NtGlobalFlag; ULONG ExSuiteMask; -extern LOADER_MODULE KeLoaderModules[64]; -extern ULONG KeLoaderModuleCount; -extern ULONG KiServiceLimit; -BOOLEAN NoGuiBoot = FALSE; - /* Init flags and settings */ ULONG ExpInitializationPhase; BOOLEAN ExpInTextModeSetup; BOOLEAN IoRemoteBootClient; ULONG InitSafeBootMode; + +BOOLEAN NoGuiBoot = FALSE; /* NT Boot Path */ UNICODE_STRING NtSystemRoot; @@ -291,52 +288,6 @@ DbgPrint("No system drive found!\n"); KEBUGCHECK (NO_BOOT_DEVICE); - } -} - -VOID -FORCEINLINE -ParseAndCacheLoadedModules(VOID) -{ - ULONG i; - PCHAR Name; - - /* Loop the Module List and get the modules we want */ - for (i = 1; i < KeLoaderModuleCount; i++) - { - /* Get the Name of this Module */ - if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\'))) - { - /* Save the name */ - Name = (PCHAR)KeLoaderModules[i].String; - } - else - { - /* No name, skip */ - Name++; - } - - /* Now check for any of the modules we will need later */ - if (!_stricmp(Name, "ansi.nls")) - { - CachedModules[AnsiCodepage] = &KeLoaderModules[i]; - } - else if (!_stricmp(Name, "oem.nls")) - { - CachedModules[OemCodepage] = &KeLoaderModules[i]; - } - else if (!_stricmp(Name, "casemap.nls")) - { - CachedModules[UnicodeCasemap] = &KeLoaderModules[i]; - } - else if (!_stricmp(Name, "system") || !_stricmp(Name, "system.hiv")) - { - CachedModules[SystemRegistry] = &KeLoaderModules[i]; - } - else if (!_stricmp(Name, "hardware") || !_stricmp(Name, "hardware.hiv")) - { - CachedModules[HardwareRegistry] = &KeLoaderModules[i]; - } } } @@ -577,9 +528,6 @@ PLIST_ENTRY NextEntry, ListHead; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; - /* FIXME: Deprecate soon */ - ParseAndCacheLoadedModules(); - /* Validate Loader */ if (!ExpIsLoaderValid(LoaderBlock)) { Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h Thu Oct 5 06:02:27 2006 @@ -17,18 +17,6 @@ KPROFILE_SOURCE Source; LIST_ENTRY ListEntry; } KPROFILE_SOURCE_OBJECT, *PKPROFILE_SOURCE_OBJECT; - -/* Cached modules from the loader block */ -typedef enum _CACHED_MODULE_TYPE -{ - AnsiCodepage, - OemCodepage, - UnicodeCasemap, - SystemRegistry, - HardwareRegistry, - MaximumCachedModuleType, -} CACHED_MODULE_TYPE, *PCACHED_MODULE_TYPE; -extern PLOADER_MODULE CachedModules[MaximumCachedModuleType]; typedef enum _CONNECT_TYPE { @@ -122,6 +110,7 @@ extern LARGE_INTEGER KiTimeIncrementReciprocal; extern UCHAR KiTimeIncrementShiftCount; extern ULONG KiTimeLimitIsrMicroseconds; +extern ULONG KiServiceLimit; extern LIST_ENTRY BugcheckCallbackListHead, BugcheckReasonCallbackListHead; extern KSPIN_LOCK BugCheckCallbackLock; extern KDPC KiExpireTimerDpc; Modified: trunk/reactos/ntoskrnl/ke/freeldr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ke/freeldr.c (original) +++ trunk/reactos/ntoskrnl/ke/freeldr.c Thu Oct 5 06:02:27 2006 @@ -18,7 +18,6 @@ LOADER_MODULE KeLoaderModules[64]; ULONG KeLoaderModuleCount; static CHAR KeLoaderModuleStrings[64][256]; -PLOADER_MODULE CachedModules[MaximumCachedModuleType]; /* FreeLDR Memory Data */ ADDRESS_RANGE KeMemoryMap[64]; @@ -171,10 +170,6 @@ if (!(_stricmp(DriverName, "hardware")) || !(_stricmp(DriverName, "hardware.hiv"))) { - /* Save registry data */ - LoaderBlock->RegistryBase = ModStart; - LoaderBlock->RegistryLength = ModSize; - /* Create an MD for it */ MdEntry = &BldrMemoryDescriptors[i]; MdEntry->MemoryType = LoaderRegistryData;
18 years, 2 months
1
0
0
0
[ion] 24408: - Implement ExpInitNls to initialize the NLS Section using the new semantics recently implemented. Works pretty much like the previous code in rtl/nls.c except it uses the new variable names as well as maps a view of the NLS Table into the system process.c - Delete rtl/nls.c and all the associated deprecated code. - Do MmInit1 and SharedUserData stuff *after* initializing the initial thread, to avoid an ASSERT during bootup.
by ion@svn.reactos.org
Author: ion Date: Thu Oct 5 05:44:54 2006 New Revision: 24408 URL:
http://svn.reactos.org/svn/reactos?rev=24408&view=rev
Log: - Implement ExpInitNls to initialize the NLS Section using the new semantics recently implemented. Works pretty much like the previous code in rtl/nls.c except it uses the new variable names as well as maps a view of the NLS Table into the system process.c - Delete rtl/nls.c and all the associated deprecated code. - Do MmInit1 and SharedUserData stuff *after* initializing the initial thread, to avoid an ASSERT during bootup. Removed: trunk/reactos/ntoskrnl/rtl/nls.c Modified: trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/include/internal/ex.h trunk/reactos/ntoskrnl/include/internal/rtl.h trunk/reactos/ntoskrnl/ke/i386/kiinit.c trunk/reactos/ntoskrnl/mm/process.c trunk/reactos/ntoskrnl/ntoskrnl.rbuild trunk/reactos/ntoskrnl/rtl/libsupp.c Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Oct 5 05:44:54 2006 @@ -45,8 +45,103 @@ ULONG ExpUnicodeCaseTableDataOffset; NLSTABLEINFO ExpNlsTableInfo; ULONG ExpNlsTableSize; +PVOID ExpNlsSectionPointer; /* FUNCTIONS ****************************************************************/ + +VOID +NTAPI +ExpInitNls(VOID) +{ + LARGE_INTEGER SectionSize; + NTSTATUS Status; + HANDLE NlsSection; + PVOID SectionBase = NULL; + ULONG ViewSize = 0; + LARGE_INTEGER SectionOffset = {{0}}; + + /* Set the section size */ + SectionSize.QuadPart = ExpNlsTableSize; + + /* Create the NLS Section */ + Status = ZwCreateSection(&NlsSection, + SECTION_ALL_ACCESS, + NULL, + &SectionSize, + PAGE_READWRITE, + SEC_COMMIT, + NULL); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 1, 0, 0); + } + + /* Get a pointer to the section */ + Status = ObReferenceObjectByHandle(NlsSection, + SECTION_ALL_ACCESS, + MmSectionObjectType, + KernelMode, + &ExpNlsSectionPointer, + NULL); + ZwClose(NlsSection); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0); + } + + /* Map the NLS Section in system space */ + Status = MmMapViewInSystemSpace(ExpNlsSectionPointer, + &SectionBase, + &ExpNlsTableSize); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0); + } + + /* Copy the codepage data in its new location. */ + RtlMoveMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize); + + /* Free the previously allocated buffer and set the new location */ + ExFreePool(ExpNlsTableBase); + ExpNlsTableBase = SectionBase; + + /* Initialize the NLS Tables */ + RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase + + ExpAnsiCodePageDataOffset), + (PVOID)((ULONG_PTR)ExpNlsTableBase + + ExpOemCodePageDataOffset), + (PVOID)((ULONG_PTR)ExpNlsTableBase + + ExpUnicodeCaseTableDataOffset), + &ExpNlsTableInfo); + RtlResetRtlTranslations(&ExpNlsTableInfo); + + /* Reset the base to 0 */ + SectionBase = NULL; + + /* Map the section in the system process */ + Status = MmMapViewOfSection(ExpNlsSectionPointer, + PsGetCurrentProcess(), + &SectionBase, + 0L, + 0L, + &SectionOffset, + &ViewSize, + ViewShare, + 0L, + PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + /* Failed */ + KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 5, 0, 0); + } + + /* Copy the table into the system process and set this as the base */ + RtlMoveMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize); + ExpNlsTableBase = SectionBase; +} static VOID @@ -781,8 +876,8 @@ /* Call KD Providers at Phase 2 */ KdInitSystem(2, KeLoaderBlock); - /* Import and create NLS Data and Sections */ - RtlpInitNls(); + /* Create NLS section */ + ExpInitNls(); /* Import and Load Registry Hives */ CmInitHives(ExpInTextModeSetup); 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 Thu Oct 5 05:44:54 2006 @@ -14,6 +14,9 @@ extern FAST_MUTEX ExpEnvironmentLock; extern ERESOURCE ExpFirmwareTableResource; extern LIST_ENTRY ExpFirmwareTableProviderListHead; +ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset; +ULONG ExpUnicodeCaseTableDataOffset; +PVOID ExpNlsSectionPointer; #define MAX_FAST_REFS 7 Modified: trunk/reactos/ntoskrnl/include/internal/rtl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/rtl.h (original) +++ trunk/reactos/ntoskrnl/include/internal/rtl.h Thu Oct 5 05:44:54 2006 @@ -1,47 +1,5 @@ #ifndef __NTOSKRNL_INCLUDE_INTERNAL_NLS_H #define __NTOSKRNL_INCLUDE_INTERNAL_NLS_H - -extern PVOID NlsSectionObject; - -extern ULONG NlsAnsiTableOffset; -extern ULONG NlsOemTableOffset; -extern ULONG NlsUnicodeTableOffset; - -extern PUSHORT NlsUnicodeUpcaseTable; -extern PUSHORT NlsUnicodeLowercaseTable; - -VOID -NTAPI -RtlpInitNls(VOID); - -VOID -NTAPI -RtlpImportAnsiCodePage( - PUSHORT TableBase, - ULONG Size -); - -VOID -NTAPI -RtlpImportOemCodePage( - PUSHORT TableBase, - ULONG Size -); - -VOID -NTAPI -RtlpImportUnicodeCasemap( - PUSHORT TableBase, - ULONG Size -); - -VOID -NTAPI -RtlpCreateInitialNlsTables(VOID); - -VOID -NTAPI -RtlpCreateNlsSection(VOID); NTSTATUS NTAPI Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original) +++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Thu Oct 5 05:44:54 2006 @@ -407,34 +407,6 @@ DPRINT1("SMP Boot support not yet present\n"); } - /* Initialize Kernel Memory Address Space */ - MmInit1(FirstKrnlPhysAddr, - LastKrnlPhysAddr, - LastKernelAddress, - (PADDRESS_RANGE)&KeMemoryMap, - KeMemoryMapRangeCount, - 4096); - - /* Sets up the Text Sections of the Kernel and HAL for debugging */ - LdrInit1(); - - /* Set the NX Support policy */ - SharedUserData->NXSupportPolicy = NXSupportPolicy; - - /* Set basic CPU Features that user mode can read */ - SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = - (KeFeatureBits & KF_MMX); - SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = - (KeFeatureBits & KF_CMPXCHG8B); - SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = - ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI)); - SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = - ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI64)); - SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = - (KeFeatureBits & KF_3DNOW); - SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = - (KeFeatureBits & KF_RDTSC); - /* Setup the Idle Thread */ KeInitializeThread(InitProcess, InitThread, @@ -454,6 +426,34 @@ /* HACK for MmUpdatePageDir */ ((PETHREAD)InitThread)->ThreadsProcess = (PEPROCESS)InitProcess; + /* Initialize Kernel Memory Address Space */ + MmInit1(FirstKrnlPhysAddr, + LastKrnlPhysAddr, + LastKernelAddress, + (PADDRESS_RANGE)&KeMemoryMap, + KeMemoryMapRangeCount, + 4096); + + /* Sets up the Text Sections of the Kernel and HAL for debugging */ + LdrInit1(); + + /* Set the NX Support policy */ + SharedUserData->NXSupportPolicy = NXSupportPolicy; + + /* Set basic CPU Features that user mode can read */ + SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] = + (KeFeatureBits & KF_MMX); + SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = + (KeFeatureBits & KF_CMPXCHG8B); + SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = + ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI)); + SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = + ((KeFeatureBits & KF_FXSR) && (KeFeatureBits & KF_XMMI64)); + SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = + (KeFeatureBits & KF_3DNOW); + SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = + (KeFeatureBits & KF_RDTSC); + /* Set up the thread-related fields in the PRCB */ Prcb->CurrentThread = InitThread; Prcb->NextThread = NULL; Modified: trunk/reactos/ntoskrnl/mm/process.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/process.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/mm/process.c (original) +++ trunk/reactos/ntoskrnl/mm/process.c Thu Oct 5 05:44:54 2006 @@ -291,7 +291,7 @@ /* Map NLS Tables */ DPRINT("Mapping NLS\n"); - Status = MmMapViewOfSection(NlsSectionObject, + Status = MmMapViewOfSection(ExpNlsSectionPointer, (PEPROCESS)Process, &TableBase, 0, @@ -322,9 +322,9 @@ Peb->Mutant = NULL; /* NLS */ - Peb->AnsiCodePageData = (char*)TableBase + NlsAnsiTableOffset; - Peb->OemCodePageData = (char*)TableBase + NlsOemTableOffset; - Peb->UnicodeCaseTableData = (char*)TableBase + NlsUnicodeTableOffset; + Peb->AnsiCodePageData = (PCHAR)TableBase + ExpAnsiCodePageDataOffset; + Peb->OemCodePageData = (PCHAR)TableBase + ExpOemCodePageDataOffset; + Peb->UnicodeCaseTableData = (PCHAR)TableBase + ExpUnicodeCaseTableDataOffset; /* Default Version Data (could get changed below) */ Peb->OSMajorVersion = NtMajorVersion; Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Thu Oct 5 05:44:54 2006 @@ -315,7 +315,6 @@ </if> <file>libsupp.c</file> <file>misc.c</file> - <file>nls.c</file> <file>regio.c</file> <file>strtok.c</file> </directory> Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/libsupp.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/rtl/libsupp.c (original) +++ trunk/reactos/ntoskrnl/rtl/libsupp.c Thu Oct 5 05:44:54 2006 @@ -197,9 +197,6 @@ PKTHREAD Thread = KeGetCurrentThread(); /* FIXME: Super native implementation */ - - /* FIXME: ROS HACK */ - if (!Thread) return FALSE; /* Start with defaults */ *StackBegin = Thread->StackLimit; Removed: trunk/reactos/ntoskrnl/rtl/nls.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/nls.c?rev=244…
============================================================================== --- trunk/reactos/ntoskrnl/rtl/nls.c (original) +++ trunk/reactos/ntoskrnl/rtl/nls.c (removed) @@ -1,178 +1,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/rtl/nls.c - * PURPOSE: Bitmap functions - * - * PROGRAMMERS: Eric Kohl - */ - -#include <ntoskrnl.h> -#define NDEBUG -#include <internal/debug.h> - -#if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, RtlpInitNls) -#pragma alloc_text(INIT, RtlpImportAnsiCodePage) -#pragma alloc_text(INIT, RtlpImportOemCodePage) -#pragma alloc_text(INIT, RtlpImportUnicodeCasemap) -#pragma alloc_text(INIT, RtlpCreateInitialNlsTables) -#pragma alloc_text(INIT, RtlpCreateNlsSection) -#endif - - -/* GLOBALS *******************************************************************/ - - -static PUSHORT NlsAnsiCodePageTable = NULL; -static ULONG NlsAnsiCodePageTableSize = 0; - -static PUSHORT NlsOemCodePageTable = NULL; -static ULONG NlsOemCodePageTableSize = 0; - -static PUSHORT NlsUnicodeCasemapTable = NULL; -static ULONG NlsUnicodeCasemapTableSize = 0; - -PVOID NlsSectionObject = NULL; -static PVOID NlsSectionBase = NULL; -static ULONG NlsSectionViewSize = 0; - -ULONG NlsAnsiTableOffset = 0; -ULONG NlsOemTableOffset = 0; -ULONG NlsUnicodeTableOffset = 0; - - -/* FUNCTIONS *****************************************************************/ - -VOID -INIT_FUNCTION -STDCALL -RtlpInitNls(VOID) -{ - ULONG_PTR BaseAddress; - - /* Import NLS Data */ - BaseAddress = CachedModules[AnsiCodepage]->ModStart; - RtlpImportAnsiCodePage((PUSHORT)BaseAddress, - CachedModules[AnsiCodepage]->ModEnd - BaseAddress); - - BaseAddress = CachedModules[OemCodepage]->ModStart; - RtlpImportOemCodePage((PUSHORT)BaseAddress, - CachedModules[OemCodepage]->ModEnd - BaseAddress); - - BaseAddress = CachedModules[UnicodeCasemap]->ModStart; - RtlpImportUnicodeCasemap((PUSHORT)BaseAddress, - CachedModules[UnicodeCasemap]->ModEnd - BaseAddress); - - /* Create the NLS section */ - RtlpCreateNlsSection(); -} - -VOID -INIT_FUNCTION -NTAPI -RtlpImportAnsiCodePage(PUSHORT TableBase, - ULONG Size) -{ - NlsAnsiCodePageTable = TableBase; - NlsAnsiCodePageTableSize = Size; -} - - -VOID -INIT_FUNCTION -NTAPI -RtlpImportOemCodePage(PUSHORT TableBase, - ULONG Size) -{ - NlsOemCodePageTable = TableBase; - NlsOemCodePageTableSize = Size; -} - - -VOID -NTAPI -INIT_FUNCTION -RtlpImportUnicodeCasemap(PUSHORT TableBase, - ULONG Size) -{ - NlsUnicodeCasemapTable = TableBase; - NlsUnicodeCasemapTableSize = Size; -} - -VOID -NTAPI -INIT_FUNCTION -RtlpCreateNlsSection(VOID) -{ - NLSTABLEINFO NlsTable; - LARGE_INTEGER SectionSize; - NTSTATUS Status; - - DPRINT("RtlpCreateNlsSection() called\n"); - - NlsSectionViewSize = ROUND_UP(NlsAnsiCodePageTableSize, PAGE_SIZE) + - ROUND_UP(NlsOemCodePageTableSize, PAGE_SIZE) + - ROUND_UP(NlsUnicodeCasemapTableSize, PAGE_SIZE); - - DPRINT("NlsSectionViewSize %lx\n", NlsSectionViewSize); - - SectionSize.QuadPart = (LONGLONG)NlsSectionViewSize; - Status = MmCreateSection(&NlsSectionObject, - SECTION_ALL_ACCESS, - NULL, - &SectionSize, - PAGE_READWRITE, - SEC_COMMIT, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmCreateSection() failed\n"); - KEBUGCHECKEX(0x32, Status, 1, 1, 0); - } - Status = ObInsertObject(NlsSectionObject, - NULL, - SECTION_ALL_ACCESS, - 0, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - ObDereferenceObject(NlsSectionObject); - } - Status = MmMapViewInSystemSpace(NlsSectionObject, - &NlsSectionBase, - &NlsSectionViewSize); - if (!NT_SUCCESS(Status)) - { - DPRINT1("MmMapViewInSystemSpace() failed\n"); - KEBUGCHECKEX(0x32, Status, 1, 3, 0); - } - - DPRINT("NlsSection: Base %p Size %lx\n", - NlsSectionBase, - NlsSectionViewSize); - - NlsAnsiTableOffset = 0; - RtlCopyMemory((PVOID)((ULONG)NlsSectionBase + NlsAnsiTableOffset), - NlsAnsiCodePageTable, - NlsAnsiCodePageTableSize); - - NlsOemTableOffset = NlsAnsiTableOffset + ROUND_UP(NlsAnsiCodePageTableSize, PAGE_SIZE); - RtlCopyMemory((PVOID)((ULONG)NlsSectionBase + NlsOemTableOffset), - NlsOemCodePageTable, - NlsOemCodePageTableSize); - - NlsUnicodeTableOffset = NlsOemTableOffset + ROUND_UP(NlsOemCodePageTableSize, PAGE_SIZE); - RtlCopyMemory((PVOID)((ULONG)NlsSectionBase + NlsUnicodeTableOffset), - NlsUnicodeCasemapTable, - NlsUnicodeCasemapTableSize); - - RtlInitNlsTables ((PVOID)((ULONG)NlsSectionBase + NlsAnsiTableOffset), - (PVOID)((ULONG)NlsSectionBase + NlsOemTableOffset), - (PVOID)((ULONG)NlsSectionBase + NlsUnicodeTableOffset), - &NlsTable); - - RtlResetRtlTranslations (&NlsTable); -}
18 years, 2 months
1
0
0
0
[gedmurphy] 24407: add a few more icons to the device imagelist
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Thu Oct 5 02:29:18 2006 New Revision: 24407 URL:
http://svn.reactos.org/svn/reactos?rev=24407&view=rev
Log: add a few more icons to the device imagelist Modified: trunk/reactos/dll/win32/setupapi/res/icons/10.ico trunk/reactos/dll/win32/setupapi/res/icons/20.ico trunk/reactos/dll/win32/setupapi/res/icons/28.ico trunk/reactos/dll/win32/setupapi/res/icons/501.ico Modified: trunk/reactos/dll/win32/setupapi/res/icons/10.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/res/ico…
============================================================================== Binary files - no diff available. Modified: trunk/reactos/dll/win32/setupapi/res/icons/20.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/res/ico…
============================================================================== Binary files - no diff available. Modified: trunk/reactos/dll/win32/setupapi/res/icons/28.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/res/ico…
============================================================================== Binary files - no diff available. Modified: trunk/reactos/dll/win32/setupapi/res/icons/501.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/res/ico…
============================================================================== Binary files - no diff available.
18 years, 2 months
1
0
0
0
[cwittich] 24406: -removed unused var
by cwittich@svn.reactos.org
Author: cwittich Date: Thu Oct 5 02:06:00 2006 New Revision: 24406 URL:
http://svn.reactos.org/svn/reactos?rev=24406&view=rev
Log: -removed unused var Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
============================================================================== --- trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Thu Oct 5 02:06:00 2006 @@ -812,7 +812,6 @@ Module& module = *ProjectNode.modules[i]; std::string vcproj_file = VcprojFileName ( module ); - std::string vcproj_file_user = vcproj_file + "CHRIS-NOTEBOOK.Christoph.user"; _generate_sln_project ( OUT, module, vcproj_file, sln_guid, module.guid, module.non_if_data.libraries ); } _generate_sln_footer ( OUT );
18 years, 2 months
1
0
0
0
[fireball] 24405: - Add most needed memory-manipulating functions. Some places are really crappy (like WinLdrSetProcessorContext's IDT filling), will be fixed soon. - FIXME: Since FreeLdr doesn't really keep track of which memory is of which type, this code has a massive hack for guessing the memory type, which is incorrect for future usage
by fireball@svn.reactos.org
Author: fireball Date: Thu Oct 5 01:58:36 2006 New Revision: 24405 URL:
http://svn.reactos.org/svn/reactos?rev=24405&view=rev
Log: - Add most needed memory-manipulating functions. Some places are really crappy (like WinLdrSetProcessorContext's IDT filling), will be fixed soon. - FIXME: Since FreeLdr doesn't really keep track of which memory is of which type, this code has a massive hack for guessing the memory type, which is incorrect for future usage Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c Thu Oct 5 01:58:36 2006 @@ -19,11 +19,370 @@ #undef KIP0PCRADDRESS #define KIP0PCRADDRESS 0xffdff000 +// +// This is the zone which is used by the OS loader +// +#define LOADER_HIGH_ZONE ((16*1024*1024) >> MM_PAGE_SHIFT) //16Mb page + #define HYPER_SPACE_ENTRY 0x300 +//TODO: Check if this is correct +PCHAR MemTypeDesc[] = { + "ExceptionBlock ", + "SystemBlock ", + "Free ", + "Bad ", + "LoadedProgram ", + "FirmwareTemporary ", + "FirmwarePermanent ", + "OsloaderHeap ", + "OsloaderStack ", + "SystemCode ", + "HalCode ", + "BootDriver ", + "ConsoleInDriver ", + "ConsoleOutDriver ", + "StartupDpcStack ", + "StartupKernelStack", + "StartupPanicStack ", + "StartupPcrPage ", + "StartupPdrPage ", + "RegistryData ", + "MemoryData ", + "NlsData ", + "SpecialMemory ", + "BBTMemory ", + "Maximum " + }; + +VOID +WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); + + +VOID +MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + UINT64 BasePage, + UINT64 PageCount, + ULONG Type); +VOID +WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor); + +VOID +WinLdrRemoveDescriptor(IN PMEMORY_ALLOCATION_DESCRIPTOR Descriptor); + +VOID +WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss); + +// This is needed only for SetProcessorContext routine +#pragma pack(2) + typedef struct + { + USHORT Limit; + ULONG Base; + } GDTIDT; +#pragma pack(4) + +// this is needed for new IDT filling +#if 0 +extern ULONG_PTR i386DivideByZero; +extern ULONG_PTR i386DebugException; +extern ULONG_PTR i386NMIException; +extern ULONG_PTR i386Breakpoint; +extern ULONG_PTR i386Overflow; +extern ULONG_PTR i386BoundException; +extern ULONG_PTR i386InvalidOpcode; +extern ULONG_PTR i386FPUNotAvailable; +extern ULONG_PTR i386DoubleFault; +extern ULONG_PTR i386CoprocessorSegment; +extern ULONG_PTR i386InvalidTSS; +extern ULONG_PTR i386SegmentNotPresent; +extern ULONG_PTR i386StackException; +extern ULONG_PTR i386GeneralProtectionFault; +extern ULONG_PTR i386PageFault; // exc 14 +extern ULONG_PTR i386CoprocessorError; // exc 16 +extern ULONG_PTR i386AlignmentCheck; // exc 17 +#endif + /* GLOBALS ***************************************************************/ +PHARDWARE_PTE PDE; +PHARDWARE_PTE HalPT; + +PUCHAR PhysicalPageTablesBuffer; +PUCHAR KernelPageTablesBuffer; +ULONG PhysicalPageTables; +ULONG KernelPageTables; + +MEMORY_ALLOCATION_DESCRIPTOR Mad[1024]; +ULONG MadCount = 0; + + /* FUNCTIONS **************************************************************/ + +BOOLEAN +MempAllocatePageTables() +{ + ULONG NumPageTables, TotalSize; + PUCHAR Buffer; + // It's better to allocate PDE + PTEs contigiuos + + // Max number of entries = MaxPageNum >> 10 + // FIXME: This is a number to describe ALL physical memory + // and windows doesn't expect ALL memory mapped... + NumPageTables = (GetSystemMemorySize() >> MM_PAGE_SHIFT) >> 10; + + DbgPrint((DPRINT_WINDOWS, "NumPageTables = %d\n", NumPageTables)); + + // Allocate memory block for all these things: + // PDE, HAL mapping page table, physical mapping, kernel mapping + TotalSize = (1+1+NumPageTables*2)*MM_PAGE_SIZE; + Buffer = MmAllocateMemory(TotalSize); + + if (Buffer == NULL) + { + UiMessageBox("Impossible to allocate memory block for page tables!"); + return FALSE; + } + + // Zero all this memory block + RtlZeroMemory(Buffer, TotalSize); + + // Set up pointers correctly now + PDE = (PHARDWARE_PTE)Buffer; + + // Map the page directory at 0xC0000000 (maps itself) + PDE[HYPER_SPACE_ENTRY].PageFrameNumber = (ULONG)PDE >> MM_PAGE_SHIFT; + PDE[HYPER_SPACE_ENTRY].Valid = 1; + PDE[HYPER_SPACE_ENTRY].Write = 1; + + // The last PDE slot is allocated for HAL's memory mapping (Virtual Addresses 0xFFC00000 - 0xFFFFFFFF) + HalPT = (PHARDWARE_PTE)&Buffer[MM_PAGE_SIZE*1]; + + // Map it + PDE[1023].PageFrameNumber = (ULONG)HalPT >> MM_PAGE_SHIFT; + PDE[1023].Valid = 1; + PDE[1023].Write = 1; + + // Store pointers to the tables for easier access + PhysicalPageTablesBuffer = &Buffer[MM_PAGE_SIZE*2]; + KernelPageTablesBuffer = PhysicalPageTablesBuffer + NumPageTables*MM_PAGE_SIZE; + + // Zero counters of page tables used + PhysicalPageTables = 0; + KernelPageTables = 0; + + return TRUE; +} + +VOID +MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT) +{ + //Print(L"Creating PDE Entry %X\n", Entry); + + // Identity mapping + *PhysicalPT = (PHARDWARE_PTE)&PhysicalPageTablesBuffer[PhysicalPageTables*MM_PAGE_SIZE]; + PhysicalPageTables++; + + PDE[Entry].PageFrameNumber = (ULONG)*PhysicalPT >> MM_PAGE_SHIFT; + PDE[Entry].Valid = 1; + PDE[Entry].Write = 1; + + if (Entry+(KSEG0_BASE >> 22) > 1023) + { + DbgPrint((DPRINT_WINDOWS, "WARNING! Entry: %X > 1023\n", Entry+(KSEG0_BASE >> 22))); + } + + // Kernel-mode mapping + *KernelPT = (PHARDWARE_PTE)&KernelPageTablesBuffer[KernelPageTables*MM_PAGE_SIZE]; + KernelPageTables++; + + PDE[Entry+(KSEG0_BASE >> 22)].PageFrameNumber = ((ULONG)*KernelPT >> MM_PAGE_SHIFT); + PDE[Entry+(KSEG0_BASE >> 22)].Valid = 1; + PDE[Entry+(KSEG0_BASE >> 22)].Write = 1; +} + +BOOLEAN +MempSetupPaging(IN ULONG StartPage, + IN ULONG NumberOfPages) +{ + PHARDWARE_PTE PhysicalPT; + PHARDWARE_PTE KernelPT; + ULONG Entry, Page; + + //Print(L"MempSetupPaging: SP 0x%X, Number: 0x%X\n", StartPage, NumberOfPages); + + // HACK + if (StartPage+NumberOfPages >= 0x80000) + { + // + // We can't map this as it requires more than 1 PDE + // and in fact it's not possible at all ;) + // + //Print(L"skipping...\n"); + return TRUE; + } + + // + // Now actually set up the page tables for identity mapping + // + for (Page=StartPage; Page < StartPage+NumberOfPages; Page++) + { + Entry = Page >> 10; + + if (((PULONG)PDE)[Entry] == 0) + { + MempAllocatePTE(Entry, &PhysicalPT, &KernelPT); + } + else + { + PhysicalPT = (PHARDWARE_PTE)(PDE[Entry].PageFrameNumber << MM_PAGE_SHIFT); + KernelPT = (PHARDWARE_PTE)(PDE[Entry+(KSEG0_BASE >> 22)].PageFrameNumber << MM_PAGE_SHIFT); + } + + if (Page == 0) + { + PhysicalPT[Page & 0x3ff].PageFrameNumber = Page; + PhysicalPT[Page & 0x3ff].Valid = 0; + PhysicalPT[Page & 0x3ff].Write = 0; + + KernelPT[Page & 0x3ff].PageFrameNumber = Page; + KernelPT[Page & 0x3ff].Valid = 0; + KernelPT[Page & 0x3ff].Write = 0; + } + else + { + PhysicalPT[Page & 0x3ff].PageFrameNumber = Page; + PhysicalPT[Page & 0x3ff].Valid = 1; + PhysicalPT[Page & 0x3ff].Write = 1; + + KernelPT[Page & 0x3ff].PageFrameNumber = Page; + KernelPT[Page & 0x3ff].Valid = 1; + KernelPT[Page & 0x3ff].Write = 1; + } + } + + return TRUE; +} + +VOID +MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + UINT64 BasePage, + UINT64 PageCount, + ULONG Type) +{ + BOOLEAN Status; + + // + // Check for some weird stuff at the top + // + if (BasePage + PageCount > 0xF0000) + { + // + // Just skip this, without even adding to MAD list + // + return; + } + + // + // Base page and page count are always set + // + Mad[MadCount].BasePage = BasePage; + Mad[MadCount].PageCount = PageCount; + + // + // Check if it's more than the allowed for OS loader + // if yes - don't map the pages, just add as FirmwareTemporary + // + if (BasePage + PageCount > LOADER_HIGH_ZONE) + { + Mad[MadCount].MemoryType = LoaderFirmwareTemporary; + + WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); + MadCount++; + + Status = MempSetupPaging(BasePage, PageCount); + if (!Status) + { + DbgPrint((DPRINT_WINDOWS, "Error during WinLdrpSetupPaging\n")); + return; + } + return; + } + + if (BasePage == 0xFFF && PageCount == 1) + { + Mad[MadCount].MemoryType = LoaderSpecialMemory; + + WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); + MadCount++; + + // + // Map it + // + Status = MempSetupPaging(BasePage, PageCount); + if (!Status) + { + DbgPrint((DPRINT_WINDOWS, "Error during MempSetupPaging\n")); + return; + } + } + else if (BasePage == 0 && PageCount == 1) + { + Mad[MadCount].MemoryType = LoaderFirmwarePermanent; + + WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); + MadCount++; + + // + // Map it + // + Status = MempSetupPaging(BasePage, PageCount); + if (!Status) + { + DbgPrint((DPRINT_WINDOWS, "Error during MempSetupPaging\n")); + return; + } + } + else + { + // + // Now choose memory type as usual. FIXME!!! + // + if (Type == 0) + { + Mad[MadCount].MemoryType = LoaderFree; + } + else if (Type != 0 && Type != 1) + { + Mad[MadCount].MemoryType = LoaderFirmwarePermanent; + } + else if (Type == 1) + { + Mad[MadCount].MemoryType = LoaderSystemCode; + } + else + { + Mad[MadCount].MemoryType = LoaderFirmwarePermanent; + } + + // + // Add descriptor + // + WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]); + MadCount++; + + // + // Map it + // + Status = MempSetupPaging(BasePage, PageCount); + if (!Status) + { + DbgPrint((DPRINT_WINDOWS, "Error during MempSetupPaging\n")); + return; + } + } +} BOOLEAN WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, @@ -31,5 +390,557 @@ ULONG TssBasePage, PVOID GdtIdt) { - return FALSE; + ULONG i, PagesCount; + ULONG LastPageIndex, LastPageType; + PPAGE_LOOKUP_TABLE_ITEM MemoryMap; + ULONG NoEntries; + PKTSS Tss; + + // + // Creating a suitable memory map for the Windows can be tricky, so let's + // give a few advices: + // 1) One must not map the whole available memory pages to PDE! + // Map only what's needed - 16Mb, 24Mb, 32Mb max I think, + // thus occupying 4, 6 or 8 PDE entries for identical mapping, + // the same quantity for KSEG0_BASE mapping, one more entry for + // hyperspace and one more entry for HAL physical pages mapping. + // 2) Memory descriptors must map *the whole* physical memory + // showing any memory above 16/24/32 as FirmwareTemporary + // + // 3) Overall memory blocks count must not exceed 30 + // + + // + // During MmInitMachineDependent, the kernel zeroes PDE at the following address + // 0xC0300000 - 0xC03007FC + // + // Then it finds the best place for non-paged pool: + // StartPde C0300F70, EndPde C0300FF8, NumberOfPages C13, NextPhysPage 3AD + // + + // Before we start mapping pages, create a block of memory, which will contain + // PDE and PTEs + if (MempAllocatePageTables() == FALSE) + return FALSE; + + // Setup an entry for each descriptor + MemoryMap = MmGetMemoryMap(&NoEntries); + if (MemoryMap == NULL) + { + UiMessageBox("Can not retrieve the current memory map"); + return FALSE; + } + + DbgPrint((DPRINT_WINDOWS, "Got memory map with %d entries\n")); + + // Construct a good memory map from what we've got + PagesCount = 1; + LastPageIndex = 0; + LastPageType = MemoryMap[0].PageAllocated; + for(i=1;i<NoEntries;i++) + { + if (MemoryMap[i].PageAllocated == LastPageType) + { + PagesCount++; + } + else + { + // Add the region + MempAddMemoryBlock(LoaderBlock, LastPageIndex, PagesCount, LastPageType); + + // Reset our counter vars + LastPageIndex = i; + LastPageType = MemoryMap[i].PageAllocated; + PagesCount = 1; + } + } + + DbgPrint((DPRINT_WINDOWS, "MadCount: %d\n", MadCount)); + + WinLdrpDumpMemoryDescriptors(LoaderBlock); //FIXME: Delete! + + // Map our loader image, so we can continue running + /*Status = MempSetupPaging(OsLoaderBase >> MM_PAGE_SHIFT, OsLoaderSize >> MM_PAGE_SHIFT); + if (!Status) + { + UiMessageBox("Error during MempSetupPaging"); + return; + }*/ + + //VideoDisplayString(L"Hello from VGA, going into the kernel\n"); + DbgPrint((DPRINT_WINDOWS, "HalPT: 0x%X\n", HalPT)); + + // Page Tables have been setup, make special handling for PCR and TSS + // (which is done in BlSetupFotNt in usual ntldr) + HalPT[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber = PcrBasePage+1; + HalPT[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1; + HalPT[(KI_USER_SHARED_DATA - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1; + + HalPT[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].PageFrameNumber = PcrBasePage; + HalPT[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Valid = 1; + HalPT[(KIP0PCRADDRESS - 0xFFC00000) >> MM_PAGE_SHIFT].Write = 1; + + // Map VGA memory + //VideoMemoryBase = MmMapIoSpace(0xb8000, 4000, MmNonCached); + //DbgPrint((DPRINT_WINDOWS, "VideoMemoryBase: 0x%X\n", VideoMemoryBase)); + + Tss = (PKTSS)(KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT)); + + // Fill the memory descriptor list and + //PrepareMemoryDescriptorList(); + DbgPrint((DPRINT_WINDOWS, "Memory Descriptor List prepared, printing PDE\n")); + List_PaToVa(&LoaderBlock->MemoryDescriptorListHead); + + { + ULONG *PDE_Addr=(ULONG *)PDE;//0xC0300000; + int j; + + DbgPrint((DPRINT_WINDOWS, "\nPDE\n")); + + for (i=0; i<128; i++) + { + DbgPrint((DPRINT_WINDOWS, "0x%04X | ", i*8)); + + for (j=0; j<8; j++) + { + DbgPrint((DPRINT_WINDOWS, "0x%08X ", PDE_Addr[i*8+j])); + } + + DbgPrint((DPRINT_WINDOWS, "\n")); + } + } + + + // Enable paging + //BS->ExitBootServices(ImageHandle,MapKey); + + // Disable Interrupts + Ke386DisableInterrupts(); + + // Re-initalize EFLAGS + Ke386EraseFlags(); + + // Set the PDBR + Ke386SetPageTableDirectory((ULONG_PTR)PDE); + + // Enable paging by modifying CR0 + Ke386SetCr0(Ke386GetCr0() | CR0_PG); + + // Set processor context + WinLdrSetProcessorContext(GdtIdt, KIP0PCRADDRESS, KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT)); + + // Zero KI_USER_SHARED_DATA page + memset((PVOID)KI_USER_SHARED_DATA, 0, MM_PAGE_SIZE); + + return TRUE; } + +// Two special things this func does: it sorts descriptors, +// and it merges free ones +VOID +WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, + IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor) +{ + PLIST_ENTRY ListHead = &LoaderBlock->MemoryDescriptorListHead; + PLIST_ENTRY PreviousEntry, NextEntry; + PMEMORY_ALLOCATION_DESCRIPTOR PreviousDescriptor = NULL, NextDescriptor = NULL; + + DbgPrint((DPRINT_WINDOWS, "BP=0x%X PC=0x%X %s\n", NewDescriptor->BasePage, + NewDescriptor->PageCount, MemTypeDesc[NewDescriptor->MemoryType])); + + /* Find a place where to insert the new descriptor to */ + PreviousEntry = ListHead; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + NextDescriptor = CONTAINING_RECORD(NextEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + if (NewDescriptor->BasePage < NextDescriptor->BasePage) + break; + + PreviousEntry = NextEntry; + PreviousDescriptor = NextDescriptor; + NextEntry = NextEntry->Flink; + } + + /* Don't forget about merging free areas */ + if (NewDescriptor->MemoryType != LoaderFree) + { + /* Just insert, nothing to merge */ + InsertHeadList(PreviousEntry, &NewDescriptor->ListEntry); + } + else + { + /* Previous block also free? */ + if ((PreviousEntry != ListHead) && (PreviousDescriptor->MemoryType == LoaderFree) && + ((PreviousDescriptor->BasePage + PreviousDescriptor->PageCount) == + NewDescriptor->BasePage)) + { + /* Just enlarge previous descriptor's PageCount */ + PreviousDescriptor->PageCount += NewDescriptor->PageCount; + NewDescriptor = PreviousDescriptor; + } + else + { + /* Nope, just insert */ + InsertHeadList(PreviousEntry, &NewDescriptor->ListEntry); + } + + /* Next block is free ?*/ + if ((NextEntry != ListHead) && + (NextDescriptor->MemoryType == LoaderFree) && + ((NewDescriptor->BasePage + NewDescriptor->PageCount) == NextDescriptor->BasePage)) + { + /* Enlarge next descriptor's PageCount */ + NewDescriptor->PageCount += NextDescriptor->PageCount; + RemoveEntryList(&NextDescriptor->ListEntry); + } + } + + return; +} + +VOID +WinLdrSetProcessorContext(PVOID GdtIdt, IN ULONG Pcr, IN ULONG Tss) +{ + GDTIDT GdtDesc, IdtDesc, OldIdt; + PKGDTENTRY pGdt; + PKIDTENTRY pIdt; + ULONG Ldt = 0; + //ULONG i; + + DbgPrint((DPRINT_WINDOWS, "GDtIdt %p, Pcr %p, Tss 0x%08X\n", + GdtIdt, Pcr, Tss)); + + // Kernel expects the PCR to be zero-filled on startup + // FIXME: Why zero it here when we can zero it right after allocation? + RtlZeroMemory((PVOID)Pcr, MM_PAGE_SIZE); //FIXME: Why zero only 1 page when we allocate 2? + + // Get old values of GDT and IDT + Ke386GetGlobalDescriptorTable(GdtDesc); + Ke386GetInterruptDescriptorTable(IdtDesc); + + // Save old IDT + OldIdt.Base = IdtDesc.Base; + OldIdt.Limit = IdtDesc.Limit; + + // Prepare new IDT+GDT + GdtDesc.Base = KSEG0_BASE | (ULONG_PTR)GdtIdt; + GdtDesc.Limit = NUM_GDT * sizeof(KGDTENTRY) - 1; + IdtDesc.Base = (ULONG)((PUCHAR)GdtDesc.Base + GdtDesc.Limit + 1); + IdtDesc.Limit = NUM_IDT * sizeof(KIDTENTRY) - 1; + + // ======================== + // Fill all descriptors now + // ======================== + + pGdt = (PKGDTENTRY)GdtDesc.Base; + pIdt = (PKIDTENTRY)IdtDesc.Base; + + // + // Code selector (0x8) + // Flat 4Gb + // + pGdt[1].LimitLow = 0xFFFF; + pGdt[1].BaseLow = 0; + pGdt[1].HighWord.Bytes.BaseMid = 0; + pGdt[1].HighWord.Bytes.Flags1 = 0x9A; + pGdt[1].HighWord.Bytes.Flags2 = 0xCF; + pGdt[1].HighWord.Bytes.BaseHi = 0; + + // + // Data selector (0x10) + // Flat 4Gb + // + pGdt[2].LimitLow = 0xFFFF; + pGdt[2].BaseLow = 0; + pGdt[2].HighWord.Bytes.BaseMid = 0; + pGdt[2].HighWord.Bytes.Flags1 = 0x92; + pGdt[2].HighWord.Bytes.Flags2 = 0xCF; + pGdt[2].HighWord.Bytes.BaseHi = 0; + + // + // Selector (0x18) + // Flat 2Gb + // + pGdt[3].LimitLow = 0xFFFF; + pGdt[3].BaseLow = 0; + pGdt[3].HighWord.Bytes.BaseMid = 0; + pGdt[3].HighWord.Bytes.Flags1 = 0xFA; + pGdt[3].HighWord.Bytes.Flags2 = 0xCF; + pGdt[3].HighWord.Bytes.BaseHi = 0; + + // + // Selector (0x20) + // Flat 2Gb + // + pGdt[4].LimitLow = 0xFFFF; + pGdt[4].BaseLow = 0; + pGdt[4].HighWord.Bytes.BaseMid = 0; + pGdt[4].HighWord.Bytes.Flags1 = 0xF2; + pGdt[4].HighWord.Bytes.Flags2 = 0xCF; + pGdt[4].HighWord.Bytes.BaseHi = 0; + + // + // TSS Selector (0x28) + // + pGdt[5].LimitLow = 0x78-1; // 60 dwords + pGdt[5].BaseLow = (USHORT)(Tss & 0xffff); + pGdt[5].HighWord.Bytes.BaseMid = (UCHAR)((Tss >> 16) & 0xff); + pGdt[5].HighWord.Bytes.Flags1 = 0x89; + pGdt[5].HighWord.Bytes.Flags2 = 0x00; + pGdt[5].HighWord.Bytes.BaseHi = (UCHAR)((Tss >> 24) & 0xff); + + // + // PCR Selector (0x30) + // + pGdt[6].LimitLow = 0x01; + pGdt[6].BaseLow = (USHORT)(Pcr & 0xffff); + pGdt[6].HighWord.Bytes.BaseMid = (UCHAR)((Pcr >> 16) & 0xff); + pGdt[6].HighWord.Bytes.Flags1 = 0x92; + pGdt[6].HighWord.Bytes.Flags2 = 0xC0; + pGdt[6].HighWord.Bytes.BaseHi = (UCHAR)((Pcr >> 24) & 0xff); + + // + // Selector (0x38) + // + pGdt[7].LimitLow = 0xFFFF; + pGdt[7].BaseLow = 0; + pGdt[7].HighWord.Bytes.BaseMid = 0; + pGdt[7].HighWord.Bytes.Flags1 = 0xF3; + pGdt[7].HighWord.Bytes.Flags2 = 0x40; + pGdt[7].HighWord.Bytes.BaseHi = 0; + + // + // Some BIOS fuck (0x40) + // + pGdt[8].LimitLow = 0xFFFF; + pGdt[8].BaseLow = 0x400; + pGdt[8].HighWord.Bytes.BaseMid = 0; + pGdt[8].HighWord.Bytes.Flags1 = 0xF2; + pGdt[8].HighWord.Bytes.Flags2 = 0x0; + pGdt[8].HighWord.Bytes.BaseHi = 0; + + // + // Selector (0x48) + // + pGdt[9].LimitLow = 0; + pGdt[9].BaseLow = 0; + pGdt[9].HighWord.Bytes.BaseMid = 0; + pGdt[9].HighWord.Bytes.Flags1 = 0; + pGdt[9].HighWord.Bytes.Flags2 = 0; + pGdt[9].HighWord.Bytes.BaseHi = 0; + + // + // Selector (0x50) + // + pGdt[10].LimitLow = 0xFFFF; //FIXME: Not correct! + pGdt[10].BaseLow = 0; + pGdt[10].HighWord.Bytes.BaseMid = 0x2; + pGdt[10].HighWord.Bytes.Flags1 = 0x89; + pGdt[10].HighWord.Bytes.Flags2 = 0; + pGdt[10].HighWord.Bytes.BaseHi = 0; + + // + // Selector (0x58) + // + pGdt[11].LimitLow = 0xFFFF; + pGdt[11].BaseLow = 0; + pGdt[11].HighWord.Bytes.BaseMid = 0x2; + pGdt[11].HighWord.Bytes.Flags1 = 0x9A; + pGdt[11].HighWord.Bytes.Flags2 = 0; + pGdt[11].HighWord.Bytes.BaseHi = 0; + + // + // Selector (0x60) + // + pGdt[12].LimitLow = 0xFFFF; + pGdt[12].BaseLow = 0; //FIXME: Maybe not correct, but noone cares + pGdt[12].HighWord.Bytes.BaseMid = 0x2; + pGdt[12].HighWord.Bytes.Flags1 = 0x92; + pGdt[12].HighWord.Bytes.Flags2 = 0; + pGdt[12].HighWord.Bytes.BaseHi = 0; + + // + // Video buffer Selector (0x68) + // + pGdt[13].LimitLow = 0x3FFF; + pGdt[13].BaseLow = 0x8000; //FIXME: I guess not correct for UGA + pGdt[13].HighWord.Bytes.BaseMid = 0x0B; + pGdt[13].HighWord.Bytes.Flags1 = 0x92; + pGdt[13].HighWord.Bytes.Flags2 = 0; + pGdt[13].HighWord.Bytes.BaseHi = 0; + + // + // Points to GDT (0x70) + // + pGdt[14].LimitLow = NUM_GDT*sizeof(KGDTENTRY) - 1; + pGdt[14].BaseLow = 0x7000; + pGdt[14].HighWord.Bytes.BaseMid = 0xFF; + pGdt[14].HighWord.Bytes.Flags1 = 0x92; + pGdt[14].HighWord.Bytes.Flags2 = 0; + pGdt[14].HighWord.Bytes.BaseHi = 0xFF; + + // + // Some unused descriptors should go here + // ... + + // + // Fill IDT with Traps + // +#if 0 + pIdt[0].Offset = (i386DivideByZero | KSEG0_BASE) & 0xFFFF; + pIdt[0].ExtendedOffset = 0x8; // Selector + pIdt[0].Access = 0x8F00; + pIdt[0].Selector = (i386DivideByZero | KSEG0_BASE) >> 16; // Extended Offset + + pIdt[1].Offset = (i386DebugException | KSEG0_BASE) & 0xFFFF; + pIdt[1].ExtendedOffset = 0x8; // Selector + pIdt[1].Access = 0x8F00; + pIdt[1].Selector = (i386DebugException | KSEG0_BASE) >> 16; // Extended Offset + + pIdt[2].Offset = (i386NMIException | KSEG0_BASE) & 0xFFFF; + pIdt[2].ExtendedOffset = 0x8; // Selector + pIdt[2].Access = 0x8F00; + pIdt[2].Selector = (i386NMIException | KSEG0_BASE) >> 16; // Extended Offset + + pIdt[3].Offset = (i386Breakpoint | KSEG0_BASE) & 0xFFFF; + pIdt[3].ExtendedOffset = 0x8; // Selector + pIdt[3].Access = 0x8F00; + pIdt[3].Selector = (i386Breakpoint | KSEG0_BASE) >> 16; // Extended Offset + + pIdt[4].Offset = (i386Overflow | KSEG0_BASE) & 0xFFFF; + pIdt[4].ExtendedOffset = 0x8; // Selector + pIdt[4].Access = 0x8F00; + pIdt[4].Selector = (i386Overflow | KSEG0_BASE) >> 16; // Extended Offset + + pIdt[5].Selector = (i386BoundException | KSEG0_BASE) >> 16; // Extended Offset + pIdt[5].Offset = (i386BoundException | KSEG0_BASE) & 0xFFFF; + pIdt[5].ExtendedOffset = 0x8; // Selector + pIdt[5].Access = 0x8F00; + + pIdt[6].Selector = (i386InvalidOpcode | KSEG0_BASE) >> 16; // Extended Offset + pIdt[6].Offset = (i386InvalidOpcode | KSEG0_BASE) & 0xFFFF; + pIdt[6].ExtendedOffset = 0x8; // Selector + pIdt[6].Access = 0x8F00; + + pIdt[7].Selector = (i386FPUNotAvailable | KSEG0_BASE) >> 16; // Extended Offset + pIdt[7].Offset = (i386FPUNotAvailable | KSEG0_BASE) & 0xFFFF; + pIdt[7].ExtendedOffset = 0x8; // Selector + pIdt[7].Access = 0x8F00; + + pIdt[8].Selector = (i386DoubleFault | KSEG0_BASE) >> 16; // Extended Offset + pIdt[8].Offset = (i386DoubleFault | KSEG0_BASE) & 0xFFFF; + pIdt[8].ExtendedOffset = 0x8; // Selector + pIdt[8].Access = 0x8F00; + + pIdt[9].Selector = (i386CoprocessorSegment | KSEG0_BASE) >> 16; // Extended Offset + pIdt[9].Offset = (i386CoprocessorSegment | KSEG0_BASE) & 0xFFFF; + pIdt[9].ExtendedOffset = 0x8; // Selector + pIdt[9].Access = 0x8F00; + + pIdt[10].Selector = (i386InvalidTSS | KSEG0_BASE) >> 16; // Extended Offset + pIdt[10].Offset = (i386InvalidTSS | KSEG0_BASE) & 0xFFFF; + pIdt[10].ExtendedOffset = 0x8; // Selector + pIdt[10].Access = 0x8F00; + + pIdt[11].Selector = (i386SegmentNotPresent | KSEG0_BASE) >> 16; // Extended Offset + pIdt[11].Offset = (i386SegmentNotPresent | KSEG0_BASE) & 0xFFFF; + pIdt[11].ExtendedOffset = 0x8; // Selector + pIdt[11].Access = 0x8F00; + + pIdt[12].Selector = (i386StackException | KSEG0_BASE) >> 16; // Extended Offset + pIdt[12].Offset = (i386StackException | KSEG0_BASE) & 0xFFFF; + pIdt[12].ExtendedOffset = 0x8; // Selector + pIdt[12].Access = 0x8F00; + + pIdt[13].Selector = (i386GeneralProtectionFault | KSEG0_BASE) >> 16; // Extended Offset + pIdt[13].Offset = (i386GeneralProtectionFault | KSEG0_BASE) & 0xFFFF; + pIdt[13].ExtendedOffset = 0x8; // Selector + pIdt[13].Access = 0x8F00; + + pIdt[14].Selector = (i386PageFault | KSEG0_BASE) >> 16; // Extended Offset + pIdt[14].Offset = (i386PageFault | KSEG0_BASE) & 0xFFFF; + pIdt[14].ExtendedOffset = 0x8; // Selector + pIdt[14].Access = 0x8F00; + + pIdt[15].Selector = 0; // Extended Offset + pIdt[15].Offset = 0; + pIdt[15].ExtendedOffset = 0; // Selector + pIdt[15].Access = 0; + + pIdt[16].Selector = (i386CoprocessorError | KSEG0_BASE) >> 16; // Extended Offset + pIdt[16].Offset = (i386CoprocessorError | KSEG0_BASE) & 0xFFFF; + pIdt[16].ExtendedOffset = 0x8; // Selector + pIdt[16].Access = 0x8F00; + + pIdt[17].Selector = (i386AlignmentCheck | KSEG0_BASE) >> 16; // Extended Offset + pIdt[17].Offset = (i386AlignmentCheck | KSEG0_BASE) & 0xFFFF; + pIdt[17].ExtendedOffset = 0x8; // Selector + pIdt[17].Access = 0x8F00; +#endif + + /*for (i=0; i<16; i++) + { + //pIdt[i].Offset = ((ULONG_PTR)i386GeneralProtectionFault | KSEG0_BASE) & 0xFFFF; + //pIdt[i].ExtendedOffset = 0x8; // Selector + //pIdt[i].Access = 0x8F00; + //pIdt[i].Selector = ((ULONG_PTR)i386GeneralProtectionFault | KSEG0_BASE) >> 16; // Extended Offset + + pIdt[i].Offset = ((ULONG_PTR)i386GeneralProtectionFault | KSEG0_BASE) & 0xFFFF; + pIdt[i].ExtendedOffset = ((ULONG_PTR)i386GeneralProtectionFault | KSEG0_BASE) >> 16; // Extended Offset + pIdt[i].Access = 0x8F00; + pIdt[i].Selector = 0x8; + }*/ + + // Copy the old IDT + RtlCopyMemory(pIdt, (PVOID)OldIdt.Base, OldIdt.Limit); + + + // Mask interrupts + //asm("cli\n"); // they are already masked before enabling paged mode + + // Load GDT+IDT + Ke386SetGlobalDescriptorTable(GdtDesc); + Ke386SetInterruptDescriptorTable(IdtDesc); + + // Jump to proper CS and clear prefetch queue + asm("ljmp $0x08, $mb1\n" + "mb1:\n"); + + // Set SS selector + asm(".intel_syntax noprefix\n"); + asm("mov ax, 0x10\n"); // DataSelector=0x10 + asm("mov ss, ax\n"); + asm(".att_syntax\n"); + + // Set DS and ES selectors + Ke386SetDs(0x10); + Ke386SetEs(0x10); // this is vital for rep stosd + + // LDT = not used ever, thus set to 0 + Ke386SetLocalDescriptorTable(Ldt); + + // Load TSR + Ke386SetTr(0x28); + + // Clear GS + asm(".intel_syntax noprefix\n"); + asm("push 0\n"); + asm("pop gs\n"); + asm(".att_syntax\n"); + + // Set FS to PCR + Ke386SetFs(0x30); + + // Real end of the function, just for information + /* do not uncomment! + pop edi; + pop esi; + pop ebx; + mov esp, ebp; + pop ebp; + ret + */ +}
18 years, 2 months
1
0
0
0
[cwittich] 24404: -support debugging of control panel applets
by cwittich@svn.reactos.org
Author: cwittich Date: Thu Oct 5 01:47:43 2006 New Revision: 24404 URL:
http://svn.reactos.org/svn/reactos?rev=24404&view=rev
Log: -support debugging of control panel applets Modified: trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Modified: trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
============================================================================== --- trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp Thu Oct 5 01:47:43 2006 @@ -384,6 +384,15 @@ remove ( SuoFileName ( module ).c_str () ); remove ( VcprojFileName ( module ).c_str () ); + string username = getenv ( "USERNAME" ); + string computername = getenv ( "COMPUTERNAME" ); + string vcproj_file_user = ""; + + if ((computername != "") && (username != "")) + vcproj_file_user = VcprojFileName ( module ) + "." + computername + "." + username + ".user"; + + remove ( vcproj_file_user.c_str () ); + _get_object_files ( module, out ); for ( size_t j = 0; j < out.size (); j++) { Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/…
============================================================================== --- trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Thu Oct 5 01:47:43 2006 @@ -70,6 +70,14 @@ size_t i; string vcproj_file = VcprojFileName(module); + + string username = getenv ( "USERNAME" ); + string computername = getenv ( "COMPUTERNAME" ); + string vcproj_file_user = ""; + + if ((computername != "") && (username != "")) + vcproj_file_user = vcproj_file + "." + computername + "." + username + ".user"; + printf ( "Creating
MSVC.NET
project: '%s'\n", vcproj_file.c_str() ); FILE* OUT = fopen ( vcproj_file.c_str(), "wb" ); @@ -616,7 +624,57 @@ fprintf ( OUT, "\t<Globals>\r\n" ); fprintf ( OUT, "\t</Globals>\r\n" ); fprintf ( OUT, "</VisualStudioProject>\r\n" ); - fclose(OUT); + fclose ( OUT ); + + /* User configuration file */ + if (vcproj_file_user != "") + { + OUT = fopen ( vcproj_file_user.c_str(), "wb" ); + fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" ); + fprintf ( OUT, "<VisualStudioUserFile\r\n" ); + fprintf ( OUT, "\tProjectType=\"Visual C++\"\r\n" ); + fprintf ( OUT, "\tVersion=\"%s\"\r\n", configuration.VSProjectVersion.c_str() ); + fprintf ( OUT, "\tShowAllFiles=\"false\"\r\n" ); + fprintf ( OUT, "\t>\r\n" ); + + fprintf ( OUT, "\t<Configurations>\r\n" ); + for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) + { + const MSVCConfiguration& cfg = *m_configurations[icfg]; + fprintf ( OUT, "\t\t<Configuration\r\n" ); + fprintf ( OUT, "\t\t\tName=\"%s|Win32\"\r\n", cfg.name.c_str() ); + fprintf ( OUT, "\t\t\t>\r\n" ); + fprintf ( OUT, "\t\t\t<DebugSettings\r\n" ); + fprintf ( OUT, "\t\t\t\tCommand=\"rundll32.exe\"\r\n" ); + fprintf ( OUT, "\t\t\t\tCommandArguments=\" shell32,Control_RunDLL "$(TargetPath)",@\"\r\n" ); + fprintf ( OUT, "\t\t\t\tAttach=\"false\"\r\n" ); + fprintf ( OUT, "\t\t\t\tDebuggerType=\"3\"\r\n" ); + fprintf ( OUT, "\t\t\t\tRemote=\"1\"\r\n" ); + string remote_machine = "\t\t\t\tRemoteMachine=\"" + computername + "\"\r\n"; + fprintf ( OUT, remote_machine.c_str() ); + fprintf ( OUT, "\t\t\t\tRemoteCommand=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tHttpUrl=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tPDBPath=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tSQLDebugging=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tEnvironment=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tEnvironmentMerge=\"true\"\r\n" ); + fprintf ( OUT, "\t\t\t\tDebuggerFlavor=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tMPIRunCommand=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tMPIRunArguments=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tMPIRunWorkingDirectory=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tApplicationCommand=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tApplicationArguments=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tShimCommand=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tMPIAcceptMode=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t\tMPIAcceptFilter=\"\"\r\n" ); + fprintf ( OUT, "\t\t\t/>\r\n" ); + fprintf ( OUT, "\t\t</Configuration>\r\n" ); + } + fprintf ( OUT, "\t</Configurations>\r\n" ); + fprintf ( OUT, "</VisualStudioUserFile>\r\n" ); + fclose ( OUT ); + } + } std::string @@ -754,6 +812,7 @@ Module& module = *ProjectNode.modules[i]; std::string vcproj_file = VcprojFileName ( module ); + std::string vcproj_file_user = vcproj_file + "CHRIS-NOTEBOOK.Christoph.user"; _generate_sln_project ( OUT, module, vcproj_file, sln_guid, module.guid, module.non_if_data.libraries ); } _generate_sln_footer ( OUT );
18 years, 2 months
1
0
0
0
← Newer
1
...
25
26
27
28
29
30
31
...
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