Commit c67728f7 authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent ac602513
......@@ -444,6 +444,7 @@ static BOOL do_register_dll( const struct register_dll_info *info, const WCHAR *
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 struct register_dll_info *info, const WCHAR *
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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment