From b4cd06102513560a89cd2508fa9fad21933d3fc6 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 15 Aug 2000 12:44:47 +0000 Subject: [PATCH] Improved shared user page Initialized windows and system directories svn path=/trunk/; revision=1301 --- reactos/include/ddk/ketypes.h | 7 ++++++ reactos/include/kernel32/kernel32.h | 13 +++------- reactos/include/napi/shared_data.h | 39 ++++++++++++++++++++++++++++- reactos/include/napi/types.h | 6 +++++ reactos/include/ntdll/rtl.h | 4 +-- reactos/lib/kernel32/file/curdir.c | 3 +-- reactos/lib/kernel32/misc/dllmain.c | 30 +++++++++++++++++++--- reactos/lib/kernel32/misc/error.c | 18 ++----------- reactos/lib/ntdll/def/ntdll.def | 5 +++- reactos/lib/ntdll/def/ntdll.edf | 6 ++++- reactos/lib/ntdll/rtl/misc.c | 18 +++---------- reactos/ntoskrnl/ke/main.c | 10 +++++++- 12 files changed, 108 insertions(+), 51 deletions(-) diff --git a/reactos/include/ddk/ketypes.h b/reactos/include/ddk/ketypes.h index b20868f872a..42da152572c 100644 --- a/reactos/include/ddk/ketypes.h +++ b/reactos/include/ddk/ketypes.h @@ -255,4 +255,11 @@ typedef struct _KINTERRUPT KIRQL SynchLevel; } KINTERRUPT, *PKINTERRUPT; +typedef struct _KSYSTEM_TIME +{ + ULONG LowPart; + LONG High1Part; + LONG High2Part; +} KSYSTEM_TIME, *PKSYSTEM_TIME; + #endif /* __INCLUDE_DDK_KETYPES_H */ diff --git a/reactos/include/kernel32/kernel32.h b/reactos/include/kernel32/kernel32.h index 770dbf3ef14..599ae781852 100644 --- a/reactos/include/kernel32/kernel32.h +++ b/reactos/include/kernel32/kernel32.h @@ -6,14 +6,15 @@ #define UNIMPLEMENTED DbgPrint("%s at %s:%d is unimplemented\n",__FUNCTION__,__FILE__,__LINE__); #ifdef NDEBUG -#define DPRINT(args...) +#define DPRINT(args...) #define CHECKPOINT #else #define DPRINT(args...) do { DbgPrint("(KERNEL32:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); #define CHECKPOINT do { DbgPrint("(KERNEL32:%s:%d) Checkpoint\n",__FILE__,__LINE__); } while(0); #endif -#define DPRINT1(args...) do { DbgPrint("(KERNEL32:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); +#define DPRINT1(args...) do { DbgPrint("(KERNEL32:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); +#define CHECKPOINT1 do { DbgPrint("(KERNEL32:%s:%d) Checkpoint\n",__FILE__,__LINE__); } while(0); #define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24)) @@ -34,14 +35,6 @@ extern WINBOOL bIsFileApiAnsi; /* FUNCTION PROTOTYPES ********************************************************/ -BOOL __ErrorReturnFalse(ULONG ErrorCode); -PVOID __ErrorReturnNull(ULONG ErrorCode); - -BOOL KERNEL32_AnsiToUnicode(PWSTR DestStr, - LPCSTR SrcStr, - ULONG MaxLen); -PWSTR InternalAnsiToUnicode(PWSTR Out, LPCSTR In, ULONG MaxLength); - BOOLEAN STDCALL IsConsoleHandle(HANDLE Handle); WINBOOL STDCALL CloseConsoleHandle(HANDLE Handle); diff --git a/reactos/include/napi/shared_data.h b/reactos/include/napi/shared_data.h index 5bdace3734e..e1f1a03d7a4 100644 --- a/reactos/include/napi/shared_data.h +++ b/reactos/include/napi/shared_data.h @@ -1,10 +1,47 @@ #ifndef __INCLUDE_NAPI_SHARED_DATA_H #define __INCLUDE_NAPI_SHARED_DATA_H +#define PROCESSOR_FEATURES_MAX 64 + +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE +{ + StandardDesign, + NEC98x86, + EndAlternatives +} ALTERNATIVE_ARCHITECTURE_TYPE; + + typedef struct _KUSER_SHARED_DATA { - ULONG TickCountLow; + volatile ULONG TickCountLow; ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG DosDeviceMap; + ULONG CryptoExponent; + ULONG TimeZoneId; + UCHAR DosDeviceDriveType[32]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURES_MAX]; + + // NT5 / Win2k specific ?? + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG SuiteMask; +#ifdef REMOTE_BOOT + ULONG SystemFlags; + UCHAR RemoteBootServerPath[260]; +#endif + BOOLEAN KdDebuggerEnabled; } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; #define KERNEL_SHARED_DATA_BASE (0xFFDF0000) diff --git a/reactos/include/napi/types.h b/reactos/include/napi/types.h index aa4d58e76d1..93f2651c059 100644 --- a/reactos/include/napi/types.h +++ b/reactos/include/napi/types.h @@ -39,6 +39,12 @@ typedef enum _SECTION_INHERIT { ViewUnmap = 2 } SECTION_INHERIT; +typedef enum _NT_PRODUCT_TYPE +{ + NtProductWinNt = 1, + NtProductLanManNt, + NtProductServer +} NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE; /* File information for IRP_MJ_QUERY_INFORMATION (and SET) */ typedef enum _FILE_INFORMATION_CLASS diff --git a/reactos/include/ntdll/rtl.h b/reactos/include/ntdll/rtl.h index 95c47d89830..035b23b4c1a 100644 --- a/reactos/include/ntdll/rtl.h +++ b/reactos/include/ntdll/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.18 2000/08/11 12:30:18 ekohl Exp $ +/* $Id: rtl.h,v 1.19 2000/08/15 12:37:46 ekohl Exp $ * */ @@ -176,7 +176,7 @@ RtlGetLongestNtPathLength ( ULONG STDCALL RtlGetNtGlobalFlags(VOID); -BOOLEAN STDCALL RtlGetNtProductType(PULONG ProductType); +BOOLEAN STDCALL RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType); ULONG STDCALL diff --git a/reactos/lib/kernel32/file/curdir.c b/reactos/lib/kernel32/file/curdir.c index 34e94d4772c..f44761cfc9e 100644 --- a/reactos/lib/kernel32/file/curdir.c +++ b/reactos/lib/kernel32/file/curdir.c @@ -1,4 +1,4 @@ -/* $Id: curdir.c,v 1.25 2000/06/03 14:47:31 ea Exp $ +/* $Id: curdir.c,v 1.26 2000/08/15 12:38:26 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -22,7 +22,6 @@ /* GLOBAL VARIABLES **********************************************************/ -/* FIXME initialize them on startup !! */ UNICODE_STRING SystemDirectory; UNICODE_STRING WindowsDirectory; diff --git a/reactos/lib/kernel32/misc/dllmain.c b/reactos/lib/kernel32/misc/dllmain.c index ee5e9a747bd..5cb1c67cc72 100644 --- a/reactos/lib/kernel32/misc/dllmain.c +++ b/reactos/lib/kernel32/misc/dllmain.c @@ -1,4 +1,4 @@ -/* $Id: dllmain.c,v 1.12 2000/07/06 14:34:48 dwelch Exp $ +/* $Id: dllmain.c,v 1.13 2000/08/15 12:39:18 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -11,23 +11,29 @@ #include #include +#include #include #include #define NDEBUG #include + +extern UNICODE_STRING SystemDirectory; +extern UNICODE_STRING WindowsDirectory; + + WINBOOL STDCALL DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved); - BOOL WINAPI DllMainCRTStartup(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) { return(DllMain(hDll,dwReason,lpReserved)); } + WINBOOL STDCALL DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) @@ -40,7 +46,9 @@ WINBOOL STDCALL DllMain(HANDLE hInst, case DLL_PROCESS_ATTACH: { NTSTATUS Status; - + PKUSER_SHARED_DATA SharedUserData = + (PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE; + DPRINT("DLL_PROCESS_ATTACH\n"); /* * Connect to the csrss server @@ -51,6 +59,22 @@ WINBOOL STDCALL DllMain(HANDLE hInst, DbgPrint("Failed to connect to csrss.exe: expect trouble\n"); // ZwTerminateProcess(NtCurrentProcess(), Status); } + + /* + * Initialize WindowsDirectory and SystemDirectory + */ + DPRINT("NtSystemRoot: %S\n", + SharedUserData->NtSystemRoot); + RtlCreateUnicodeString (&WindowsDirectory, + SharedUserData->NtSystemRoot); + SystemDirectory.MaximumLength = WindowsDirectory.MaximumLength + 18; + SystemDirectory.Length = WindowsDirectory.Length + 18; + SystemDirectory.Buffer = RtlAllocateHeap (RtlGetProcessHeap (), + 0, + SystemDirectory.MaximumLength); + wcscpy (SystemDirectory.Buffer, WindowsDirectory.Buffer); + wcscat (SystemDirectory.Buffer, L"\\System32"); + break; } case DLL_PROCESS_DETACH: diff --git a/reactos/lib/kernel32/misc/error.c b/reactos/lib/kernel32/misc/error.c index fbcef317006..03ae3b0a702 100644 --- a/reactos/lib/kernel32/misc/error.c +++ b/reactos/lib/kernel32/misc/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.13 2000/04/25 23:22:53 ea Exp $ +/* $Id: error.c,v 1.14 2000/08/15 12:39:18 ekohl Exp $ * * reactos/lib/kernel32/misc/error.c * @@ -18,7 +18,7 @@ SetLastErrorByStatus ( NTSTATUS Status ) { - DWORD Error = RtlNtStatusToDosError (Status); + DWORD Error = RtlNtStatusToDosError (Status); SetLastError (Error); return (Error); } @@ -41,20 +41,6 @@ GetLastError (VOID) } -BOOL -__ErrorReturnFalse (ULONG ErrorCode) -{ - return(FALSE); -} - - -PVOID -__ErrorReturnNull (ULONG ErrorCode) -{ - return(NULL); -} - - WINBOOL STDCALL Beep (DWORD dwFreq, DWORD dwDuration) diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 9658d233aff..1e6ccc3d163 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.60 2000/08/11 17:30:20 ea Exp $ +; $Id: ntdll.def,v 1.61 2000/08/15 12:40:19 ekohl Exp $ ; ; ReactOS Operating System ; @@ -266,6 +266,8 @@ NtYieldExecution@0 ;PfxInitialize ;PfxInsertPrefix ;PfxRemovePrefix +;PropertyLengthAsVariant +;RestoreEm87Context ;RtlAbortRXact RtlAbsoluteToSelfRelativeSD@12 RtlAcquirePebLock@0 @@ -602,6 +604,7 @@ RtlxAnsiStringToUnicodeSize@4 RtlxOemStringToUnicodeSize@4 RtlxUnicodeStringToAnsiSize@4 RtlxUnicodeStringToOemSize@4 +;SaveEm87Context ZwAcceptConnectPort@24 ZwAccessCheck@32 ZwAccessCheckAndAuditAlarm@44 diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index 96f059520cf..92454aecc17 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,4 +1,4 @@ -; $Id: ntdll.edf,v 1.49 2000/08/11 17:30:20 ea Exp $ +; $Id: ntdll.edf,v 1.50 2000/08/15 12:40:19 ekohl Exp $ ; ; ReactOS Operating System ; @@ -48,6 +48,7 @@ LdrLoadDll ;LdrShutdownProcess ;LdrShutdownThread LdrUnloadDll +;LdrVerifyImageMatchesChecksum NlsAnsiCodePage DATA NlsMbCodePageTag DATA NlsMbOemCodePageTag DATA @@ -265,6 +266,8 @@ NtYieldExecution=NtYieldExecution@0 ;PfxInitialize ;PfxInsertPrefix ;PfxRemovePrefix +;PropertyLengthAsVariant +;RestoreEm87Context ;RtlAbortRXact RtlAbsoluteToSelfRelativeSD=RtlAbsoluteToSelfRelativeSD@12 RtlAcquirePebLock=RtlAcquirePebLock@0 @@ -600,6 +603,7 @@ RtlxAnsiStringToUnicodeSize=RtlxAnsiStringToUnicodeSize@4 RtlxOemStringToUnicodeSize=RtlxOemStringToUnicodeSize@4 RtlxUnicodeStringToAnsiSize=RtlxUnicodeStringToAnsiSize@4 RtlxUnicodeStringToOemSize=RtlxUnicodeStringToOemSize@4 +;SaveEm87Context ZwAcceptConnectPort=ZwAcceptConnectPort@24 ZwAccessCheck=ZwAccessCheck@32 ZwAccessCheckAndAuditAlarm=ZwAccessCheckAndAuditAlarm@44 diff --git a/reactos/lib/ntdll/rtl/misc.c b/reactos/lib/ntdll/rtl/misc.c index 3cff8d17f2a..a76a1aa06a2 100644 --- a/reactos/lib/ntdll/rtl/misc.c +++ b/reactos/lib/ntdll/rtl/misc.c @@ -1,4 +1,4 @@ -/* $Id: misc.c,v 1.1 2000/08/11 12:35:47 ekohl Exp $ +/* $Id: misc.c,v 1.2 2000/08/15 12:41:13 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,11 +13,11 @@ #include #include +#include /* GLOBALS ******************************************************************/ extern ULONG NtGlobalFlag; -static ULONG NtProductType = 0; /* FUNCTIONS ****************************************************************/ @@ -69,19 +69,9 @@ RtlGetNtGlobalFlags(VOID) */ BOOLEAN STDCALL -RtlGetNtProductType(PULONG ProductType) +RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType) { - if (NtProductType != 0) - { - *ProductType = NtProductType; - return TRUE; - } - - /* FIXME: read product type from registry */ - NtProductType = 1; /* Workstation */ - - *ProductType = NtProductType; - + *ProductType = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->NtProductType; return TRUE; } diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 5543de007a8..45595aafe50 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.56 2000/07/30 18:22:34 dwelch Exp $ +/* $Id: main.c,v 1.57 2000/08/15 12:44:47 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -26,6 +26,7 @@ #include #include +#include //#define NDEBUG #include @@ -186,6 +187,13 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock) NULL, NULL); + /* set system root in shared user page */ + wcscpy (((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtSystemRoot, + L"C:\\reactos"); + + ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtProductType = NtProductWinNt; + + /* * Launch initial process */