[SYSSETUP]: Code formatting, and exclusively use UNICODE strings.
[reactos.git] / reactos / dll / win32 / syssetup / install.c
index 2c018c1..6d467b1 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "precomp.h"
 
-#include <tchar.h>
+#include <io.h>
 #include <wincon.h>
 #include <winnls.h>
 #include <winsvc.h>
@@ -75,19 +75,16 @@ FatalError(char *pszFmt,...)
 
 static HRESULT
 CreateShellLink(
-    LPCTSTR pszLinkPath,
-    LPCTSTR pszCmd,
-    LPCTSTR pszArg,
-    LPCTSTR pszDir,
-    LPCTSTR pszIconPath,
-    int iIconNr,
-    LPCTSTR pszComment)
+    LPCWSTR pszLinkPath,
+    LPCWSTR pszCmd,
+    LPCWSTR pszArg,
+    LPCWSTR pszDir,
+    LPCWSTR pszIconPath,
+    INT iIconNr,
+    LPCWSTR pszComment)
 {
     IShellLink *psl;
     IPersistFile *ppf;
-#ifndef _UNICODE
-    WCHAR wszBuf[MAX_PATH];
-#endif /* _UNICODE */
 
     HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl);
 
@@ -119,14 +116,7 @@ CreateShellLink(
 
         if (SUCCEEDED(hr))
         {
-#ifdef _UNICODE
             hr = ppf->lpVtbl->Save(ppf, pszLinkPath, TRUE);
-#else /* _UNICODE */
-            MultiByteToWideChar(CP_ACP, 0, pszLinkPath, -1, wszBuf, MAX_PATH);
-
-            hr = ppf->lpVtbl->Save(ppf, wszBuf, TRUE);
-#endif /* _UNICODE */
-
             ppf->lpVtbl->Release(ppf);
         }
 
@@ -139,75 +129,73 @@ CreateShellLink(
 
 static BOOL
 CreateShortcut(
-    LPCTSTR pszFolder,
-    LPCTSTR pszName,
-    LPCTSTR pszCommand,
-    LPCTSTR pszDescription,
+    LPCWSTR pszFolder,
+    LPCWSTR pszName,
+    LPCWSTR pszCommand,
+    LPCWSTR pszDescription,
     INT iIconNr,
-    LPCTSTR pszWorkingDir)
+    LPCWSTR pszWorkingDir)
 {
-    TCHAR szPath[MAX_PATH];
-    TCHAR szExeName[MAX_PATH];
-    TCHAR szWorkingDirBuf[MAX_PATH];
-    LPTSTR Ptr;
-    LPTSTR lpFilePart;
+    WCHAR szPath[MAX_PATH];
+    WCHAR szExeName[MAX_PATH];
+    WCHAR szWorkingDirBuf[MAX_PATH];
+    LPWSTR Ptr;
+    LPWSTR lpFilePart;
     DWORD dwLen;
 
-    if (ExpandEnvironmentStrings(pszCommand,
-                                 szPath,
-                                 sizeof(szPath) / sizeof(szPath[0])) == 0)
+    if (ExpandEnvironmentStringsW(pszCommand, szPath, ARRAYSIZE(szPath)) == 0)
     {
-        _tcscpy(szPath, pszCommand);
+        wcscpy(szPath, pszCommand);
     }
 
-    if ((_taccess(szPath, 0 )) == -1)
+    if (_waccess(szPath, 0) == -1)
         /* Expected error, don't return FALSE */
         return TRUE;
 
-    dwLen = GetFullPathName(szPath,
-                            sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0]),
-                            szWorkingDirBuf,
-                            &lpFilePart);
-    if (dwLen != 0 && dwLen <= sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0]))
+    dwLen = GetFullPathNameW(szPath,
+                             ARRAYSIZE(szWorkingDirBuf),
+                             szWorkingDirBuf,
+                             &lpFilePart);
+    if (dwLen != 0 && dwLen <= ARRAYSIZE(szWorkingDirBuf))
     {
         /* Since those should only be called with (.exe) files,
            lpFilePart has not to be NULL */
         ASSERT(lpFilePart != NULL);
 
         /* Save the file name */
-        _tcscpy(szExeName, lpFilePart);
+        wcscpy(szExeName, lpFilePart);
 
-        if (pszWorkingDir == NULL || pszWorkingDir[0] == _T('\0'))
+        if (pszWorkingDir == NULL || pszWorkingDir[0] == L'\0')
         {
             /* We're only interested in the path. Cut the file name off.
                Also remove the trailing backslash unless the working directory
                is only going to be a drive, ie. C:\ */
-            *(lpFilePart--) = _T('\0');
-            if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] == _T(':') &&
-                  szWorkingDirBuf[2] == _T('\\')))
+            *(lpFilePart--) = L'\0';
+            if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] == L':' &&
+                  szWorkingDirBuf[2] == L'\\'))
             {
-                *lpFilePart = _T('\0');
+                *lpFilePart = L'\0';
             }
             pszWorkingDir = szWorkingDirBuf;
         }
     }
