James Hawkins : advpack: Add stub handling for the RegisterOCXs command.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 20 08:46:12 CDT 2006


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

Author: James Hawkins <truiken at gmail.com>
Date:   Thu Apr 20 01:36:26 2006 -0500

advpack: Add stub handling for the RegisterOCXs command.

---

 dlls/advpack/install.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/dlls/advpack/install.c b/dlls/advpack/install.c
index 538451a..d280a42 100644
--- a/dlls/advpack/install.c
+++ b/dlls/advpack/install.c
@@ -54,6 +54,18 @@ typedef struct _ADVInfo
     BOOL need_reboot;
 } ADVInfo;
 
+typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, void *arg);
+
+/* Advanced INF commands */
+static const WCHAR RegisterOCXs[] = {'R','e','g','i','s','t','e','r','O','C','X','s',0};
+
+/* Advanced INF callbacks */
+static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, void *arg)
+{
+    FIXME("Unhandled command: RegisterOCXs\n");
+    return E_FAIL;
+}
+
 /* 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)
@@ -86,6 +98,61 @@ static BOOL is_full_path(LPWSTR path)
     return FALSE;
 }
 
+/* retrieves the contents of a field, dynamically growing the buffer if necessary */
+static WCHAR *get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer,
+                               WCHAR *static_buffer, DWORD *size)
+{
+    DWORD required;
+
+    if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
+
+    if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+    {
+        /* now grow the buffer */
+        if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
+        if (!(buffer = HeapAlloc(GetProcessHeap(), 0, required*sizeof(WCHAR)))) return NULL;
+        *size = required;
+        if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
+    }
+
+    if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
+    return NULL;
+}
+
+/* iterates over all fields of a certain key of a certain section */
+static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
+                                      iterate_fields_func callback, void *arg)
+{
+    WCHAR static_buffer[200];
+    WCHAR *buffer = static_buffer;
+    DWORD size = sizeof(static_buffer) / sizeof(WCHAR);
+    INFCONTEXT context;
+    HRESULT hr = E_FAIL;
+
+    BOOL ok = SetupFindFirstLineW(hinf, section, key, &context);
+    while (ok)
+    {
+        UINT i, count = SetupGetFieldCount(&context);
+
+        for (i = 1; i <= count; i++)
+        {
+            if (!(buffer = get_field_string(&context, i, buffer, static_buffer, &size)))
+                goto done;
+
+            if ((hr = callback(hinf, buffer, arg)) != S_OK)
+                goto done;
+        }
+
+        ok = SetupFindNextMatchLineW(&context, key, &context);
+    }
+
+    hr = S_OK;
+
+ done:
+    if (buffer && buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
+    return hr;
+}
+
 /* performs a setupapi-level install of the INF file */
 static HRESULT spapi_install(ADVInfo *info)
 {
@@ -121,6 +188,17 @@ static HRESULT spapi_install(ADVInfo *in
     return S_OK;
 }
 
+/* processes the Advanced INF commands */
+static HRESULT adv_install(ADVInfo *info)
+{
+    HRESULT hr;
+
+    hr = iterate_section_fields(info->hinf, info->install_sec,
+                                RegisterOCXs, register_ocxs_callback, NULL);
+
+    return hr;
+}
+
 /* loads the INF file and performs checks on it */
 HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
                      LPCWSTR working_dir, DWORD flags, ADVInfo *info)
@@ -586,6 +664,10 @@ HRESULT WINAPI RunSetupCommandW(HWND hWn
         goto done;
 
     hr = spapi_install(&info);
+    if (hr != S_OK)
+        goto done;
+
+    hr = adv_install(&info);
 
 done:
     install_release(&info);




More information about the wine-cvs mailing list