Sync to trunk head(r38096)
[reactos.git] / reactos / dll / win32 / advapi32 / sec / misc.c
index c3a284f..f1442eb 100644 (file)
@@ -1,11 +1,17 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
+ * WINE COPYRIGHT: 
+ * Copyright 1999, 2000 Juergen Schmied <juergen.schmied@debitel.net>
+ * Copyright 2003 CodeWeavers Inc. (Ulrich Czekalla)
+ * Copyright 2006 Robert Reif
+ *
  * PROJECT:         ReactOS system libraries
- * FILE:            lib/advapi32/sec/misc.c
+ * FILE:            dll/win32/advapi32/sec/misc.c
  * PURPOSE:         Miscellaneous security functions (some ported from Wine)
  */
 
 #include <advapi32.h>
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
@@ -127,6 +133,101 @@ static const AccountSid ACCOUNT_SIDS[] = {
     { WinBuiltinPerfLoggingUsersSid, Performance_Log_Users, BUILTIN, SidTypeAlias },
 };
 
+static const WCHAR SE_CREATE_TOKEN_NAME_W[] =
+ { 'S','e','C','r','e','a','t','e','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_ASSIGNPRIMARYTOKEN_NAME_W[] =
+ { 'S','e','A','s','s','i','g','n','P','r','i','m','a','r','y','T','o','k','e','n','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_LOCK_MEMORY_NAME_W[] =
+ { 'S','e','L','o','c','k','M','e','m','o','r','y','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_INCREASE_QUOTA_NAME_W[] =
+ { 'S','e','I','n','c','r','e','a','s','e','Q','u','o','t','a','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_MACHINE_ACCOUNT_NAME_W[] =
+ { 'S','e','M','a','c','h','i','n','e','A','c','c','o','u','n','t','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_TCB_NAME_W[] =
+ { 'S','e','T','c','b','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_SECURITY_NAME_W[] =
+ { 'S','e','S','e','c','u','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_TAKE_OWNERSHIP_NAME_W[] =
+ { 'S','e','T','a','k','e','O','w','n','e','r','s','h','i','p','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_LOAD_DRIVER_NAME_W[] =
+ { 'S','e','L','o','a','d','D','r','i','v','e','r','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_SYSTEM_PROFILE_NAME_W[] =
+ { 'S','e','S','y','s','t','e','m','P','r','o','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_SYSTEMTIME_NAME_W[] =
+ { 'S','e','S','y','s','t','e','m','t','i','m','e','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_PROF_SINGLE_PROCESS_NAME_W[] =
+ { 'S','e','P','r','o','f','i','l','e','S','i','n','g','l','e','P','r','o','c','e','s','s','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_INC_BASE_PRIORITY_NAME_W[] =
+ { 'S','e','I','n','c','r','e','a','s','e','B','a','s','e','P','r','i','o','r','i','t','y','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_CREATE_PAGEFILE_NAME_W[] =
+ { 'S','e','C','r','e','a','t','e','P','a','g','e','f','i','l','e','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_CREATE_PERMANENT_NAME_W[] =
+ { 'S','e','C','r','e','a','t','e','P','e','r','m','a','n','e','n','t','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_BACKUP_NAME_W[] =
+ { 'S','e','B','a','c','k','u','p','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_RESTORE_NAME_W[] =
+ { 'S','e','R','e','s','t','o','r','e','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_SHUTDOWN_NAME_W[] =
+ { 'S','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_DEBUG_NAME_W[] =
+ { 'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_AUDIT_NAME_W[] =
+ { 'S','e','A','u','d','i','t','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_SYSTEM_ENVIRONMENT_NAME_W[] =
+ { 'S','e','S','y','s','t','e','m','E','n','v','i','r','o','n','m','e','n','t','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_CHANGE_NOTIFY_NAME_W[] =
+ { 'S','e','C','h','a','n','g','e','N','o','t','i','f','y','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_REMOTE_SHUTDOWN_NAME_W[] =
+ { 'S','e','R','e','m','o','t','e','S','h','u','t','d','o','w','n','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_UNDOCK_NAME_W[] =
+ { 'S','e','U','n','d','o','c','k','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_SYNC_AGENT_NAME_W[] =
+ { 'S','e','S','y','n','c','A','g','e','n','t','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_ENABLE_DELEGATION_NAME_W[] =
+ { 'S','e','E','n','a','b','l','e','D','e','l','e','g','a','t','i','o','n','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_MANAGE_VOLUME_NAME_W[] =
+ { 'S','e','M','a','n','a','g','e','V','o','l','u','m','e','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_IMPERSONATE_NAME_W[] =
+ { 'S','e','I','m','p','e','r','s','o','n','a','t','e','P','r','i','v','i','l','e','g','e',0 };
+static const WCHAR SE_CREATE_GLOBAL_NAME_W[] =
+ { 'S','e','C','r','e','a','t','e','G','l','o','b','a','l','P','r','i','v','i','l','e','g','e',0 };
+
+static const WCHAR * const WellKnownPrivNames[SE_MAX_WELL_KNOWN_PRIVILEGE + 1] =
+{
+    NULL,
+    NULL,
+    SE_CREATE_TOKEN_NAME_W,
+    SE_ASSIGNPRIMARYTOKEN_NAME_W,
+    SE_LOCK_MEMORY_NAME_W,
+    SE_INCREASE_QUOTA_NAME_W,
+    SE_MACHINE_ACCOUNT_NAME_W,
+    SE_TCB_NAME_W,
+    SE_SECURITY_NAME_W,
+    SE_TAKE_OWNERSHIP_NAME_W,
+    SE_LOAD_DRIVER_NAME_W,
+    SE_SYSTEM_PROFILE_NAME_W,
+    SE_SYSTEMTIME_NAME_W,
+    SE_PROF_SINGLE_PROCESS_NAME_W,
+    SE_INC_BASE_PRIORITY_NAME_W,
+    SE_CREATE_PAGEFILE_NAME_W,
+    SE_CREATE_PERMANENT_NAME_W,
+    SE_BACKUP_NAME_W,
+    SE_RESTORE_NAME_W,
+    SE_SHUTDOWN_NAME_W,
+    SE_DEBUG_NAME_W,
+    SE_AUDIT_NAME_W,
+    SE_SYSTEM_ENVIRONMENT_NAME_W,
+    SE_CHANGE_NOTIFY_NAME_W,
+    SE_REMOTE_SHUTDOWN_NAME_W,
+    SE_UNDOCK_NAME_W,
+    SE_SYNC_AGENT_NAME_W,
+    SE_ENABLE_DELEGATION_NAME_W,
+    SE_MANAGE_VOLUME_NAME_W,
+    SE_IMPERSONATE_NAME_W,
+    SE_CREATE_GLOBAL_NAME_W,
+};
+
+
 /* Interface to ntmarta.dll ***************************************************/
 
 NTMARTA NtMartaStatic = { 0 };
@@ -242,7 +343,7 @@ UnloadNtMarta(VOID)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 AreAllAccessesGranted(DWORD GrantedAccess,
                       DWORD DesiredAccess)
 {
@@ -255,7 +356,7 @@ AreAllAccessesGranted(DWORD GrantedAccess,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 AreAnyAccessesGranted(DWORD GrantedAccess,
                       DWORD DesiredAccess)
 {
@@ -264,6 +365,31 @@ AreAnyAccessesGranted(DWORD GrantedAccess,
 }
 
 
+/************************************************************
+ *                ADVAPI_IsLocalComputer
+ *
+ * Checks whether the server name indicates local machine.
+ */
+BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
+{
+    DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
+    BOOL Result;
+    LPWSTR buf;
+
+    if (!ServerName || !ServerName[0])
+        return TRUE;
+
+    buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
+    Result = GetComputerNameW(buf,  &dwSize);
+    if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
+        ServerName += 2;
+    Result = Result && !lstrcmpW(ServerName, buf);
+    HeapFree(GetProcessHeap(), 0, buf);
+
+    return Result;
+}
+
+
 /******************************************************************************
  * GetFileSecurityA [ADVAPI32.@]
  *
@@ -395,7 +521,7 @@ GetFileSecurityW(LPCWSTR lpFileName,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 GetKernelObjectSecurity(HANDLE Handle,
                         SECURITY_INFORMATION RequestedInformation,
                         PSECURITY_DESCRIPTOR pSecurityDescriptor,
@@ -426,7 +552,7 @@ GetKernelObjectSecurity(HANDLE Handle,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 SetFileSecurityA(LPCSTR lpFileName,
                  SECURITY_INFORMATION SecurityInformation,
                  PSECURITY_DESCRIPTOR pSecurityDescriptor)
@@ -460,7 +586,7 @@ SetFileSecurityA(LPCSTR lpFileName,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 SetFileSecurityW(LPCWSTR lpFileName,
                  SECURITY_INFORMATION SecurityInformation,
                  PSECURITY_DESCRIPTOR pSecurityDescriptor)
@@ -530,7 +656,7 @@ SetFileSecurityW(LPCWSTR lpFileName,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 SetKernelObjectSecurity(HANDLE Handle,
                         SECURITY_INFORMATION SecurityInformation,
                         PSECURITY_DESCRIPTOR SecurityDescriptor)
@@ -574,7 +700,7 @@ ImpersonateAnonymousToken(IN HANDLE ThreadHandle)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 ImpersonateLoggedOnUser(HANDLE hToken)
 {
     SECURITY_QUALITY_OF_SERVICE Qos;
@@ -658,7 +784,7 @@ ImpersonateLoggedOnUser(HANDLE hToken)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
 {
     NTSTATUS Status;
@@ -678,7 +804,7 @@ ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 RevertToSelf(VOID)
 {
     NTSTATUS Status;
@@ -864,7 +990,7 @@ GetUserNameW(LPWSTR lpszName,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupAccountSidA(LPCSTR lpSystemName,
                   PSID lpSid,
                   LPSTR lpName,
@@ -1100,7 +1226,7 @@ LookupAccountSidW(LPCWSTR pSystemName,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupAccountNameA(LPCSTR SystemName,
                    LPCSTR AccountName,
                    PSID Sid,
@@ -1237,7 +1363,7 @@ LookupAccountNameW(LPCWSTR lpSystemName,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupPrivilegeValueA(LPCSTR lpSystemName,
                       LPCSTR lpName,
                       PLUID lpLuid)
@@ -1252,25 +1378,27 @@ LookupPrivilegeValueA(LPCSTR lpSystemName,
         RtlCreateUnicodeStringFromAsciiz(&SystemName,
                                          (LPSTR)lpSystemName);
     }
+       else
+               SystemName.Buffer = NULL;
 
     /* Check the privilege name is not NULL */
     if (lpName == NULL)
     {
-        SetLastError(ERROR_INVALID_PARAMETER);
+        SetLastError(ERROR_NO_SUCH_PRIVILEGE);
         return FALSE;
     }
 
     RtlCreateUnicodeStringFromAsciiz(&Name,
                                      (LPSTR)lpName);
 
-    Result = LookupPrivilegeValueW((lpSystemName != NULL) ? SystemName.Buffer : NULL,
+    Result = LookupPrivilegeValueW(SystemName.Buffer,
                                    Name.Buffer,
                                    lpLuid);
 
     RtlFreeUnicodeString(&Name);
 
     /* Remote system? */
-    if (lpSystemName != NULL)
+    if (SystemName.Buffer != NULL)
     {
         RtlFreeUnicodeString(&SystemName);
     }
@@ -1285,7 +1413,7 @@ LookupPrivilegeValueA(LPCSTR lpSystemName,
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupPrivilegeValueW(LPCWSTR SystemName,
                       LPCWSTR PrivName,
                       PLUID Luid)
@@ -1296,7 +1424,6 @@ LookupPrivilegeValueW(LPCWSTR SystemName,
       L"SeAssignPrimaryTokenPrivilege",
       L"SeLockMemoryPrivilege",
       L"SeIncreaseQuotaPrivilege",
-      L"SeUnsolicitedInputPrivilege",
       L"SeMachineAccountPrivilege",
       L"SeTcbPrivilege",
       L"SeSecurityPrivilege",
@@ -1334,9 +1461,9 @@ LookupPrivilegeValueW(LPCWSTR SystemName,
 
   for (Priv = 0; Priv < sizeof(DefaultPrivNames) / sizeof(DefaultPrivNames[0]); Priv++)
     {
-      if (0 == wcscmp(PrivName, DefaultPrivNames[Priv]))
+      if (0 == wcsicmp(PrivName, DefaultPrivNames[Priv]))
         {
-          Luid->LowPart = Priv + 1;
+          Luid->LowPart = Priv + SE_MIN_WELL_KNOWN_PRIVILEGE;
           Luid->HighPart = 0;
           return TRUE;
         }
@@ -1354,7 +1481,7 @@ LookupPrivilegeValueW(LPCWSTR SystemName,
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupPrivilegeDisplayNameA(LPCSTR lpSystemName,
                             LPCSTR lpName,
                             LPSTR lpDisplayName,
@@ -1373,7 +1500,7 @@ LookupPrivilegeDisplayNameA(LPCSTR lpSystemName,
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupPrivilegeDisplayNameW(LPCWSTR lpSystemName,
                             LPCWSTR lpName,
                             LPWSTR lpDisplayName,
@@ -1389,36 +1516,102 @@ LookupPrivilegeDisplayNameW(LPCWSTR lpSystemName,
 /**********************************************************************
  * LookupPrivilegeNameA                                EXPORTED
  *
- * @unimplemented
+ * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupPrivilegeNameA(LPCSTR lpSystemName,
                      PLUID lpLuid,
                      LPSTR lpName,
-                     LPDWORD cbName)
+                     LPDWORD cchName)
 {
-    FIXME("%s() not implemented!\n", __FUNCTION__);
-    SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+    UNICODE_STRING lpSystemNameW;
+    BOOL ret;
+    DWORD wLen = 0;
+
+    TRACE("%s %p %p %p\n", debugstr_a(lpSystemName), lpLuid, lpName, cchName);
+
+    RtlCreateUnicodeStringFromAsciiz(&lpSystemNameW, lpSystemName);
+    ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, NULL, &wLen);
+    if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+    {
+        LPWSTR lpNameW = HeapAlloc(GetProcessHeap(), 0, wLen * sizeof(WCHAR));
+
+        ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, lpNameW,
+         &wLen);
+        if (ret)
+        {
+            /* Windows crashes if cchName is NULL, so will I */
+            unsigned int len = WideCharToMultiByte(CP_ACP, 0, lpNameW, -1, lpName,
+             *cchName, NULL, NULL);
+
+            if (len == 0)
+            {
+                /* WideCharToMultiByte failed */
+                ret = FALSE;
+            }
+            else if (len > *cchName)
+            {
+                *cchName = len;
+                SetLastError(ERROR_INSUFFICIENT_BUFFER);
+                ret = FALSE;
+            }
+            else
+            {
+                /* WideCharToMultiByte succeeded, output length needs to be
+                 * length not including NULL terminator
+                 */
+                *cchName = len - 1;
+            }
+        }
+        HeapFree(GetProcessHeap(), 0, lpNameW);
+    }
+    RtlFreeUnicodeString(&lpSystemNameW);
+    return ret;
 }
 
 
 /**********************************************************************
  * LookupPrivilegeNameW                                EXPORTED
  *
- * @unimplemented
+ * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 LookupPrivilegeNameW(LPCWSTR lpSystemName,
                      PLUID lpLuid,
                      LPWSTR lpName,
-                     LPDWORD cbName)
+                     LPDWORD cchName)
 {
-    FIXME("%s() not implemented!\n", __FUNCTION__);
-    SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+    size_t privNameLen;
+
+    TRACE("%s,%p,%p,%p\n",debugstr_w(lpSystemName), lpLuid, lpName, cchName);
+
+    if (!ADVAPI_IsLocalComputer(lpSystemName))
+    {
+        SetLastError(RPC_S_SERVER_UNAVAILABLE);
+        return FALSE;
+    }
+    if (lpLuid->HighPart || (lpLuid->LowPart < SE_MIN_WELL_KNOWN_PRIVILEGE ||
+     lpLuid->LowPart > SE_MAX_WELL_KNOWN_PRIVILEGE))
+    {
+        SetLastError(ERROR_NO_SUCH_PRIVILEGE);
+        return FALSE;
+    }
+    privNameLen = strlenW(WellKnownPrivNames[lpLuid->LowPart]);
+    /* Windows crashes if cchName is NULL, so will I */
+    if (*cchName <= privNameLen)
+    {
+        *cchName = privNameLen + 1;
+        SetLastError(ERROR_INSUFFICIENT_BUFFER);
+        return FALSE;
+    }
+    else
+    {
+        strcpyW(lpName, WellKnownPrivNames[lpLuid->LowPart]);
+        *cchName = privNameLen;
+        return TRUE;
+    }
 }
 
 
@@ -1604,7 +1797,7 @@ ProtectSacl:
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetNamedSecurityInfoW(LPWSTR pObjectName,
                       SE_OBJECT_TYPE ObjectType,
                       SECURITY_INFORMATION SecurityInfo,
@@ -1655,7 +1848,7 @@ GetNamedSecurityInfoW(LPWSTR pObjectName,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetNamedSecurityInfoA(LPSTR pObjectName,
                       SE_OBJECT_TYPE ObjectType,
                       SECURITY_INFORMATION SecurityInfo,
@@ -1697,7 +1890,7 @@ GetNamedSecurityInfoA(LPSTR pObjectName,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 SetNamedSecurityInfoW(LPWSTR pObjectName,
                       SE_OBJECT_TYPE ObjectType,
                       SECURITY_INFORMATION SecurityInfo,
@@ -1745,7 +1938,7 @@ SetNamedSecurityInfoW(LPWSTR pObjectName,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 SetNamedSecurityInfoA(LPSTR pObjectName,
                       SE_OBJECT_TYPE ObjectType,
                       SECURITY_INFORMATION SecurityInfo,
@@ -1785,7 +1978,7 @@ SetNamedSecurityInfoA(LPSTR pObjectName,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 GetSecurityInfo(HANDLE handle,
                 SE_OBJECT_TYPE ObjectType,
                 SECURITY_INFORMATION SecurityInfo,
@@ -1924,7 +2117,7 @@ GetSecurityInfoExW(HANDLE hObject,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 ImpersonateNamedPipeClient(HANDLE hNamedPipe)
 {
     IO_STATUS_BLOCK StatusBlock;
@@ -1956,7 +2149,7 @@ ImpersonateNamedPipeClient(HANDLE hNamedPipe)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR ParentDescriptor,
                             PSECURITY_DESCRIPTOR CreatorDescriptor,
                             PSECURITY_DESCRIPTOR *NewDescriptor,
@@ -1986,7 +2179,7 @@ CreatePrivateObjectSecurity(PSECURITY_DESCRIPTOR ParentDescriptor,
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 CreatePrivateObjectSecurityEx(PSECURITY_DESCRIPTOR ParentDescriptor,
                               PSECURITY_DESCRIPTOR CreatorDescriptor,
                               PSECURITY_DESCRIPTOR* NewDescriptor,
@@ -2005,7 +2198,7 @@ CreatePrivateObjectSecurityEx(PSECURITY_DESCRIPTOR ParentDescriptor,
  * @unimplemented
  */
 BOOL
-STDCALL
+WINAPI
 CreatePrivateObjectSecurityWithMultipleInheritance(PSECURITY_DESCRIPTOR ParentDescriptor,
                                                    PSECURITY_DESCRIPTOR CreatorDescriptor,
                                                    PSECURITY_DESCRIPTOR* NewDescriptor,
@@ -2025,7 +2218,7 @@ CreatePrivateObjectSecurityWithMultipleInheritance(PSECURITY_DESCRIPTOR ParentDe
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR *ObjectDescriptor)
 {
     NTSTATUS Status;
@@ -2045,7 +2238,7 @@ DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR *ObjectDescriptor)
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR ObjectDescriptor,
                          SECURITY_INFORMATION SecurityInformation,
                          PSECURITY_DESCRIPTOR ResultantDescriptor,
@@ -2073,7 +2266,7 @@ GetPrivateObjectSecurity(PSECURITY_DESCRIPTOR ObjectDescriptor,
  * @implemented
  */
 BOOL
-STDCALL
+WINAPI
 SetPrivateObjectSecurity(SECURITY_INFORMATION SecurityInformation,
                          PSECURITY_DESCRIPTOR ModificationDescriptor,
                          PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
@@ -2101,7 +2294,7 @@ SetPrivateObjectSecurity(SECURITY_INFORMATION SecurityInformation,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 TreeResetNamedSecurityInfoW(LPWSTR pObjectName,
                             SE_OBJECT_TYPE ObjectType,
                             SECURITY_INFORMATION SecurityInfo,
@@ -2178,7 +2371,7 @@ typedef struct _INERNAL_FNPROGRESSW_DATA
     PVOID Args;
 } INERNAL_FNPROGRESSW_DATA, *PINERNAL_FNPROGRESSW_DATA;
 
-static VOID STDCALL
+static VOID WINAPI
 InternalfnProgressW(LPWSTR pObjectName,
                     DWORD Status,
                     PPROG_INVOKE_SETTING pInvokeSetting,
@@ -2234,7 +2427,7 @@ InternalfnProgressW(LPWSTR pObjectName,
  * @implemented
  */
 DWORD
-STDCALL
+WINAPI
 TreeResetNamedSecurityInfoA(LPSTR pObjectName,
                             SE_OBJECT_TYPE ObjectType,
                             SECURITY_INFORMATION SecurityInfo,