setupapi: Added support for calling executables in a RegisterDlls section.
This commit is contained in:
parent
ac60251312
commit
c67728f7c6
@ -444,6 +444,7 @@ static BOOL do_register_dll( const struct register_dll_info *info, const WCHAR *
|
|||||||
HMODULE module;
|
HMODULE module;
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
SP_REGISTER_CONTROL_STATUSW status;
|
SP_REGISTER_CONTROL_STATUSW status;
|
||||||
|
IMAGE_NT_HEADERS *nt;
|
||||||
|
|
||||||
status.cbSize = sizeof(status);
|
status.cbSize = sizeof(status);
|
||||||
status.FileName = path;
|
status.FileName = path;
|
||||||
@ -473,6 +474,45 @@ static BOOL do_register_dll( const struct register_dll_info *info, const WCHAR *
|
|||||||
goto done;
|
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)
|
if (flags & FLG_REGSVR_DLLREGISTER)
|
||||||
{
|
{
|
||||||
const char *entry_point = info->unregister ? "DllUnregisterServer" : "DllRegisterServer";
|
const char *entry_point = info->unregister ? "DllUnregisterServer" : "DllRegisterServer";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user