diff --git a/reactos/lib/rtl/registry.c b/reactos/lib/rtl/registry.c index 1f79d8a6104..61fb119ab4c 100644 --- a/reactos/lib/rtl/registry.c +++ b/reactos/lib/rtl/registry.c @@ -44,7 +44,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo, if (RelativeTo & RTL_REGISTRY_HANDLE) { - Status = NtDuplicateObject(NtCurrentProcess(), + Status = ZwDuplicateObject(NtCurrentProcess(), (HANDLE)Path, NtCurrentProcess(), KeyHandle, @@ -129,7 +129,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo, if (Create == TRUE) { - Status = NtCreateKey(KeyHandle, + Status = ZwCreateKey(KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes, 0, @@ -139,7 +139,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo, } else { - Status = NtOpenKey(KeyHandle, + Status = ZwOpenKey(KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes); } @@ -165,7 +165,7 @@ RtlCheckRegistryKey(IN ULONG RelativeTo, if (!NT_SUCCESS(Status)) return(Status); - NtClose(KeyHandle); + ZwClose(KeyHandle); return(STATUS_SUCCESS); } @@ -188,7 +188,7 @@ RtlCreateRegistryKey(IN ULONG RelativeTo, if (!NT_SUCCESS(Status)) return(Status); - NtClose(KeyHandle); + ZwClose(KeyHandle); return(STATUS_SUCCESS); } @@ -216,10 +216,10 @@ RtlDeleteRegistryValue(IN ULONG RelativeTo, RtlInitUnicodeString(&Name, ValueName); - Status = NtDeleteValueKey(KeyHandle, + Status = ZwDeleteValueKey(KeyHandle, &Name); - NtClose(KeyHandle); + ZwClose(KeyHandle); return(Status); } @@ -240,7 +240,7 @@ RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath) DPRINT ("RtlFormatCurrentUserKeyPath() called\n"); - Status = NtOpenThreadToken (NtCurrentThread (), + Status = ZwOpenThreadToken (NtCurrentThread (), TOKEN_READ, TRUE, &TokenHandle); @@ -248,30 +248,30 @@ RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath) { if (Status != STATUS_NO_TOKEN) { - DPRINT1 ("NtOpenThreadToken() failed (Status %lx)\n", Status); + DPRINT1 ("ZwOpenThreadToken() failed (Status %lx)\n", Status); return Status; } - Status = NtOpenProcessToken (NtCurrentProcess (), + Status = ZwOpenProcessToken (NtCurrentProcess (), TOKEN_READ, &TokenHandle); if (!NT_SUCCESS (Status)) { - DPRINT1 ("NtOpenProcessToken() failed (Status %lx)\n", Status); + DPRINT1 ("ZwOpenProcessToken() failed (Status %lx)\n", Status); return Status; } } SidBuffer = (PSID_AND_ATTRIBUTES)Buffer; - Status = NtQueryInformationToken (TokenHandle, + Status = ZwQueryInformationToken (TokenHandle, TokenUser, (PVOID)SidBuffer, 256, &Length); - NtClose (TokenHandle); + ZwClose (TokenHandle); if (!NT_SUCCESS(Status)) { - DPRINT1 ("NtQueryInformationToken() failed (Status %lx)\n", Status); + DPRINT1 ("ZwQueryInformationToken() failed (Status %lx)\n", Status); return Status; } @@ -329,7 +329,7 @@ RtlOpenCurrentUser(IN ACCESS_MASK DesiredAccess, OBJ_CASE_INSENSITIVE, NULL, NULL); - Status = NtOpenKey(KeyHandle, + Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes); RtlFreeUnicodeString(&KeyPath); @@ -346,7 +346,7 @@ RtlOpenCurrentUser(IN ACCESS_MASK DesiredAccess, OBJ_CASE_INSENSITIVE, NULL, NULL); - Status = NtOpenKey(KeyHandle, + Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes); @@ -403,7 +403,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo, if (((QueryEntry->Flags & (RTL_QUERY_REGISTRY_SUBKEY | RTL_QUERY_REGISTRY_TOPKEY)) != 0) && (BaseKeyHandle != CurrentKeyHandle)) { - NtClose(CurrentKeyHandle); + ZwClose(CurrentKeyHandle); CurrentKeyHandle = BaseKeyHandle; } @@ -418,7 +418,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo, OBJ_CASE_INSENSITIVE, BaseKeyHandle, NULL); - Status = NtOpenKey(&CurrentKeyHandle, + Status = ZwOpenKey(&CurrentKeyHandle, KEY_ALL_ACCESS, &ObjectAttributes); if (!NT_SUCCESS(Status)) @@ -439,7 +439,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo, break; } - Status = NtQueryValueKey(CurrentKeyHandle, + Status = ZwQueryValueKey(CurrentKeyHandle, &KeyName, KeyValuePartialInformation, ValueInfo, @@ -601,7 +601,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo, break; } - Status = NtQueryValueKey(CurrentKeyHandle, + Status = ZwQueryValueKey(CurrentKeyHandle, &KeyName, KeyValuePartialInformation, ValueInfo, @@ -725,7 +725,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo, Index = 0; while (TRUE) { - Status = NtEnumerateValueKey(CurrentKeyHandle, + Status = ZwEnumerateValueKey(CurrentKeyHandle, Index, KeyValueFullInformation, FullValueInfo, @@ -848,9 +848,9 @@ RtlQueryRegistryValues(IN ULONG RelativeTo, } if (CurrentKeyHandle != BaseKeyHandle) - NtClose(CurrentKeyHandle); + ZwClose(CurrentKeyHandle); - NtClose(BaseKeyHandle); + ZwClose(BaseKeyHandle); return(Status); } @@ -881,14 +881,14 @@ RtlWriteRegistryValue(IN ULONG RelativeTo, RtlInitUnicodeString(&Name, ValueName); - Status = NtSetValueKey(KeyHandle, + Status = ZwSetValueKey(KeyHandle, &Name, 0, ValueType, ValueData, ValueLength); if (NT_SUCCESS(Status)) - NtClose(KeyHandle); + ZwClose(KeyHandle); return(Status); } @@ -908,7 +908,7 @@ RtlpNtCreateKey(OUT HANDLE KeyHandle, if (ObjectAttributes != NULL) ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); - return(NtCreateKey(KeyHandle, + return(ZwCreateKey(KeyHandle, DesiredAccess, ObjectAttributes, 0, @@ -941,7 +941,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle, return(STATUS_NO_MEMORY); } - Status = NtEnumerateKey(KeyHandle, + Status = ZwEnumerateKey(KeyHandle, Index, KeyBasicInformation, KeyInfo, @@ -978,7 +978,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle, NTSTATUS STDCALL RtlpNtMakeTemporaryKey(IN HANDLE KeyHandle) { - return(NtDeleteKey(KeyHandle)); + return(ZwDeleteKey(KeyHandle)); } @@ -994,7 +994,7 @@ RtlpNtOpenKey(OUT HANDLE KeyHandle, if (ObjectAttributes != NULL) ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); - return(NtOpenKey(KeyHandle, + return(ZwOpenKey(KeyHandle, DesiredAccess, ObjectAttributes)); } @@ -1027,7 +1027,7 @@ RtlpNtQueryValueKey(IN HANDLE KeyHandle, if (ValueInfo == NULL) return(STATUS_NO_MEMORY); - Status = NtQueryValueKey(KeyHandle, + Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, ValueInfo, @@ -1068,7 +1068,7 @@ RtlpNtSetValueKey(IN HANDLE KeyHandle, RtlInitUnicodeString(&ValueName, NULL); - return(NtSetValueKey(KeyHandle, + return(ZwSetValueKey(KeyHandle, &ValueName, 0, Type, diff --git a/reactos/ntoskrnl/ex/event.c b/reactos/ntoskrnl/ex/event.c index 2daf1249af4..840e339974d 100644 --- a/reactos/ntoskrnl/ex/event.c +++ b/reactos/ntoskrnl/ex/event.c @@ -124,58 +124,77 @@ NtCreateEvent(OUT PHANDLE EventHandle, IN EVENT_TYPE EventType, IN BOOLEAN InitialState) { +/* + * @implemented + */ +NTSTATUS STDCALL +NtCreateEvent(OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN EVENT_TYPE EventType, + IN BOOLEAN InitialState) +{ + KPROCESSOR_MODE PreviousMode; PKEVENT Event; HANDLE hEvent; - NTSTATUS Status; - OBJECT_ATTRIBUTES SafeObjectAttributes; - - if (ObjectAttributes != NULL) + NTSTATUS Status = STATUS_SUCCESS; + + PreviousMode = ExGetPreviousMode(); + + if(PreviousMode == UserMode) + { + _SEH_TRY { - Status = MmCopyFromCaller(&SafeObjectAttributes, ObjectAttributes, - sizeof(OBJECT_ATTRIBUTES)); - if (!NT_SUCCESS(Status)) - { - return(Status); - } - ObjectAttributes = &SafeObjectAttributes; + ProbeForWrite(EventHandle, + sizeof(HANDLE), + sizeof(ULONG)); } - - Status = ObCreateObject(ExGetPreviousMode(), - ExEventObjectType, - ObjectAttributes, - ExGetPreviousMode(), - NULL, - sizeof(KEVENT), - 0, - 0, - (PVOID*)&Event); - if (!NT_SUCCESS(Status)) + _SEH_HANDLE { - return(Status); + Status = _SEH_GetExceptionCode(); } - KeInitializeEvent(Event, - EventType, - InitialState); - - Status = ObInsertObject ((PVOID)Event, - NULL, - DesiredAccess, - 0, - NULL, - &hEvent); - ObDereferenceObject(Event); - if (!NT_SUCCESS(Status)) + _SEH_END; + } + + Status = ObCreateObject(PreviousMode, + ExEventObjectType, + ObjectAttributes, + PreviousMode, + NULL, + sizeof(KEVENT), + 0, + 0, + (PVOID*)&Event); + if(NT_SUCCESS(Status)) + { + KeInitializeEvent(Event, + EventType, + InitialState); + + + Status = ObInsertObject((PVOID)Event, + NULL, + DesiredAccess, + 0, + NULL, + &hEvent); + ObDereferenceObject(Event); + + if(NT_SUCCESS(Status)) { - return Status; + _SEH_TRY + { + *EventHandle = hEvent; + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; } - - Status = MmCopyToCaller(EventHandle, &hEvent, sizeof(HANDLE)); - if (!NT_SUCCESS(Status)) - { - ZwClose(hEvent); - return(Status); - } - return(STATUS_SUCCESS); + } + + return Status; } diff --git a/reactos/ntoskrnl/ke/i386/syscall.S b/reactos/ntoskrnl/ke/i386/syscall.S index 2ad8a1e942d..7fe46716de2 100644 --- a/reactos/ntoskrnl/ke/i386/syscall.S +++ b/reactos/ntoskrnl/ke/i386/syscall.S @@ -70,7 +70,7 @@ _KiSystemService: movw %bx, %fs /* Save the previous exception list */ - pushl %fs:KPCR_EXCEPTION_LIST // + 0x2C + pushl %fs:KPCR_EXCEPTION_LIST // + 0x2C /* Set the exception handler chain terminator */ movl $0xffffffff, %fs:KPCR_EXCEPTION_LIST @@ -79,11 +79,11 @@ _KiSystemService: movl %fs:KPCR_CURRENT_THREAD, %esi /* Save the old previous mode */ - pushl %ss:KTHREAD_PREVIOUS_MODE(%esi) // + 0x30 + pushl %ss:KTHREAD_PREVIOUS_MODE(%esi) // + 0x30 /* Set the new previous mode based on the saved CS selector */ movl 0x24(%esp), %ebx - and $1, %ebx + andl $1, %ebx movb %bl, %ss:KTHREAD_PREVIOUS_MODE(%esi) /* Save other registers */ @@ -95,20 +95,14 @@ _KiSystemService: pushl %gs // + 0x48 sub $0x28, %esp // + 0x70 -#if 0 #ifdef DBG /* Trick gdb 6 into backtracing over the system call */ - /* FIXME: %ebp is *never* initialized */ pushl 4(%ebp) /* DebugEIP */ // + 0x74 pushl (%ebp) /* DebugEBP */ // + 0x78 #else pushl 0x60(%esp) /* DebugEIP */ // + 0x74 pushl %ebp /* DebugEBP */ // + 0x78 #endif -#else - pushl $0 /* DebugEIP */ // + 0x74 - pushl $0 /* DebugEBP */ // + 0x78 -#endif /* Load the segment registers */ sti @@ -320,7 +314,6 @@ KiBBTUnexpectedRange: InvalidCall: /* Invalid System Call */ - int $3 movl $STATUS_INVALID_SYSTEM_SERVICE, %eax movl %eax, KTRAP_FRAME_EAX(%ebp) jmp _KiServiceExit diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 597e3faf901..c0f7a41b3a4 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -307,7 +307,7 @@ LdrLoadModule(PUNICODE_STRING Filename, NULL, NULL); CHECKPOINT; - Status = NtOpenFile(&FileHandle, + Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &ObjectAttributes, &IoStatusBlock, @@ -322,7 +322,7 @@ LdrLoadModule(PUNICODE_STRING Filename, CHECKPOINT; /* Get the size of the file */ - Status = NtQueryInformationFile(FileHandle, + Status = ZwQueryInformationFile(FileHandle, &IoStatusBlock, &FileStdInfo, sizeof(FileStdInfo), @@ -348,7 +348,7 @@ LdrLoadModule(PUNICODE_STRING Filename, CHECKPOINT; /* Load driver into memory chunk */ - Status = NtReadFile(FileHandle, + Status = ZwReadFile(FileHandle, 0, 0, 0, &IoStatusBlock, ModuleLoadBase, @@ -363,7 +363,7 @@ LdrLoadModule(PUNICODE_STRING Filename, } CHECKPOINT; - NtClose(FileHandle); + ZwClose(FileHandle); Status = LdrProcessModule(ModuleLoadBase, Filename, diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 7630e1ae169..aa9bf1e60bb 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -601,7 +601,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL, ASSERT_IRQL(APC_LEVEL); - if(AccessMode == UserMode && ObjectAttributes != NULL) + if(ObjectAttributesAccessMode == UserMode && ObjectAttributes != NULL) { Status = STATUS_SUCCESS; _SEH_TRY diff --git a/reactos/ntoskrnl/se/token.c b/reactos/ntoskrnl/se/token.c index b8ddffbc10d..2205748bf8d 100644 --- a/reactos/ntoskrnl/se/token.c +++ b/reactos/ntoskrnl/se/token.c @@ -1579,7 +1579,6 @@ NtCreateToken(OUT PHANDLE UnsafeTokenHandle, HANDLE TokenHandle; PTOKEN AccessToken; NTSTATUS Status; - OBJECT_ATTRIBUTES SafeObjectAttributes; POBJECT_ATTRIBUTES ObjectAttributes; LUID TokenId; LUID ModifiedId; @@ -1587,14 +1586,6 @@ NtCreateToken(OUT PHANDLE UnsafeTokenHandle, ULONG uLength; ULONG i; - Status = MmCopyFromCaller(&SafeObjectAttributes, - UnsafeObjectAttributes, - sizeof(OBJECT_ATTRIBUTES)); - if (!NT_SUCCESS(Status)) - return(Status); - - ObjectAttributes = &SafeObjectAttributes; - Status = ZwAllocateLocallyUniqueId(&TokenId); if (!NT_SUCCESS(Status)) return(Status); diff --git a/reactos/subsys/system/userinit/userinit.c b/reactos/subsys/system/userinit/userinit.c index 2e7bfd1f9b1..ecbcf96456e 100644 --- a/reactos/subsys/system/userinit/userinit.c +++ b/reactos/subsys/system/userinit/userinit.c @@ -143,6 +143,7 @@ WinMain(HINSTANCE hInst, LPSTR lpszCmdLine, int nCmdShow) { + DPRINT1("Hello\n"); SetUserSettings(); StartShell(); return 0; diff --git a/reactos/subsys/win32k/ntuser/desktop.c b/reactos/subsys/win32k/ntuser/desktop.c index 57e595fbc79..2de3f2369f4 100644 --- a/reactos/subsys/win32k/ntuser/desktop.c +++ b/reactos/subsys/win32k/ntuser/desktop.c @@ -596,7 +596,7 @@ NtUserCreateDesktop( */ Status = ObCreateObject( - ExGetPreviousMode(), + KernelMode, ExDesktopObjectType, &ObjectAttributes, ExGetPreviousMode(), diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index 8b25ed4fb46..8d87948e2b6 100644 --- a/reactos/subsys/win32k/ntuser/winsta.c +++ b/reactos/subsys/win32k/ntuser/winsta.c @@ -324,7 +324,7 @@ NtUserCreateWindowStation( DPRINT("Creating window station (%wZ)\n", &WindowStationName); Status = ObCreateObject( - ExGetPreviousMode(), + KernelMode, ExWindowStationObjectType, &ObjectAttributes, ExGetPreviousMode(), @@ -336,7 +336,7 @@ NtUserCreateWindowStation( if (!NT_SUCCESS(Status)) { - DPRINT("Failed creating window station (%wZ)\n", &WindowStationName); + DPRINT1("Failed creating window station (%wZ)\n", &WindowStationName); ExFreePool(WindowStationName.Buffer); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; diff --git a/reactos/tools/helper.mk b/reactos/tools/helper.mk index ca0e8d48b64..34fc17fa129 100644 --- a/reactos/tools/helper.mk +++ b/reactos/tools/helper.mk @@ -618,8 +618,10 @@ endif # if needed, until their problems can be found # ifeq ($(OPTIMIZED), 1) - MK_CFLAGS += -O2 -Wno-strict-aliasing - MK_CPPFLAGS += -O2 -Wno-strict-aliasing + ifneq ($(TARGET_NAME), bootvid) + MK_CFLAGS += -O2 -Wno-strict-aliasing + MK_CPPFLAGS += -O2 -Wno-strict-aliasing + endif endif ifneq ($(TARGET_LIBS),)