Module: wine Branch: refs/heads/master Commit: c26245077de0759d10a531a4e7575798fa374ecf URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=c26245077de0759d10a531a4...
Author: James Hawkins truiken@gmail.com Date: Wed Mar 29 11:36:04 2006 -0600
advpack: Open the INF file if the RSC_FLAG_INF flag is specified.
---
dlls/advpack/install.c | 19 +++++++++++++++++++ dlls/advpack/tests/install.c | 13 +++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/advpack/install.c b/dlls/advpack/install.c index f44c042..042f761 100644 --- a/dlls/advpack/install.c +++ b/dlls/advpack/install.c @@ -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 hWn 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 hWn 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; } diff --git a/dlls/advpack/tests/install.c b/dlls/advpack/tests/install.c index 26f0fa4..d8eee76 100644 --- a/dlls/advpack/tests/install.c +++ b/dlls/advpack/tests/install.c @@ -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");