2005-01-20 21:03:13 +01:00
|
|
|
/*
|
|
|
|
* Unit tests for advpack.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Robert Reif
|
2005-04-27 11:37:25 +02:00
|
|
|
* Copyright (C) 2005 Sami Aario
|
2005-01-20 21:03:13 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-20 21:03:13 +01:00
|
|
|
*/
|
|
|
|
|
2005-11-08 13:43:35 +01:00
|
|
|
#include <stdio.h>
|
2007-10-25 22:23:15 +02:00
|
|
|
#include <stdarg.h>
|
2005-01-20 21:03:13 +01:00
|
|
|
#include <windows.h>
|
2005-02-14 12:02:46 +01:00
|
|
|
#include <advpub.h>
|
2005-04-27 11:37:25 +02:00
|
|
|
#include <assert.h>
|
2005-01-20 21:03:13 +01:00
|
|
|
#include "wine/test.h"
|
2005-02-14 12:02:46 +01:00
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
/* defines for the TranslateInfString/Ex tests */
|
2006-01-23 17:29:41 +01:00
|
|
|
#define TEST_STRING1 "\\Application Name"
|
2005-11-08 13:43:35 +01:00
|
|
|
#define TEST_STRING2 "%49001%\\Application Name"
|
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
/* defines for the SetPerUserSecValues tests */
|
|
|
|
#define GUID_KEY "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\guid"
|
2013-10-15 10:49:55 +02:00
|
|
|
#define REG_VAL_EXISTS(key, value) !RegQueryValueExA(key, value, NULL, NULL, NULL, NULL)
|
|
|
|
#define OPEN_GUID_KEY() !RegOpenKeyA(HKEY_LOCAL_MACHINE, GUID_KEY, &guid)
|
2006-04-06 10:48:49 +02:00
|
|
|
|
2008-03-09 12:15:05 +01:00
|
|
|
static HMODULE hAdvPack;
|
2006-02-27 20:50:03 +01:00
|
|
|
static HRESULT (WINAPI *pCloseINFEngine)(HINF);
|
2005-04-27 11:37:25 +02:00
|
|
|
static HRESULT (WINAPI *pDelNode)(LPCSTR,DWORD);
|
2006-07-28 22:32:25 +02:00
|
|
|
static HRESULT (WINAPI *pGetVersionFromFile)(LPCSTR,LPDWORD,LPDWORD,BOOL);
|
2006-02-27 20:50:03 +01:00
|
|
|
static HRESULT (WINAPI *pOpenINFEngine)(PCSTR,PCSTR,DWORD,HINF*,PVOID);
|
2013-10-15 10:49:55 +02:00
|
|
|
static HRESULT (WINAPI *pSetPerUserSecValues)(PPERUSERSECTIONA pPerUser);
|
2006-07-28 22:32:25 +02:00
|
|
|
static HRESULT (WINAPI *pTranslateInfString)(LPCSTR,LPCSTR,LPCSTR,LPCSTR,LPSTR,DWORD,LPDWORD,LPVOID);
|
2006-02-27 20:50:03 +01:00
|
|
|
static HRESULT (WINAPI *pTranslateInfStringEx)(HINF,PCSTR,PCSTR,PCSTR,PSTR,DWORD,PDWORD,PVOID);
|
2005-01-20 21:03:13 +01:00
|
|
|
|
2007-07-04 11:32:10 +02:00
|
|
|
static CHAR inf_file[MAX_PATH];
|
2007-08-10 23:28:34 +02:00
|
|
|
static CHAR PROG_FILES_ROOT[MAX_PATH];
|
2006-02-27 20:50:25 +01:00
|
|
|
static CHAR PROG_FILES[MAX_PATH];
|
2007-10-25 22:23:15 +02:00
|
|
|
static CHAR APP_PATH[MAX_PATH];
|
|
|
|
static DWORD APP_PATH_LEN;
|
2006-02-27 20:50:25 +01:00
|
|
|
|
|
|
|
static void get_progfiles_dir(void)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
|
|
|
|
RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey);
|
2007-08-10 23:28:34 +02:00
|
|
|
RegQueryValueExA(hkey, "ProgramFilesDir", NULL, NULL, (LPBYTE)PROG_FILES_ROOT, &size);
|
2006-02-27 20:50:25 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2007-10-25 22:23:15 +02:00
|
|
|
lstrcpyA(PROG_FILES, PROG_FILES_ROOT + 3); /* skip C:\ */
|
|
|
|
lstrcpyA(APP_PATH, PROG_FILES_ROOT);
|
|
|
|
lstrcatA(APP_PATH, TEST_STRING1);
|
|
|
|
APP_PATH_LEN = lstrlenA(APP_PATH) + 1;
|
2006-02-27 20:50:25 +01:00
|
|
|
}
|
|
|
|
|
2006-02-27 20:49:50 +01:00
|
|
|
static BOOL init_function_pointers(void)
|
|
|
|
{
|
2008-03-09 12:15:05 +01:00
|
|
|
hAdvPack = LoadLibraryA("advpack.dll");
|
2006-02-27 20:49:50 +01:00
|
|
|
|
|
|
|
if (!hAdvPack)
|
|
|
|
return FALSE;
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
pCloseINFEngine = (void*)GetProcAddress(hAdvPack, "CloseINFEngine");
|
2006-02-27 20:49:50 +01:00
|
|
|
pDelNode = (void *)GetProcAddress(hAdvPack, "DelNode");
|
|
|
|
pGetVersionFromFile = (void *)GetProcAddress(hAdvPack, "GetVersionFromFile");
|
2006-02-27 20:50:03 +01:00
|
|
|
pOpenINFEngine = (void*)GetProcAddress(hAdvPack, "OpenINFEngine");
|
2006-04-06 10:48:49 +02:00
|
|
|
pSetPerUserSecValues = (void*)GetProcAddress(hAdvPack, "SetPerUserSecValues");
|
2006-02-27 20:49:50 +01:00
|
|
|
pTranslateInfString = (void *)GetProcAddress(hAdvPack, "TranslateInfString");
|
2006-02-27 20:50:03 +01:00
|
|
|
pTranslateInfStringEx = (void*)GetProcAddress(hAdvPack, "TranslateInfStringEx");
|
2006-02-27 20:49:50 +01:00
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
if (!pCloseINFEngine || !pDelNode || !pGetVersionFromFile ||
|
2006-04-06 10:48:49 +02:00
|
|
|
!pOpenINFEngine || !pSetPerUserSecValues || !pTranslateInfString)
|
2008-06-08 12:31:26 +02:00
|
|
|
{
|
2009-02-26 09:45:17 +01:00
|
|
|
win_skip("Needed functions are not available\n");
|
2008-06-08 12:31:26 +02:00
|
|
|
FreeLibrary(hAdvPack);
|
2006-02-27 20:49:50 +01:00
|
|
|
return FALSE;
|
2008-06-08 12:31:26 +02:00
|
|
|
}
|
2006-02-27 20:49:50 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void version_test(void)
|
2005-01-20 21:03:13 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD major, minor;
|
|
|
|
|
|
|
|
major = minor = 0;
|
2005-02-14 12:02:46 +01:00
|
|
|
hr = pGetVersionFromFile("kernel32.dll", &major, &minor, FALSE);
|
2005-01-20 21:03:13 +01:00
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
|
2006-10-12 02:12:46 +02:00
|
|
|
"0x%08x\n", hr);
|
|
|
|
trace("kernel32.dll Language ID: 0x%08x, Codepage ID: 0x%08x\n",
|
2005-01-20 21:03:13 +01:00
|
|
|
major, minor);
|
|
|
|
|
|
|
|
major = minor = 0;
|
2005-02-14 12:02:46 +01:00
|
|
|
hr = pGetVersionFromFile("kernel32.dll", &major, &minor, TRUE);
|
2005-01-20 21:03:13 +01:00
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(kernel32.dll) failed, returned "
|
2006-10-12 02:12:46 +02:00
|
|
|
"0x%08x\n", hr);
|
2005-01-20 21:03:13 +01:00
|
|
|
trace("kernel32.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
|
|
|
|
HIWORD(minor), LOWORD(minor));
|
2005-11-14 13:27:39 +01:00
|
|
|
|
|
|
|
major = minor = 0;
|
|
|
|
hr = pGetVersionFromFile("advpack.dll", &major, &minor, FALSE);
|
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(advpack.dll) failed, returned "
|
2006-10-12 02:12:46 +02:00
|
|
|
"0x%08x\n", hr);
|
|
|
|
trace("advpack.dll Language ID: 0x%08x, Codepage ID: 0x%08x\n",
|
2005-11-14 13:27:39 +01:00
|
|
|
major, minor);
|
|
|
|
|
|
|
|
major = minor = 0;
|
|
|
|
hr = pGetVersionFromFile("advpack.dll", &major, &minor, TRUE);
|
|
|
|
ok (hr == S_OK, "GetVersionFromFileEx(advpack.dll) failed, returned "
|
2006-10-12 02:12:46 +02:00
|
|
|
"0x%08x\n", hr);
|
2005-11-14 13:27:39 +01:00
|
|
|
trace("advpack.dll version: %d.%d.%d.%d\n", HIWORD(major), LOWORD(major),
|
|
|
|
HIWORD(minor), LOWORD(minor));
|
2005-01-20 21:03:13 +01:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void delnode_test(void)
|
2005-04-27 11:37:25 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
HANDLE hn;
|
|
|
|
CHAR currDir[MAX_PATH];
|
2010-08-19 23:33:02 +02:00
|
|
|
UINT currDirLen;
|
2005-04-27 11:37:25 +02:00
|
|
|
|
|
|
|
/* Native DelNode apparently does not support relative paths, so we use
|
|
|
|
absolute paths for testing */
|
|
|
|
currDirLen = GetCurrentDirectoryA(sizeof(currDir) / sizeof(CHAR), currDir);
|
|
|
|
assert(currDirLen > 0 && currDirLen < sizeof(currDir) / sizeof(CHAR));
|
|
|
|
|
2005-08-15 12:47:31 +02:00
|
|
|
if(currDir[currDirLen - 1] == '\\')
|
|
|
|
currDir[--currDirLen] = 0;
|
|
|
|
|
2005-04-27 11:37:25 +02:00
|
|
|
/* Simple tests; these should fail. */
|
|
|
|
hr = pDelNode(NULL, 0);
|
|
|
|
ok (hr == E_FAIL, "DelNode called with NULL pathname should return E_FAIL\n");
|
|
|
|
hr = pDelNode("", 0);
|
|
|
|
ok (hr == E_FAIL, "DelNode called with empty pathname should return E_FAIL\n");
|
|
|
|
|
|
|
|
/* Test deletion of a file. */
|
2013-10-15 10:49:55 +02:00
|
|
|
hn = CreateFileA("DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
2005-04-27 11:37:25 +02:00
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
2013-10-15 10:49:55 +02:00
|
|
|
hr = pDelNode(lstrcatA(currDir, "\\DelNodeTestFile1"), 0);
|
2005-04-27 11:37:25 +02:00
|
|
|
ok (hr == S_OK, "DelNode failed deleting a single file\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of an empty directory. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
2013-10-15 10:49:55 +02:00
|
|
|
hr = pDelNode(lstrcatA(currDir, "\\DelNodeTestDir"), 0);
|
2005-04-27 11:37:25 +02:00
|
|
|
ok (hr == S_OK, "DelNode failed deleting an empty directory\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of a directory containing one file. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
2013-10-15 10:49:55 +02:00
|
|
|
hn = CreateFileA("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
2005-04-27 11:37:25 +02:00
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
2013-10-15 10:49:55 +02:00
|
|
|
hr = pDelNode(lstrcatA(currDir, "\\DelNodeTestDir"), 0);
|
2005-04-27 11:37:25 +02:00
|
|
|
ok (hr == S_OK, "DelNode failed deleting a directory containing one file\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
|
|
|
|
/* Test deletion of a directory containing multiple files. */
|
|
|
|
CreateDirectoryA("DelNodeTestDir", NULL);
|
2013-10-15 10:49:55 +02:00
|
|
|
hn = CreateFileA("DelNodeTestDir\\DelNodeTestFile1", GENERIC_WRITE, 0, NULL,
|
2005-04-27 11:37:25 +02:00
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
2013-10-15 10:49:55 +02:00
|
|
|
hn = CreateFileA("DelNodeTestDir\\DelNodeTestFile2", GENERIC_WRITE, 0, NULL,
|
2005-04-27 11:37:25 +02:00
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
2013-10-15 10:49:55 +02:00
|
|
|
hn = CreateFileA("DelNodeTestDir\\DelNodeTestFile3", GENERIC_WRITE, 0, NULL,
|
2005-04-27 11:37:25 +02:00
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
assert(hn != INVALID_HANDLE_VALUE);
|
|
|
|
CloseHandle(hn);
|
2013-10-15 10:49:55 +02:00
|
|
|
hr = pDelNode(lstrcatA(currDir, "\\DelNodeTestDir"), 0);
|
2005-04-27 11:37:25 +02:00
|
|
|
ok (hr == S_OK, "DelNode failed deleting a directory containing multiple files\n");
|
|
|
|
currDir[currDirLen] = '\0';
|
|
|
|
}
|
|
|
|
|
2007-10-25 22:23:15 +02:00
|
|
|
static void append_str(char **str, const char *data, ...)
|
2005-11-08 13:43:35 +01:00
|
|
|
{
|
2007-10-25 22:23:15 +02:00
|
|
|
va_list valist;
|
|
|
|
|
|
|
|
va_start(valist, data);
|
|
|
|
vsprintf(*str, data, valist);
|
2005-11-08 13:43:35 +01:00
|
|
|
*str += strlen(*str);
|
2007-10-25 22:23:15 +02:00
|
|
|
va_end(valist);
|
2005-11-08 13:43:35 +01:00
|
|
|
}
|
|
|
|
|
2007-03-10 22:00:47 +01:00
|
|
|
static void create_inf_file(void)
|
2005-11-08 13:43:35 +01:00
|
|
|
{
|
|
|
|
char data[1024];
|
|
|
|
char *ptr = data;
|
2005-11-10 12:37:03 +01:00
|
|
|
DWORD dwNumberOfBytesWritten;
|
2013-10-15 10:49:55 +02:00
|
|
|
HANDLE hf = CreateFileA(inf_file, GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
|
|
|
append_str(&ptr, "[Version]\n");
|
|
|
|
append_str(&ptr, "Signature=\"$Chicago$\"\n");
|
|
|
|
append_str(&ptr, "[CustInstDestSection]\n");
|
|
|
|
append_str(&ptr, "49001=ProgramFilesDir\n");
|
2007-08-10 23:28:34 +02:00
|
|
|
append_str(&ptr, "49010=DestA,1\n");
|
|
|
|
append_str(&ptr, "49020=DestB\n");
|
|
|
|
append_str(&ptr, "49030=DestC\n");
|
2005-11-08 13:43:35 +01:00
|
|
|
append_str(&ptr, "[ProgramFilesDir]\n");
|
|
|
|
append_str(&ptr, "HKLM,\"Software\\Microsoft\\Windows\\CurrentVersion\",");
|
2007-10-25 22:23:15 +02:00
|
|
|
append_str(&ptr, "\"ProgramFilesDir\",,\"%%24%%\\%%LProgramF%%\"\n");
|
2005-11-08 13:43:35 +01:00
|
|
|
append_str(&ptr, "[section]\n");
|
|
|
|
append_str(&ptr, "NotACustomDestination=Version\n");
|
|
|
|
append_str(&ptr, "CustomDestination=CustInstDestSection\n");
|
|
|
|
append_str(&ptr, "[Options.NTx86]\n");
|
|
|
|
append_str(&ptr, "49001=ProgramFilesDir\n");
|
|
|
|
append_str(&ptr, "InstallDir=%%49001%%\\%%DefaultAppPath%%\n");
|
2007-08-10 23:28:34 +02:00
|
|
|
append_str(&ptr, "Result1=%%49010%%\n");
|
|
|
|
append_str(&ptr, "Result2=%%49020%%\n");
|
|
|
|
append_str(&ptr, "Result3=%%49030%%\n");
|
2005-11-08 13:43:35 +01:00
|
|
|
append_str(&ptr, "CustomHDestination=CustInstDestSection\n");
|
|
|
|
append_str(&ptr, "[Strings]\n");
|
|
|
|
append_str(&ptr, "DefaultAppPath=\"Application Name\"\n");
|
2007-10-25 22:23:15 +02:00
|
|
|
append_str(&ptr, "LProgramF=\"%s\"\n", PROG_FILES);
|
2007-08-10 23:28:34 +02:00
|
|
|
append_str(&ptr, "[DestA]\n");
|
2007-10-25 22:23:15 +02:00
|
|
|
append_str(&ptr, "HKLM,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%\\%%LProgramF%%'\n");
|
2007-08-10 23:28:34 +02:00
|
|
|
append_str(&ptr, "[DestB]\n");
|
|
|
|
append_str(&ptr, "'HKLM','Software\\Microsoft\\Windows\\CurrentVersion',");
|
|
|
|
append_str(&ptr, "'ProgramFilesDir',,\"%%24%%\"\n");
|
|
|
|
append_str(&ptr, "[DestC]\n");
|
|
|
|
append_str(&ptr, "HKLM,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n");
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL);
|
2005-11-08 13:43:35 +01:00
|
|
|
CloseHandle(hf);
|
|
|
|
}
|
|
|
|
|
2007-03-10 22:00:47 +01:00
|
|
|
static void translateinfstring_test(void)
|
2005-11-08 13:43:35 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
DWORD dwSize;
|
|
|
|
|
|
|
|
create_inf_file();
|
|
|
|
|
|
|
|
/* pass in a couple invalid parameters */
|
|
|
|
hr = pTranslateInfString(NULL, NULL, NULL, NULL, buffer, MAX_PATH, &dwSize, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", (UINT)hr);
|
|
|
|
|
|
|
|
/* try to open an inf file that doesn't exist */
|
|
|
|
hr = pTranslateInfString("c:\\a.inf", "Options.NTx86", "Options.NTx86",
|
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-22 12:58:25 +01:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || hr == E_INVALIDARG ||
|
|
|
|
hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND),
|
|
|
|
"Expected E_INVALIDARG, 0x80070002 or 0x8007007e, got 0x%08x\n", (UINT)hr);
|
|
|
|
|
|
|
|
if(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))
|
|
|
|
{
|
2008-10-20 22:07:39 +02:00
|
|
|
win_skip("WinNT 3.51 detected. Skipping tests for TranslateInfString()\n");
|
2005-11-22 12:58:25 +01:00
|
|
|
return;
|
|
|
|
}
|
2005-11-08 13:43:35 +01:00
|
|
|
|
|
|
|
/* try a nonexistent section */
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfString(inf_file, "idontexist", "Options.NTx86",
|
2005-11-08 13:43:35 +01:00
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2009-01-26 08:30:49 +01:00
|
|
|
if (hr == E_ACCESSDENIED)
|
|
|
|
{
|
|
|
|
skip("TranslateInfString is broken\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-11-08 13:43:35 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", (UINT)hr);
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
2006-10-12 02:12:46 +02:00
|
|
|
ok(dwSize == 25, "Expected size 25, got %d\n", dwSize);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* try other nonexistent section */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfString(inf_file, "Options.NTx86", "idontexist",
|
2005-11-08 13:43:35 +01:00
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-10 12:37:03 +01:00
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND || hr == E_INVALIDARG,
|
|
|
|
"Expected SPAPI_E_LINE_NOT_FOUND or E_INVALIDARG, got 0x%08x\n", (UINT)hr);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* try nonexistent key */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfString(inf_file, "Options.NTx86", "Options.NTx86",
|
2005-11-08 13:43:35 +01:00
|
|
|
"notvalid", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-10 12:37:03 +01:00
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND || hr == E_INVALIDARG,
|
|
|
|
"Expected SPAPI_E_LINE_NOT_FOUND or E_INVALIDARG, got 0x%08x\n", (UINT)hr);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* test the behavior of pszInstallSection */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfString(inf_file, "section", "Options.NTx86",
|
2005-11-08 13:43:35 +01:00
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
2005-11-10 12:37:03 +01:00
|
|
|
ok(hr == ERROR_SUCCESS || hr == E_FAIL,
|
|
|
|
"Expected ERROR_SUCCESS or E_FAIL, got 0x%08x\n", (UINT)hr);
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
if(hr == ERROR_SUCCESS)
|
2005-11-08 13:43:35 +01:00
|
|
|
{
|
2007-10-25 22:23:15 +02:00
|
|
|
ok(!strcmp(buffer, APP_PATH), "Expected '%s', got '%s'\n", APP_PATH, buffer);
|
|
|
|
ok(dwSize == APP_PATH_LEN, "Expected size %d, got %d\n", APP_PATH_LEN, dwSize);
|
2005-11-08 13:43:35 +01:00
|
|
|
}
|
|
|
|
|
2005-11-10 12:37:03 +01:00
|
|
|
buffer[0] = 0;
|
2005-11-08 13:43:35 +01:00
|
|
|
/* try without a pszInstallSection */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfString(inf_file, NULL, "Options.NTx86",
|
2005-11-08 13:43:35 +01:00
|
|
|
"InstallDir", buffer, MAX_PATH, &dwSize, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got 0x%08x\n", (UINT)hr);
|
2006-02-21 04:40:59 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
2006-10-12 02:12:46 +02:00
|
|
|
ok(dwSize == 25, "Expected size 25, got %d\n", dwSize);
|
2006-02-21 04:40:59 +01:00
|
|
|
}
|
2005-11-08 13:43:35 +01:00
|
|
|
|
2013-10-15 10:49:55 +02:00
|
|
|
DeleteFileA("c:\\a.inf");
|
|
|
|
DeleteFileA(inf_file);
|
2005-11-08 13:43:35 +01:00
|
|
|
}
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
static void translateinfstringex_test(void)
|
|
|
|
{
|
|
|
|
HINF hinf;
|
|
|
|
HRESULT hr;
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
|
2008-08-05 00:52:01 +02:00
|
|
|
hr = pOpenINFEngine(inf_file, NULL, 0, &hinf, NULL);
|
|
|
|
if (hr == E_UNEXPECTED)
|
|
|
|
{
|
2009-02-26 09:45:17 +01:00
|
|
|
win_skip("Skipping tests on win9x because of brokenness\n");
|
2008-08-05 00:52:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
create_inf_file();
|
|
|
|
|
|
|
|
/* need to see if there are any flags */
|
|
|
|
|
|
|
|
/* try a NULL filename */
|
|
|
|
hr = pOpenINFEngine(NULL, "Options.NTx86", 0, &hinf, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try an empty filename */
|
|
|
|
hr = pOpenINFEngine("", "Options.NTx86", 0, &hinf, NULL);
|
2008-05-30 22:10:52 +02:00
|
|
|
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) /* NT+ */ ||
|
|
|
|
hr == HRESULT_FROM_WIN32(E_UNEXPECTED) /* 9x */,
|
|
|
|
"Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND or E_UNEXPECTED), got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try a NULL hinf */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pOpenINFEngine(inf_file, "Options.NTx86", 0, NULL, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* open the INF without the Install section specified */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pOpenINFEngine(inf_file, NULL, 0, &hinf, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try a NULL hinf */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(NULL, inf_file, "Options.NTx86", "InstallDir",
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try a NULL filename */
|
|
|
|
hr = pTranslateInfStringEx(hinf, NULL, "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try an empty filename */
|
2007-01-10 05:21:17 +01:00
|
|
|
memset(buffer, 'a', 25);
|
|
|
|
buffer[24] = '\0';
|
2006-02-27 20:50:03 +01:00
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, "", "Options.NTx86", "InstallDir",
|
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
2006-10-12 02:12:46 +02:00
|
|
|
ok(size == 25, "Expected size 25, got %d\n", size);
|
2006-02-27 20:50:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* try a NULL translate section */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, NULL, "InstallDir",
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try an empty translate section */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "", "InstallDir",
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND, "Expected SPAPI_E_LINE_NOT_FOUND, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try a NULL translate key */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", NULL,
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* try an empty translate key */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "",
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == SPAPI_E_LINE_NOT_FOUND, "Expected SPAPI_E_LINE_NOT_FOUND, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* successfully translate the string */
|
2007-01-10 05:21:17 +01:00
|
|
|
memset(buffer, 'a', 25);
|
|
|
|
buffer[24] = '\0';
|
2006-02-27 20:50:03 +01:00
|
|
|
size = MAX_PATH;
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "InstallDir",
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(!strcmp(buffer, TEST_STRING2), "Expected %s, got %s\n", TEST_STRING2, buffer);
|
2006-10-12 02:12:46 +02:00
|
|
|
ok(size == 25, "Expected size 25, got %d\n", size);
|
2006-02-27 20:50:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* try a NULL hinf */
|
|
|
|
hr = pCloseINFEngine(NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* successfully close the hinf */
|
|
|
|
hr = pCloseINFEngine(hinf);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* open the inf with the install section */
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pOpenINFEngine(inf_file, "section", 0, &hinf, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
|
|
|
/* translate the string with the install section specified */
|
2007-10-25 22:23:15 +02:00
|
|
|
memset(buffer, 'a', APP_PATH_LEN);
|
|
|
|
buffer[APP_PATH_LEN - 1] = '\0';
|
2006-02-27 20:50:03 +01:00
|
|
|
size = MAX_PATH;
|
2007-07-04 11:32:10 +02:00
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "InstallDir",
|
2006-02-27 20:50:03 +01:00
|
|
|
buffer, size, &size, NULL);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2007-10-25 22:23:15 +02:00
|
|
|
ok(!strcmp(buffer, APP_PATH), "Expected %s, got %s\n", APP_PATH, buffer);
|
|
|
|
ok(size == APP_PATH_LEN, "Expected size %d, got %d\n", APP_PATH_LEN, size);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
2007-08-10 23:28:34 +02:00
|
|
|
/* Single quote test (Note size includes null on return from call) */
|
2007-10-25 22:23:15 +02:00
|
|
|
memset(buffer, 'a', APP_PATH_LEN);
|
|
|
|
buffer[APP_PATH_LEN - 1] = '\0';
|
2007-08-10 23:28:34 +02:00
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result1",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2013-10-15 10:49:55 +02:00
|
|
|
ok(!lstrcmpiA(buffer, PROG_FILES_ROOT),
|
2007-08-10 23:28:35 +02:00
|
|
|
"Expected %s, got %s\n", PROG_FILES_ROOT, buffer);
|
2010-08-19 23:33:02 +02:00
|
|
|
ok(size == strlen(PROG_FILES_ROOT)+1, "Expected size %d, got %d\n",
|
2007-08-10 23:28:35 +02:00
|
|
|
lstrlenA(PROG_FILES_ROOT)+1, size);
|
2007-08-10 23:28:34 +02:00
|
|
|
|
2007-10-25 22:23:15 +02:00
|
|
|
memset(buffer, 'a', APP_PATH_LEN);
|
|
|
|
buffer[APP_PATH_LEN - 1] = '\0';
|
2007-08-10 23:28:34 +02:00
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result2",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2013-10-15 10:49:55 +02:00
|
|
|
ok(!lstrcmpiA(buffer, PROG_FILES_ROOT),
|
2007-08-10 23:28:34 +02:00
|
|
|
"Expected %s, got %s\n", PROG_FILES_ROOT, buffer);
|
2010-08-19 23:33:02 +02:00
|
|
|
ok(size == strlen(PROG_FILES_ROOT)+1, "Expected size %d, got %d\n",
|
2007-08-10 23:28:34 +02:00
|
|
|
lstrlenA(PROG_FILES_ROOT)+1, size);
|
|
|
|
|
|
|
|
{
|
|
|
|
char drive[MAX_PATH];
|
2013-10-15 10:49:55 +02:00
|
|
|
lstrcpyA(drive, PROG_FILES_ROOT);
|
2007-08-10 23:28:34 +02:00
|
|
|
drive[3] = 0x00; /* Just keep the system drive plus '\' */
|
|
|
|
|
2007-10-25 22:23:15 +02:00
|
|
|
memset(buffer, 'a', APP_PATH_LEN);
|
|
|
|
buffer[APP_PATH_LEN - 1] = '\0';
|
2007-08-10 23:28:34 +02:00
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result3",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2013-10-15 10:49:55 +02:00
|
|
|
ok(!lstrcmpiA(buffer, drive),
|
2007-08-10 23:28:34 +02:00
|
|
|
"Expected %s, got %s\n", drive, buffer);
|
2010-08-19 23:33:02 +02:00
|
|
|
ok(size == strlen(drive)+1, "Expected size %d, got %d\n",
|
2007-08-10 23:28:34 +02:00
|
|
|
lstrlenA(drive)+1, size);
|
|
|
|
}
|
|
|
|
|
2006-02-27 20:50:03 +01:00
|
|
|
/* close the INF again */
|
|
|
|
hr = pCloseINFEngine(hinf);
|
2006-12-08 08:13:57 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-02-27 20:50:03 +01:00
|
|
|
|
2007-07-04 11:32:10 +02:00
|
|
|
DeleteFileA(inf_file);
|
2008-05-29 17:35:03 +02:00
|
|
|
|
|
|
|
/* Create another .inf file which is just here to trigger a wine bug */
|
|
|
|
{
|
|
|
|
char data[1024];
|
|
|
|
char *ptr = data;
|
|
|
|
DWORD dwNumberOfBytesWritten;
|
2013-10-15 10:49:55 +02:00
|
|
|
HANDLE hf = CreateFileA(inf_file, GENERIC_WRITE, 0, NULL,
|
2008-05-29 17:35:03 +02:00
|
|
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
append_str(&ptr, "[Version]\n");
|
|
|
|
append_str(&ptr, "Signature=\"$Chicago$\"\n");
|
|
|
|
append_str(&ptr, "[section]\n");
|
|
|
|
append_str(&ptr, "NotACustomDestination=Version\n");
|
|
|
|
append_str(&ptr, "CustomDestination=CustInstDestSection\n");
|
|
|
|
append_str(&ptr, "[CustInstDestSection]\n");
|
|
|
|
append_str(&ptr, "49010=DestA,1\n");
|
|
|
|
append_str(&ptr, "49020=DestB\n");
|
|
|
|
append_str(&ptr, "49030=DestC\n");
|
|
|
|
append_str(&ptr, "49040=DestD\n");
|
|
|
|
append_str(&ptr, "[Options.NTx86]\n");
|
|
|
|
append_str(&ptr, "Result2=%%49030%%\n");
|
|
|
|
append_str(&ptr, "[DestA]\n");
|
|
|
|
append_str(&ptr, "HKLM,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n");
|
|
|
|
/* The point of this test is to have HKCU just before the quoted HKLM */
|
|
|
|
append_str(&ptr, "[DestB]\n");
|
|
|
|
append_str(&ptr, "HKCU,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n");
|
|
|
|
append_str(&ptr, "[DestC]\n");
|
|
|
|
append_str(&ptr, "'HKLM','Software\\Microsoft\\Windows\\CurrentVersion',");
|
|
|
|
append_str(&ptr, "'ProgramFilesDir',,\"%%24%%\"\n");
|
|
|
|
append_str(&ptr, "[DestD]\n");
|
|
|
|
append_str(&ptr, "HKLM,\"Software\\Garbage\",\"ProgramFilesDir\",,'%%24%%'\n");
|
|
|
|
|
|
|
|
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL);
|
|
|
|
CloseHandle(hf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* open the inf with the install section */
|
|
|
|
hr = pOpenINFEngine(inf_file, "section", 0, &hinf, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
/* Single quote test (Note size includes null on return from call) */
|
|
|
|
memset(buffer, 'a', APP_PATH_LEN);
|
|
|
|
buffer[APP_PATH_LEN - 1] = '\0';
|
|
|
|
size = MAX_PATH;
|
|
|
|
hr = pTranslateInfStringEx(hinf, inf_file, "Options.NTx86", "Result2",
|
|
|
|
buffer, size, &size, NULL);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2013-10-15 10:49:55 +02:00
|
|
|
ok(!lstrcmpiA(buffer, PROG_FILES_ROOT),
|
2008-05-29 17:35:03 +02:00
|
|
|
"Expected %s, got %s\n", PROG_FILES_ROOT, buffer);
|
2010-08-19 23:33:02 +02:00
|
|
|
ok(size == strlen(PROG_FILES_ROOT)+1, "Expected size %d, got %d\n",
|
2008-05-29 17:35:03 +02:00
|
|
|
lstrlenA(PROG_FILES_ROOT)+1, size);
|
|
|
|
|
|
|
|
/* close the INF again */
|
|
|
|
hr = pCloseINFEngine(hinf);
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
|
|
|
|
|
|
|
DeleteFileA(inf_file);
|
2006-02-27 20:50:03 +01:00
|
|
|
}
|
|
|
|
|
2006-07-28 22:32:25 +02:00
|
|
|
static BOOL check_reg_str(HKEY hkey, LPCSTR name, LPCSTR value)
|
2006-04-06 10:48:49 +02:00
|
|
|
{
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
char check[MAX_PATH];
|
|
|
|
|
2013-10-15 10:49:55 +02:00
|
|
|
if (RegQueryValueExA(hkey, name, NULL, NULL, (LPBYTE)check, &size))
|
2006-04-06 10:48:49 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2013-10-15 10:49:55 +02:00
|
|
|
return !lstrcmpA(check, value);
|
2006-04-06 10:48:49 +02:00
|
|
|
}
|
|
|
|
|
2006-07-28 22:32:25 +02:00
|
|
|
static BOOL check_reg_dword(HKEY hkey, LPCSTR name, DWORD value)
|
2006-04-06 10:48:49 +02:00
|
|
|
{
|
|
|
|
DWORD size = sizeof(DWORD);
|
|
|
|
DWORD check;
|
|
|
|
|
2013-10-15 10:49:55 +02:00
|
|
|
if (RegQueryValueExA(hkey, name, NULL, NULL, (LPBYTE)&check, &size))
|
2006-04-06 10:48:49 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return (check == value);
|
|
|
|
}
|
|
|
|
|
2006-08-18 20:57:46 +02:00
|
|
|
static void setperusersecvalues_test(void)
|
2006-04-06 10:48:49 +02:00
|
|
|
{
|
2013-10-15 10:49:55 +02:00
|
|
|
PERUSERSECTIONA peruser;
|
2006-04-06 10:48:49 +02:00
|
|
|
HRESULT hr;
|
|
|
|
HKEY guid;
|
|
|
|
|
2013-10-15 10:49:55 +02:00
|
|
|
lstrcpyA(peruser.szDispName, "displayname");
|
|
|
|
lstrcpyA(peruser.szLocale, "locale");
|
|
|
|
lstrcpyA(peruser.szStub, "stub");
|
|
|
|
lstrcpyA(peruser.szVersion, "1,1,1,1");
|
|
|
|
lstrcpyA(peruser.szCompID, "compid");
|
2006-04-06 10:48:49 +02:00
|
|
|
peruser.dwIsInstalled = 1;
|
|
|
|
peruser.bRollback = FALSE;
|
|
|
|
|
2006-04-07 15:30:21 +02:00
|
|
|
/* try a NULL pPerUser */
|
2006-11-24 10:12:58 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* This crashes on systems with IE7 */
|
|
|
|
hr = pSetPerUserSecValues(NULL);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
|
|
|
|
ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n");
|
|
|
|
}
|
2006-04-07 15:30:21 +02:00
|
|
|
|
|
|
|
/* at the very least, szGUID must be valid */
|
|
|
|
peruser.szGUID[0] = '\0';
|
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2006-10-12 02:12:46 +02:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
|
2006-04-07 15:30:21 +02:00
|
|
|
ok(!OPEN_GUID_KEY(), "Expected guid key to not exist\n");
|
|
|
|
|
2006-04-06 10:48:49 +02:00
|
|
|
/* set initial values */
|
2013-10-15 10:49:55 +02:00
|
|
|
lstrcpyA(peruser.szGUID, "guid");
|
2006-04-06 10:48:49 +02:00
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2009-01-26 08:30:49 +01:00
|
|
|
if (hr == E_FAIL)
|
|
|
|
{
|
|
|
|
skip("SetPerUserSecValues is broken\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-02-09 17:18:44 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(OPEN_GUID_KEY(), "Expected guid key to exist\n");
|
|
|
|
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
|
|
|
|
ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "Version", "1,1,1,1"), "Expected 1,1,1,1\n");
|
|
|
|
ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
|
2006-04-06 10:48:49 +02:00
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n");
|
|
|
|
|
|
|
|
/* raise the version, but bRollback is FALSE, so vals not saved */
|
2013-10-15 10:49:55 +02:00
|
|
|
lstrcpyA(peruser.szVersion, "2,1,1,1");
|
2006-04-06 10:48:49 +02:00
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2008-02-09 17:18:44 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
|
|
|
|
ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_str(guid, "StubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "Version", "2,1,1,1"), "Expected 2,1,1,1\n");
|
|
|
|
ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
|
2006-04-06 10:48:49 +02:00
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldDisplayName"), "Expected OldDisplayName to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldLocale"), "Expected OldLocale to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldStubPath"), "Expected OldStubPath to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "OldVersion"), "Expected OldVersion to not exist\n");
|
|
|
|
ok(!REG_VAL_EXISTS(guid, "RealStubPath"), "Expected RealStubPath to not exist\n");
|
|
|
|
|
|
|
|
/* raise the version again, bRollback is TRUE so vals are saved */
|
2006-04-08 08:03:30 +02:00
|
|
|
peruser.bRollback = TRUE;
|
2013-10-15 10:49:55 +02:00
|
|
|
lstrcpyA(peruser.szVersion, "3,1,1,1");
|
2006-04-06 10:48:49 +02:00
|
|
|
hr = pSetPerUserSecValues(&peruser);
|
2008-02-09 17:18:44 +01:00
|
|
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
2006-04-08 08:03:30 +02:00
|
|
|
ok(check_reg_str(guid, NULL, "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "ComponentID", "compid"), "Expected compid\n");
|
|
|
|
ok(check_reg_str(guid, "Locale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_dword(guid, "IsInstalled", 1), "Expected 1\n");
|
|
|
|
ok(check_reg_str(guid, "Version", "3,1,1,1"), "Expected 3,1,1,1\n");
|
2006-04-06 10:48:49 +02:00
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
ok(check_reg_str(guid, "OldDisplayName", "displayname"), "Expected displayname\n");
|
|
|
|
ok(check_reg_str(guid, "OldLocale", "locale"), "Expected locale\n");
|
|
|
|
ok(check_reg_str(guid, "RealStubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "OldStubPath", "stub"), "Expected stub\n");
|
|
|
|
ok(check_reg_str(guid, "OldVersion", "2,1,1,1"), "Expected 2,1,1,1\n");
|
|
|
|
ok(check_reg_str(guid, "StubPath",
|
|
|
|
"rundll32.exe advpack.dll,UserInstStubWrapper guid"),
|
|
|
|
"Expected real stub\n");
|
|
|
|
}
|
|
|
|
|
2013-10-15 10:49:55 +02:00
|
|
|
RegDeleteKeyA(HKEY_LOCAL_MACHINE, GUID_KEY);
|
2006-04-06 10:48:49 +02:00
|
|
|
}
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
START_TEST(advpack)
|
|
|
|
{
|
2006-02-27 20:49:50 +01:00
|
|
|
if (!init_function_pointers())
|
2005-02-14 12:02:46 +01:00
|
|
|
return;
|
|
|
|
|
2007-07-04 11:32:10 +02:00
|
|
|
/* Make sure we create the temporary file in a directory
|
|
|
|
* were we have enough rights
|
|
|
|
*/
|
2013-10-15 10:49:55 +02:00
|
|
|
GetTempPathA(MAX_PATH, inf_file);
|
|
|
|
lstrcatA(inf_file,"test.inf");
|
2007-07-04 11:32:10 +02:00
|
|
|
|
2006-02-27 20:50:25 +01:00
|
|
|
get_progfiles_dir();
|
|
|
|
|
2005-01-20 21:03:13 +01:00
|
|
|
version_test();
|
2005-04-27 11:37:25 +02:00
|
|
|
delnode_test();
|
2006-04-06 10:48:49 +02:00
|
|
|
setperusersecvalues_test();
|
2005-11-08 13:43:35 +01:00
|
|
|
translateinfstring_test();
|
2006-02-27 20:50:03 +01:00
|
|
|
translateinfstringex_test();
|
2008-03-09 12:15:05 +01:00
|
|
|
|
|
|
|
FreeLibrary(hAdvPack);
|
2005-01-20 21:03:13 +01:00
|
|
|
}
|