On Mon, Nov 2, 2015 at 5:15 AM, Jacek Caban jacek@codeweavers.com wrote:
...
See attached patches. On the quick look it seems similar to the one you mentioned, except it avoids text relocations. The patch is definitely not finished nor ready for proper review, but it's enough to get things to build and run. I haven't even tested that with Chromium nor other apps that need it (well, I haven't tested it at all, really). ...
For Chrome/Steam it absolutely must look like this for "XP" mode (from my patch, you can clearly use your offset trick and have KiFastSystemCall do the lookup): output( "\tmovl $%s, %%eax\n", syscall_name(odp->name) ); output( "\tmovl $%s, %%edx\n", asm_name("KiFastSystemCall") ); output( "\tcall *%%edx\n" ); output( "\tret $%d\n", args * get_ptr_size() ); output( "\tnop\n" );
It also must handle other modes like Win8 (see https://github.com/adobe/chromium/blob/master/sandbox/src/service_resolver_3...), for example in XP WoW64 mode: output( "\tmovl $%s, %%eax\n", syscall_name(odp->name) ); output( "\t.byte 0x33\n\t.byte 0xc9\n" ); /* xor %ecx, ecx */ output( "\tleal 4(%%esp), %%edx\n" ); output( "\tcall *%%fs:0xc0\n" ); /* X86SwitchTo64BitMode */ output( "\tret $%d\n", args * get_ptr_size() ); output( "\tnop\n" ); Note: %fs:0xc0 must be initialized to X86SwitchTo64BitMode _very_ early (server_init_thread is a good place).
So, I think we need to output several wrappers and have a "redirector" thunk for our own internal use (example): output( "\tmovl %s, %%eax\n", asm_name("is_wow64") ); output( "\tcmpl $1, %%eax\n" ); output( "\tje %s%s%s\n", asm_name(""), "__syscall_xp_wow64_", odp->name ); output( "\tjmp %s%s%s\n", asm_name(""), "__syscall_xp_", odp->name );
Then, similar to how we do relays, we need to pick the appropriate table based on the selected OS version and WoW64 status and expose that to apps. Most of this idea is in my patch 6 (https://dl.dropboxusercontent.com/u/195059/wine/ntdll-Syscall_Wrappers/0006-...), which I have tested with Steam pretty extensively. However, I cannot get the WoW64 version to "work" because of the 64-bit "webhelper" crap - for some reason it cannot read the 64-bit ntdll memory.
Best, Erich