[ADVPACK] Sync with Wine Staging 3.17. CORE-15127
[reactos.git] / dll / win32 / advpack / install.c
index 6079625..c3caf3a 100644 (file)
@@ -115,28 +115,22 @@ static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *ar
     per_user.bRollback = FALSE;
     per_user.dwIsInstalled = 0;
 
-    SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName,
-                     sizeof(per_user.szDispName) / sizeof(WCHAR), &size);
+    SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, ARRAY_SIZE(per_user.szDispName), &size);
 
-    SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion,
-                     sizeof(per_user.szVersion) / sizeof(WCHAR), &size);
+    SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, ARRAY_SIZE(per_user.szVersion), &size);
 
     if (SetupFindFirstLineW(hinf, field, is_installed, &context))
     {
         SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
     }
 
-    SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID,
-                     sizeof(per_user.szCompID) / sizeof(WCHAR), &size);
+    SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, ARRAY_SIZE(per_user.szCompID), &size);
 
-    SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID,
-                     sizeof(per_user.szGUID) / sizeof(WCHAR), &size);
+    SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, ARRAY_SIZE(per_user.szGUID), &size);
 
-    SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale,
-                     sizeof(per_user.szLocale) / sizeof(WCHAR), &size);
+    SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, ARRAY_SIZE(per_user.szLocale), &size);
 
-    SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub,
-                     sizeof(per_user.szStub) / sizeof(WCHAR), &size);
+    SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, ARRAY_SIZE(per_user.szStub), &size);
 
     return SetPerUserSecValuesW(&per_user);
 }
@@ -154,8 +148,7 @@ static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg)
         WCHAR buffer[MAX_INF_STRING_LENGTH];
 
         /* get OCX filename */
-        if (!SetupGetStringFieldW(&context, 1, buffer,
-                                  sizeof(buffer) / sizeof(WCHAR), NULL))
+        if (!SetupGetStringFieldW(&context, 1, buffer, ARRAY_SIZE(buffer), NULL))
             continue;
 
         hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
@@ -205,13 +198,24 @@ static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, const void *
 
 /* sequentially returns pointers to parameters in a parameter list
  * returns NULL if the parameter is empty, e.g. one,,three  */
-LPWSTR get_parameter(LPWSTR *params, WCHAR separator)
+LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted)
 {
     LPWSTR token = *params;
 
     if (!*params)
         return NULL;
 
+    if (quoted && *token == '"')
+    {
+        WCHAR *end = strchrW(token + 1, '"');
+        if (end)
+        {
+            *end = 0;
+            *params = end + 1;
+            token = token + 1;
+        }
+    }
+
     *params = strchrW(*params, separator);
     if (*params)
         *(*params)++ = '\0';
@@ -262,7 +266,7 @@ static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
 {
     WCHAR static_buffer[200];
     WCHAR *buffer = static_buffer;
-    DWORD size = sizeof(static_buffer) / sizeof(WCHAR);
+    DWORD size = ARRAY_SIZE(static_buffer);
     INFCONTEXT context;
     HRESULT hr = E_FAIL;
 
@@ -634,8 +638,7 @@ HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved)
     RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf);
     RtlCreateUnicodeStringFromAsciiz(&section, pCab->pszSection);
     
-    MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath,
-                        sizeof(cabinfo.szSrcPath) / sizeof(WCHAR));
+    MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath, ARRAY_SIZE(cabinfo.szSrcPath));
 
     cabinfo.pszInf = inf.Buffer;
     cabinfo.pszSection = section.Buffer;
@@ -760,12 +763,16 @@ INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT sho
     cmdline_ptr = cmdline_copy;
     lstrcpyW(cmdline_copy, cmdline);
 
-    inf_filename = get_parameter(&cmdline_ptr, ',');
-    install_sec = get_parameter(&cmdline_ptr, ',');
+    inf_filename = get_parameter(&cmdline_ptr, ',', TRUE);
+    install_sec = get_parameter(&cmdline_ptr, ',', TRUE);
 
-    str_flags = get_parameter(&cmdline_ptr, ',');
+    str_flags = get_parameter(&cmdline_ptr, ',', TRUE);
     if (str_flags)
-        flags = atolW(str_flags);
+    {
+        DWORD inf_flags = atolW(str_flags);
+        if (inf_flags & LIS_QUIET) flags |= RSC_FLAG_QUIET;
+        if (inf_flags & LIS_NOGRPCONV) flags |= RSC_FLAG_NGCONV;
+    }
 
     ZeroMemory(&info, sizeof(ADVInfo));
 
@@ -853,12 +860,12 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I
     cmdline_ptr = cmdline_copy;
     lstrcpyW(cmdline_copy, cmdline);
 
-    cabinfo.pszInf = get_parameter(&cmdline_ptr, ',');
-    cabinfo.pszSection = get_parameter(&cmdline_ptr, ',');
-    cabinfo.pszCab = get_parameter(&cmdline_ptr, ',');
+    cabinfo.pszInf = get_parameter(&cmdline_ptr, ',', TRUE);
+    cabinfo.pszSection = get_parameter(&cmdline_ptr, ',', TRUE);
+    cabinfo.pszCab = get_parameter(&cmdline_ptr, ',', TRUE);
     *cabinfo.szSrcPath = '\0';
 
-    flags = get_parameter(&cmdline_ptr, ',');
+    flags = get_parameter(&cmdline_ptr, ',', TRUE);
     if (flags)
         cabinfo.dwFlags = atolW(flags);