-    else if (pszWorkingDir && pszWorkingDir[0] == _T('\0'))
+    else if (pszWorkingDir && pszWorkingDir[0] == L'\0')
     {
         pszWorkingDir = NULL;
     }
 
-    _tcscpy(szPath, pszFolder);
+    wcscpy(szPath, pszFolder);
 
     Ptr = PathAddBackslash(szPath);
 
-    _tcscpy(Ptr, pszName);
+    wcscpy(Ptr, pszName);
 
     // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
-    return SUCCEEDED(CreateShellLink(szPath, szExeName, _T(""), pszWorkingDir, szExeName, iIconNr, pszDescription));
+    return SUCCEEDED(CreateShellLink(szPath, szExeName, L"", pszWorkingDir, szExeName, iIconNr, pszDescription));
 }
 
 
-static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR  pszSection, LPCWSTR pszFolder)
+static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder)
 {
     INFCONTEXT Context;
     DWORD dwFieldCount;
@@ -226,22 +214,22 @@ static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR  pszSection, LPCWSTR ps
         if (dwFieldCount < 4)
             continue;
 
-        if (!SetupGetStringFieldW(&Context, 1, szCommand, MAX_PATH, NULL))
+        if (!SetupGetStringFieldW(&Context, 1, szCommand, ARRAYSIZE(szCommand), NULL))
             continue;
 
-        if (!SetupGetStringFieldW(&Context, 2, szName, MAX_PATH, NULL))
+        if (!SetupGetStringFieldW(&Context, 2, szName, ARRAYSIZE(szName), NULL))
             continue;
 
-        if (!SetupGetStringFieldW(&Context, 3, szDescription, MAX_PATH, NULL))
+        if (!SetupGetStringFieldW(&Context, 3, szDescription, ARRAYSIZE(szDescription), NULL))
             continue;
 
         if (!SetupGetIntField(&Context, 4, &iIconNr))
             continue;
 
-        if (dwFieldCount < 5 || !SetupGetStringFieldW(&Context, 5, szDirectory, MAX_PATH, NULL))
+        if (dwFieldCount < 5 || !SetupGetStringFieldW(&Context, 5, szDirectory, ARRAYSIZE(szDirectory), NULL))
             szDirectory[0] = L'\0';
 
-        _tcscat(szName, L".lnk");
+        wcscat(szName, L".lnk");
 
         CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr, szDirectory);
 
@@ -268,13 +256,13 @@ static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
         if (SetupGetFieldCount(&Context) < 2)
             continue;
 
-        if (!SetupGetStringFieldW(&Context, 0, szFolderSection, MAX_PATH, NULL))
+        if (!SetupGetStringFieldW(&Context, 0, szFolderSection, ARRAYSIZE(szFolderSection), NULL))
             continue;
 
         if (!SetupGetIntField(&Context, 1, &csidl))
             continue;
 
