From 3f4b08acc72791d1c9bb244c39f0721b8da180de Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Mon, 2 Jan 2017 15:38:48 +0800
Subject: kernel32: On process entry store PEB address in %ebx.

8k demo custom PE loader depends on this.
---
 dlls/kernel32/process.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index fdf272f61b0..231844b80a7 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1073,12 +1073,19 @@ __ASM_GLOBAL_FUNC( call_process_entry,
                     __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
                     "movl %esp,%ebp\n\t"
                     __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+                    "pushl %ebx\n\t"
+                    __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
+                    "subl $12,%esp\n\t"
                     "pushl 4(%ebp)\n\t"  /* deliberately mis-align the stack by 8, Doom 3 needs this */
                     "pushl 4(%ebp)\n\t"  /* Driller expects readable address at this offset */
                     "pushl 4(%ebp)\n\t"
                     "pushl 8(%ebp)\n\t"
+                    "movl 8(%ebp),%ebx\n\t"
                     "call *12(%ebp)\n\t"
-                    "leave\n\t"
+                    "leal -4(%ebp),%esp\n\t"
+                    "popl %ebx\n\t"
+                    __ASM_CFI(".cfi_same_value %ebx\n\t")
+                    "popl %ebp\n\t"
                     __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
                     __ASM_CFI(".cfi_same_value %ebp\n\t")
                     "ret" )
-- 
2.11.0

