Skip to content

Commit

Permalink
Update error handling with PhDosErrorToNtStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Aug 29, 2023
1 parent 03733d5 commit 03f9a38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions phlib/secedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ NTSTATUS PhGetSeObjectSecurity(
);

if (win32Result != ERROR_SUCCESS)
return NTSTATUS_FROM_WIN32(win32Result);
return PhDosErrorToNtStatus(win32Result);

*SecurityDescriptor = PhAllocateCopy(securityDescriptor, RtlLengthSecurityDescriptor(securityDescriptor));
LocalFree(securityDescriptor);
Expand Down Expand Up @@ -1734,7 +1734,7 @@ NTSTATUS PhSetSeObjectSecurity(
);

if (win32Result != ERROR_SUCCESS)
return NTSTATUS_FROM_WIN32(win32Result);
return PhDosErrorToNtStatus(win32Result);

return STATUS_SUCCESS;
}
26 changes: 17 additions & 9 deletions phlib/secwmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ NTSTATUS PhpGetPowerPolicySecurityDescriptor(
);

if (status != ERROR_SUCCESS)
return NTSTATUS_FROM_WIN32(status);
return PhDosErrorToNtStatus(status);

// PowerReadSecurityDescriptor/PowerWriteSecurityDescriptor both use the same SDDL
// format as registry keys and are RPC wrappers for this registry key:
Expand All @@ -137,7 +137,7 @@ NTSTATUS PhpGetPowerPolicySecurityDescriptor(

LocalFree(policyGuid);

return NTSTATUS_FROM_WIN32(status);
return PhDosErrorToNtStatus(status);
}

NTSTATUS PhpSetPowerPolicySecurityDescriptor(
Expand Down Expand Up @@ -165,7 +165,7 @@ NTSTATUS PhpSetPowerPolicySecurityDescriptor(
);

if (status != ERROR_SUCCESS)
return NTSTATUS_FROM_WIN32(status);
return PhDosErrorToNtStatus(status);

status = PowerWriteSecurityDescriptor_I(
ACCESS_DEFAULT_SECURITY_DESCRIPTOR,
Expand All @@ -181,7 +181,7 @@ NTSTATUS PhpSetPowerPolicySecurityDescriptor(

LocalFree(policyGuid);

return NTSTATUS_FROM_WIN32(status);
return PhDosErrorToNtStatus(status);
}

// Terminal server security descriptors
Expand Down Expand Up @@ -294,8 +294,11 @@ NTSTATUS PhGetWmiNamespaceSecurityDescriptor(
IWbemServices* wbemServices = NULL;
IWbemClassObject* wbemClassObject = NULL;
IWbemClassObject* wbemGetSDClassObject = 0;
VARIANT variantReturnValue = { VT_EMPTY };
VARIANT variantArrayValue = { VT_EMPTY };
VARIANT variantArrayValue;
VARIANT variantReturnValue;

RtlZeroMemory(&variantArrayValue, sizeof(VARIANT));
RtlZeroMemory(&variantReturnValue, sizeof(VARIANT));

if (!(imageBaseAddress = PhGetWbemProxImageBaseAddress()))
return STATUS_UNSUCCESSFUL;
Expand Down Expand Up @@ -464,8 +467,11 @@ NTSTATUS PhSetWmiNamespaceSecurityDescriptor(
PSECURITY_DESCRIPTOR relativeSecurityDescriptor = 0;
ULONG relativeSecurityDescriptorLength = 0;
BOOLEAN freeSecurityDescriptor = FALSE;
VARIANT variantArrayValue = { VT_EMPTY };
VARIANT variantReturnValue = { VT_EMPTY };
VARIANT variantArrayValue;
VARIANT variantReturnValue;

RtlZeroMemory(&variantArrayValue, sizeof(VARIANT));
RtlZeroMemory(&variantReturnValue, sizeof(VARIANT));

if (!(imageBaseAddress = PhGetWbemProxImageBaseAddress()))
return STATUS_UNSUCCESSFUL;
Expand Down Expand Up @@ -676,7 +682,9 @@ HRESULT PhRestartDefenderOfflineScan(
IWbemServices* wbemServices = NULL;
IWbemClassObject* wbemClassObject = NULL;
IWbemClassObject* wbemStartClassObject = 0;
VARIANT variantReturnValue = { VT_EMPTY };
VARIANT variantReturnValue;

RtlZeroMemory(&variantReturnValue, sizeof(VARIANT));

if (!(imageBaseAddress = PhGetWbemProxImageBaseAddress()))
return STATUS_UNSUCCESSFUL;
Expand Down

0 comments on commit 03f9a38

Please sign in to comment.