-        if (!SetupGetStringFieldW(&Context, 2, szFolder, MAX_PATH, NULL))
+        if (!SetupGetStringFieldW(&Context, 2, szFolder, ARRAYSIZE(szFolder), NULL))
             continue;
 
         if (FAILED(SHGetFolderPathAndSubDirW(NULL, csidl|CSIDL_FLAG_CREATE, (HANDLE)-1, SHGFP_TYPE_DEFAULT, szFolder, szPath)))
@@ -282,7 +270,7 @@ static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
 
         CreateShortcutsFromSection(hinf, szFolderSection, szPath);
 
-    }while (SetupFindNextLine(&Context, &Context));
+    } while (SetupFindNextLine(&Context, &Context));
 
     CoUninitialize();
 
@@ -299,32 +287,30 @@ CreateTempDir(
     HKEY hKey;
 
     if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
-                     L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
-                     0,
-                     KEY_QUERY_VALUE,
-                     &hKey) != ERROR_SUCCESS)
+                      L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
+                      0,
+                      KEY_QUERY_VALUE,
+                      &hKey) != ERROR_SUCCESS)
     {
         FatalError("Error: %lu\n", GetLastError());
         return;
     }
 
     /* Get temp dir */
-    dwLength = MAX_PATH * sizeof(WCHAR);
+    dwLength = ARRAYSIZE(szBuffer) * sizeof(WCHAR);
     if (RegQueryValueExW(hKey,
-                        VarName,
-                        NULL,
-                        NULL,
-                        (LPBYTE)szBuffer,
-                        &dwLength) != ERROR_SUCCESS)
+                         VarName,
+                         NULL,
+                         NULL,
+                         (LPBYTE)szBuffer,
+                         &dwLength) != ERROR_SUCCESS)
     {
         FatalError("Error: %lu\n", GetLastError());
         goto cleanup;
     }
 
     /* Expand it */
-    if (!ExpandEnvironmentStringsW(szBuffer,
-                                  szTempDir,
-                                  MAX_PATH))
+    if (!ExpandEnvironmentStringsW(szBuffer, szTempDir, ARRAYSIZE(szTempDir)))
     {
         FatalError("Error: %lu\n", GetLastError());
         goto cleanup;
@@ -362,10 +348,10 @@ InstallSysSetupInfDevices(VOID)
     do
     {
         if (!SetupGetStringFieldW(&InfContext,
-                                 0,
-                                 szLineBuffer,
-                                 sizeof(szLineBuffer)/sizeof(szLineBuffer[0]),
-                                 &dwLineLength))
+                                  0,
+                                  szLineBuffer,
+                                  ARRAYSIZE(szLineBuffer),
+                                  &dwLineLength))
         {
             return FALSE;
         }
@@ -389,9 +375,9 @@ InstallSysSetupInfComponents(VOID)
     HINF hComponentInf = INVALID_HANDLE_VALUE;
 
     if (!SetupFindFirstLineW(hSysSetupInf,
-                            L"Infs.Always",
-                            NULL,
-                            &InfContext))
+                             L"Infs.Always",
+                             NULL,
+                             &InfContext))
     {
         DPRINT("No Inf.Always section found\n");
     }
