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