Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proton & CW HACK 23072 Simulate Write Copy #8

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dlls/ntdll/unix/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,20 @@ static void dlopen_32on64_opengl32(void)
}
#endif

BOOL simulate_writecopy;

static void hacks_init(void)
{
const char *env_str;

env_str = getenv("WINE_SIMULATE_WRITECOPY");
if (env_str) simulate_writecopy = atoi(env_str);
else simulate_writecopy = main_argc > 1 && (
strstr(main_argv[1], "UplayWebCore.exe")
|| strstr(main_argv[1], "Battle.net.exe") /* CW HACK 23072 */
);
}

/***********************************************************************
* start_main_thread
*/
Expand All @@ -2479,6 +2493,7 @@ static void start_main_thread(void)
signal_init_thread( teb );
dbg_init();
startup_info_size = server_init_process();
hacks_init();
msync_init();
esync_init();
virtual_map_user_shared_data();
Expand Down
1 change: 1 addition & 0 deletions dlls/ntdll/unix/unix_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ extern USHORT ds32_sel DECLSPEC_HIDDEN;
extern USHORT cs64_sel DECLSPEC_HIDDEN;
#endif

extern BOOL simulate_writecopy;

extern void init_environment( int argc, char *argv[], char *envp[] ) DECLSPEC_HIDDEN;
extern void init_startup_info(void) DECLSPEC_HIDDEN;
Expand Down
11 changes: 11 additions & 0 deletions dlls/ntdll/unix/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct file_view
#define VPROT_GUARD 0x10
#define VPROT_COMMITTED 0x20
#define VPROT_WRITEWATCH 0x40
#define VPROT_COPIED 0x80
/* per-mapping protection flags */
#define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */

Expand Down Expand Up @@ -4134,6 +4135,16 @@ 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_COPIED.\n");

set_page_vprot_bits(base, size, VPROT_COPIED, 0);
vprot |= VPROT_COPIED;
old = get_win32_prot( vprot, view->protect );
}
}
else status = STATUS_NOT_COMMITTED;
}
Expand Down
Loading