diff --git a/reactos/ntoskrnl/config/ntapi.c b/reactos/ntoskrnl/config/ntapi.c index 636090873a4..ec60cea1c18 100644 --- a/reactos/ntoskrnl/config/ntapi.c +++ b/reactos/ntoskrnl/config/ntapi.c @@ -34,11 +34,11 @@ NtCreateKey(OUT PHANDLE KeyHandle, PAGED_CODE(); DPRINT("NtCreateKey(OB 0x%wZ)\n", ObjectAttributes->ObjectName); - /* Prepare to probe parameters */ - _SEH_TRY + /* Check for user-mode caller */ + if (PreviousMode == UserMode) { - /* Check for user-mode caller */ - if (PreviousMode == UserMode) + /* Prepare to probe parameters */ + _SEH_TRY { /* Check if we have a class */ if (Class) @@ -50,32 +50,43 @@ NtCreateKey(OUT PHANDLE KeyHandle, sizeof(WCHAR)); ParseContext.Class = *Class; } - + /* Probe the key handle */ ProbeForWriteHandle(KeyHandle); *KeyHandle = NULL; - + /* Probe object attributes */ ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 4); } - else + _SEH_HANDLE { - /* Save the class directly */ - if (Class) ParseContext.Class = *Class; + /* Get the error code */ + Status = _SEH_GetExceptionCode(); } + _SEH_END; + if(!NT_SUCCESS(Status)) return Status; + } + else + { + /* Save the class directly */ + if (Class) ParseContext.Class = *Class; + } - /* Setup the parse context */ - ParseContext.CreateOperation = TRUE; - ParseContext.CreateOptions = CreateOptions; + /* Setup the parse context */ + ParseContext.CreateOperation = TRUE; + ParseContext.CreateOptions = CreateOptions; - /* Do the create */ - Status = ObOpenObjectByName(ObjectAttributes, - CmpKeyObjectType, - PreviousMode, - NULL, - DesiredAccess, - &ParseContext, - &Handle); + /* Do the create */ + Status = ObOpenObjectByName(ObjectAttributes, + CmpKeyObjectType, + PreviousMode, + NULL, + DesiredAccess, + &ParseContext, + &Handle); + + _SEH_TRY + { if (NT_SUCCESS(Status)) *KeyHandle = Handle; /* Return data to user */ @@ -105,11 +116,11 @@ NtOpenKey(OUT PHANDLE KeyHandle, PAGED_CODE(); DPRINT("NtOpenKey(OB 0x%wZ)\n", ObjectAttributes->ObjectName); - /* Prepare to probe parameters */ - _SEH_TRY + /* Check for user-mode caller */ + if (PreviousMode == UserMode) { - /* Check for user-mode caller */ - if (PreviousMode == UserMode) + /* Prepare to probe parameters */ + _SEH_TRY { /* Probe the key handle */ ProbeForWriteHandle(KeyHandle); @@ -118,23 +129,36 @@ NtOpenKey(OUT PHANDLE KeyHandle, /* Probe object attributes */ ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 4); } + _SEH_HANDLE + { + /* Get the status */ + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + } - /* Just let the object manager handle this */ - Status = ObOpenObjectByName(ObjectAttributes, - CmpKeyObjectType, - ExGetPreviousMode(), - NULL, - DesiredAccess, - &ParseContext, - &Handle); - if (NT_SUCCESS(Status)) *KeyHandle = Handle; - } - _SEH_HANDLE + /* Just let the object manager handle this */ + Status = ObOpenObjectByName(ObjectAttributes, + CmpKeyObjectType, + ExGetPreviousMode(), + NULL, + DesiredAccess, + &ParseContext, + &Handle); + + if (NT_SUCCESS(Status)) { - /* Get the status */ - Status = _SEH_GetExceptionCode(); + _SEH_TRY + { + *KeyHandle = Handle; + } + _SEH_HANDLE + { + /* Get the status */ + Status = _SEH_GetExceptionCode(); + } + _SEH_END; } - _SEH_END; /* Return status */ return Status;