Open Freeman310 opened 8 months ago
It broke at some point upstream but should work on Valve trees. Can't remember exactly what it was, but the fix we shipped eventually broke as well down the line.
Proton works. But I would like it to work in new Wine versions as well. I've been trying to solve it for a week now, but no luck.
It broke at some point upstream but should work on Valve trees. Can't remember exactly what it was, but the fix we shipped eventually broke as well down the line.
Apparently the fix we ship from proton still works. It's enabled by _protonify="true"
in your config. Or you can add it by hand through userpatches:
From 98bce52ddf46c0c8c6be57c27d4aa9c48303798b Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Tue, 14 Mar 2023 21:12:22 -0600
Subject: [PATCH] ntdll: HACK: Add WINE_SIMULATE_WRITECOPY option.
CW-Bug-Id: #22034
Edit: Enable for UplayWebCore.exe
---
dlls/ntdll/unix/loader.c | 5 +++++
dlls/ntdll/unix/unix_private.h | 1 +
dlls/ntdll/unix/virtual.c | 13 +++++++++++--
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 9f00e45..67d071a 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1346,6 +1346,7 @@ const unixlib_entry_t unix_call_wow64_funcs[] =
BOOL ac_odyssey;
BOOL fsync_simulate_sched_quantum;
+BOOL simulate_writecopy;
static void hacks_init(void)
{
@@ -1367,6 +1368,10 @@ static void hacks_init(void)
if (fsync_simulate_sched_quantum)
ERR("HACK: Simulating sched quantum in fsync.\n");
+ env_str = getenv("WINE_SIMULATE_WRITECOPY");
+ if (env_str) simulate_writecopy = atoi(env_str);
+ else if (main_argc > 1 && strstr(main_argv[1], "UplayWebCore.exe")) simulate_writecopy = TRUE;
+
env_str = getenv("SteamGameId");
if (env_str && !strcmp(env_str, "50130"))
setenv("WINESTEAMNOEXEC", "1", 0);
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 2bf8975..8a5baf3 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -175,6 +175,7 @@ extern struct ldt_copy __wine_ldt_copy;
extern BOOL ac_odyssey;
extern BOOL fsync_simulate_sched_quantum;
+extern BOOL simulate_writecopy;
extern void init_environment( int argc, char *argv[], char *envp[] );
extern void init_startup_info(void);
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 59c0e6d..9a7af20 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1107,7 +1107,8 @@ static const char *get_prot_str( BYTE prot )
buffer[0] = (prot & VPROT_COMMITTED) ? 'c' : '-';
buffer[1] = (prot & VPROT_GUARD) ? 'g' : ((prot & VPROT_WRITEWATCH) ? 'H' : '-');
buffer[2] = (prot & VPROT_READ) ? 'r' : '-';
- buffer[3] = (prot & VPROT_WRITECOPY) ? 'W' : ((prot & VPROT_WRITE) ? 'w' : '-');
+ buffer[3] = (prot & VPROT_WRITECOPY) ? (prot & VPROT_WRITTEN ? 'w' : 'W')
+ : ((prot & VPROT_WRITE) ? 'w' : '-');
buffer[4] = (prot & VPROT_EXEC) ? 'x' : '-';
buffer[5] = 0;
return buffer;
@@ -4730,6 +4731,33 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
{
old = get_win32_prot( vprot, view->protect );
status = set_protection( view, base, size, new_prot );
+
+ if (simulate_writecopy && status == STATUS_SUCCESS
+ && ((old == PAGE_WRITECOPY || old == PAGE_EXECUTE_WRITECOPY)))
+ {
+ TRACE("Setting VPROT_WRITTEN.\n");
+
+ set_page_vprot_bits(base, size, VPROT_WRITTEN, 0);
+ vprot |= VPROT_WRITTEN;
+ old = get_win32_prot( vprot, view->protect );
+ }
+ else if (status == STATUS_SUCCESS && (view->protect & SEC_IMAGE) &&
+ base == (void*)NtCurrentTeb()->Peb->ImageBaseAddress)
+ {
+ /* GTA5 HACK: Mark first page as copied. */
+ const WCHAR gta5W[] = { 'g','t','a','5','.','e','x','e',0 };
+ WCHAR *name, *p;
+
+ name = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
+ p = wcsrchr(name, '\\');
+ p = p ? p+1 : name;
+
+ if(!wcsicmp(p, gta5W))
+ {
+ FIXME("HACK: changing GTA5.exe vprot\n");
+ set_page_vprot_bits(base, page_size, VPROT_WRITTEN, 0);
+ }
+ }
}
else status = STATUS_NOT_COMMITTED;
}
I apologize for the long silence. I will try your patch soon. I hope it helps.
@Tk-Glitch @Freeman310 I just tried this against wine master staging 9.6.r1.g164a792c
.
With vanilla upstream wine, ubisoft connect won't launch at all. The wine debug terminal just opens really quick, then closes, repeating in an infinite loop.
With _protonify="true"
, ubisoft connect technically launches, but (shortly after it opens) shows a dialog box with "Ubisoft Connect has detected an unrecoverable error and must shut down." then closes when you hit OK.
The actual Add WINE_SIMULATE_WRITECOPY option.
patch that you wrote out fails to apply, regardless of the _protonify
setting.
When trying to launch Ubisoft Connect, it crashes with an error.
I tried to change static const WCHAR opt = L" --use-gl=swiftshader" to static const WCHAR opt = L" --use-angle=vulkan" in dlls/kernelbase/process.c.
As a result, Ubisoft Connect tries to start but crashes and it loops.