Alexandre Julliard : setupapi: Added support for calling executables in a RegisterDlls section.

Alexandre Julliard julliard at wine.codeweavers.com
Sat Mar 18 12:51:30 CST 2006


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Mar 17 23:08:27 2006 +0100

setupapi: Added support for calling executables in a RegisterDlls section.

---

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

diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c
index 4cdfdcf..43544da 100644
--- a/dlls/setupapi/install.c
+++ b/dlls/setupapi/install.c
@@ -444,6 +444,7 @@ static BOOL do_register_dll( const struc
     HMODULE module;
     HRESULT res;
     SP_REGISTER_CONTROL_STATUSW status;
+    IMAGE_NT_HEADERS *nt;
 
     status.cbSize = sizeof(status);
     status.FileName = path;
@@ -473,6 +474,45 @@ static BOOL do_register_dll( const struc
         goto done;
     }
 
+    if ((nt = RtlImageNtHeader( module )) && !(nt->FileHeader.Characteristics & IMAGE_FILE_DLL))
+    {
+        /* file is an executable, not a dll */
+        STARTUPINFOW startup;
+        PROCESS_INFORMATION info;
+        WCHAR *cmd_line;
+        BOOL res;
+        static const WCHAR format[] = {'"','%','s','"',' ','%','s',0};
+        static const WCHAR default_args[] = {'/','R','e','g','S','e','r','v','e','r',0};
+
+        FreeLibrary( module );
+        module = NULL;
+        if (!args) args = default_args;
+        cmd_line = HeapAlloc( GetProcessHeap(), 0, (strlenW(path) + strlenW(args) + 4) * sizeof(WCHAR) );
+        sprintfW( cmd_line, format, path, args );
+        memset( &startup, 0, sizeof(startup) );
+        startup.cb = sizeof(startup);
+        TRACE( "executing %s\n", debugstr_w(cmd_line) );
+        res = CreateProcessW( NULL, cmd_line, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info );
+        HeapFree( GetProcessHeap(), 0, cmd_line );
+        if (!res)
+        {
+            status.FailureCode = SPREG_LOADLIBRARY;
+            status.Win32Error = GetLastError();
+            goto done;
+        }
+        CloseHandle( info.hThread );
+
+        if (WaitForSingleObject( info.hProcess, timeout*1000 ) == WAIT_TIMEOUT)
+        {
+            /* timed out, kill the process */
+            TerminateProcess( info.hProcess, 1 );
+            status.FailureCode = SPREG_TIMEOUT;
+            status.Win32Error = ERROR_TIMEOUT;
+        }
+        CloseHandle( info.hProcess );
+        goto done;
+    }
+
     if (flags & FLG_REGSVR_DLLREGISTER)
     {
         const char *entry_point = info->unregister ? "DllUnregisterServer" : "DllRegisterServer";




More information about the wine-cvs mailing list