diff options
Diffstat (limited to 'src/burn/engine')
-rw-r--r-- | src/burn/engine/core.cpp | 35 | ||||
-rw-r--r-- | src/burn/engine/core.h | 23 | ||||
-rw-r--r-- | src/burn/engine/embedded.cpp | 9 | ||||
-rw-r--r-- | src/burn/engine/engine.cpp | 9 | ||||
-rw-r--r-- | src/burn/engine/exeengine.cpp | 15 | ||||
-rw-r--r-- | src/burn/engine/netfxchainer.cpp | 8 |
6 files changed, 67 insertions, 32 deletions
diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 716e5af1..90bbc8f6 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp | |||
@@ -12,6 +12,7 @@ struct BURN_CACHE_THREAD_CONTEXT | |||
12 | }; | 12 | }; |
13 | 13 | ||
14 | 14 | ||
15 | static PFN_CREATEPROCESSW vpfnCreateProcessW = ::CreateProcessW; | ||
15 | static PFN_PROCWAITFORCOMPLETION vpfnProcWaitForCompletion = ProcWaitForCompletion; | 16 | static PFN_PROCWAITFORCOMPLETION vpfnProcWaitForCompletion = ProcWaitForCompletion; |
16 | 17 | ||
17 | 18 | ||
@@ -1947,12 +1948,46 @@ LExit: | |||
1947 | } | 1948 | } |
1948 | 1949 | ||
1949 | extern "C" void CoreFunctionOverride( | 1950 | extern "C" void CoreFunctionOverride( |
1951 | __in_opt PFN_CREATEPROCESSW pfnCreateProcessW, | ||
1950 | __in_opt PFN_PROCWAITFORCOMPLETION pfnProcWaitForCompletion | 1952 | __in_opt PFN_PROCWAITFORCOMPLETION pfnProcWaitForCompletion |
1951 | ) | 1953 | ) |
1952 | { | 1954 | { |
1955 | vpfnCreateProcessW = pfnCreateProcessW; | ||
1953 | vpfnProcWaitForCompletion = pfnProcWaitForCompletion; | 1956 | vpfnProcWaitForCompletion = pfnProcWaitForCompletion; |
1954 | } | 1957 | } |
1955 | 1958 | ||
1959 | extern "C" HRESULT CoreCreateProcess( | ||
1960 | __in_opt LPCWSTR wzApplicationName, | ||
1961 | __inout_opt LPWSTR sczCommandLine, | ||
1962 | __in BOOL fInheritHandles, | ||
1963 | __in DWORD dwCreationFlags, | ||
1964 | __in_opt LPCWSTR wzCurrentDirectory, | ||
1965 | __in WORD wShowWindow, | ||
1966 | __out LPPROCESS_INFORMATION pProcessInformation | ||
1967 | ) | ||
1968 | { | ||
1969 | HRESULT hr = S_OK; | ||
1970 | STARTUPINFOW si = { }; | ||
1971 | size_t cchCurrentDirectory = 0; | ||
1972 | |||
1973 | // CreateProcessW has undocumented MAX_PATH restriction for lpCurrentDirectory even when long path support is enabled. | ||
1974 | if (wzCurrentDirectory && FAILED(::StringCchLengthW(wzCurrentDirectory, MAX_PATH - 1, &cchCurrentDirectory))) | ||
1975 | { | ||
1976 | wzCurrentDirectory = NULL; | ||
1977 | } | ||
1978 | |||
1979 | si.cb = sizeof(si); | ||
1980 | si.wShowWindow = wShowWindow; | ||
1981 | |||
1982 | if (!vpfnCreateProcessW(wzApplicationName, sczCommandLine, NULL, NULL, fInheritHandles, dwCreationFlags, NULL, wzCurrentDirectory, &si, pProcessInformation)) | ||
1983 | { | ||
1984 | ExitWithLastError(hr, "CreateProcessW failed with return code: %d", Dutil_er); | ||
1985 | } | ||
1986 | |||
1987 | LExit: | ||
1988 | return hr; | ||
1989 | } | ||
1990 | |||
1956 | extern "C" HRESULT DAPI CoreWaitForProcCompletion( | 1991 | extern "C" HRESULT DAPI CoreWaitForProcCompletion( |
1957 | __in HANDLE hProcess, | 1992 | __in HANDLE hProcess, |
1958 | __in DWORD dwTimeout, | 1993 | __in DWORD dwTimeout, |
diff --git a/src/burn/engine/core.h b/src/burn/engine/core.h index 14dbabcc..31f63ed4 100644 --- a/src/burn/engine/core.h +++ b/src/burn/engine/core.h | |||
@@ -174,6 +174,19 @@ typedef struct _BURN_APPLY_CONTEXT | |||
174 | DWORD dwCacheCheckpoint; | 174 | DWORD dwCacheCheckpoint; |
175 | } BURN_APPLY_CONTEXT; | 175 | } BURN_APPLY_CONTEXT; |
176 | 176 | ||
177 | typedef BOOL (STDAPICALLTYPE *PFN_CREATEPROCESSW)( | ||
178 | __in_opt LPCWSTR lpApplicationName, | ||
179 | __inout_opt LPWSTR lpCommandLine, | ||
180 | __in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes, | ||
181 | __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, | ||
182 | __in BOOL bInheritHandles, | ||
183 | __in DWORD dwCreationFlags, | ||
184 | __in_opt LPVOID lpEnvironment, | ||
185 | __in_opt LPCWSTR lpCurrentDirectory, | ||
186 | __in LPSTARTUPINFOW lpStartupInfo, | ||
187 | __out LPPROCESS_INFORMATION lpProcessInformation | ||
188 | ); | ||
189 | |||
177 | typedef HRESULT (DAPI *PFN_PROCWAITFORCOMPLETION)( | 190 | typedef HRESULT (DAPI *PFN_PROCWAITFORCOMPLETION)( |
178 | __in HANDLE hProcess, | 191 | __in HANDLE hProcess, |
179 | __in DWORD dwTimeout, | 192 | __in DWORD dwTimeout, |
@@ -287,8 +300,18 @@ HRESULT CoreParseCommandLine( | |||
287 | __inout HANDLE* phSourceEngineFile | 300 | __inout HANDLE* phSourceEngineFile |
288 | ); | 301 | ); |
289 | void CoreFunctionOverride( | 302 | void CoreFunctionOverride( |
303 | __in_opt PFN_CREATEPROCESSW pfnCreateProcessW, | ||
290 | __in_opt PFN_PROCWAITFORCOMPLETION pfnProcWaitForCompletion | 304 | __in_opt PFN_PROCWAITFORCOMPLETION pfnProcWaitForCompletion |
291 | ); | 305 | ); |
306 | HRESULT CoreCreateProcess( | ||
307 | __in_opt LPCWSTR wzApplicationName, | ||
308 | __inout_opt LPWSTR sczCommandLine, | ||
309 | __in BOOL fInheritHandles, | ||
310 | __in DWORD dwCreationFlags, | ||
311 | __in_opt LPCWSTR wzCurrentDirectory, | ||
312 | __in WORD wShowWindow, | ||
313 | __out LPPROCESS_INFORMATION pProcessInformation | ||
314 | ); | ||
292 | HRESULT DAPI CoreWaitForProcCompletion( | 315 | HRESULT DAPI CoreWaitForProcCompletion( |
293 | __in HANDLE hProcess, | 316 | __in HANDLE hProcess, |
294 | __in DWORD dwTimeout, | 317 | __in DWORD dwTimeout, |
diff --git a/src/burn/engine/embedded.cpp b/src/burn/engine/embedded.cpp index 58af5574..4c3de98e 100644 --- a/src/burn/engine/embedded.cpp +++ b/src/burn/engine/embedded.cpp | |||
@@ -52,7 +52,6 @@ extern "C" HRESULT EmbeddedRunBundle( | |||
52 | DWORD dwCurrentProcessId = ::GetCurrentProcessId(); | 52 | DWORD dwCurrentProcessId = ::GetCurrentProcessId(); |
53 | HANDLE hCreatedPipesEvent = NULL; | 53 | HANDLE hCreatedPipesEvent = NULL; |
54 | LPWSTR sczCommand = NULL; | 54 | LPWSTR sczCommand = NULL; |
55 | STARTUPINFOW si = { }; | ||
56 | PROCESS_INFORMATION pi = { }; | 55 | PROCESS_INFORMATION pi = { }; |
57 | BURN_PIPE_RESULT result = { }; | 56 | BURN_PIPE_RESULT result = { }; |
58 | 57 | ||
@@ -79,10 +78,8 @@ extern "C" HRESULT EmbeddedRunBundle( | |||
79 | ExitOnFailure(hr, "Failed to append user args."); | 78 | ExitOnFailure(hr, "Failed to append user args."); |
80 | } | 79 | } |
81 | 80 | ||
82 | if (!::CreateProcessW(wzExecutablePath, sczCommand, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) | 81 | hr = CoreCreateProcess(wzExecutablePath, sczCommand, TRUE, CREATE_NO_WINDOW, NULL, 0, &pi); |
83 | { | 82 | ExitOnFailure(hr, "Failed to create embedded process at path: %ls", wzExecutablePath); |
84 | ExitWithLastError(hr, "Failed to create embedded process at path: %ls", wzExecutablePath); | ||
85 | } | ||
86 | 83 | ||
87 | connection.dwProcessId = ::GetProcessId(pi.hProcess); | 84 | connection.dwProcessId = ::GetProcessId(pi.hProcess); |
88 | connection.hProcess = pi.hProcess; | 85 | connection.hProcess = pi.hProcess; |
@@ -95,7 +92,7 @@ extern "C" HRESULT EmbeddedRunBundle( | |||
95 | ExitOnFailure(hr, "Failed to process messages from embedded message."); | 92 | ExitOnFailure(hr, "Failed to process messages from embedded message."); |
96 | 93 | ||
97 | // Get the return code from the embedded process. | 94 | // Get the return code from the embedded process. |
98 | hr = ProcWaitForCompletion(connection.hProcess, INFINITE, pdwExitCode); | 95 | hr = CoreWaitForProcCompletion(connection.hProcess, INFINITE, pdwExitCode); |
99 | ExitOnFailure(hr, "Failed to wait for embedded executable: %ls", wzExecutablePath); | 96 | ExitOnFailure(hr, "Failed to wait for embedded executable: %ls", wzExecutablePath); |
100 | 97 | ||
101 | LExit: | 98 | LExit: |
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp index 13075497..413db69b 100644 --- a/src/burn/engine/engine.cpp +++ b/src/burn/engine/engine.cpp | |||
@@ -445,7 +445,6 @@ static HRESULT RunUntrusted( | |||
445 | LPWSTR sczCachedCleanRoomBundlePath = NULL; | 445 | LPWSTR sczCachedCleanRoomBundlePath = NULL; |
446 | LPWSTR sczParameters = NULL; | 446 | LPWSTR sczParameters = NULL; |
447 | LPWSTR sczFullCommandLine = NULL; | 447 | LPWSTR sczFullCommandLine = NULL; |
448 | STARTUPINFOW si = { }; | ||
449 | PROCESS_INFORMATION pi = { }; | 448 | PROCESS_INFORMATION pi = { }; |
450 | HANDLE hFileAttached = NULL; | 449 | HANDLE hFileAttached = NULL; |
451 | HANDLE hFileSelf = NULL; | 450 | HANDLE hFileSelf = NULL; |
@@ -484,12 +483,8 @@ static HRESULT RunUntrusted( | |||
484 | hr = StrAllocFormattedSecure(&sczFullCommandLine, L"\"%ls\" %ls", wzCleanRoomBundlePath, sczParameters); | 483 | hr = StrAllocFormattedSecure(&sczFullCommandLine, L"\"%ls\" %ls", wzCleanRoomBundlePath, sczParameters); |
485 | ExitOnFailure(hr, "Failed to allocate full command-line."); | 484 | ExitOnFailure(hr, "Failed to allocate full command-line."); |
486 | 485 | ||
487 | si.cb = sizeof(si); | 486 | hr = CoreCreateProcess(wzCleanRoomBundlePath, sczFullCommandLine, TRUE, 0, NULL, static_cast<WORD>(pEngineState->command.nCmdShow), &pi); |
488 | si.wShowWindow = static_cast<WORD>(pEngineState->command.nCmdShow); | 487 | ExitOnFailure(hr, "Failed to launch clean room process: %ls", sczFullCommandLine); |
489 | if (!::CreateProcessW(wzCleanRoomBundlePath, sczFullCommandLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) | ||
490 | { | ||
491 | ExitWithLastError(hr, "Failed to launch clean room process: %ls", sczFullCommandLine); | ||
492 | } | ||
493 | 488 | ||
494 | hProcess = pi.hProcess; | 489 | hProcess = pi.hProcess; |
495 | pi.hProcess = NULL; | 490 | pi.hProcess = NULL; |
diff --git a/src/burn/engine/exeengine.cpp b/src/burn/engine/exeengine.cpp index 701adb74..1168f5ea 100644 --- a/src/burn/engine/exeengine.cpp +++ b/src/burn/engine/exeengine.cpp | |||
@@ -687,7 +687,6 @@ extern "C" HRESULT ExeEngineRunProcess( | |||
687 | { | 687 | { |
688 | HRESULT hr = S_OK; | 688 | HRESULT hr = S_OK; |
689 | LPWSTR sczCommand = NULL; | 689 | LPWSTR sczCommand = NULL; |
690 | STARTUPINFOW si = { }; | ||
691 | PROCESS_INFORMATION pi = { }; | 690 | PROCESS_INFORMATION pi = { }; |
692 | GENERIC_EXECUTE_MESSAGE message = { }; | 691 | GENERIC_EXECUTE_MESSAGE message = { }; |
693 | int nResult = IDNOACTION; | 692 | int nResult = IDNOACTION; |
@@ -695,7 +694,6 @@ extern "C" HRESULT ExeEngineRunProcess( | |||
695 | BOOL fDelayedCancel = FALSE; | 694 | BOOL fDelayedCancel = FALSE; |
696 | BOOL fFireAndForget = BURN_PACKAGE_TYPE_EXE == pPackage->type && pPackage->Exe.fFireAndForget; | 695 | BOOL fFireAndForget = BURN_PACKAGE_TYPE_EXE == pPackage->type && pPackage->Exe.fFireAndForget; |
697 | BOOL fInheritHandles = BURN_PACKAGE_TYPE_BUNDLE == pPackage->type; | 696 | BOOL fInheritHandles = BURN_PACKAGE_TYPE_BUNDLE == pPackage->type; |
698 | size_t cchCachedDirectory = 0; | ||
699 | 697 | ||
700 | // Always add user supplied arguments last. | 698 | // Always add user supplied arguments last. |
701 | if (wzUserArgs) | 699 | if (wzUserArgs) |
@@ -704,19 +702,10 @@ extern "C" HRESULT ExeEngineRunProcess( | |||
704 | ExitOnFailure(hr, "Failed to append user args."); | 702 | ExitOnFailure(hr, "Failed to append user args."); |
705 | } | 703 | } |
706 | 704 | ||
707 | // CreateProcessW has undocumented MAX_PATH restriction for lpCurrentDirectory even when long path support is enabled. | ||
708 | if (wzCachedDirectory && FAILED(::StringCchLengthW(wzCachedDirectory, MAX_PATH - 1, &cchCachedDirectory))) | ||
709 | { | ||
710 | wzCachedDirectory = NULL; | ||
711 | } | ||
712 | |||
713 | // Make the cache location of the executable the current directory to help those executables | 705 | // Make the cache location of the executable the current directory to help those executables |
714 | // that expect stuff to be relative to them. | 706 | // that expect stuff to be relative to them. |
715 | si.cb = sizeof(si); | 707 | hr = CoreCreateProcess(wzExecutablePath, sczCommand ? sczCommand : sczBaseCommand, fInheritHandles, CREATE_NO_WINDOW, wzCachedDirectory, 0, &pi); |
716 | if (!::CreateProcessW(wzExecutablePath, sczCommand ? sczCommand : sczBaseCommand, NULL, NULL, fInheritHandles, CREATE_NO_WINDOW, NULL, wzCachedDirectory, &si, &pi)) | 708 | ExitOnFailure(hr, "Failed to CreateProcess on path: %ls", wzExecutablePath); |
717 | { | ||
718 | ExitWithLastError(hr, "Failed to CreateProcess on path: %ls", wzExecutablePath); | ||
719 | } | ||
720 | 709 | ||
721 | message.type = GENERIC_EXECUTE_MESSAGE_PROCESS_STARTED; | 710 | message.type = GENERIC_EXECUTE_MESSAGE_PROCESS_STARTED; |
722 | message.dwUIHint = MB_OK; | 711 | message.dwUIHint = MB_OK; |
diff --git a/src/burn/engine/netfxchainer.cpp b/src/burn/engine/netfxchainer.cpp index 68ddb093..86a06373 100644 --- a/src/burn/engine/netfxchainer.cpp +++ b/src/burn/engine/netfxchainer.cpp | |||
@@ -345,7 +345,6 @@ extern "C" HRESULT NetFxRunChainer( | |||
345 | LPWSTR sczSectionName = NULL; | 345 | LPWSTR sczSectionName = NULL; |
346 | LPWSTR sczCommand = NULL; | 346 | LPWSTR sczCommand = NULL; |
347 | NetFxChainer* pNetfxChainer = NULL; | 347 | NetFxChainer* pNetfxChainer = NULL; |
348 | STARTUPINFOW si = { }; | ||
349 | PROCESS_INFORMATION pi = { }; | 348 | PROCESS_INFORMATION pi = { }; |
350 | HRESULT hrInternalError = 0; | 349 | HRESULT hrInternalError = 0; |
351 | 350 | ||
@@ -372,11 +371,8 @@ extern "C" HRESULT NetFxRunChainer( | |||
372 | ExitOnFailure(hr, "Failed to append user args."); | 371 | ExitOnFailure(hr, "Failed to append user args."); |
373 | } | 372 | } |
374 | 373 | ||
375 | si.cb = sizeof(si); | 374 | hr = CoreCreateProcess(wzExecutablePath, sczCommand, FALSE, CREATE_NO_WINDOW, NULL, 0, &pi); |
376 | if (!::CreateProcessW(wzExecutablePath, sczCommand, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) | 375 | ExitOnFailure(hr, "Failed to CreateProcess on path: %ls", wzExecutablePath); |
377 | { | ||
378 | ExitWithLastError(hr, "Failed to CreateProcess on path: %ls", wzExecutablePath); | ||
379 | } | ||
380 | 376 | ||
381 | HANDLE handles[2] = { pi.hProcess, pNetfxChainer->hEventChaineeSend }; | 377 | HANDLE handles[2] = { pi.hProcess, pNetfxChainer->hEventChaineeSend }; |
382 | 378 | ||