diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-12-14 17:04:17 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-12-14 17:04:17 +0100 |
| commit | 2a33cf4e609a8fa1418d2f8f03b271cc0e40080f (patch) | |
| tree | 52a6d3d1eb78dcc3d17ba3fbbee6a27c6346c7d4 /src/wrapped32 | |
| parent | 6698a844f60752285372e091ad7912c6074a2c41 (diff) | |
| download | box64-2a33cf4e609a8fa1418d2f8f03b271cc0e40080f.tar.gz box64-2a33cf4e609a8fa1418d2f8f03b271cc0e40080f.zip | |
[BOX32][WRAPPER] Many fixes and improvments to X11 wrapping
Diffstat (limited to 'src/wrapped32')
| -rw-r--r-- | src/wrapped32/generated/functions_list.txt | 3 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedlibx11types32.h | 2 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.c | 2 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.h | 1 | ||||
| -rw-r--r-- | src/wrapped32/wrappedlibx11.c | 22 | ||||
| -rw-r--r-- | src/wrapped32/wrappedlibx11_private.h | 2 | ||||
| -rw-r--r-- | src/wrapped32/wrappedlibxext.c | 60 | ||||
| -rw-r--r-- | src/wrapped32/wrappedlibxi.c | 3 |
8 files changed, 55 insertions, 40 deletions
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index c63cc256..88fbb09c 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -1193,6 +1193,7 @@ #() iFEXLLp -> iFEXLLp #() iFEXLpi -> iFEXLpi #() iFEXLpp -> iFEXLpp +#() iFEXpii -> iFEXpii #() iFEXpLp -> iFEXpLp #() iFEXppu -> iFEXppu #() iFEXppp -> iFEXppp @@ -2510,6 +2511,8 @@ wrappedlibx11: - XGetWMColormapWindows - XGetWMNormalHints - XGetWMProtocols +- iFXpii: + - _XReply - iFXppp: - XCheckIfEvent - XIfEvent diff --git a/src/wrapped32/generated/wrappedlibx11types32.h b/src/wrapped32/generated/wrappedlibx11types32.h index a695bec8..fbf30c42 100644 --- a/src/wrapped32/generated/wrappedlibx11types32.h +++ b/src/wrapped32/generated/wrappedlibx11types32.h @@ -49,6 +49,7 @@ typedef int32_t (*iFXLlp_t)(void*, uintptr_t, intptr_t, void*); typedef int32_t (*iFXLLp_t)(void*, uintptr_t, uintptr_t, void*); typedef int32_t (*iFXLpi_t)(void*, uintptr_t, void*, int32_t); typedef int32_t (*iFXLpp_t)(void*, uintptr_t, void*, void*); +typedef int32_t (*iFXpii_t)(void*, void*, int32_t, int32_t); typedef int32_t (*iFXppp_t)(void*, void*, void*, void*); typedef uintptr_t (*LFXLpi_t)(void*, uintptr_t, void*, int32_t); typedef void* (*pFXlpp_t)(void*, intptr_t, void*, void*); @@ -160,6 +161,7 @@ typedef uintptr_t (*LFXLiiuuuiupLp_t)(void*, uintptr_t, int32_t, int32_t, uint32 GO(XGetWMColormapWindows, iFXLpp_t) \ GO(XGetWMNormalHints, iFXLpp_t) \ GO(XGetWMProtocols, iFXLpp_t) \ + GO(_XReply, iFXpii_t) \ GO(XCheckIfEvent, iFXppp_t) \ GO(XIfEvent, iFXppp_t) \ GO(XCreateColormap, LFXLpi_t) \ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index acba4ab5..18149a10 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -1284,6 +1284,7 @@ typedef int32_t (*iFEXLlp_t)(x64emu_t*, void*, uintptr_t, intptr_t, void*); typedef int32_t (*iFEXLLp_t)(x64emu_t*, void*, uintptr_t, uintptr_t, void*); typedef int32_t (*iFEXLpi_t)(x64emu_t*, void*, uintptr_t, void*, int32_t); typedef int32_t (*iFEXLpp_t)(x64emu_t*, void*, uintptr_t, void*, void*); +typedef int32_t (*iFEXpii_t)(x64emu_t*, void*, void*, int32_t, int32_t); typedef int32_t (*iFEXpLp_t)(x64emu_t*, void*, void*, uintptr_t, void*); typedef int32_t (*iFEXppu_t)(x64emu_t*, void*, void*, void*, uint32_t); typedef int32_t (*iFEXppp_t)(x64emu_t*, void*, void*, void*, void*); @@ -3052,6 +3053,7 @@ void iFEXLlp_32(x64emu_t *emu, uintptr_t fcn) { iFEXLlp_t fn = (iFEXLlp_t)fcn; R void iFEXLLp_32(x64emu_t *emu, uintptr_t fcn) { iFEXLLp_t fn = (iFEXLLp_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16)); } void iFEXLpi_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpi_t fn = (iFEXLpi_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void iFEXLpp_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpp_t fn = (iFEXLpp_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); } +void iFEXpii_32(x64emu_t *emu, uintptr_t fcn) { iFEXpii_t fn = (iFEXpii_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void iFEXpLp_32(x64emu_t *emu, uintptr_t fcn) { iFEXpLp_t fn = (iFEXpLp_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16)); } void iFEXppu_32(x64emu_t *emu, uintptr_t fcn) { iFEXppu_t fn = (iFEXppu_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16)); } void iFEXppp_32(x64emu_t *emu, uintptr_t fcn) { iFEXppp_t fn = (iFEXppp_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); } diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 6c13fc2d..0d38a813 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -1234,6 +1234,7 @@ void iFEXLlp_32(x64emu_t *emu, uintptr_t fnc); void iFEXLLp_32(x64emu_t *emu, uintptr_t fnc); void iFEXLpi_32(x64emu_t *emu, uintptr_t fnc); void iFEXLpp_32(x64emu_t *emu, uintptr_t fnc); +void iFEXpii_32(x64emu_t *emu, uintptr_t fnc); void iFEXpLp_32(x64emu_t *emu, uintptr_t fnc); void iFEXppu_32(x64emu_t *emu, uintptr_t fnc); void iFEXppp_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedlibx11.c b/src/wrapped32/wrappedlibx11.c index a2aac6b1..014aa35f 100644 --- a/src/wrapped32/wrappedlibx11.c +++ b/src/wrapped32/wrappedlibx11.c @@ -1978,8 +1978,10 @@ EXPORT int my32_XGetWindowAttributes(x64emu_t* emu, void* dpy, XID window, my_XW my_XWindowAttributes_t l_attr = {0}; int ret = my->XGetWindowAttributes(dpy, window, &l_attr); convert_XWindowAttributes_to_32(dpy, attr, &l_attr); - attr->screen = to_ptrv(&screen32); - convert_Screen_to_32(&screen32, l_attr.screen); + if(ret) { + attr->screen = to_ptrv(&screen32); + convert_Screen_to_32(&screen32, l_attr.screen); + } return ret; } @@ -2251,8 +2253,13 @@ EXPORT void* my32_XGetVisualInfo(x64emu_t* emu, void* dpy, long mask, my_XVisual { my_XVisualInfo_t template_l = {0}; if(template) convert_XVisualInfo_to_64_novisual(dpy, &template_l, template); - my_XVisualInfo_t* ret = my->XGetVisualInfo(dpy, mask, template?(&template_l):NULL, n); - inplace_XVisualInfo_shrink(dpy, ret); + void* ret = my->XGetVisualInfo(dpy, mask, template?(&template_l):NULL, n); + if(ret) { + my_XVisualInfo_t* src = ret; + my_XVisualInfo_32_t* dst = ret; + for(int i=0; i<*n; ++i) + convert_XVisualInfo_to_32(dpy, &dst[i], &src[i]); + } return ret; } @@ -2653,6 +2660,13 @@ EXPORT int my32_XScreenNumberOfScreen(x64emu_t* emu, void* s) return my->XScreenNumberOfScreen(getScreen64(dpy, s)); } +EXPORT int my32__XReply(x64emu_t* emu, void* dpy, void* rep, int extra, int discard) +{ + int ret = my->_XReply(dpy, rep, extra, discard); + printf_log(LOG_DEBUG, " (reply type:%hhu, length:32+%u) ", *(uint8_t*)rep, ((uint32_t*)rep)[1]); + return ret; +} + #define CUSTOM_INIT \ AddAutomaticBridge(lib->w.bridge, vFp_32, *(void**)dlsym(lib->w.lib, "_XLockMutex_fn"), 0, "_XLockMutex_fn"); \ AddAutomaticBridge(lib->w.bridge, vFp_32, *(void**)dlsym(lib->w.lib, "_XUnlockMutex_fn"), 0, "_XUnlockMutex_fn"); \ diff --git a/src/wrapped32/wrappedlibx11_private.h b/src/wrapped32/wrappedlibx11_private.h index a10fa39e..1d762269 100644 --- a/src/wrapped32/wrappedlibx11_private.h +++ b/src/wrapped32/wrappedlibx11_private.h @@ -996,7 +996,7 @@ GO(XRemoveFromSaveSet, iFXL) GO(XRemoveHost, iFXbiip_) GO(XRemoveHosts, iFXbiip_i) GO(XReparentWindow, iFXLLii) -GO(_XReply, iFXpii) +GOM(_XReply, iFEXpii) GO(XResetScreenSaver, iFX) GO(XResizeWindow, iFXLuu) GO(XResourceManagerString, pFX) diff --git a/src/wrapped32/wrappedlibxext.c b/src/wrapped32/wrappedlibxext.c index 8acbdee7..4fe006fa 100644 --- a/src/wrapped32/wrappedlibxext.c +++ b/src/wrapped32/wrappedlibxext.c @@ -84,7 +84,7 @@ static void* reverse_exterrorhandleFct(void* fct) static uintptr_t my_create_gc_fct_##A = 0; \ static int my_create_gc_##A(void* a, uint32_t b, void* c) \ { \ - return RunFunctionFmt(my_create_gc_fct_##A, "pup", getDisplay(a), b, c); \ + return RunFunctionFmt(my_create_gc_fct_##A, "pup", FindDisplay(a), b, c); \ } SUPER() #undef GO @@ -106,7 +106,7 @@ static void* find_create_gc_Fct(void* fct) static uintptr_t my_copy_gc_fct_##A = 0; \ static int my_copy_gc_##A(void* a, uint32_t b, void* c) \ { \ - return RunFunctionFmt(my_copy_gc_fct_##A, "pup", getDisplay(a), b, c); \ + return RunFunctionFmt(my_copy_gc_fct_##A, "pup", FindDisplay(a), b, c); \ } SUPER() #undef GO @@ -128,7 +128,7 @@ static void* find_copy_gc_Fct(void* fct) static uintptr_t my_flush_gc_fct_##A = 0; \ static int my_flush_gc_##A(void* a, uint32_t b, void* c) \ { \ - return RunFunctionFmt(my_flush_gc_fct_##A, "pup", getDisplay(a), b, c); \ + return RunFunctionFmt(my_flush_gc_fct_##A, "pup", FindDisplay(a), b, c);\ } SUPER() #undef GO @@ -150,7 +150,7 @@ static void* find_flush_gc_Fct(void* fct) static uintptr_t my_free_gc_fct_##A = 0; \ static int my_free_gc_##A(void* a, uint32_t b, void* c) \ { \ - return RunFunctionFmt(my_free_gc_fct_##A, "pup", getDisplay(a), b, c); \ + return RunFunctionFmt(my_free_gc_fct_##A, "pup", FindDisplay(a), b, c); \ } SUPER() #undef GO @@ -173,7 +173,7 @@ static uintptr_t my_create_font_fct_##A = 0; static int my_create_font_##A(void* a, void* b, void* c) \ { \ inplace_XFontStruct_shrink(b); \ - int ret = RunFunctionFmt(my_create_font_fct_##A, "ppp", getDisplay(a), b, c); \ + int ret = RunFunctionFmt(my_create_font_fct_##A, "ppp", FindDisplay(a), b, c); \ inplace_XFontStruct_enlarge(b); \ return ret; \ } @@ -198,7 +198,7 @@ static uintptr_t my_free_font_fct_##A = 0; static int my_free_font_##A(void* a, void* b, void* c) \ { \ inplace_XFontStruct_shrink(b); \ - int ret = RunFunctionFmt(my_free_font_fct_##A, "ppp", getDisplay(a), b, c); \ + int ret = RunFunctionFmt(my_free_font_fct_##A, "ppp", FindDisplay(a), b, c);\ inplace_XFontStruct_enlarge(b); \ return ret; \ } @@ -222,7 +222,7 @@ static void* find_free_font_Fct(void* fct) static uintptr_t my_close_display_fct_##A = 0; \ static int my_close_display_##A(void* a, void* b) \ { \ - return RunFunctionFmt(my_close_display_fct_##A, "pp", getDisplay(a), b); \ + return RunFunctionFmt(my_close_display_fct_##A, "pp", FindDisplay(a), b); \ } SUPER() #undef GO @@ -245,7 +245,7 @@ static uintptr_t my32_wire_to_event_fct_##A = 0; static int my32_wire_to_event_##A(void* dpy, void* re, void* event) \ { \ static my_XEvent_32_t re_s = {0}; \ - int ret = (int)RunFunctionFmt(my32_wire_to_event_fct_##A, "ppp", getDisplay(dpy), &re_s, event);\ + int ret = (int)RunFunctionFmt(my32_wire_to_event_fct_##A, "ppp", FindDisplay(dpy), &re_s, event);\ unconvertXEvent(re, &re_s); \ return ret; \ } @@ -305,7 +305,7 @@ static int my32_event_to_wire_##A(void* dpy, void* re, void* event) { \ my_XEvent_32_t re_s = {0}; \ convertXEvent(&re_s, re); \ - return (int)RunFunctionFmt(my32_event_to_wire_fct_##A, "ppp", getDisplay(dpy), &re_s, event); \ + return (int)RunFunctionFmt(my32_event_to_wire_fct_##A, "ppp", FindDisplay(dpy), &re_s, event); \ } SUPER() #undef GO @@ -360,7 +360,7 @@ static void* reverse_event_to_wire_Fct(library_t* lib, void* fct) static uintptr_t my_error_fct_##A = 0; \ static int my_error_##A(void* a, void* b, void* c, int* d) \ { \ - return RunFunctionFmt(my_error_fct_##A, "pppp", getDisplay(a), b, c, d); \ + return RunFunctionFmt(my_error_fct_##A, "pppp", FindDisplay(a), b, c, d); \ } SUPER() #undef GO @@ -382,7 +382,7 @@ static void* find_error_Fct(void* fct) static uintptr_t my_error_string_fct_##A = 0; \ static int my_error_string_##A(void* a, int b, void* c, void* d, int e) \ { \ - return RunFunctionFmt(my_error_string_fct_##A, "pippi", getDisplay(a), b, c, d, e); \ + return RunFunctionFmt(my_error_string_fct_##A, "pippi", FindDisplay(a), b, c, d, e);\ } SUPER() #undef GO @@ -492,26 +492,6 @@ EXPORT void* my32_XSetExtensionErrorHandler(x64emu_t* emu, void* handler) return reverse_exterrorhandleFct(my->XSetExtensionErrorHandler(find_exterrorhandle_Fct(handler))); } -//EXPORT void* my32_XextAddDisplay(x64emu_t* emu, void* extinfo, void* dpy, void* extname, my32_XExtensionHooks* hooks, int nevents, void* data) -//{ -// my32_XExtensionHooks natives = {0}; -// #define GO(A) natives.A = find_##A##_Fct(hooks->A); -// GO(create_gc) -// GO(copy_gc) -// GO(flush_gc) -// GO(free_gc) -// GO(create_font) -// GO(free_font) -// GO(close_display) -// GO(wire_to_event) -// GO(event_to_wire) -// GO(error) -// GO(error_string) -// #undef GO -// void *ret = my->XextAddDisplay(extinfo, dpy, extname, &natives, nevents, data); -// return ret; -//} - EXPORT void* my32_XdbeGetVisualInfo(x64emu_t* emu, void* dpy, XID_32* draws, int* num) { XID draws_l[*num]; @@ -557,17 +537,29 @@ EXPORT void* my32_XextAddDisplay(x64emu_t* emu, void* ext, void* dpy, void* name GO(error_string); #undef GO } - inplace_XExtensionInfo_shrink(my->XextAddDisplay(inplace_XExtensionInfo_enlarge(ext), dpy, name, hooks?(&hooks_l):NULL, nevents, data)); + my_XExtensionInfo_t ext_l = {0}; + convert_XExtensionInfo_to_64(&ext_l, ext); + void* ret = my->XextAddDisplay(&ext_l, dpy, name, hooks?(&hooks_l):NULL, nevents, data); + convert_XExtensionInfo_to_32(ext, &ext_l); + //inplace_XExtDisplayInfo_shrink(ret); //no need, XExtensionInfo will shrink XExtDisplayInfo in the process + return ret; } EXPORT void* my32_XextFindDisplay(x64emu_t* emu, void* ext, void* dpy) { - return inplace_XExtensionInfo_shrink(my->XextFindDisplay(inplace_XExtensionInfo_enlarge(ext), dpy)); + my_XExtensionInfo_t ext_l = {0}; + convert_XExtensionInfo_to_64(&ext_l, ext); + void* ret = my->XextFindDisplay(&ext_l, dpy); + convert_XExtensionInfo_to_32(ext, &ext_l); + //inplace_XExtDisplayInfo_shrink(ret); //no need, XExtensionInfo will shrink XExtDisplayInfo in the process + return ret; } EXPORT int my32_XextRemoveDisplay(x64emu_t* emu, void* ext, void* dpy) { - return my->XextRemoveDisplay(inplace_XExtensionInfo_enlarge(ext), dpy); + int ret = my->XextRemoveDisplay(inplace_XExtensionInfo_enlarge(ext), dpy); + inplace_XExtensionInfo_shrink(ext); + return ret; } #if 0 diff --git a/src/wrapped32/wrappedlibxi.c b/src/wrapped32/wrappedlibxi.c index 90ac4c33..6c37bf57 100644 --- a/src/wrapped32/wrappedlibxi.c +++ b/src/wrapped32/wrappedlibxi.c @@ -113,7 +113,8 @@ EXPORT void my32_XFreeDeviceState(x64emu_t* emu, void* ds) EXPORT void* my32_XListInputDevices(x64emu_t* emu, void* dpy, int* n) { - return inplace_XDeviceInfo_shrink(my->XListInputDevices(dpy, n)); + void* ret = my->XListInputDevices(dpy, n); + return inplace_XDeviceInfo_shrink(ret, *n); } EXPORT void my32_XFreeDeviceList(x64emu_t* emu, void* l) |