Fix Wine Staging Bug #162 - Caesar III demo installer crashes.

This commit is contained in:
Erich E. Hoover 2015-03-15 15:35:20 -06:00
parent d57ae8c150
commit 547d1a988d
3 changed files with 57 additions and 2 deletions

View File

@ -0,0 +1,53 @@
From 9934111898d494f3c2bdd5cdfcaaf5bc3055966c Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Sun, 15 Mar 2015 15:30:51 -0600
Subject: krnl386: Invalid console handles should translate into real handles
when creating a new process.
Fixes Wine Staging Bug #162 - Caesar III demo installer crashes.
---
dlls/krnl386.exe16/file.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/dlls/krnl386.exe16/file.c b/dlls/krnl386.exe16/file.c
index 1386fe1..04825ef 100644
--- a/dlls/krnl386.exe16/file.c
+++ b/dlls/krnl386.exe16/file.c
@@ -53,21 +53,24 @@ static HANDLE dos_handles[DOS_TABLE_SIZE];
*/
static void FILE_InitProcessDosHandles( void )
{
+ HANDLE hStdInput, hStdOutput, hStdError;
static BOOL init_done /* = FALSE */;
HANDLE cp = GetCurrentProcess();
if (init_done) return;
init_done = TRUE;
- DuplicateHandle(cp, GetStdHandle(STD_INPUT_HANDLE), cp, &dos_handles[0],
- 0, TRUE, DUPLICATE_SAME_ACCESS);
- DuplicateHandle(cp, GetStdHandle(STD_OUTPUT_HANDLE), cp, &dos_handles[1],
- 0, TRUE, DUPLICATE_SAME_ACCESS);
- DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[2],
- 0, TRUE, DUPLICATE_SAME_ACCESS);
- DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[3],
- 0, TRUE, DUPLICATE_SAME_ACCESS);
- DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[4],
- 0, TRUE, DUPLICATE_SAME_ACCESS);
+ hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ hStdError = GetStdHandle(STD_ERROR_HANDLE);
+ /* Invalid console handles need to translate to real handles in a new process */
+ if (!hStdInput) hStdInput = INVALID_HANDLE_VALUE;
+ if (!hStdOutput) hStdOutput = INVALID_HANDLE_VALUE;
+ if (!hStdError) hStdError = INVALID_HANDLE_VALUE;
+ DuplicateHandle(cp, hStdInput, cp, &dos_handles[0], 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(cp, hStdOutput, cp, &dos_handles[1], 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(cp, hStdError, cp, &dos_handles[2], 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(cp, hStdError, cp, &dos_handles[3], 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(cp, hStdError, cp, &dos_handles[4], 0, TRUE, DUPLICATE_SAME_ACCESS);
}
/***********************************************************************
--
1.9.1

View File

@ -2377,11 +2377,13 @@ fi
# | * [#36216] Hearthstone fails to start
# |
# | Modified files:
# | * dlls/kernel32/console.c, dlls/kernel32/environ.c, dlls/kernel32/tests/process.c
# | * dlls/kernel32/console.c, dlls/kernel32/environ.c, dlls/kernel32/tests/process.c, dlls/krnl386.exe16/file.c
# |
if test "$enable_kernel32_Console_Handles" -eq 1; then
patch_apply kernel32-Console_Handles/0001-kernel32-Invalid-console-handles-for-new-processes-a.patch
patch_apply kernel32-Console_Handles/0001-krnl386-Invalid-console-handles-should-translate-int.patch
patch_apply kernel32-Console_Handles/0002-kernel32-Invalid-console-handles-for-new-processes-a.patch
(
echo '+ { "Erich E. Hoover", "krnl386: Invalid console handles should translate into real handles when creating a new process.", 1 },';
echo '+ { "Erich E. Hoover", "kernel32: Invalid console handles for new processes are 0, not INVALID_HANDLE_VALUE.", 1 },';
) >> "$patchlist"
fi