advpack: Open the INF file if the RSC_FLAG_INF flag is specified.

This commit is contained in:
James Hawkins 2006-03-29 11:36:04 -06:00 committed by Alexandre Julliard
parent 724a4b36c2
commit c26245077d
2 changed files with 28 additions and 4 deletions

View File

@ -33,6 +33,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(advpack);
#define SPAPI_ERROR 0xE0000000L
#define SPAPI_PREFIX 0x800F0000L
#define SPAPI_MASK 0xFFFFL
#define HRESULT_FROM_SPAPI(x) ((x & SPAPI_MASK) | SPAPI_PREFIX)
/* this structure very closely resembles parameters of RunSetupCommand() */
typedef struct
{
@ -293,6 +298,9 @@ HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
LPCWSTR lpszTitle, HANDLE *phEXE,
DWORD dwFlags, LPVOID pvReserved )
{
HINF hinf;
DWORD err;
TRACE("(%p, %s, %s, %s, %s, %p, 0x%08lx, %p)\n",
hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
debugstr_w(szDir), debugstr_w(lpszTitle),
@ -307,5 +315,16 @@ HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
if (!(dwFlags & RSC_FLAG_INF))
return launch_exe(szCmdName, szDir, phEXE);
hinf = SetupOpenInfFileW(szCmdName, NULL, INF_STYLE_WIN4, NULL);
if (hinf == INVALID_HANDLE_VALUE)
{
err = GetLastError();
if (err & SPAPI_ERROR)
return HRESULT_FROM_SPAPI(err);
else
return HRESULT_FROM_WIN32(err);
}
SetupCloseInfFile(hinf);
return E_UNEXPECTED;
}

View File

@ -40,6 +40,14 @@ static BOOL init_function_pointers()
return TRUE;
}
static BOOL is_spapi_err(DWORD err)
{
const DWORD SPAPI_PREFIX = 0x800F0000L;
const DWORD SPAPI_MASK = 0xFFFF0000L;
return (((err & SPAPI_MASK) ^ SPAPI_PREFIX) == 0);
}
static void test_RunSetupCommand()
{
HRESULT hr;
@ -72,10 +80,7 @@ static void test_RunSetupCommand()
/* try to run an exe with the RSC_FLAG_INF flag */
hexe = (HANDLE)0xdeadbeef;
hr = pRunSetupCommand(NULL, "winver.exe", "Install", "c:\\windows\\system32", "Title", &hexe, RSC_FLAG_INF, NULL);
todo_wine
{
ok(hr == SPAPI_E_WRONG_INF_STYLE, "Expected SPAPI_E_WRONG_INF_STYLE, got %ld\n", hr);
}
ok(is_spapi_err(hr), "Expected a setupapi error, got %ld\n", hr);
ok(hexe == (HANDLE)0xdeadbeef, "Expected hexe to be 0xdeadbeef\n");
ok(!TerminateProcess(hexe, 0), "Expected TerminateProcess to fail\n");