advpack: Use wide-char string literals.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-10-07 00:51:57 +02:00 committed by Alexandre Julliard
parent 86ab6bc9a7
commit 2a2001b300
5 changed files with 46 additions and 133 deletions

View File

@ -41,13 +41,7 @@ typedef HRESULT (WINAPI *DLLREGISTER) (void);
#define PREFIX_LEN 5
/* registry path of the Installed Components key for per-user stubs */
static const WCHAR setup_key[] = {
'S','O','F','T','W','A','R','E','\\',
'M','i','c','r','o','s','o','f','t','\\',
'A','c','t','i','v','e',' ','S','e','t','u','p','\\',
'I','n','s','t','a','l','l','e','d',' ',
'C','o','m','p','o','n','e','n','t','s',0
};
static const WCHAR setup_key[] = L"SOFTWARE\\Microsoft\\Active Setup\\Installed Components";
/* Strip single quotes from a token - note size includes NULL */
static void strip_quotes(WCHAR *buffer, DWORD *size)
@ -73,9 +67,6 @@ static void get_dest_dir(HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dw
HKEY root, subkey = 0;
DWORD size;
static const WCHAR hklm[] = {'H','K','L','M',0};
static const WCHAR hkcu[] = {'H','K','C','U',0};
/* load the destination parameters */
SetupFindFirstLineW(hInf, pszSection, NULL, &context);
SetupGetStringFieldW(&context, 1, prefix, PREFIX_LEN + 2, &size);
@ -85,9 +76,9 @@ static void get_dest_dir(HINF hInf, PCWSTR pszSection, PWSTR pszBuffer, DWORD dw
SetupGetStringFieldW(&context, 3, value, MAX_PATH + 2, &size);
strip_quotes(value, &size);
if (!lstrcmpW(prefix, hklm))
if (!lstrcmpW(prefix, L"HKLM"))
root = HKEY_LOCAL_MACHINE;
else if (!lstrcmpW(prefix, hkcu))
else if (!lstrcmpW(prefix, L"HKCU"))
root = HKEY_CURRENT_USER;
else
root = NULL;
@ -115,13 +106,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
DWORD size;
int ldid;
static const WCHAR source_dir[] = {'S','o','u','r','c','e','D','i','r',0};
static const WCHAR custDestW[] = {
'C','u','s','t','o','m','D','e','s','t','i','n','a','t','i','o','n',0
};
if (!SetupGetLineTextW(NULL, hInf, pszInstallSection, custDestW,
if (!SetupGetLineTextW(NULL, hInf, pszInstallSection, L"CustomDestination",
field, MAX_FIELD_LENGTH, &size))
return;
@ -165,7 +150,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
}
/* set dest to pszWorkingDir if key is SourceDir */
if (pszWorkingDir && !lstrcmpiW(value, source_dir))
if (pszWorkingDir && !lstrcmpiW(value, L"SourceDir"))
lstrcpynW(dest, pszWorkingDir, MAX_PATH);
else
get_dest_dir(hInf, value, dest, MAX_PATH);
@ -559,12 +544,6 @@ HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW* pPerUser)
{
HKEY setup, guid;
static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
static const WCHAR locale[] = {'L','o','c','a','l','e',0};
static const WCHAR compid[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
static const WCHAR isinstalled[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
TRACE("(%p)\n", pPerUser);
if (!pPerUser || !*pPerUser->szGUID)
@ -585,25 +564,25 @@ HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW* pPerUser)
if (*pPerUser->szStub)
{
RegSetValueExW(guid, stub_path, 0, REG_SZ, (LPBYTE)pPerUser->szStub,
RegSetValueExW(guid, L"StubPath", 0, REG_SZ, (BYTE *)pPerUser->szStub,
(lstrlenW(pPerUser->szStub) + 1) * sizeof(WCHAR));
}
if (*pPerUser->szVersion)
{
RegSetValueExW(guid, version, 0, REG_SZ, (LPBYTE)pPerUser->szVersion,
RegSetValueExW(guid, L"Version", 0, REG_SZ, (BYTE *)pPerUser->szVersion,
(lstrlenW(pPerUser->szVersion) + 1) * sizeof(WCHAR));
}
if (*pPerUser->szLocale)
{
RegSetValueExW(guid, locale, 0, REG_SZ, (LPBYTE)pPerUser->szLocale,
RegSetValueExW(guid, L"Locale", 0, REG_SZ, (BYTE *)pPerUser->szLocale,
(lstrlenW(pPerUser->szLocale) + 1) * sizeof(WCHAR));
}
if (*pPerUser->szCompID)
{
RegSetValueExW(guid, compid, 0, REG_SZ, (LPBYTE)pPerUser->szCompID,
RegSetValueExW(guid, L"ComponentID", 0, REG_SZ, (BYTE *)pPerUser->szCompID,
(lstrlenW(pPerUser->szCompID) + 1) * sizeof(WCHAR));
}
@ -613,7 +592,7 @@ HRESULT WINAPI SetPerUserSecValuesW(PERUSERSECTIONW* pPerUser)
(lstrlenW(pPerUser->szDispName) + 1) * sizeof(WCHAR));
}
RegSetValueExW(guid, isinstalled, 0, REG_DWORD,
RegSetValueExW(guid, L"IsInstalled", 0, REG_DWORD,
(LPBYTE)&pPerUser->dwIsInstalled, sizeof(DWORD));
RegCloseKey(guid);
@ -911,10 +890,6 @@ HRESULT WINAPI UserInstStubWrapperW(HWND hWnd, HINSTANCE hInstance,
HRESULT hr = S_OK;
BOOL res;
static const WCHAR real_stub_path[] = {
'R','e','a','l','S','t','u','b','P','a','t','h',0
};
TRACE("(%p, %p, %s, %i)\n", hWnd, hInstance, debugstr_w(pszParms), nShow);
if (!pszParms || !*pszParms)
@ -931,7 +906,7 @@ HRESULT WINAPI UserInstStubWrapperW(HWND hWnd, HINSTANCE hInstance,
return E_FAIL;
}
res = RegQueryValueExW(guid, real_stub_path, NULL, NULL, (LPBYTE)stub, &size);
res = RegQueryValueExW(guid, L"RealStubPath", NULL, NULL, (BYTE *)stub, &size);
if (res || !*stub)
goto done;

View File

@ -120,14 +120,6 @@ HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir,
WCHAR szIniPath[MAX_PATH];
LPCWSTR szString = NULL;
static const WCHAR szBackupEntry[] = {
'-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0
};
static const WCHAR backslash[] = {'\\',0};
static const WCHAR ini[] = {'.','i','n','i',0};
static const WCHAR backup[] = {'b','a','c','k','u','p',0};
TRACE("(%s, %s, %s, %d)\n", debugstr_w(lpcszFileList),
debugstr_w(lpcszBackupDir), debugstr_w(lpcszBaseName), dwFlags);
@ -139,21 +131,21 @@ HRESULT WINAPI AddDelBackupEntryW(LPCWSTR lpcszFileList, LPCWSTR lpcszBackupDir,
else
GetWindowsDirectoryW(szIniPath, MAX_PATH);
lstrcatW(szIniPath, backslash);
lstrcatW(szIniPath, L"\\");
lstrcatW(szIniPath, lpcszBaseName);
lstrcatW(szIniPath, ini);
lstrcatW(szIniPath, L".ini");
SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_NORMAL);
if (dwFlags & AADBE_ADD_ENTRY)
szString = szBackupEntry;
szString = L"-1,0,0,0,0,0,-1";
else if (dwFlags & AADBE_DEL_ENTRY)
szString = NULL;
/* add or delete the INI entries */
while (*lpcszFileList)
{
WritePrivateProfileStringW(backup, lpcszFileList, szString, szIniPath);
WritePrivateProfileStringW(L"backup", lpcszFileList, szString, szIniPath);
lpcszFileList += lstrlenW(lpcszFileList) + 1;
}
@ -332,10 +324,6 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
DWORD fattrs = GetFileAttributesW(fname);
HRESULT ret = E_FAIL;
static const WCHAR asterisk[] = {'*',0};
static const WCHAR dot[] = {'.',0};
static const WCHAR dotdot[] = {'.','.',0};
if (fattrs & FILE_ATTRIBUTE_DIRECTORY)
{
HANDLE hFindFile;
@ -345,7 +333,7 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
/* Generate a path with wildcard suitable for iterating */
if (fname_len && fname[fname_len-1] != '\\') fname[fname_len++] = '\\';
lstrcpyW(fname + fname_len, asterisk);
lstrcpyW(fname + fname_len, L"*");
if ((hFindFile = FindFirstFileW(fname, &w32fd)) != INVALID_HANDLE_VALUE)
{
@ -353,8 +341,7 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
for (done = FALSE; !done; done = !FindNextFileW(hFindFile, &w32fd))
{
TRACE("%s\n", debugstr_w(w32fd.cFileName));
if (lstrcmpW(dot, w32fd.cFileName) != 0 &&
lstrcmpW(dotdot, w32fd.cFileName) != 0)
if (lstrcmpW(L".", w32fd.cFileName) != 0 && lstrcmpW(L"..", w32fd.cFileName) != 0)
{
lstrcpyW(fname + fname_len, w32fd.cFileName);
if (DELNODE_recurse_dirtree(fname, flags) != S_OK)
@ -1063,12 +1050,6 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer,
BOOL bFileCopied = FALSE;
UINT uValueLen;
static const WCHAR backslash[] = {'\\',0};
static const WCHAR translation[] = {
'\\','V','a','r','F','i','l','e','I','n','f','o',
'\\','T','r','a','n','s','l','a','t','i','o','n',0
};
TRACE("(%s, %p, %p, %d)\n", debugstr_w(lpszFilename),
pdwMSVer, pdwLSVer, bVersion);
@ -1106,8 +1087,7 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer,
if (bVersion)
{
if (!VerQueryValueW(pVersionInfo, backslash,
(LPVOID *)&pFixedVersionInfo, &uValueLen))
if (!VerQueryValueW(pVersionInfo, L"\\", (void **)&pFixedVersionInfo, &uValueLen))
goto done;
if (!uValueLen)
@ -1118,7 +1098,7 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer,
}
else
{
if (!VerQueryValueW(pVersionInfo, translation,
if (!VerQueryValueW(pVersionInfo, L"\\VarFileInfo\\Translation",
(LPVOID *)&pLangAndCodePage, &uValueLen))
goto done;

View File

@ -59,20 +59,6 @@ typedef struct _ADVInfo
typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, const void *arg);
/* Advanced INF commands */
static const WCHAR CheckAdminRights[] = {
'C','h','e','c','k','A','d','m','i','n','R','i','g','h','t','s',0
};
static const WCHAR DelDirs[] = {'D','e','l','D','i','r','s',0};
static const WCHAR PerUserInstall[] = {'P','e','r','U','s','e','r','I','n','s','t','a','l','l',0};
static const WCHAR RegisterOCXs[] = {'R','e','g','i','s','t','e','r','O','C','X','s',0};
static const WCHAR RunPreSetupCommands[] = {
'R','u','n','P','r','e','S','e','t','u','p','C','o','m','m','a','n','d','s',0
};
static const WCHAR RunPostSetupCommands[] = {
'R','u','n','P','o','s','t','S','e','t','u','p','C','o','m','m','a','n','d','s',0
};
/* Advanced INF callbacks */
static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, const void *arg)
{
@ -103,33 +89,25 @@ static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *ar
INFCONTEXT context;
DWORD size;
static const WCHAR disp_name[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
static const WCHAR is_installed[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
static const WCHAR comp_id[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
static const WCHAR guid[] = {'G','U','I','D',0};
static const WCHAR locale[] = {'L','o','c','a','l','e',0};
static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
per_user.bRollback = FALSE;
per_user.dwIsInstalled = 0;
SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, ARRAY_SIZE(per_user.szDispName), &size);
SetupGetLineTextW(NULL, hinf, field, L"DisplayName", per_user.szDispName, ARRAY_SIZE(per_user.szDispName), &size);
SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, ARRAY_SIZE(per_user.szVersion), &size);
SetupGetLineTextW(NULL, hinf, field, L"Version", per_user.szVersion, ARRAY_SIZE(per_user.szVersion), &size);
if (SetupFindFirstLineW(hinf, field, is_installed, &context))
if (SetupFindFirstLineW(hinf, field, L"IsInstalled", &context))
{
SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
}
SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, ARRAY_SIZE(per_user.szCompID), &size);
SetupGetLineTextW(NULL, hinf, field, L"ComponentID", per_user.szCompID, ARRAY_SIZE(per_user.szCompID), &size);
SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, ARRAY_SIZE(per_user.szGUID), &size);
SetupGetLineTextW(NULL, hinf, field, L"GUID", per_user.szGUID, ARRAY_SIZE(per_user.szGUID), &size);
SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, ARRAY_SIZE(per_user.szLocale), &size);
SetupGetLineTextW(NULL, hinf, field, L"Locale", per_user.szLocale, ARRAY_SIZE(per_user.szLocale), &size);
SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, ARRAY_SIZE(per_user.szStub), &size);
SetupGetLineTextW(NULL, hinf, field, L"StubPath", per_user.szStub, ARRAY_SIZE(per_user.szStub), &size);
return SetPerUserSecValuesW(&per_user);
}
@ -299,8 +277,7 @@ static HRESULT check_admin_rights(const ADVInfo *info)
INFCONTEXT context;
HRESULT hr = S_OK;
if (!SetupFindFirstLineW(info->hinf, info->install_sec,
CheckAdminRights, &context))
if (!SetupFindFirstLineW(info->hinf, info->install_sec, L"CheckAdminRights", &context))
return S_OK;
if (!SetupGetIntField(&context, 1, &check))
@ -356,30 +333,29 @@ static HRESULT adv_install(ADVInfo *info)
if (hr != S_OK)
return hr;
hr = iterate_section_fields(info->hinf, info->install_sec, RunPreSetupCommands,
hr = iterate_section_fields(info->hinf, info->install_sec, L"RunPreSetupCommands",
run_setup_commands_callback, info);
if (hr != S_OK)
return hr;
OleInitialize(NULL);
hr = iterate_section_fields(info->hinf, info->install_sec,
RegisterOCXs, register_ocxs_callback, NULL);
L"RegisterOCXs", register_ocxs_callback, NULL);
OleUninitialize();
if (hr != S_OK)
return hr;
hr = iterate_section_fields(info->hinf, info->install_sec,
PerUserInstall, per_user_install_callback, info);
L"PerUserInstall", per_user_install_callback, info);
if (hr != S_OK)
return hr;
hr = iterate_section_fields(info->hinf, info->install_sec, RunPostSetupCommands,
hr = iterate_section_fields(info->hinf, info->install_sec, L"RunPostSetupCommands",
run_setup_commands_callback, info);
if (hr != S_OK)
return hr;
hr = iterate_section_fields(info->hinf, info->install_sec,
DelDirs, del_dirs_callback, info);
hr = iterate_section_fields(info->hinf, info->install_sec, L"DelDirs", del_dirs_callback, info);
if (hr != S_OK)
return hr;
@ -393,9 +369,6 @@ static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR work
LPCWSTR ptr;
DWORD len;
static const WCHAR backslash[] = {'\\',0};
static const WCHAR inf_dir[] = {'\\','I','N','F',0};
if ((ptr = wcsrchr(inf_filename, '\\')))
{
len = ptr - inf_filename + 1;
@ -409,7 +382,7 @@ static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR work
else
{
GetCurrentDirectoryW(MAX_PATH, path);
lstrcatW(path, backslash);
lstrcatW(path, L"\\");
lstrcatW(path, inf_filename);
/* check if the INF file is in the current directory */
@ -421,7 +394,7 @@ static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR work
{
/* default to the windows\inf directory if all else fails */
GetWindowsDirectoryW(path, MAX_PATH);
lstrcatW(path, inf_dir);
lstrcatW(path, L"\\INF");
}
len = lstrlenW(path) + 1;
@ -445,7 +418,6 @@ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
HRESULT hr;
LPCWSTR ptr, path;
static const WCHAR backslash[] = {'\\',0};
if (!(ptr = wcsrchr(inf_filename, '\\')))
ptr = inf_filename;
@ -485,7 +457,7 @@ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
return E_OUTOFMEMORY;
lstrcpyW(info->inf_path, info->working_dir);
lstrcatW(info->inf_path, backslash);
lstrcatW(info->inf_path, L"\\");
lstrcatW(info->inf_path, info->inf_filename);
/* RunSetupCommand opens unmodified filename parameter */

View File

@ -31,23 +31,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(advpack);
static const WCHAR REGINST[] = {'R','E','G','I','N','S','T',0};
static const WCHAR Strings[] = {'S','t','r','i','n','g','s',0};
static const WCHAR MOD_PATH[] = {'_','M','O','D','_','P','A','T','H',0};
static const WCHAR SYS_MOD_PATH[] = {'_','S','Y','S','_','M','O','D','_','P','A','T','H',0};
static const WCHAR SystemRoot[] = {'S','y','s','t','e','m','R','o','o','t',0};
static const WCHAR escaped_SystemRoot[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0};
static const WCHAR quote[] = {'\"',0};
static BOOL get_temp_ini_path(LPWSTR name)
{
static const WCHAR prefix[] = {'a','v','p',0};
WCHAR tmp_dir[MAX_PATH];
if(!GetTempPathW(ARRAY_SIZE(tmp_dir), tmp_dir))
return FALSE;
if(!GetTempFileNameW(tmp_dir, prefix, 0, name))
if (!GetTempFileNameW(tmp_dir, L"avp", 0, name))
return FALSE;
return TRUE;
}
@ -65,7 +56,7 @@ static BOOL create_tmp_ini_file(HMODULE hm, WCHAR *ini_file)
goto error;
}
if(!(hrsrc = FindResourceW(hm, REGINST, REGINST))) {
if (!(hrsrc = FindResourceW(hm, L"REGINST", L"REGINST"))) {
ERR("Can't find REGINST resource\n");
goto error;
}
@ -180,16 +171,16 @@ static HRESULT write_predefined_strings(HMODULE hm, LPCWSTR ini_path)
if (!GetModuleFileNameW(hm, mod_path + 1, ARRAY_SIZE(mod_path) - 2))
return E_FAIL;
lstrcatW(mod_path, quote);
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, ini_path);
lstrcatW(mod_path, L"\"");
WritePrivateProfileStringW(L"Strings", L"_MOD_PATH", mod_path, ini_path);
*sys_root = '\0';
GetEnvironmentVariableW(SystemRoot, sys_root, ARRAY_SIZE(sys_root));
GetEnvironmentVariableW(L"SystemRoot", sys_root, ARRAY_SIZE(sys_root));
if(!wcsnicmp(sys_root, mod_path + 1, lstrlenW(sys_root)))
{
*sys_mod_path = '\"';
lstrcpyW(sys_mod_path + 1, escaped_SystemRoot);
lstrcpyW(sys_mod_path + 1, L"%SystemRoot%");
lstrcatW(sys_mod_path, mod_path + 1 + lstrlenW(sys_root));
}
else
@ -198,7 +189,7 @@ static HRESULT write_predefined_strings(HMODULE hm, LPCWSTR ini_path)
lstrcpyW(sys_mod_path, mod_path);
}
WritePrivateProfileStringW(Strings, SYS_MOD_PATH, sys_mod_path, ini_path);
WritePrivateProfileStringW(L"Strings", L"_SYS_MOD_PATH", sys_mod_path, ini_path);
return S_OK;
}
@ -242,9 +233,9 @@ HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstT
tmp_value[0] = '\"';
lstrcpyW(tmp_value + 1, pstTable->pse[i].pszValue);
lstrcatW(tmp_value, quote);
WritePrivateProfileStringW(Strings, pstTable->pse[i].pszName, tmp_value, tmp_ini_path);
lstrcatW(tmp_value, L"\"");
WritePrivateProfileStringW(L"Strings", pstTable->pse[i].pszName, tmp_value, tmp_ini_path);
}
}

View File

@ -472,12 +472,7 @@ static void test_ExtractFiles(void)
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
if(pExtractFilesW) {
static const WCHAR extract_cabW[] = {'e','x','t','r','a','c','t','.','c','a','b',0};
static const WCHAR destW[] = {'d','e','s','t',0};
static const WCHAR file_listW[] =
{'a','.','t','x','t',':','t','e','s','t','d','i','r','\\','c','.','t','x','t',0};
hr = pExtractFilesW(extract_cabW, destW, 0, file_listW, NULL, 0);
hr = pExtractFilesW(L"extract.cab", L"dest", 0, L"a.txt:testdir\\c.txt", NULL, 0);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");