@@ -400,20 +386,20 @@ InstallSysSetupInfComponents(VOID)
         do
         {
             if (!SetupGetStringFieldW(&InfContext,
-                                     1, // Get the component name
-                                     szNameBuffer,
-                                     sizeof(szNameBuffer)/sizeof(szNameBuffer[0]),
-                                     NULL))
+                                      1, // Get the component name
+                                      szNameBuffer,
+                                      ARRAYSIZE(szNameBuffer),
+                                      NULL))
             {
                 FatalError("Error while trying to get component name \n");
                 return FALSE;
             }
 
             if (!SetupGetStringFieldW(&InfContext,
-                                     2, // Get the component install section
-                                     szSectionBuffer,
-                                     sizeof(szSectionBuffer)/sizeof(szSectionBuffer[0]),
-                                     NULL))
+                                      2, // Get the component install section
+                                      szSectionBuffer,
+                                      ARRAYSIZE(szSectionBuffer),
+                                      NULL))
             {
                 FatalError("Error while trying to get component install section \n");
                 return FALSE;
@@ -433,16 +419,16 @@ InstallSysSetupInfComponents(VOID)
             }
 
             if (!SetupInstallFromInfSectionW(NULL,
-                                            hComponentInf,
-                                            szSectionBuffer,
-                                            SPINST_ALL,
-                                            NULL,
-                                            NULL,
-                                            SP_COPY_NEWER,
-                                            SetupDefaultQueueCallbackW,
-                                            NULL,
-                                            NULL,
-                                            NULL))
+                                             hComponentInf,
+                                             szSectionBuffer,
+                                             SPINST_ALL,
+                                             NULL,
+                                             NULL,
+                                             SP_COPY_NEWER,
+                                             SetupDefaultQueueCallbackW,
+                                             NULL,
+                                             NULL,
+                                             NULL))
            {
                 FatalError("Error while trying to install : %S (Error: %lu)\n", szNameBuffer, GetLastError());
                 SetupCloseInfFile(hComponentInf);
@@ -459,7 +445,6 @@ InstallSysSetupInfComponents(VOID)
 
 
 
-
 BOOL
 RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
 {
@@ -479,7 +464,7 @@ RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
     do
     {
         /* Get the name of the current type library */
-        if (!SetupGetStringFieldW(&InfContext, 1, szName, MAX_PATH, NULL))
+        if (!SetupGetStringFieldW(&InfContext, 1, szName, ARRAYSIZE(szName), NULL))
         {
             FatalError("SetupGetStringFieldW failed\n");
             continue;
@@ -496,7 +481,7 @@ RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
         }
 
         p = PathAddBackslash(szPath);
-        _tcscpy(p, szName);
+        wcscpy(p, szName);
 
         hmod = LoadLibraryW(szName);
         if (hmod == NULL)
@@ -507,7 +492,7 @@ RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
 
         __wine_register_resources(hmod);
 
-    }while (SetupFindNextLine(&InfContext, &InfContext));
+    } while (SetupFindNextLine(&InfContext, &InfContext));
 
     return TRUE;
 }
