James Hawkins : advpack: Forward RegInstallA to its Unicode counterpart.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 4 05:37:49 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: e475634799800f56c1e4f58d6b6fea3f6df5d115
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=e475634799800f56c1e4f58d6b6fea3f6df5d115

Author: James Hawkins <truiken at gmail.com>
Date:   Mon Apr  3 12:04:46 2006 -0500

advpack: Forward RegInstallA to its Unicode counterpart.

---

 dlls/advpack/advpack.spec |    2 -
 dlls/advpack/reg.c        |  104 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 84 insertions(+), 22 deletions(-)

diff --git a/dlls/advpack/advpack.spec b/dlls/advpack/advpack.spec
index 1728537..f94146c 100644
--- a/dlls/advpack/advpack.spec
+++ b/dlls/advpack/advpack.spec
@@ -50,7 +50,7 @@
 @ stdcall RebootCheckOnInstallW(long wstr wstr long)
 @ stdcall RebootCheckOnInstall(long str str long) RebootCheckOnInstallA
 @ stdcall RegInstallA(ptr str ptr)
-# stdcall RegInstallW(ptr wstr ptr)
+@ stdcall RegInstallW(ptr wstr ptr)
 @ stdcall RegInstall(ptr str ptr) RegInstallA
 @ stdcall RegRestoreAllA(ptr str long)
 @ stdcall RegRestoreAllW(ptr wstr long)
diff --git a/dlls/advpack/reg.c b/dlls/advpack/reg.c
index 7784dc7..854cff3 100644
--- a/dlls/advpack/reg.c
+++ b/dlls/advpack/reg.c
@@ -97,9 +97,82 @@ error:
     return FALSE;
 }
 
+static void strentry_atow(STRENTRYA *aentry, STRENTRYW *wentry)
+{
+    DWORD name_len, val_len;
+
+    name_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, NULL, 0);
+    val_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, NULL, 0);
+
+    wentry->pszName = HeapAlloc(GetProcessHeap(), 0, name_len * sizeof(WCHAR));
+    wentry->pszValue = HeapAlloc(GetProcessHeap(), 0, val_len * sizeof(WCHAR));
+
+    MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, wentry->pszName, name_len);
+    MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, wentry->pszValue, val_len);
+}
+
+static STRTABLEW *strtable_atow(const STRTABLEA *atable)
+{
+    STRTABLEW *wtable;
+    DWORD j;
+
+    wtable = HeapAlloc(GetProcessHeap(), 0, sizeof(STRTABLEW));
+    wtable->pse = HeapAlloc(GetProcessHeap(), 0, atable->cEntries * sizeof(STRENTRYW));
+    wtable->cEntries = atable->cEntries;
+
+    for (j = 0; j < wtable->cEntries; j++)
+        strentry_atow(&atable->pse[j], &wtable->pse[j]);
+
+    return wtable;
+}
+
+static void free_strtable(STRTABLEW *wtable)
+{
+    DWORD j;
+
+    for (j = 0; j < wtable->cEntries; j++)
+    {
+        HeapFree(GetProcessHeap(), 0, wtable->pse[j].pszName);
+        HeapFree(GetProcessHeap(), 0, wtable->pse[j].pszValue);
+    }
+
+    HeapFree(GetProcessHeap(), 0, wtable->pse);
+    HeapFree(GetProcessHeap(), 0, wtable);
+}
+
 /***********************************************************************
  *          RegInstallA (advpack.@)
  *
+ * See RegInstallW.
+ */
+HRESULT WINAPI RegInstallA(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable)
+{
+    UNICODE_STRING section;
+    STRTABLEW *wtable;
+    HRESULT hr;
+
+    TRACE("(%p, %s, %p)\n", hm, debugstr_a(pszSection), pstTable);
+
+    if (pstTable)
+        wtable = strtable_atow(pstTable);
+    else
+        wtable = NULL;
+
+    RtlCreateUnicodeStringFromAsciiz(&section, pszSection);
+
+    hr = RegInstallW(hm, section.Buffer, wtable);
+
+    if (pstTable)
+        free_strtable(wtable);
+
+    RtlFreeUnicodeString(&section);
+
+    return hr;
+}
+
+/***********************************************************************
+ *          RegInstallW (advpack.@)
+ *
  * Loads an INF from a string resource, adds entries to the string
  * substitution table, and executes the INF.
  *
@@ -112,20 +185,15 @@ error:
  *   Success: S_OK.
  *   Failure: E_FAIL.
  */
-HRESULT WINAPI RegInstallA(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable)
+HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstTable)
 {
     int i;
     WCHAR tmp_ini_path[MAX_PATH];
     WCHAR mod_path[MAX_PATH + 2], sys_mod_path[MAX_PATH + 2], sys_root[MAX_PATH];
     HINF hinf;
-    WCHAR quote[] = {'\"',0};
-    UNICODE_STRING section;
-
-    TRACE("(%p %s %p)\n", hm, pszSection, pstTable);
+    static const WCHAR quote[] = {'\"',0};
 
-    if (pstTable) for(i = 0; i < pstTable->cEntries; i++)
-        TRACE("%d: %s -> %s\n", i, pstTable->pse[i].pszName,
-             pstTable->pse[i].pszValue);
+    TRACE("(%p, %s, %p)\n", hm, debugstr_w(pszSection), pstTable);
 
     if(!create_tmp_ini_file(hm, tmp_ini_path))
         return E_FAIL;
@@ -150,16 +218,13 @@ HRESULT WINAPI RegInstallA(HMODULE hm, L
 
     /* Write the additional string table */
     if (pstTable) for(i = 0; i < pstTable->cEntries; i++) {
-        char tmp_value[MAX_PATH + 2];
-        UNICODE_STRING name, value;
+        WCHAR tmp_value[MAX_PATH + 2];
+
         tmp_value[0] = '\"';
-        strcpy(tmp_value + 1, pstTable->pse[i].pszValue);
-        strcat(tmp_value, "\"");
-        RtlCreateUnicodeStringFromAsciiz(&name, pstTable->pse[i].pszName);
-        RtlCreateUnicodeStringFromAsciiz(&value, tmp_value);
-        WritePrivateProfileStringW(Strings, name.Buffer, value.Buffer, tmp_ini_path);
-        RtlFreeUnicodeString(&name);
-        RtlFreeUnicodeString(&value);
+        lstrcpyW(tmp_value + 1, pstTable->pse[i].pszValue);
+        lstrcatW(tmp_value, quote);
+
+        WritePrivateProfileStringW(Strings, pstTable->pse[i].pszName, tmp_value, tmp_ini_path);
     }
     /* flush cache */
     WritePrivateProfileStringW(NULL, NULL, NULL, tmp_ini_path);
@@ -175,12 +240,9 @@ HRESULT WINAPI RegInstallA(HMODULE hm, L
     SetupOpenAppendInfFileW(NULL, hinf, NULL);
 
     /* Need to do a lot more here */
-    RtlCreateUnicodeStringFromAsciiz(&section, pszSection);
-    SetupInstallFromInfSectionW(NULL, hinf, section.Buffer,
+    SetupInstallFromInfSectionW(NULL, hinf, pszSection,
                                 SPINST_INIFILES | SPINST_REGISTRY | SPINST_PROFILEITEMS,
                                 HKEY_LOCAL_MACHINE, NULL, 0, NULL, NULL, NULL, NULL);
-    RtlFreeUnicodeString(&section);
-
     
     SetupCloseInfFile(hinf);
     DeleteFileW(tmp_ini_path);




More information about the wine-cvs mailing list