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 | |
| parent | 6698a844f60752285372e091ad7912c6074a2c41 (diff) | |
| download | box64-2a33cf4e609a8fa1418d2f8f03b271cc0e40080f.tar.gz box64-2a33cf4e609a8fa1418d2f8f03b271cc0e40080f.zip | |
[BOX32][WRAPPER] Many fixes and improvments to X11 wrapping
Diffstat (limited to 'src')
| -rwxr-xr-x | src/emu/x86int3.c | 6 | ||||
| -rw-r--r-- | src/libtools/my_x11_conv.c | 212 | ||||
| -rw-r--r-- | src/libtools/my_x11_conv.h | 5 | ||||
| -rw-r--r-- | src/libtools/my_x11_defs.h | 24 | ||||
| -rw-r--r-- | src/libtools/my_x11_defs_32.h | 38 | ||||
| -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 |
13 files changed, 290 insertions, 90 deletions
diff --git a/src/emu/x86int3.c b/src/emu/x86int3.c index a89f9a84..66b5d6ef 100755 --- a/src/emu/x86int3.c +++ b/src/emu/x86int3.c @@ -340,6 +340,12 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr) snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+8))); } else if(strstr(s, "XRRSetScreenSize")==s) { snprintf(buff, 255, "%04d|%p: Calling %s(%p, %u, %d, %d, %d, %d)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, (char *)from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), from_ptri(ulong_t, R_ESP+8), from_ptri(int, R_ESP+12), from_ptri(int, R_ESP+16), from_ptri(int, R_ESP+20), from_ptri(int, R_ESP+24)); + } else if(strstr(s, "XextAddDisplay")==s) { + snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p, \'%s\', %p, %d, %p)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+12)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+16)), from_ptri(int, R_ESP+20), from_ptrv(*(ptr_t*)from_ptr(R_ESP+24))); + } else if(strstr(s, "_XGetRequest")==s) { + snprintf(buff, 255, "%04d|%p: Calling %s(%p, %hhu, %u)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), from_ptri(uint8_t, R_ESP+8), from_ptri(ulong_t, R_ESP+12)); + } else if(strstr(s, "_XReply")==s) { + snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p, %d, %d)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), from_ptri(int, R_ESP+12), from_ptri(int, R_ESP+16)); } else if(strstr(s, "pthread_mutex_init")==s) { snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8))); } else if(strstr(s, "pthread_mutex_lock")==s || strstr(s, "pthread_mutex_unlock")==s) { diff --git a/src/libtools/my_x11_conv.c b/src/libtools/my_x11_conv.c index dec9b3b1..f271ea12 100644 --- a/src/libtools/my_x11_conv.c +++ b/src/libtools/my_x11_conv.c @@ -231,9 +231,9 @@ void* addDisplay(void* d) my32_Displays_64[i] = dpy; ret = &my32_Displays_32[i]; free_funcs = &my32_free_funcs_32[i]; - ret->free_funcs = to_ptrv(free_funcs); + ret->free_funcs = (dpy->free_funcs)?to_ptrv(free_funcs):0; lock_fns = &my32_lock_fns_32[i]; - ret->lock_fns = to_ptrv(lock_fns); + ret->lock_fns = (dpy->lock_fns)?to_ptrv(lock_fns):0; my32_Displays_Visuals[i] = kh_init(visuals); } } @@ -248,13 +248,11 @@ void* addDisplay(void* d) #define GO(A, W)\ if(dpy->A) \ - if(!CheckBridged(system, dpy->A)) \ - ret->A = AddCheckBridge(system, W, dpy->A, 0, #A); \ + ret->A = AddCheckBridge(system, W, dpy->A, 0, #A); \ #define GO2(A, B, W) \ if(dpy->A && dpy->A->B) \ - if(!CheckBridged(system, dpy->A->B)) \ - A->B = AddCheckBridge(system, W, dpy->A->B, 0, #B "_" #A); \ + A->B = AddCheckBridge(system, W, dpy->A->B, 0, #B "_" #A); \ ret->vendor = to_cstring(dpy->vendor); ret->fd = dpy->fd; @@ -298,8 +296,8 @@ void* addDisplay(void* d) //TODO: event_vec? //TODO: wire_vec? //TODO: async_handlers? - GO2(lock_fns, lock_display, vFp_32) - GO2(lock_fns, unlock_display, vFp_32) + GO2(lock_fns, lock_display, vFX_32) + GO2(lock_fns, unlock_display, vFX_32) GO(idlist_alloc, vFppi_32) //TODO: error_vec? //TODO: flushes @@ -341,6 +339,8 @@ void refreshDisplay(void* dpy) my_XDisplay_32_t* dst = FindDisplay(dpy); // sync last request dst->request = src->request; + // num lock + dst->num_lock = src->num_lock; // sync screens if(dst->nscreens!=src->nscreens) { my_Screen_32_t* screens = from_ptrv(dst->screens); @@ -350,6 +350,53 @@ void refreshDisplay(void* dpy) for(int i=0; i<dst->nscreens; ++i) convert_Screen_to_32(screens+i, src->screens+i); } + // functions + bridge_t* system = my_context->libx11->w.bridge; + int N = -1; + for(int i=0; i<N_DISPLAY && (N==-1); ++i) { + if(my32_Displays_64[i]==dpy) + N = i; + } + struct my_XFreeFuncs_32 *free_funcs = &my32_free_funcs_32[N]; + dst->free_funcs = (src->free_funcs)?to_ptrv(free_funcs):0; + struct my_XLockPtrs_32 *lock_fns = &my32_lock_fns_32[N]; + dst->lock_fns = (src->lock_fns)?to_ptrv(lock_fns):0; + #define GO(A, W)\ + if(src->A) \ + dst->A = AddCheckBridge(system, W, src->A, 0, #A); \ + + #define GO2(A, B, W) \ + if(src->A && src->A->B) \ + A->B = AddCheckBridge(system, W, src->A->B, 0, #B "_" #A); \ + + GO2(free_funcs, atoms, vFp_32) + GO2(free_funcs, modifiermap, iFp_32) + GO2(free_funcs, key_bindings, vFp_32) + GO2(free_funcs, context_db, vFp_32) + GO2(free_funcs, defaultCCCs, vFp_32) + GO2(free_funcs, clientCmaps, vFp_32) + GO2(free_funcs, intensityMaps, vFp_32) + GO2(free_funcs, im_filters, vFp_32) + GO2(free_funcs, xkb, vFp_32) + GO(resource_alloc, LFp_32) + GO(synchandler, iFp_32) + //TODO: ext_procs? + //TODO: event_vec? + //TODO: wire_vec? + //TODO: async_handlers? + GO2(lock_fns, lock_display, vFX_32) + GO2(lock_fns, unlock_display, vFX_32) + GO(idlist_alloc, vFppi_32) + //TODO: error_vec? + //TODO: flushes + //TODO: im_fd_info? + //TODO: conn_watchers + GO(savedsynchandler, iFp_32) + //TODO: generic_event_vec? + //TODO: generic_event_copy_vec? + + #undef GO + #undef GO2 } void convert_XWMints_to_64(void* d, void* s) @@ -577,7 +624,7 @@ void inplace_XExtDisplayInfo_shrink(void* a) my_XExtDisplayInfo_32_t* dst = a; dst->next = to_ptrv(src->next); - dst->display = to_ptrv(getDisplay(src->display)); + dst->display = to_ptrv(FindDisplay(src->display)); dst->codes = to_ptrv(src->codes); dst->data = to_ptrv(src->data); } @@ -589,15 +636,15 @@ void inplace_XExtDisplayInfo_enlarge(void* a) dst->data = from_ptrv(src->data); dst->codes = from_ptrv(src->codes); - dst->display = FindDisplay(from_ptrv(src->display)); + dst->display = getDisplay(from_ptrv(src->display)); dst->next = from_ptrv(src->next); } -void* inplace_XExtensionInfo_shrink(void* a) +void convert_XExtensionInfo_to_32(void* d, void* s) { - if(!a) return a; - my_XExtensionInfo_t* src = a; - my_XExtensionInfo_32_t* dst = a; + if(!s || !d) return; + my_XExtensionInfo_t* src = s; + my_XExtensionInfo_32_t* dst = d; my_XExtDisplayInfo_t* head = src->head; while(head) { @@ -608,13 +655,12 @@ void* inplace_XExtensionInfo_shrink(void* a) dst->head = to_ptrv(src->head); dst->cur = to_ptrv(src->cur); dst->ndisplays = src->ndisplays; - return a; } -void* inplace_XExtensionInfo_enlarge(void* a) +void convert_XExtensionInfo_to_64(void* d, void* s) { - if(!a) return a; - my_XExtensionInfo_32_t* src = a; - my_XExtensionInfo_t* dst = a; + if(!d || !s) return; + my_XExtensionInfo_32_t* src = s; + my_XExtensionInfo_t* dst = d; dst->ndisplays = src->ndisplays; dst->cur = from_ptrv(src->cur); @@ -624,6 +670,17 @@ void* inplace_XExtensionInfo_enlarge(void* a) inplace_XExtDisplayInfo_enlarge(head); head = head->next; } +} +void* inplace_XExtensionInfo_shrink(void* a) +{ + if(a) + convert_XExtensionInfo_to_32(a, a); + return a; +} +void* inplace_XExtensionInfo_enlarge(void* a) +{ + if(a) + convert_XExtensionInfo_to_64(a, a); return a; } @@ -1185,9 +1242,31 @@ void convert_XAnyClassInfo_to_32(void* d, void* s) if(!d || !s) return; my_XAnyClassInfo_t* src = s; my_XAnyClassInfo_32_t* dst = d; - - dst->c_class = to_ulong(src->c_class); - dst->length = src->length; + int len = src->length; + switch(src->c_class) { + case 2: //ValuatorClass + { + my_XValuatorInfo_t* src = s; + my_XValuatorInfo_32_t* dst = d; + dst->c_class = to_ulong(src->c_class); + dst->length = src->length; + dst->num_axes = src->num_axes; + dst->mode = src->mode; + dst->motion_buffer = to_ulong(src->motion_buffer); + dst->axes = to_ptrv(src->axes); + } + break; + case 0: //KeyClass + case 1: //ButtonClass + case 3: //FeedbackClass + case 4: //ProximityClass + case 5: //FocusClass + case 6: //OtherClass + case 7: //AttachClass + default: + dst->c_class = to_ulong(src->c_class); + memmove(d+4, s+8, len-4); + } } void convert_XAnyClassInfo_to_64(void* d, void* s) @@ -1196,8 +1275,31 @@ void convert_XAnyClassInfo_to_64(void* d, void* s) my_XAnyClassInfo_32_t* src = s; my_XAnyClassInfo_t* dst = d; - dst->length = src->length; - dst->c_class = from_ulong(src->c_class); + int len = src->length; + switch(src->c_class) { + case 2: //ValuatorClass + { + my_XValuatorInfo_32_t* src = s; + my_XValuatorInfo_t* dst = d; + dst->axes = from_ptrv(src->axes); + dst->motion_buffer = from_ulong(src->motion_buffer); + dst->mode = src->mode; + dst->num_axes = src->num_axes; + dst->length = src->length; + dst->c_class = from_ulong(src->c_class); + } + break; + case 0: //KeyClass + case 1: //ButtonClass + case 3: //FeedbackClass + case 4: //ProximityClass + case 5: //FocusClass + case 6: //OtherClass + case 7: //AttachClass + default: + memmove(d+8, s+4, len-4); + dst->c_class = from_ulong(src->c_class); + } } void* inplace_XAnyClassInfo_shrink(void* a) { @@ -1212,20 +1314,32 @@ void* inplace_XAnyClassInfo_enlarge(void* a) return a; } -void* inplace_XDeviceInfo_shrink(void* a) +void* inplace_XDeviceInfo_shrink(void* a, int n) { if(a) { my_XDeviceInfo_t* src = a; my_XDeviceInfo_32_t* dst = a; - for(int i=0; i<src->num_classes; ++i) - convert_XAnyClassInfo_to_32(&((my_XAnyClassInfo_32_t*)src->inputclassinfo)[i], &src->inputclassinfo[i]); - dst->id = to_ulong(src->id); - dst->type = to_ulong(src->type); - dst->name = to_ptrv(src->name); - dst->num_classes = src->num_classes; - dst->use = src->use; - dst->inputclassinfo = to_ptrv(src->inputclassinfo); + for(int i=0; i<n; ++i, ++src, ++dst) { + void* p = src->inputclassinfo; + for(int j=0; j<src->num_classes; ++j) { + my_XAnyClassInfo_32_t* dst_c = p; + my_XAnyClassInfo_t* src_c = p; + int len = src_c->length; + convert_XAnyClassInfo_to_32(dst_c, src_c); + p += len; + } + dst->id = to_ulong(src->id); + dst->type = to_ulong(src->type); + dst->name = to_ptrv(src->name); + dst->num_classes = src->num_classes; + dst->use = src->use; + dst->inputclassinfo = to_ptrv(src->inputclassinfo); + } + // mark last record, even on only 1 record, thos last 2 uint32_t are free + dst->inputclassinfo = 0; + dst->name = 0; + } return a; } @@ -1234,15 +1348,29 @@ void* inplace_XDeviceInfo_enlarge(void* a) if(a) { my_XDeviceInfo_32_t* src = a; my_XDeviceInfo_t* dst = a; - - dst->inputclassinfo = from_ptrv(src->inputclassinfo); - dst->use = src->use; - dst->num_classes = src->num_classes; - dst->name = from_ptrv(src->name); - dst->type = from_ulong(src->type); - dst->id = from_ulong(src->id); - for(int i=dst->num_classes-1; i>=0; --i) - convert_XAnyClassInfo_to_64(&dst->inputclassinfo[i], &((my_XAnyClassInfo_32_t*)dst->inputclassinfo)[i]); + int n = 0; + while(src[n].inputclassinfo && src[n].name) ++n; + src+=n-1; + dst+=n-1; + for(int i=n-1; i>=0; --i, --src, --dst) { + dst->inputclassinfo = from_ptrv(src->inputclassinfo); + dst->use = src->use; + dst->num_classes = src->num_classes; + dst->name = from_ptrv(src->name); + dst->type = from_ulong(src->type); + dst->id = from_ulong(src->id); + for(int j=dst->num_classes-1; j>=0; --j) { + void* p = dst->inputclassinfo; + my_XAnyClassInfo_t* dst_c = p; + my_XAnyClassInfo_32_t* src_c = p; + for(int k=0; k<j; ++k) { + p+=src_c->length; + dst_c = p; + src_c = p; + } + convert_XAnyClassInfo_to_64(dst_c, src_c); + } + } } return a; } diff --git a/src/libtools/my_x11_conv.h b/src/libtools/my_x11_conv.h index d119e9e4..ed5b5523 100644 --- a/src/libtools/my_x11_conv.h +++ b/src/libtools/my_x11_conv.h @@ -54,6 +54,8 @@ void inplace_XdbeScreenVisualInfo_enlarge(void* a); void inplace_XExtDisplayInfo_shrink(void* a); void inplace_XExtDisplayInfo_enlarge(void* a); +void convert_XExtensionInfo_to_32(void* d, void* s); +void convert_XExtensionInfo_to_64(void* d, void* s); void* inplace_XExtensionInfo_shrink(void* a); void* inplace_XExtensionInfo_enlarge(void* a); @@ -108,6 +110,7 @@ void convert_XAnyClassInfo_to_32(void* d, void* s); void convert_XAnyClassInfo_to_64(void* d, void* s); void* inplace_XAnyClassInfo_shrink(void* a); void* inplace_XAnyClassInfo_enlarge(void* a); -void* inplace_XDeviceInfo_shrink(void* a); +void* inplace_XDeviceInfo_shrink(void* a, int n); void* inplace_XDeviceInfo_enlarge(void* a); + #endif//MY_X11_CONV \ No newline at end of file diff --git a/src/libtools/my_x11_defs.h b/src/libtools/my_x11_defs.h index 5626b2af..889a47ec 100644 --- a/src/libtools/my_x11_defs.h +++ b/src/libtools/my_x11_defs.h @@ -1400,6 +1400,30 @@ typedef struct my_XAnyClassinfo_s { int length; } my_XAnyClassInfo_t; +typedef struct my_XKeyInfo_s +{ + XID c_class; + int length; + unsigned short min_keycode; + unsigned short max_keycode; + unsigned short num_keys; +} my_XKeyInfo_t; +typedef struct my_XButtonInfo_s +{ + XID c_class; + int length; + short num_buttons; +} my_XButtonInfo_t; +typedef struct my_XValuatorInfo_s +{ + XID c_class; + int length; + unsigned char num_axes; + unsigned char mode; + unsigned long motion_buffer; + void* axes; //XAxisInfoPtr +} my_XValuatorInfo_t; + typedef struct my_XDeviceInfo_s { XID id; diff --git a/src/libtools/my_x11_defs_32.h b/src/libtools/my_x11_defs_32.h index a95936a5..56971dba 100644 --- a/src/libtools/my_x11_defs_32.h +++ b/src/libtools/my_x11_defs_32.h @@ -158,21 +158,21 @@ typedef struct my_XDisplay_32_s volatile ulong_t flags; int min_keycode; int max_keycode; - ptr_t keysyms; //void * + ptr_t keysyms; //void * //offset = 0xA0 ptr_t modifiermap; //void * int keysyms_per_keycode; ptr_t xdefaults; //char * - ptr_t scratch_buffer; //char * + ptr_t scratch_buffer; //char * //offset = 0xB0 ulong_t scratch_length; int ext_number; ptr_t ext_procs; //struct my_XExten * - ptr_t event_vec; //int (*event_vec[128])(void *, void *, void *); - ptr_t wire_vec; //int (*wire_vec[128])(void *, void *, void *); - XID_32 lock_meaning; - ptr_t lock; //void* + ptr_t event_vec[128]; //int (*event_vec[128])(void *, void *, void *); // start at 0xC0 + ptr_t wire_vec[128]; //int (*wire_vec[128])(void *, void *, void *); + XID_32 lock_meaning; //offset = 0x4C0 + ptr_t lock; //void* ptr_t async_handlers; //struct my_XInternalAsync * ulong_t bigreq_size; - ptr_t lock_fns; //struct my_XLockPtrs * + ptr_t lock_fns; //struct my_XLockPtrs * //offset = 0x4D0 ptr_t idlist_alloc; //void (*idlist_alloc)(void *, void *, int); ptr_t key_bindings; //void* XID_32 cursor_font; @@ -1342,6 +1342,30 @@ typedef struct my_XAnyClassinfo_32_s { int length; } my_XAnyClassInfo_32_t; +typedef struct my_XKeyInfo_32_s +{ + XID_32 c_class; + int length; + unsigned short min_keycode; + unsigned short max_keycode; + unsigned short num_keys; +} my_XKeyInfo_32_t; +typedef struct my_XButtonInfo_32_s +{ + XID_32 c_class; + int length; + short num_buttons; +} my_XButtonInfo_32_t; +typedef struct my_XValuatorInfo_32_s +{ + XID_32 c_class; + int length; + unsigned char num_axes; + unsigned char mode; + ulong_t motion_buffer; + ptr_t axes; //XAxisInfoPtr +} my_XValuatorInfo_32_t; + typedef struct my_XDeviceInfo_32_s { XID_32 id; 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) |