First patch to fix seriously broken ROS (thank Thomas). Work in progress, will be cleaned up at the end

svn path=/trunk/; revision=13199
This commit is contained in:
Alex Ionescu 2005-01-21 23:35:19 +00:00
parent 1b5ef0524f
commit 686128e903
10 changed files with 110 additions and 104 deletions

View file

@ -44,7 +44,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
if (RelativeTo & RTL_REGISTRY_HANDLE) if (RelativeTo & RTL_REGISTRY_HANDLE)
{ {
Status = NtDuplicateObject(NtCurrentProcess(), Status = ZwDuplicateObject(NtCurrentProcess(),
(HANDLE)Path, (HANDLE)Path,
NtCurrentProcess(), NtCurrentProcess(),
KeyHandle, KeyHandle,
@ -129,7 +129,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
if (Create == TRUE) if (Create == TRUE)
{ {
Status = NtCreateKey(KeyHandle, Status = ZwCreateKey(KeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&ObjectAttributes, &ObjectAttributes,
0, 0,
@ -139,7 +139,7 @@ RtlpGetRegistryHandle(ULONG RelativeTo,
} }
else else
{ {
Status = NtOpenKey(KeyHandle, Status = ZwOpenKey(KeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&ObjectAttributes); &ObjectAttributes);
} }
@ -165,7 +165,7 @@ RtlCheckRegistryKey(IN ULONG RelativeTo,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return(Status); return(Status);
NtClose(KeyHandle); ZwClose(KeyHandle);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -188,7 +188,7 @@ RtlCreateRegistryKey(IN ULONG RelativeTo,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return(Status); return(Status);
NtClose(KeyHandle); ZwClose(KeyHandle);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -216,10 +216,10 @@ RtlDeleteRegistryValue(IN ULONG RelativeTo,
RtlInitUnicodeString(&Name, RtlInitUnicodeString(&Name,
ValueName); ValueName);
Status = NtDeleteValueKey(KeyHandle, Status = ZwDeleteValueKey(KeyHandle,
&Name); &Name);
NtClose(KeyHandle); ZwClose(KeyHandle);
return(Status); return(Status);
} }
@ -240,7 +240,7 @@ RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath)
DPRINT ("RtlFormatCurrentUserKeyPath() called\n"); DPRINT ("RtlFormatCurrentUserKeyPath() called\n");
Status = NtOpenThreadToken (NtCurrentThread (), Status = ZwOpenThreadToken (NtCurrentThread (),
TOKEN_READ, TOKEN_READ,
TRUE, TRUE,
&TokenHandle); &TokenHandle);
@ -248,30 +248,30 @@ RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath)
{ {
if (Status != STATUS_NO_TOKEN) if (Status != STATUS_NO_TOKEN)
{ {
DPRINT1 ("NtOpenThreadToken() failed (Status %lx)\n", Status); DPRINT1 ("ZwOpenThreadToken() failed (Status %lx)\n", Status);
return Status; return Status;
} }
Status = NtOpenProcessToken (NtCurrentProcess (), Status = ZwOpenProcessToken (NtCurrentProcess (),
TOKEN_READ, TOKEN_READ,
&TokenHandle); &TokenHandle);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT1 ("NtOpenProcessToken() failed (Status %lx)\n", Status); DPRINT1 ("ZwOpenProcessToken() failed (Status %lx)\n", Status);
return Status; return Status;
} }
} }
SidBuffer = (PSID_AND_ATTRIBUTES)Buffer; SidBuffer = (PSID_AND_ATTRIBUTES)Buffer;
Status = NtQueryInformationToken (TokenHandle, Status = ZwQueryInformationToken (TokenHandle,
TokenUser, TokenUser,
(PVOID)SidBuffer, (PVOID)SidBuffer,
256, 256,
&Length); &Length);
NtClose (TokenHandle); ZwClose (TokenHandle);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1 ("NtQueryInformationToken() failed (Status %lx)\n", Status); DPRINT1 ("ZwQueryInformationToken() failed (Status %lx)\n", Status);
return Status; return Status;
} }
@ -329,7 +329,7 @@ RtlOpenCurrentUser(IN ACCESS_MASK DesiredAccess,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,
NULL, NULL,
NULL); NULL);
Status = NtOpenKey(KeyHandle, Status = ZwOpenKey(KeyHandle,
DesiredAccess, DesiredAccess,
&ObjectAttributes); &ObjectAttributes);
RtlFreeUnicodeString(&KeyPath); RtlFreeUnicodeString(&KeyPath);
@ -346,7 +346,7 @@ RtlOpenCurrentUser(IN ACCESS_MASK DesiredAccess,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,
NULL, NULL,
NULL); NULL);
Status = NtOpenKey(KeyHandle, Status = ZwOpenKey(KeyHandle,
DesiredAccess, DesiredAccess,
&ObjectAttributes); &ObjectAttributes);
@ -403,7 +403,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
if (((QueryEntry->Flags & (RTL_QUERY_REGISTRY_SUBKEY | RTL_QUERY_REGISTRY_TOPKEY)) != 0) && if (((QueryEntry->Flags & (RTL_QUERY_REGISTRY_SUBKEY | RTL_QUERY_REGISTRY_TOPKEY)) != 0) &&
(BaseKeyHandle != CurrentKeyHandle)) (BaseKeyHandle != CurrentKeyHandle))
{ {
NtClose(CurrentKeyHandle); ZwClose(CurrentKeyHandle);
CurrentKeyHandle = BaseKeyHandle; CurrentKeyHandle = BaseKeyHandle;
} }
@ -418,7 +418,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
OBJ_CASE_INSENSITIVE, OBJ_CASE_INSENSITIVE,
BaseKeyHandle, BaseKeyHandle,
NULL); NULL);
Status = NtOpenKey(&CurrentKeyHandle, Status = ZwOpenKey(&CurrentKeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&ObjectAttributes); &ObjectAttributes);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -439,7 +439,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
break; break;
} }
Status = NtQueryValueKey(CurrentKeyHandle, Status = ZwQueryValueKey(CurrentKeyHandle,
&KeyName, &KeyName,
KeyValuePartialInformation, KeyValuePartialInformation,
ValueInfo, ValueInfo,
@ -601,7 +601,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
break; break;
} }
Status = NtQueryValueKey(CurrentKeyHandle, Status = ZwQueryValueKey(CurrentKeyHandle,
&KeyName, &KeyName,
KeyValuePartialInformation, KeyValuePartialInformation,
ValueInfo, ValueInfo,
@ -725,7 +725,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
Index = 0; Index = 0;
while (TRUE) while (TRUE)
{ {
Status = NtEnumerateValueKey(CurrentKeyHandle, Status = ZwEnumerateValueKey(CurrentKeyHandle,
Index, Index,
KeyValueFullInformation, KeyValueFullInformation,
FullValueInfo, FullValueInfo,
@ -848,9 +848,9 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
} }
if (CurrentKeyHandle != BaseKeyHandle) if (CurrentKeyHandle != BaseKeyHandle)
NtClose(CurrentKeyHandle); ZwClose(CurrentKeyHandle);
NtClose(BaseKeyHandle); ZwClose(BaseKeyHandle);
return(Status); return(Status);
} }
@ -881,14 +881,14 @@ RtlWriteRegistryValue(IN ULONG RelativeTo,
RtlInitUnicodeString(&Name, RtlInitUnicodeString(&Name,
ValueName); ValueName);
Status = NtSetValueKey(KeyHandle, Status = ZwSetValueKey(KeyHandle,
&Name, &Name,
0, 0,
ValueType, ValueType,
ValueData, ValueData,
ValueLength); ValueLength);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
NtClose(KeyHandle); ZwClose(KeyHandle);
return(Status); return(Status);
} }
@ -908,7 +908,7 @@ RtlpNtCreateKey(OUT HANDLE KeyHandle,
if (ObjectAttributes != NULL) if (ObjectAttributes != NULL)
ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE);
return(NtCreateKey(KeyHandle, return(ZwCreateKey(KeyHandle,
DesiredAccess, DesiredAccess,
ObjectAttributes, ObjectAttributes,
0, 0,
@ -941,7 +941,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
Status = NtEnumerateKey(KeyHandle, Status = ZwEnumerateKey(KeyHandle,
Index, Index,
KeyBasicInformation, KeyBasicInformation,
KeyInfo, KeyInfo,
@ -978,7 +978,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
NTSTATUS STDCALL NTSTATUS STDCALL
RtlpNtMakeTemporaryKey(IN HANDLE KeyHandle) RtlpNtMakeTemporaryKey(IN HANDLE KeyHandle)
{ {
return(NtDeleteKey(KeyHandle)); return(ZwDeleteKey(KeyHandle));
} }
@ -994,7 +994,7 @@ RtlpNtOpenKey(OUT HANDLE KeyHandle,
if (ObjectAttributes != NULL) if (ObjectAttributes != NULL)
ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE); ObjectAttributes->Attributes &= ~(OBJ_PERMANENT | OBJ_EXCLUSIVE);
return(NtOpenKey(KeyHandle, return(ZwOpenKey(KeyHandle,
DesiredAccess, DesiredAccess,
ObjectAttributes)); ObjectAttributes));
} }
@ -1027,7 +1027,7 @@ RtlpNtQueryValueKey(IN HANDLE KeyHandle,
if (ValueInfo == NULL) if (ValueInfo == NULL)
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
Status = NtQueryValueKey(KeyHandle, Status = ZwQueryValueKey(KeyHandle,
&ValueName, &ValueName,
KeyValuePartialInformation, KeyValuePartialInformation,
ValueInfo, ValueInfo,
@ -1068,7 +1068,7 @@ RtlpNtSetValueKey(IN HANDLE KeyHandle,
RtlInitUnicodeString(&ValueName, RtlInitUnicodeString(&ValueName,
NULL); NULL);
return(NtSetValueKey(KeyHandle, return(ZwSetValueKey(KeyHandle,
&ValueName, &ValueName,
0, 0,
Type, Type,

View file

@ -124,58 +124,77 @@ NtCreateEvent(OUT PHANDLE EventHandle,
IN EVENT_TYPE EventType, IN EVENT_TYPE EventType,
IN BOOLEAN InitialState) 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; PKEVENT Event;
HANDLE hEvent; HANDLE hEvent;
NTSTATUS Status; NTSTATUS Status = STATUS_SUCCESS;
OBJECT_ATTRIBUTES SafeObjectAttributes;
PreviousMode = ExGetPreviousMode();
if (ObjectAttributes != NULL)
if(PreviousMode == UserMode)
{
_SEH_TRY
{ {
Status = MmCopyFromCaller(&SafeObjectAttributes, ObjectAttributes, ProbeForWrite(EventHandle,
sizeof(OBJECT_ATTRIBUTES)); sizeof(HANDLE),
if (!NT_SUCCESS(Status)) sizeof(ULONG));
{
return(Status);
}
ObjectAttributes = &SafeObjectAttributes;
} }
_SEH_HANDLE
Status = ObCreateObject(ExGetPreviousMode(),
ExEventObjectType,
ObjectAttributes,
ExGetPreviousMode(),
NULL,
sizeof(KEVENT),
0,
0,
(PVOID*)&Event);
if (!NT_SUCCESS(Status))
{ {
return(Status); Status = _SEH_GetExceptionCode();
} }
KeInitializeEvent(Event, _SEH_END;
EventType, }
InitialState);
Status = ObCreateObject(PreviousMode,
Status = ObInsertObject ((PVOID)Event, ExEventObjectType,
NULL, ObjectAttributes,
DesiredAccess, PreviousMode,
0, NULL,
NULL, sizeof(KEVENT),
&hEvent); 0,
ObDereferenceObject(Event); 0,
if (!NT_SUCCESS(Status)) (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)) return Status;
{
ZwClose(hEvent);
return(Status);
}
return(STATUS_SUCCESS);
} }

View file

@ -70,7 +70,7 @@ _KiSystemService:
movw %bx, %fs movw %bx, %fs
/* Save the previous exception list */ /* Save the previous exception list */
pushl %fs:KPCR_EXCEPTION_LIST // + 0x2C pushl %fs:KPCR_EXCEPTION_LIST // + 0x2C
/* Set the exception handler chain terminator */ /* Set the exception handler chain terminator */
movl $0xffffffff, %fs:KPCR_EXCEPTION_LIST movl $0xffffffff, %fs:KPCR_EXCEPTION_LIST
@ -79,11 +79,11 @@ _KiSystemService:
movl %fs:KPCR_CURRENT_THREAD, %esi movl %fs:KPCR_CURRENT_THREAD, %esi
/* Save the old previous mode */ /* 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 */ /* Set the new previous mode based on the saved CS selector */
movl 0x24(%esp), %ebx movl 0x24(%esp), %ebx
and $1, %ebx andl $1, %ebx
movb %bl, %ss:KTHREAD_PREVIOUS_MODE(%esi) movb %bl, %ss:KTHREAD_PREVIOUS_MODE(%esi)
/* Save other registers */ /* Save other registers */
@ -95,20 +95,14 @@ _KiSystemService:
pushl %gs // + 0x48 pushl %gs // + 0x48
sub $0x28, %esp // + 0x70 sub $0x28, %esp // + 0x70
#if 0
#ifdef DBG #ifdef DBG
/* Trick gdb 6 into backtracing over the system call */ /* Trick gdb 6 into backtracing over the system call */
/* FIXME: %ebp is *never* initialized */
pushl 4(%ebp) /* DebugEIP */ // + 0x74 pushl 4(%ebp) /* DebugEIP */ // + 0x74
pushl (%ebp) /* DebugEBP */ // + 0x78 pushl (%ebp) /* DebugEBP */ // + 0x78
#else #else
pushl 0x60(%esp) /* DebugEIP */ // + 0x74 pushl 0x60(%esp) /* DebugEIP */ // + 0x74
pushl %ebp /* DebugEBP */ // + 0x78 pushl %ebp /* DebugEBP */ // + 0x78
#endif #endif
#else
pushl $0 /* DebugEIP */ // + 0x74
pushl $0 /* DebugEBP */ // + 0x78
#endif
/* Load the segment registers */ /* Load the segment registers */
sti sti
@ -320,7 +314,6 @@ KiBBTUnexpectedRange:
InvalidCall: InvalidCall:
/* Invalid System Call */ /* Invalid System Call */
int $3
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
movl %eax, KTRAP_FRAME_EAX(%ebp) movl %eax, KTRAP_FRAME_EAX(%ebp)
jmp _KiServiceExit jmp _KiServiceExit

View file

@ -307,7 +307,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
NULL, NULL,
NULL); NULL);
CHECKPOINT; CHECKPOINT;
Status = NtOpenFile(&FileHandle, Status = ZwOpenFile(&FileHandle,
FILE_ALL_ACCESS, FILE_ALL_ACCESS,
&ObjectAttributes, &ObjectAttributes,
&IoStatusBlock, &IoStatusBlock,
@ -322,7 +322,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
CHECKPOINT; CHECKPOINT;
/* Get the size of the file */ /* Get the size of the file */
Status = NtQueryInformationFile(FileHandle, Status = ZwQueryInformationFile(FileHandle,
&IoStatusBlock, &IoStatusBlock,
&FileStdInfo, &FileStdInfo,
sizeof(FileStdInfo), sizeof(FileStdInfo),
@ -348,7 +348,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
CHECKPOINT; CHECKPOINT;
/* Load driver into memory chunk */ /* Load driver into memory chunk */
Status = NtReadFile(FileHandle, Status = ZwReadFile(FileHandle,
0, 0, 0, 0, 0, 0,
&IoStatusBlock, &IoStatusBlock,
ModuleLoadBase, ModuleLoadBase,
@ -363,7 +363,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
} }
CHECKPOINT; CHECKPOINT;
NtClose(FileHandle); ZwClose(FileHandle);
Status = LdrProcessModule(ModuleLoadBase, Status = LdrProcessModule(ModuleLoadBase,
Filename, Filename,

View file

@ -601,7 +601,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
ASSERT_IRQL(APC_LEVEL); ASSERT_IRQL(APC_LEVEL);
if(AccessMode == UserMode && ObjectAttributes != NULL) if(ObjectAttributesAccessMode == UserMode && ObjectAttributes != NULL)
{ {
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
_SEH_TRY _SEH_TRY

View file

@ -1579,7 +1579,6 @@ NtCreateToken(OUT PHANDLE UnsafeTokenHandle,
HANDLE TokenHandle; HANDLE TokenHandle;
PTOKEN AccessToken; PTOKEN AccessToken;
NTSTATUS Status; NTSTATUS Status;
OBJECT_ATTRIBUTES SafeObjectAttributes;
POBJECT_ATTRIBUTES ObjectAttributes; POBJECT_ATTRIBUTES ObjectAttributes;
LUID TokenId; LUID TokenId;
LUID ModifiedId; LUID ModifiedId;
@ -1587,14 +1586,6 @@ NtCreateToken(OUT PHANDLE UnsafeTokenHandle,
ULONG uLength; ULONG uLength;
ULONG i; ULONG i;
Status = MmCopyFromCaller(&SafeObjectAttributes,
UnsafeObjectAttributes,
sizeof(OBJECT_ATTRIBUTES));
if (!NT_SUCCESS(Status))
return(Status);
ObjectAttributes = &SafeObjectAttributes;
Status = ZwAllocateLocallyUniqueId(&TokenId); Status = ZwAllocateLocallyUniqueId(&TokenId);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return(Status); return(Status);

View file

@ -143,6 +143,7 @@ WinMain(HINSTANCE hInst,
LPSTR lpszCmdLine, LPSTR lpszCmdLine,
int nCmdShow) int nCmdShow)
{ {
DPRINT1("Hello\n");
SetUserSettings(); SetUserSettings();
StartShell(); StartShell();
return 0; return 0;

View file

@ -596,7 +596,7 @@ NtUserCreateDesktop(
*/ */
Status = ObCreateObject( Status = ObCreateObject(
ExGetPreviousMode(), KernelMode,
ExDesktopObjectType, ExDesktopObjectType,
&ObjectAttributes, &ObjectAttributes,
ExGetPreviousMode(), ExGetPreviousMode(),

View file

@ -324,7 +324,7 @@ NtUserCreateWindowStation(
DPRINT("Creating window station (%wZ)\n", &WindowStationName); DPRINT("Creating window station (%wZ)\n", &WindowStationName);
Status = ObCreateObject( Status = ObCreateObject(
ExGetPreviousMode(), KernelMode,
ExWindowStationObjectType, ExWindowStationObjectType,
&ObjectAttributes, &ObjectAttributes,
ExGetPreviousMode(), ExGetPreviousMode(),
@ -336,7 +336,7 @@ NtUserCreateWindowStation(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Failed creating window station (%wZ)\n", &WindowStationName); DPRINT1("Failed creating window station (%wZ)\n", &WindowStationName);
ExFreePool(WindowStationName.Buffer); ExFreePool(WindowStationName.Buffer);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0; return 0;

View file

@ -618,8 +618,10 @@ endif
# if needed, until their problems can be found # if needed, until their problems can be found
# #
ifeq ($(OPTIMIZED), 1) ifeq ($(OPTIMIZED), 1)
MK_CFLAGS += -O2 -Wno-strict-aliasing ifneq ($(TARGET_NAME), bootvid)
MK_CPPFLAGS += -O2 -Wno-strict-aliasing MK_CFLAGS += -O2 -Wno-strict-aliasing
MK_CPPFLAGS += -O2 -Wno-strict-aliasing
endif
endif endif
ifneq ($(TARGET_LIBS),) ifneq ($(TARGET_LIBS),)