From 03f9a38939e461dca05fc7f7025c47999595abaa Mon Sep 17 00:00:00 2001 From: dmex Date: Wed, 30 Aug 2023 05:12:46 +1000 Subject: [PATCH] Update error handling with PhDosErrorToNtStatus --- phlib/secedit.c | 4 ++-- phlib/secwmi.c | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/phlib/secedit.c b/phlib/secedit.c index ca5f3344f767..57314e0adc3a 100644 --- a/phlib/secedit.c +++ b/phlib/secedit.c @@ -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); @@ -1734,7 +1734,7 @@ NTSTATUS PhSetSeObjectSecurity( ); if (win32Result != ERROR_SUCCESS) - return NTSTATUS_FROM_WIN32(win32Result); + return PhDosErrorToNtStatus(win32Result); return STATUS_SUCCESS; } diff --git a/phlib/secwmi.c b/phlib/secwmi.c index 0d540e9f108d..b0cf459186f3 100644 --- a/phlib/secwmi.c +++ b/phlib/secwmi.c @@ -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: @@ -137,7 +137,7 @@ NTSTATUS PhpGetPowerPolicySecurityDescriptor( LocalFree(policyGuid); - return NTSTATUS_FROM_WIN32(status); + return PhDosErrorToNtStatus(status); } NTSTATUS PhpSetPowerPolicySecurityDescriptor( @@ -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, @@ -181,7 +181,7 @@ NTSTATUS PhpSetPowerPolicySecurityDescriptor( LocalFree(policyGuid); - return NTSTATUS_FROM_WIN32(status); + return PhDosErrorToNtStatus(status); } // Terminal server security descriptors @@ -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; @@ -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; @@ -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;