@@ -537,11 +522,11 @@ EnableUserModePnpManager(VOID)
     }
 
     bRet = ChangeServiceConfigW(hService,
-                               SERVICE_NO_CHANGE,
-                               SERVICE_AUTO_START,
-                               SERVICE_NO_CHANGE,
-                               NULL, NULL, NULL,
-                               NULL, NULL, NULL, NULL);
+                                SERVICE_NO_CHANGE,
+                                SERVICE_AUTO_START,
+                                SERVICE_NO_CHANGE,
+                                NULL, NULL, NULL,
+                                NULL, NULL, NULL, NULL);
     if (!bRet)
     {
         DPRINT1("Unable to change the service configuration\n");
@@ -580,7 +565,7 @@ StatusMessageWindowProc(
         {
             WCHAR szMsg[256];
 
-            if (!LoadStringW(hDllInstance, IDS_STATUS_INSTALL_DEV, szMsg, sizeof(szMsg)/sizeof(szMsg[0])))
+            if (!LoadStringW(hDllInstance, IDS_STATUS_INSTALL_DEV, szMsg, ARRAYSIZE(szMsg)))
                 return FALSE;
             SetDlgItemTextW(hwndDlg, IDC_STATUSLABEL, szMsg);
             return TRUE;
@@ -597,12 +582,11 @@ ShowStatusMessageThread(
     HWND hWnd;
     MSG Msg;
 
-    hWnd = CreateDialogParam(
-        hDllInstance,
-        MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG),
-        GetDesktopWindow(),
-        StatusMessageWindowProc,
-        (LPARAM)NULL);
+    hWnd = CreateDialogParam(hDllInstance,
+                             MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG),
+                             GetDesktopWindow(),
+                             StatusMessageWindowProc,
+                             (LPARAM)NULL);
     if (!hWnd)
         return 0;
     *phWnd = hWnd;
@@ -664,12 +648,11 @@ IsConsoleBoot(VOID)
     BOOL bConsoleBoot = FALSE;
     LONG rc;
 
-    rc = RegOpenKeyExW(
-        HKEY_LOCAL_MACHINE,
-        L"SYSTEM\\CurrentControlSet\\Control",
-        0,
-        KEY_QUERY_VALUE,
-        &hControlKey);
+    rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                       L"SYSTEM\\CurrentControlSet\\Control",
+                       0,
+                       KEY_QUERY_VALUE,
+                       &hControlKey);
     if (rc != ERROR_SUCCESS)
         goto cleanup;
 
@@ -706,11 +689,10 @@ CommonInstall(VOID)
 {
     HWND hWnd = NULL;
 
-    hSysSetupInf = SetupOpenInfFileW(
-        L"syssetup.inf",
-        NULL,
-        INF_STYLE_WIN4,
-        NULL);
+    hSysSetupInf = SetupOpenInfFileW(L"syssetup.inf",
+                                     NULL,
+                                     INF_STYLE_WIN4,
+                                     NULL);
     if (hSysSetupInf == INVALID_HANDLE_VALUE)
     {
         FatalError("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
@@ -733,14 +715,12 @@ CommonInstall(VOID)
     {
         HANDLE hThread;
 
-        hThread = CreateThread(
-            NULL,
-            0,
-            ShowStatusMessageThread,
-            (LPVOID)&hWnd,
-            0,
-            NULL);
-
+        hThread = CreateThread(NULL,
+                               0,
+                               ShowStatusMessageThread,
+                               (LPVOID)&hWnd,
+                               0,
+                               NULL);
         if (hThread)
             CloseHandle(hThread);
     }
@@ -786,7 +766,7 @@ InstallInfSection(
     BOOL ret = FALSE;
 
     /* Get Windows directory */
-    BufferSize = MAX_PATH - 5 - wcslen(InfFile);
+    BufferSize = ARRAYSIZE(Buffer) - 5 - wcslen(InfFile);
     if (GetWindowsDirectoryW(Buffer, BufferSize) > BufferSize)
     {
         /* Function failed */
@@ -812,16 +792,15 @@ InstallInfSection(
     if (ret && InfSection)
     {
         ret = SetupInstallFromInfSectionW(
-            hWnd, hInf,
-            InfSection, SPINST_ALL,
-            NULL, NULL, SP_COPY_NEWER,
-            SetupDefaultQueueCallbackW, Context,
-            NULL, NULL);
+                hWnd, hInf,
+                InfSection, SPINST_ALL,
+                NULL, NULL, SP_COPY_NEWER,
+                SetupDefaultQueueCallbackW, Context,
+                NULL, NULL);
     }
     if (ret && InfService)
     {
-        ret = SetupInstallServicesFromInfSectionW(
-            hInf, InfService, 0);
+        ret = SetupInstallServicesFromInfSectionW(hInf, InfService, 0);
     }
 
 cleanup:
@@ -841,9 +820,9 @@ InstallLiveCD(IN HINSTANCE hInstance)
 
     /* Hack: Install TCP/IP protocol driver */
     bRes = InstallInfSection(NULL,
-                            L"nettcpip.inf",
-                            L"MS_TCPIP.PrimaryInstall",
-                            L"MS_TCPIP.PrimaryInstall.Services");
+                             L"nettcpip.inf",
+                             L"MS_TCPIP.PrimaryInstall",
+                             L"MS_TCPIP.PrimaryInstall.Services");
     if (!bRes && GetLastError() != ERROR_FILE_NOT_FOUND)
     {
         DPRINT("InstallInfSection() failed with error 0x%lx\n", GetLastError());
@@ -861,9 +840,9 @@ InstallLiveCD(IN HINSTANCE hInstance)
     _SEH2_TRY
     {
         if (!SetupInstallFromInfSectionW(NULL,
-            hSysSetupInf, L"RegistrationPhase2",
-            SPINST_ALL,
-            0, NULL, 0, NULL, NULL, NULL, NULL))
+                                         hSysSetupInf, L"RegistrationPhase2",
+                                         SPINST_ALL,
+                                         0, NULL, 0, NULL, NULL, NULL, NULL))
         {
             DPRINT1("SetupInstallFromInfSectionW failed!\n");
         }
@@ -881,17 +860,16 @@ InstallLiveCD(IN HINSTANCE hInstance)
     /* Run the shell */
     ZeroMemory(&StartupInfo, sizeof(StartupInfo));
     StartupInfo.cb = sizeof(StartupInfo);
-    bRes = CreateProcessW(
-        L"userinit.exe",
-        NULL,
-        NULL,
-        NULL,
-        FALSE,
-        0,
-        NULL,
-        NULL,
-        &StartupInfo,
-        &ProcessInformation);
+    bRes = CreateProcessW(L"userinit.exe",
+                          NULL,
+                          NULL,
+                          NULL,
+                          FALSE,
+                          0,
+                          NULL,
+                          NULL,
+                          &StartupInfo,
+                          &ProcessInformation);
     if (!bRes)
         goto error;
 
@@ -1075,10 +1053,10 @@ InitializeDefaultUserLocale(VOID)
     i = 0;
     while (LocaleData[i].pValue != NULL)
     {
-        if (GetLocaleInfo(lcid,
-                          LocaleData[i].LCType | LOCALE_NOUSEROVERRIDE,
-                          szBuffer,
-                          sizeof(szBuffer) / sizeof(WCHAR)))
+        if (GetLocaleInfoW(lcid,
+                           LocaleData[i].LCType | LOCALE_NOUSEROVERRIDE,
+                           szBuffer,
+                           ARRAYSIZE(szBuffer)))
         {
             RegSetValueExW(hLocaleKey,
                            LocaleData[i].pValue,
@@ -1100,7 +1078,7 @@ DWORD
 WINAPI
 InstallReactOS(HINSTANCE hInstance)
 {
-    TCHAR szBuffer[MAX_PATH];
+    WCHAR szBuffer[MAX_PATH];
     HANDLE token;
     TOKEN_PRIVILEGES privs;
     HKEY hKey;
@@ -1122,7 +1100,7 @@ InstallReactOS(HINSTANCE hInstance)
 
     InitializeDefaultUserLocale();
 
-    if (GetWindowsDirectory(szBuffer, sizeof(szBuffer) / sizeof(TCHAR)))
+    if (GetWindowsDirectoryW(szBuffer, ARRAYSIZE(szBuffer)))
     {
         if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                           L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
@@ -1148,7 +1126,7 @@ InstallReactOS(HINSTANCE hInstance)
         }
 
         PathAddBackslash(szBuffer);
-        _tcscat(szBuffer, _T("system"));
+        wcscat(szBuffer, L"system");
         CreateDirectory(szBuffer, NULL);
     }
 
@@ -1224,23 +1202,21 @@ InstallReactOS(HINSTANCE hInstance)
         FatalError("OpenProcessToken() failed!");
         return 0;
     }
-    if (!LookupPrivilegeValue(
-        NULL,
-        SE_SHUTDOWN_NAME,
-        &privs.Privileges[0].Luid))
+    if (!LookupPrivilegeValue(NULL,
+                              SE_SHUTDOWN_NAME,
+                              &privs.Privileges[0].Luid))
     {
         FatalError("LookupPrivilegeValue() failed!");
         return 0;
     }
     privs.PrivilegeCount = 1;
     privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-    if (AdjustTokenPrivileges(
-        token,
-        FALSE,
-        &privs,
-        0,
-        (PTOKEN_PRIVILEGES)NULL,
-        NULL) == 0)
+    if (AdjustTokenPrivileges(token,
+                              FALSE,
+                              &privs,
+                              0,
+                              (PTOKEN_PRIVILEGES)NULL,
+                              NULL) == 0)
     {
         FatalError("AdjustTokenPrivileges() failed!");
         return 0;