Skip to content

Commit

Permalink
msvcrt: Make the _iob export work again for 64 bit guests.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefand committed Mar 22, 2021
1 parent 0814883 commit 199c068
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dlls/msvcrt/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -5099,7 +5099,7 @@ int CDECL MSVCRT_fputs(const char *s, FILE* file)
void qemu_fputs(struct qemu_syscall *call)
{
struct qemu_fputs *c = (struct qemu_fputs *)(ULONG_PTR)call;
WINE_FIXME("Unverified!\n");
WINE_TRACE("\n");
c->super.iret = p_fputs(QEMU_G2H(c->s), FILE_g2h(c->file));
}

Expand Down
23 changes: 16 additions & 7 deletions dlls/msvcrt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *reserved)
WINE_DEFAULT_DEBUG_CHANNEL(qemu_msvcrt);

const struct qemu_ops *qemu_ops;
static const char *dll_name;
static HMODULE msvcrt;

static void qemu_init_dll(struct qemu_syscall *call)
{
qemu_ptr *argv;
qemu_ptr *wargv;
unsigned int i;
static HMODULE msvcrt;
const char *dll_name;
struct qemu_init_dll *c = (struct qemu_init_dll *)call;

/* Don't bother loading it twice. Msvcrt can't be unloaded and reloaded due to file handle wrapping. */
Expand Down Expand Up @@ -2435,7 +2435,6 @@ static const syscall_handler dll_functions[] =
const WINAPI syscall_handler *qemu_dll_register(const struct qemu_ops *ops, uint32_t *dll_num)
{
HMODULE msvcrt;
const char *dll_name;

qemu_ops = ops;
*dll_num = QEMU_CURRENT_DLL;
Expand All @@ -2458,13 +2457,23 @@ const WINAPI syscall_handler *qemu_dll_register(const struct qemu_ops *ops, uint
if (msvcrt_tls == TLS_OUT_OF_INDEXES)
WINE_ERR("Out of TLS indices\n");

/* Delay loading the host DLL until the guest's DllMain is called and the
* memory firewall is in place. Some functions pass pointers to static data
* in msvcr*.dll or the TLS data.
/* Delay loading the host DLL for 32 bit guests until the guest's DllMain
* is called and the memory firewall is in place. Some functions pass
* pointers to static data in msvcr*.dll or the TLS data.
*
* This is not good enough for msvcrt.dll because it is loaded by Wine DLLs,
* see qemu_init_dll. But for later versions it is good because Wine libs will
* never depend on e.g. msvcr80.dll. */
* never depend on e.g. msvcr80.dll.
*
* For 64 bit guests, load it right away. We don't have any issue with passing
* pointers into 64 bit locations and we do so via __qemu_native_data__ in the
* spec file. When ntdll resolves exports from the guest lib the host lib needs
* to be loaded for this to work. */

#if GUEST_BIT == HOST_BIT
struct qemu_init_dll dummy = {0};
qemu_init_dll(&dummy.super);
#endif

return dll_functions;
}
Expand Down

0 comments on commit 199c068

Please sign in to comment.