diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-05-13 16:31:31 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-05-13 16:31:39 +0200 |
| commit | 3b03b7aee66b0a5113932bfc745f9b895573e1da (patch) | |
| tree | 8cdc9f78cb31a9bbc87700dd9facd437ae14f201 | |
| parent | 1491270f1d2dcf37cb9e201ac69ab7a04585afc5 (diff) | |
| download | box64-3b03b7aee66b0a5113932bfc745f9b895573e1da.tar.gz box64-3b03b7aee66b0a5113932bfc745f9b895573e1da.zip | |
Added some more wrapped functions
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 10 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedgdk3types.h | 1 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibicetypes.h | 8 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibsmtypes.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 1 | ||||
| -rw-r--r-- | src/wrapped/wrappedgdk3.c | 27 | ||||
| -rw-r--r-- | src/wrapped/wrappedgdk3_private.h | 2 | ||||
| -rw-r--r-- | src/wrapped/wrappedgtk3.c | 4 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibice.c | 123 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibice_private.h | 8 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibsm.c | 38 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibsm_private.h | 4 |
13 files changed, 221 insertions, 9 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 1206c1dc..74b55489 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -2258,6 +2258,7 @@ #() vFlliiiip #() vFpiiiipp #() vFpiiliip +#() vFpiiLiip #() vFpiipCpp #() vFpiipppp #() vFpipipii @@ -3345,6 +3346,7 @@ wrappedgcrypt: wrappedgdk3: - vFpp: - gdk_init + - gdk_threads_set_lock_functions - iFpp: - gdk_init_check - uFpp: @@ -4483,6 +4485,12 @@ wrappedlibibus: - vFppppippp: - ibus_config_set_value_async wrappedlibice: +- pFp: + - IceSetErrorHandler + - IceSetIOErrorHandler +- iFpp: + - IceAddConnectionWatch + - IceRemoveConnectionWatch wrappedlibm: - iFv: - fegetround @@ -4703,6 +4711,8 @@ wrappedlibrt: - iFipip: - lio_listio wrappedlibsm: +- pFp: + - SmcSetErrorHandler - iFppp: - SmcRequestSaveYourselfPhase2 - iFpipp: diff --git a/src/wrapped/generated/wrappedgdk3types.h b/src/wrapped/generated/wrappedgdk3types.h index 3ed9d8c3..9fef4666 100644 --- a/src/wrapped/generated/wrappedgdk3types.h +++ b/src/wrapped/generated/wrappedgdk3types.h @@ -22,6 +22,7 @@ typedef uint32_t (*uFiuppp_t)(int32_t, uint32_t, void*, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ GO(gdk_init, vFpp_t) \ + GO(gdk_threads_set_lock_functions, vFpp_t) \ GO(gdk_init_check, iFpp_t) \ GO(gdk_threads_add_idle, uFpp_t) \ GO(gdk_event_handler_set, vFppp_t) \ diff --git a/src/wrapped/generated/wrappedlibicetypes.h b/src/wrapped/generated/wrappedlibicetypes.h index 900cca86..111f9be5 100644 --- a/src/wrapped/generated/wrappedlibicetypes.h +++ b/src/wrapped/generated/wrappedlibicetypes.h @@ -11,7 +11,13 @@ #define ADDED_FUNCTIONS() #endif +typedef void* (*pFp_t)(void*); +typedef int32_t (*iFpp_t)(void*, void*); -#define SUPER() ADDED_FUNCTIONS() +#define SUPER() ADDED_FUNCTIONS() \ + GO(IceSetErrorHandler, pFp_t) \ + GO(IceSetIOErrorHandler, pFp_t) \ + GO(IceAddConnectionWatch, iFpp_t) \ + GO(IceRemoveConnectionWatch, iFpp_t) #endif // __wrappedlibiceTYPES_H_ diff --git a/src/wrapped/generated/wrappedlibsmtypes.h b/src/wrapped/generated/wrappedlibsmtypes.h index 3f274278..0eef2429 100644 --- a/src/wrapped/generated/wrappedlibsmtypes.h +++ b/src/wrapped/generated/wrappedlibsmtypes.h @@ -11,11 +11,13 @@ #define ADDED_FUNCTIONS() #endif +typedef void* (*pFp_t)(void*); typedef int32_t (*iFppp_t)(void*, void*, void*); typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*); typedef void* (*pFppiiLpppip_t)(void*, void*, int32_t, int32_t, uintptr_t, void*, void*, void*, int32_t, void*); #define SUPER() ADDED_FUNCTIONS() \ + GO(SmcSetErrorHandler, pFp_t) \ GO(SmcRequestSaveYourselfPhase2, iFppp_t) \ GO(SmcInteractRequest, iFpipp_t) \ GO(SmcOpenConnection, pFppiiLpppip_t) diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 380b2bbd..35756ba3 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -2296,6 +2296,7 @@ typedef void (*vFlipuiip_t)(intptr_t, int32_t, void*, uint32_t, int32_t, int32_t typedef void (*vFlliiiip_t)(intptr_t, intptr_t, int32_t, int32_t, int32_t, int32_t, void*); typedef void (*vFpiiiipp_t)(void*, int32_t, int32_t, int32_t, int32_t, void*, void*); typedef void (*vFpiiliip_t)(void*, int32_t, int32_t, intptr_t, int32_t, int32_t, void*); +typedef void (*vFpiiLiip_t)(void*, int32_t, int32_t, uintptr_t, int32_t, int32_t, void*); typedef void (*vFpiipCpp_t)(void*, int32_t, int32_t, void*, uint8_t, void*, void*); typedef void (*vFpiipppp_t)(void*, int32_t, int32_t, void*, void*, void*, void*); typedef void (*vFpipipii_t)(void*, int32_t, void*, int32_t, void*, int32_t, int32_t); @@ -5375,6 +5376,7 @@ void vFlipuiip(x64emu_t *emu, uintptr_t fcn) { vFlipuiip_t fn = (vFlipuiip_t)fcn void vFlliiiip(x64emu_t *emu, uintptr_t fcn) { vFlliiiip_t fn = (vFlliiiip_t)fcn; fn((intptr_t)R_RDI, (intptr_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9, *(void**)(R_RSP + 8)); } void vFpiiiipp(x64emu_t *emu, uintptr_t fcn) { vFpiiiipp_t fn = (vFpiiiipp_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } void vFpiiliip(x64emu_t *emu, uintptr_t fcn) { vFpiiliip_t fn = (vFpiiliip_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (intptr_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9, *(void**)(R_RSP + 8)); } +void vFpiiLiip(x64emu_t *emu, uintptr_t fcn) { vFpiiLiip_t fn = (vFpiiLiip_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (uintptr_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9, *(void**)(R_RSP + 8)); } void vFpiipCpp(x64emu_t *emu, uintptr_t fcn) { vFpiipCpp_t fn = (vFpiipCpp_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (uint8_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } void vFpiipppp(x64emu_t *emu, uintptr_t fcn) { vFpiipppp_t fn = (vFpiipppp_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } void vFpipipii(x64emu_t *emu, uintptr_t fcn) { vFpipipii_t fn = (vFpipipii_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (void*)R_R8, (int32_t)R_R9, *(int32_t*)(R_RSP + 8)); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index bfa6ea60..84ab7636 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -2296,6 +2296,7 @@ void vFlipuiip(x64emu_t *emu, uintptr_t fnc); void vFlliiiip(x64emu_t *emu, uintptr_t fnc); void vFpiiiipp(x64emu_t *emu, uintptr_t fnc); void vFpiiliip(x64emu_t *emu, uintptr_t fnc); +void vFpiiLiip(x64emu_t *emu, uintptr_t fnc); void vFpiipCpp(x64emu_t *emu, uintptr_t fnc); void vFpiipppp(x64emu_t *emu, uintptr_t fnc); void vFpipipii(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedgdk3.c b/src/wrapped/wrappedgdk3.c index 857e5886..29d7626e 100644 --- a/src/wrapped/wrappedgdk3.c +++ b/src/wrapped/wrappedgdk3.c @@ -103,6 +103,28 @@ static void* findGDestroyNotifyFct(void* fct) printf_log(LOG_NONE, "Warning, no more slot for gdk-3 GDestroyNotify callback\n"); return NULL; } +// GCallback (generic function with 6 arguments, hopefully it's enough) +#define GO(A) \ +static uintptr_t my_GCallback_fct_##A = 0; \ +static void* my_GCallback_##A(void* a, void* b, void* c, void* d) \ +{ \ + return (void*)RunFunctionFmt(my_GCallback_fct_##A, "pppp", a, b, c, d); \ +} +SUPER() +#undef GO +static void* findGCallbackFct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_GCallback_fct_##A == (uintptr_t)fct) return my_GCallback_##A; + SUPER() + #undef GO + #define GO(A) if(my_GCallback_fct_##A == 0) {my_GCallback_fct_##A = (uintptr_t)fct; return my_GCallback_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for gdk3 generic GCallback\n"); + return NULL; +} #undef SUPER @@ -183,6 +205,11 @@ EXPORT uint32_t my3_gdk_threads_add_timeout_full(x64emu_t* emu, int priotity, ui return my->gdk_threads_add_timeout_full(priotity, interval, findGSourceFunc(f), data, findGDestroyNotifyFct(d)); } +EXPORT void my3_gdk_threads_set_lock_functions(x64emu_t* emu, void* enter_fn, void* leave_fn) +{ + my->gdk_threads_set_lock_functions(findGCallbackFct(enter_fn), findGCallbackFct(leave_fn)); +} + #define PRE_INIT \ if(box64_nogtk) \ return -1; diff --git a/src/wrapped/wrappedgdk3_private.h b/src/wrapped/wrappedgdk3_private.h index 89a63b5f..f8b2aed1 100644 --- a/src/wrapped/wrappedgdk3_private.h +++ b/src/wrapped/wrappedgdk3_private.h @@ -597,7 +597,7 @@ GOM(gdk_threads_add_timeout_full, uFEiuppp) GO(gdk_threads_enter, vFv) GO(gdk_threads_init, vFv) GO(gdk_threads_leave, vFv) -//GOM(gdk_threads_set_lock_functions, vFEpp) +GOM(gdk_threads_set_lock_functions, vFEpp) GO(gdk_toplevel_get_type, pFv) GO(gdk_unicode_to_keyval, uFu) GO(gdk_utf8_to_compound_text, iFppppp) diff --git a/src/wrapped/wrappedgtk3.c b/src/wrapped/wrappedgtk3.c index 77611a34..60671247 100644 --- a/src/wrapped/wrappedgtk3.c +++ b/src/wrapped/wrappedgtk3.c @@ -478,7 +478,7 @@ static void* findGtkClipboardTextReceivedFuncFct(void* fct) } #undef SUPER -/* + EXPORT void my3_gtk_dialog_add_buttons(x64emu_t* emu, void* dialog, void* first, uintptr_t* b) { void* btn = first; @@ -488,7 +488,7 @@ EXPORT void my3_gtk_dialog_add_buttons(x64emu_t* emu, void* dialog, void* first, btn = (void*)*(b++); } } -*/ + EXPORT void my3_gtk_message_dialog_format_secondary_text(x64emu_t* emu, void* dialog, void* fmt, void* b) { char* buf = NULL; diff --git a/src/wrapped/wrappedlibice.c b/src/wrapped/wrappedlibice.c index 3a3ff742..869f6e6b 100644 --- a/src/wrapped/wrappedlibice.c +++ b/src/wrapped/wrappedlibice.c @@ -21,5 +21,128 @@ const char* libiceName = "libICE.so.6"; #define LIBNAME libice +#define ADDED_FUNCTIONS() \ + +#include "wrappedlibicetypes.h" + +#include "wrappercallback.h" + +#define SUPER() \ +GO(0) \ +GO(1) \ +GO(2) \ +GO(3) + +// WatchProc +#define GO(A) \ +static uintptr_t my_WatchProc_fct_##A = 0; \ +static void my_WatchProc_##A(void* a, void* b, int c, void* d) \ +{ \ + RunFunctionFmt(my_WatchProc_fct_##A, "ppip", a, b, c, d); \ +} +SUPER() +#undef GO +static void* findWatchProcFct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_WatchProc_fct_##A == (uintptr_t)fct) return my_WatchProc_##A; + SUPER() + #undef GO + #define GO(A) if(my_WatchProc_fct_##A == 0) {my_WatchProc_fct_##A = (uintptr_t)fct; return my_WatchProc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libice WatchProc callback\n"); + return NULL; +} +// IceErrorHandler +#define GO(A) \ +static uintptr_t my_IceErrorHandler_fct_##A = 0; \ +static void my_IceErrorHandler_##A(void* a, int b, int c, unsigned long d, int e, int f, void* g) \ +{ \ + RunFunctionFmt(my_IceErrorHandler_fct_##A, "piiLiip", a, b, c, d, e, f, g);\ +} +SUPER() +#undef GO +static void* findIceErrorHandlerFct(void* fct) +{ + if(!fct) return NULL; + void* p; + if((p = GetNativeFnc((uintptr_t)fct))) return p; + #define GO(A) if(my_IceErrorHandler_fct_##A == (uintptr_t)fct) return my_IceErrorHandler_##A; + SUPER() + #undef GO + #define GO(A) if(my_IceErrorHandler_fct_##A == 0) {my_IceErrorHandler_fct_##A = (uintptr_t)fct; return my_IceErrorHandler_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libICE IceErrorHandler callback\n"); + return NULL; +} +static void* reverse_IceErrorHandler_Fct(void* fct) +{ + if(!fct) return fct; + if(CheckBridged(my_lib->w.bridge, fct)) + return (void*)CheckBridged(my_lib->w.bridge, fct); + #define GO(A) if(my_IceErrorHandler_##A == fct) return (void*)my_IceErrorHandler_fct_##A; + SUPER() + #undef GO + return (void*)AddBridge(my_lib->w.bridge, vFpiiLiip, fct, 0, NULL); +} +// IceIOErrorHandler +#define GO(A) \ +static uintptr_t my_IceIOErrorHandler_fct_##A = 0; \ +static void my_IceIOErrorHandler_##A(void* a) \ +{ \ + RunFunctionFmt(my_IceIOErrorHandler_fct_##A, "p", a);\ +} +SUPER() +#undef GO +static void* findIceIOErrorHandlerFct(void* fct) +{ + if(!fct) return NULL; + void* p; + if((p = GetNativeFnc((uintptr_t)fct))) return p; + #define GO(A) if(my_IceIOErrorHandler_fct_##A == (uintptr_t)fct) return my_IceIOErrorHandler_##A; + SUPER() + #undef GO + #define GO(A) if(my_IceIOErrorHandler_fct_##A == 0) {my_IceIOErrorHandler_fct_##A = (uintptr_t)fct; return my_IceIOErrorHandler_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libICE IceIOErrorHandler callback\n"); + return NULL; +} +static void* reverse_IceIOErrorHandler_Fct(void* fct) +{ + if(!fct) return fct; + if(CheckBridged(my_lib->w.bridge, fct)) + return (void*)CheckBridged(my_lib->w.bridge, fct); + #define GO(A) if(my_IceIOErrorHandler_##A == fct) return (void*)my_IceIOErrorHandler_fct_##A; + SUPER() + #undef GO + return (void*)AddBridge(my_lib->w.bridge, vFp, fct, 0, NULL); +} + +#undef SUPER + +EXPORT int my_IceAddConnectionWatch(x64emu_t* emu, void* f, void* data) +{ + return my->IceAddConnectionWatch(findWatchProcFct(f), data); +} + +EXPORT int my_IceRemoveConnectionWatch(x64emu_t* emu, void* f, void* data) +{ + return my->IceRemoveConnectionWatch(findWatchProcFct(f), data); +} + +EXPORT void* my_IceSetErrorHandler(x64emu_t* emu, void* f) +{ + return reverse_IceErrorHandler_Fct(my->IceSetErrorHandler(findIceErrorHandlerFct(f))); +} + +EXPORT void* my_IceSetIOErrorHandler(x64emu_t* emu, void* f) +{ + return reverse_IceIOErrorHandler_Fct(my->IceSetIOErrorHandler(findIceIOErrorHandlerFct(f))); +} + #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedlibice_private.h b/src/wrapped/wrappedlibice_private.h index 813d5991..6abd9913 100644 --- a/src/wrapped/wrappedlibice_private.h +++ b/src/wrapped/wrappedlibice_private.h @@ -3,7 +3,7 @@ #endif //GO(IceAcceptConnection, -//GO(IceAddConnectionWatch, +GOM(IceAddConnectionWatch, iFEpp) //GO(_IceAddOpcodeMapping, //GO(_IceAddReplyWait, //GO(IceAllocScratch, @@ -70,11 +70,11 @@ GO(IceProcessMessages, iFppp) //GO(IceRegisterForProtocolReply, //GO(IceRegisterForProtocolSetup, //GO(IceRelease, -//GO(IceRemoveConnectionWatch, +GOM(IceRemoveConnectionWatch, iFEpp) //GO(_IceSearchReplyWaits, -//GO(IceSetErrorHandler, +GOM(IceSetErrorHandler, pFEp) //GO(IceSetHostBasedAuthProc, -//GO(IceSetIOErrorHandler, +GOM(IceSetIOErrorHandler, pFEp) //GO(IceSetPaAuthData, //GO(_IceSetReplyReady, //GO(IceSetShutdownNegotiation, diff --git a/src/wrapped/wrappedlibsm.c b/src/wrapped/wrappedlibsm.c index e9907413..aaf84234 100644 --- a/src/wrapped/wrappedlibsm.c +++ b/src/wrapped/wrappedlibsm.c @@ -120,6 +120,39 @@ static void* findRequestFct(void* fct) printf_log(LOG_NONE, "Warning, no more slot for libSM Request callback\n"); return NULL; } +// SmcErrorHandler +#define GO(A) \ +static uintptr_t my_SmcErrorHandler_fct_##A = 0; \ +static void my_SmcErrorHandler_##A(void* a, int b, int c, unsigned long d, int e, int f, void* g) \ +{ \ + RunFunctionFmt(my_SmcErrorHandler_fct_##A, "piiLiip", a, b, c, d, e, f, g);\ +} +SUPER() +#undef GO +static void* findSmcErrorHandlerFct(void* fct) +{ + if(!fct) return NULL; + void* p; + if((p = GetNativeFnc((uintptr_t)fct))) return p; + #define GO(A) if(my_SmcErrorHandler_fct_##A == (uintptr_t)fct) return my_SmcErrorHandler_##A; + SUPER() + #undef GO + #define GO(A) if(my_SmcErrorHandler_fct_##A == 0) {my_SmcErrorHandler_fct_##A = (uintptr_t)fct; return my_SmcErrorHandler_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libSM SmcErrorHandler callback\n"); + return NULL; +} +static void* reverse_SmcErrorHandler_Fct(void* fct) +{ + if(!fct) return fct; + if(CheckBridged(my_lib->w.bridge, fct)) + return (void*)CheckBridged(my_lib->w.bridge, fct); + #define GO(A) if(my_SmcErrorHandler_##A == fct) return (void*)my_SmcErrorHandler_fct_##A; + SUPER() + #undef GO + return (void*)AddBridge(my_lib->w.bridge, vFpiiLiip, fct, 0, NULL); +} #undef SUPER @@ -135,4 +168,9 @@ EXPORT int my_SmcRequestSaveYourselfPhase2(x64emu_t* emu, void* smcConn, void* c return my->SmcRequestSaveYourselfPhase2(smcConn, findRequestFct(cb), data); } +EXPORT void* my_SmcSetErrorHandler(x64emu_t* emu, void* f) +{ + return reverse_SmcErrorHandler_Fct(my->SmcSetErrorHandler(findSmcErrorHandlerFct(f))); +} + #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedlibsm_private.h b/src/wrapped/wrappedlibsm_private.h index bc00fca9..7b8bb67b 100644 --- a/src/wrapped/wrappedlibsm_private.h +++ b/src/wrapped/wrappedlibsm_private.h @@ -19,7 +19,7 @@ GO(SmcRelease, pFp) GO(SmcRequestSaveYourself, vFpiiiii) GOM(SmcRequestSaveYourselfPhase2, iFEppp) GO(SmcSaveYourselfDone, vFpi) -//GOM(SmcSetErrorHandler, BFEB) +GOM(SmcSetErrorHandler, pFEp) GO(SmcSetProperties, vFpip) GO(SmcVendor, pFp) GO(SmFreeProperty, vFp) @@ -43,3 +43,5 @@ GO(SmsSaveYourself, vFpiiii) GO(SmsSaveYourselfPhase2, vFp) //GOM(SmsSetErrorHandler, BFEB) GO(SmsShutdownCancelled, vFp) + +GO(dummy_vFpiiLiip, vFpiiLiip) // for error handler \ No newline at end of file |