From e49551bda521e12f861be3a10c3391bcac73052b Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 12 Apr 2025 14:54:06 +0200 Subject: [PATCH] [BOX32][WRAPPER] Added 32bits wrapped libgbm --- CMakeLists.txt | 1 + src/library_list_32.h | 2 + src/wrapped32/generated/functions_list.txt | 8 +++ src/wrapped32/generated/wrappedgbmdefs32.h | 8 +++ src/wrapped32/generated/wrappedgbmtypes32.h | 19 ++++++ src/wrapped32/generated/wrappedgbmundefs32.h | 8 +++ src/wrapped32/generated/wrapper32.c | 10 +++ src/wrapped32/generated/wrapper32.h | 5 ++ src/wrapped32/wrappedgbm.c | 69 ++++++++++++++++++++ src/wrapped32/wrappedgbm_private.h | 42 ++++++++++++ 10 files changed, 172 insertions(+) create mode 100644 src/wrapped32/generated/wrappedgbmdefs32.h create mode 100644 src/wrapped32/generated/wrappedgbmtypes32.h create mode 100644 src/wrapped32/generated/wrappedgbmundefs32.h create mode 100644 src/wrapped32/wrappedgbm.c create mode 100644 src/wrapped32/wrappedgbm_private.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 520e4a36f..e81d85373 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -861,6 +861,7 @@ if(BOX32) "${BOX64_ROOT}/src/wrapped32/wrappedlibvdpau.c" "${BOX64_ROOT}/src/wrapped32/wrappednsl.c" "${BOX64_ROOT}/src/wrapped32/wrappedlibcups.c" + "${BOX64_ROOT}/src/wrapped32/wrappedgbm.c" ) endif() string(REPLACE ".c" "_private.h" MODROOT ${BOX64_ROOT}) diff --git a/src/library_list_32.h b/src/library_list_32.h index c7b22e188..0f40034fb 100644 --- a/src/library_list_32.h +++ b/src/library_list_32.h @@ -91,6 +91,8 @@ GO("libnsl.so.1", nsl) GO("libnsl.so", nsl) GO("libcups.so.2", libcups) GO("libcups.so", libcups) +GO("libgbm.so.1", gbm) +GO("libgbm.so", gbm) //GO("crashhandler.so", crashhandler) GO("libtcmalloc_minimal.so.0", tcmallocminimal) diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 0f5fe317e..662b7be16 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -1095,6 +1095,7 @@ #() pFpipi -> pFpipi #() pFpipp -> pFpipp #() pFpuii -> pFpuii +#() pFpupu -> pFpupu #() pFpupp -> pFpupp #() pEpLiS -> pEpLiS #() pEpLpL -> pEpLpL @@ -1421,6 +1422,7 @@ #() pFpippp -> pFpippp #() pFpuiii -> pFpuiii #() pFpuuip -> pFpuuip +#() pFpuuuu -> pFpuuuu #() pFpdddd -> pFpdddd #() pFppipi -> pFppipi #() pFppuup -> pFppuup @@ -1642,6 +1644,7 @@ #() pFpipipL -> pFpipipL #() pFpipipp -> pFpipipp #() pFpipuii -> pFpipuii +#() pFpuuupu -> pFpuuupu #() XFpppppp -> XFpppppp #() iFpupupbL_ -> iFpupupB #() iFpupbL_pp -> iFpupBpp @@ -1785,6 +1788,7 @@ #() pEEpLiiil -> pEEpLiiil #() pFEpXppip -> pFEpXppip #() pFpipiupp -> pFpipiupp +#() pFpuuupuu -> pFpuuupuu #() pFppppiii -> pFppppiii #() vFXLLiiibl_ -> vFXLLiiiB #() iFppppppbp_ -> iFppppppB @@ -1856,6 +1860,7 @@ #() pFEXpLLppp -> pFEXpLLppp #() iFXLLiippBL_ -> iFXLLiippB #() iFXLpppbL_pp -> iFXLpppBpp +#() pFpuuuuupbp_ -> pFpuuuuupB #() iFppppubpu_Iu -> iFppppuBIu #() iFpppbpu_ppuu -> iFpppBppuu #() vFppibLdd_ipiu -> vFppiBipiu @@ -2147,6 +2152,9 @@ wrappedfreetype: - FT_Load_Sfnt_Table - iFppllp: - FT_New_Memory_Face +wrappedgbm: +- vFppp: + - gbm_bo_set_user_data wrappedgnutls: - vFp: - gnutls_global_set_log_function diff --git a/src/wrapped32/generated/wrappedgbmdefs32.h b/src/wrapped32/generated/wrappedgbmdefs32.h new file mode 100644 index 000000000..663a16fe5 --- /dev/null +++ b/src/wrapped32/generated/wrappedgbmdefs32.h @@ -0,0 +1,8 @@ +/********************************************************************* + * File automatically generated by rebuild_wrappers_32.py (v0.0.2.2) * + *********************************************************************/ +#ifndef __wrappedgbmDEFS32_H_ +#define __wrappedgbmDEFS32_H_ + + +#endif // __wrappedgbmDEFS32_H_ diff --git a/src/wrapped32/generated/wrappedgbmtypes32.h b/src/wrapped32/generated/wrappedgbmtypes32.h new file mode 100644 index 000000000..5578ccbe1 --- /dev/null +++ b/src/wrapped32/generated/wrappedgbmtypes32.h @@ -0,0 +1,19 @@ +/********************************************************************* + * File automatically generated by rebuild_wrappers_32.py (v0.0.2.2) * + *********************************************************************/ +#ifndef __wrappedgbmTYPES32_H_ +#define __wrappedgbmTYPES32_H_ + +#ifndef LIBNAME +#error You should only #include this file inside a wrapped*.c file +#endif +#ifndef ADDED_FUNCTIONS +#define ADDED_FUNCTIONS() +#endif + +typedef void (*vFppp_t)(void*, void*, void*); + +#define SUPER() ADDED_FUNCTIONS() \ + GO(gbm_bo_set_user_data, vFppp_t) + +#endif // __wrappedgbmTYPES32_H_ diff --git a/src/wrapped32/generated/wrappedgbmundefs32.h b/src/wrapped32/generated/wrappedgbmundefs32.h new file mode 100644 index 000000000..39acf4ff8 --- /dev/null +++ b/src/wrapped32/generated/wrappedgbmundefs32.h @@ -0,0 +1,8 @@ +/********************************************************************* + * File automatically generated by rebuild_wrappers_32.py (v0.0.2.2) * + *********************************************************************/ +#ifndef __wrappedgbmUNDEFS32_H_ +#define __wrappedgbmUNDEFS32_H_ + + +#endif // __wrappedgbmUNDEFS32_H_ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index b102669c9..01d889c9e 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -1189,6 +1189,7 @@ typedef void* (*pFpipc_t)(void*, int32_t, void*, int8_t); typedef void* (*pFpipi_t)(void*, int32_t, void*, int32_t); typedef void* (*pFpipp_t)(void*, int32_t, void*, void*); typedef void* (*pFpuii_t)(void*, uint32_t, int32_t, int32_t); +typedef void* (*pFpupu_t)(void*, uint32_t, void*, uint32_t); typedef void* (*pFpupp_t)(void*, uint32_t, void*, void*); typedef void* (*pEpLiS_t)(void*, uintptr_t, int32_t, void*); typedef void* (*pEpLpL_t)(void*, uintptr_t, void*, uintptr_t); @@ -1515,6 +1516,7 @@ typedef void* (*pFpippi_t)(void*, int32_t, void*, void*, int32_t); typedef void* (*pFpippp_t)(void*, int32_t, void*, void*, void*); typedef void* (*pFpuiii_t)(void*, uint32_t, int32_t, int32_t, int32_t); typedef void* (*pFpuuip_t)(void*, uint32_t, uint32_t, int32_t, void*); +typedef void* (*pFpuuuu_t)(void*, uint32_t, uint32_t, uint32_t, uint32_t); typedef void* (*pFpdddd_t)(void*, double, double, double, double); typedef void* (*pFppipi_t)(void*, void*, int32_t, void*, int32_t); typedef void* (*pFppuup_t)(void*, void*, uint32_t, uint32_t, void*); @@ -1736,6 +1738,7 @@ typedef void* (*pFpiippp_t)(void*, int32_t, int32_t, void*, void*, void*); typedef void* (*pFpipipL_t)(void*, int32_t, void*, int32_t, void*, uintptr_t); typedef void* (*pFpipipp_t)(void*, int32_t, void*, int32_t, void*, void*); typedef void* (*pFpipuii_t)(void*, int32_t, void*, uint32_t, int32_t, int32_t); +typedef void* (*pFpuuupu_t)(void*, uint32_t, uint32_t, uint32_t, void*, uint32_t); typedef void* (*XFpppppp_t)(void*, void*, void*, void*, void*, void*); typedef int32_t (*iFpupupbL__t)(void*, uint32_t, void*, uint32_t, void*, struct_L_t*); typedef int32_t (*iFpupbL_pp_t)(void*, uint32_t, void*, struct_L_t*, void*, void*); @@ -1879,6 +1882,7 @@ typedef void* (*pFEpLiiiI_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int3 typedef void* (*pEEpLiiil_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t); typedef void* (*pFEpXppip_t)(x64emu_t*, void*, void*, void*, void*, int32_t, void*); typedef void* (*pFpipiupp_t)(void*, int32_t, void*, int32_t, uint32_t, void*, void*); +typedef void* (*pFpuuupuu_t)(void*, uint32_t, uint32_t, uint32_t, void*, uint32_t, uint32_t); typedef void* (*pFppppiii_t)(void*, void*, void*, void*, int32_t, int32_t, int32_t); typedef void (*vFXLLiiibl__t)(void*, uintptr_t, uintptr_t, int32_t, int32_t, int32_t, struct_l_t*); typedef int32_t (*iFppppppbp__t)(void*, void*, void*, void*, void*, void*, struct_p_t*); @@ -1950,6 +1954,7 @@ typedef uintptr_t (*LFXLpuuLLu_t)(void*, uintptr_t, void*, uint32_t, uint32_t, u typedef void* (*pFEXpLLppp_t)(x64emu_t*, void*, void*, uintptr_t, uintptr_t, void*, void*, void*); typedef int32_t (*iFXLLiippBL__t)(void*, uintptr_t, uintptr_t, int32_t, int32_t, void*, void*, struct_L_t*); typedef int32_t (*iFXLpppbL_pp_t)(void*, uintptr_t, void*, void*, void*, struct_L_t*, void*, void*); +typedef void* (*pFpuuuuupbp__t)(void*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, void*, struct_p_t*); typedef int32_t (*iFppppubpu_Iu_t)(void*, void*, void*, void*, uint32_t, struct_pu_t*, int64_t, uint32_t); typedef int32_t (*iFpppbpu_ppuu_t)(void*, void*, void*, struct_pu_t*, void*, void*, uint32_t, uint32_t); typedef void (*vFppibLdd_ipiu_t)(void*, void*, int32_t, struct_Ldd_t*, int32_t, void*, int32_t, uint32_t); @@ -3231,6 +3236,7 @@ void pFpipc_32(x64emu_t *emu, uintptr_t fcn) { pFpipc_t fn = (pFpipc_t)fcn; R_EA void pFpipi_32(x64emu_t *emu, uintptr_t fcn) { pFpipi_t fn = (pFpipi_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16))); } void pFpipp_32(x64emu_t *emu, uintptr_t fcn) { pFpipp_t fn = (pFpipp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16))); } void pFpuii_32(x64emu_t *emu, uintptr_t fcn) { pFpuii_t fn = (pFpuii_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16))); } +void pFpupu_32(x64emu_t *emu, uintptr_t fcn) { pFpupu_t fn = (pFpupu_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16))); } void pFpupp_32(x64emu_t *emu, uintptr_t fcn) { pFpupp_t fn = (pFpupp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16))); } void pEpLiS_32(x64emu_t *emu, uintptr_t fcn) { pEpLiS_t fn = (pEpLiS_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), io_convert32(from_ptriv(R_ESP + 16)))); emu->libc_err = errno; } void pEpLpL_32(x64emu_t *emu, uintptr_t fcn) { pEpLpL_t fn = (pEpLpL_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)))); emu->libc_err = errno; } @@ -3557,6 +3563,7 @@ void pFpippi_32(x64emu_t *emu, uintptr_t fcn) { pFpippi_t fn = (pFpippi_t)fcn; R void pFpippp_32(x64emu_t *emu, uintptr_t fcn) { pFpippp_t fn = (pFpippp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20))); } void pFpuiii_32(x64emu_t *emu, uintptr_t fcn) { pFpuiii_t fn = (pFpuiii_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20))); } void pFpuuip_32(x64emu_t *emu, uintptr_t fcn) { pFpuuip_t fn = (pFpuuip_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20))); } +void pFpuuuu_32(x64emu_t *emu, uintptr_t fcn) { pFpuuuu_t fn = (pFpuuuu_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptri(uint32_t, R_ESP + 20))); } void pFpdddd_32(x64emu_t *emu, uintptr_t fcn) { pFpdddd_t fn = (pFpdddd_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(double, R_ESP + 8), from_ptri(double, R_ESP + 16), from_ptri(double, R_ESP + 24), from_ptri(double, R_ESP + 32))); } void pFppipi_32(x64emu_t *emu, uintptr_t fcn) { pFppipi_t fn = (pFppipi_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(int32_t, R_ESP + 20))); } void pFppuup_32(x64emu_t *emu, uintptr_t fcn) { pFppuup_t fn = (pFppuup_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20))); } @@ -3778,6 +3785,7 @@ void pFpiippp_32(x64emu_t *emu, uintptr_t fcn) { pFpiippp_t fn = (pFpiippp_t)fcn void pFpipipL_32(x64emu_t *emu, uintptr_t fcn) { pFpipipL_t fn = (pFpipipL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ulong(from_ptri(ulong_t, R_ESP + 24)))); } void pFpipipp_32(x64emu_t *emu, uintptr_t fcn) { pFpipipp_t fn = (pFpipipp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24))); } void pFpipuii_32(x64emu_t *emu, uintptr_t fcn) { pFpipuii_t fn = (pFpipuii_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24))); } +void pFpuuupu_32(x64emu_t *emu, uintptr_t fcn) { pFpuuupu_t fn = (pFpuuupu_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptri(uint32_t, R_ESP + 24))); } void XFpppppp_32(x64emu_t *emu, uintptr_t fcn) { XFpppppp_t fn = (XFpppppp_t)fcn; R_EAX = to_ptrv(addDisplay(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)))); } void iFpupupbL__32(x64emu_t *emu, uintptr_t fcn) { iFpupupbL__t fn = (iFpupupbL__t)fcn; struct_L_t arg_24={0}; if (*(ptr_t*)(from_ptr((R_ESP + 24)))) from_struct_L(&arg_24, *(ptr_t*)(from_ptr((R_ESP + 24)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), *(ptr_t*)(from_ptr((R_ESP + 24))) ? &arg_24 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 24)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 24))), &arg_24); } void iFpupbL_pp_32(x64emu_t *emu, uintptr_t fcn) { iFpupbL_pp_t fn = (iFpupbL_pp_t)fcn; struct_L_t arg_16={0}; if (*(ptr_t*)(from_ptr((R_ESP + 16)))) from_struct_L(&arg_16, *(ptr_t*)(from_ptr((R_ESP + 16)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12), *(ptr_t*)(from_ptr((R_ESP + 16))) ? &arg_16 : NULL, from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); if (*(ptr_t*)(from_ptr((R_ESP + 16)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 16))), &arg_16); } @@ -3921,6 +3929,7 @@ void pFEpLiiiI_32(x64emu_t *emu, uintptr_t fcn) { pFEpLiiiI_t fn = (pFEpLiiiI_t) void pEEpLiiil_32(x64emu_t *emu, uintptr_t fcn) { pEEpLiiil_t fn = (pEEpLiiil_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_long(from_ptri(long_t, R_ESP + 24)))); emu->libc_err = errno; } void pFEpXppip_32(x64emu_t *emu, uintptr_t fcn) { pFEpXppip_t fn = (pFEpXppip_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), getDisplay(from_ptriv(R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptriv(R_ESP + 24))); } void pFpipiupp_32(x64emu_t *emu, uintptr_t fcn) { pFpipiupp_t fn = (pFpipiupp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(uint32_t, R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28))); } +void pFpuuupuu_32(x64emu_t *emu, uintptr_t fcn) { pFpuuupuu_t fn = (pFpuuupuu_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptri(uint32_t, R_ESP + 28))); } void pFppppiii_32(x64emu_t *emu, uintptr_t fcn) { pFppppiii_t fn = (pFppppiii_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28))); } void vFXLLiiibl__32(x64emu_t *emu, uintptr_t fcn) { vFXLLiiibl__t fn = (vFXLLiiibl__t)fcn; struct_l_t arg_28={0}; if (*(ptr_t*)(from_ptr((R_ESP + 28)))) from_struct_l(&arg_28, *(ptr_t*)(from_ptr((R_ESP + 28)))); fn(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_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), *(ptr_t*)(from_ptr((R_ESP + 28))) ? &arg_28 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 28)))) to_struct_l(*(ptr_t*)(from_ptr((R_ESP + 28))), &arg_28); } void iFppppppbp__32(x64emu_t *emu, uintptr_t fcn) { iFppppppbp__t fn = (iFppppppbp__t)fcn; struct_p_t arg_28={0}; if (*(ptr_t*)(from_ptr((R_ESP + 28)))) from_struct_p(&arg_28, *(ptr_t*)(from_ptr((R_ESP + 28)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), *(ptr_t*)(from_ptr((R_ESP + 28))) ? &arg_28 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 28)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 28))), &arg_28); } @@ -3992,6 +4001,7 @@ void LFXLpuuLLu_32(x64emu_t *emu, uintptr_t fcn) { LFXLpuuLLu_t fn = (LFXLpuuLLu void pFEXpLLppp_32(x64emu_t *emu, uintptr_t fcn) { pFEXpLLppp_t fn = (pFEXpLLppp_t)fcn; R_EAX = to_ptrv(fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28))); } void iFXLLiippBL__32(x64emu_t *emu, uintptr_t fcn) { iFXLLiippBL__t fn = (iFXLLiippBL__t)fcn; struct_L_t arg_32={0}; R_EAX = fn(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_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28), *(ptr_t*)(from_ptr((R_ESP + 32))) ? &arg_32 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 32)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 32))), &arg_32); } void iFXLpppbL_pp_32(x64emu_t *emu, uintptr_t fcn) { iFXLpppbL_pp_t fn = (iFXLpppbL_pp_t)fcn; struct_L_t arg_24={0}; if (*(ptr_t*)(from_ptr((R_ESP + 24)))) from_struct_L(&arg_24, *(ptr_t*)(from_ptr((R_ESP + 24)))); R_EAX = fn(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), from_ptriv(R_ESP + 20), *(ptr_t*)(from_ptr((R_ESP + 24))) ? &arg_24 : NULL, from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); if (*(ptr_t*)(from_ptr((R_ESP + 24)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 24))), &arg_24); } +void pFpuuuuupbp__32(x64emu_t *emu, uintptr_t fcn) { pFpuuuuupbp__t fn = (pFpuuuuupbp__t)fcn; struct_p_t arg_32={0}; if (*(ptr_t*)(from_ptr((R_ESP + 32)))) from_struct_p(&arg_32, *(ptr_t*)(from_ptr((R_ESP + 32)))); R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptri(uint32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptriv(R_ESP + 28), *(ptr_t*)(from_ptr((R_ESP + 32))) ? &arg_32 : NULL)); if (*(ptr_t*)(from_ptr((R_ESP + 32)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 32))), &arg_32); } void iFppppubpu_Iu_32(x64emu_t *emu, uintptr_t fcn) { iFppppubpu_Iu_t fn = (iFppppubpu_Iu_t)fcn; struct_pu_t arg_24={0}; if (*(ptr_t*)(from_ptr((R_ESP + 24)))) from_struct_pu(&arg_24, *(ptr_t*)(from_ptr((R_ESP + 24)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(uint32_t, R_ESP + 20), *(ptr_t*)(from_ptr((R_ESP + 24))) ? &arg_24 : NULL, from_ptri(int64_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 36)); if (*(ptr_t*)(from_ptr((R_ESP + 24)))) to_struct_pu(*(ptr_t*)(from_ptr((R_ESP + 24))), &arg_24); } void iFpppbpu_ppuu_32(x64emu_t *emu, uintptr_t fcn) { iFpppbpu_ppuu_t fn = (iFpppbpu_ppuu_t)fcn; struct_pu_t arg_16={0}; if (*(ptr_t*)(from_ptr((R_ESP + 16)))) from_struct_pu(&arg_16, *(ptr_t*)(from_ptr((R_ESP + 16)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), *(ptr_t*)(from_ptr((R_ESP + 16))) ? &arg_16 : NULL, from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32)); if (*(ptr_t*)(from_ptr((R_ESP + 16)))) to_struct_pu(*(ptr_t*)(from_ptr((R_ESP + 16))), &arg_16); } void vFppibLdd_ipiu_32(x64emu_t *emu, uintptr_t fcn) { vFppibLdd_ipiu_t fn = (vFppibLdd_ipiu_t)fcn; struct_Ldd_t arg_16={0}; if (*(ptr_t*)(from_ptr((R_ESP + 16)))) from_struct_Ldd(&arg_16, *(ptr_t*)(from_ptr((R_ESP + 16)))); fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), *(ptr_t*)(from_ptr((R_ESP + 16))) ? &arg_16 : NULL, from_ptri(int32_t, R_ESP + 20), from_ptriv(R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32)); if (*(ptr_t*)(from_ptr((R_ESP + 16)))) to_struct_Ldd(*(ptr_t*)(from_ptr((R_ESP + 16))), &arg_16); } diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 1ea4e9351..270c4478c 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -1136,6 +1136,7 @@ void pFpipc_32(x64emu_t *emu, uintptr_t fnc); void pFpipi_32(x64emu_t *emu, uintptr_t fnc); void pFpipp_32(x64emu_t *emu, uintptr_t fnc); void pFpuii_32(x64emu_t *emu, uintptr_t fnc); +void pFpupu_32(x64emu_t *emu, uintptr_t fnc); void pFpupp_32(x64emu_t *emu, uintptr_t fnc); void pEpLiS_32(x64emu_t *emu, uintptr_t fnc); void pEpLpL_32(x64emu_t *emu, uintptr_t fnc); @@ -1462,6 +1463,7 @@ void pFpippi_32(x64emu_t *emu, uintptr_t fnc); void pFpippp_32(x64emu_t *emu, uintptr_t fnc); void pFpuiii_32(x64emu_t *emu, uintptr_t fnc); void pFpuuip_32(x64emu_t *emu, uintptr_t fnc); +void pFpuuuu_32(x64emu_t *emu, uintptr_t fnc); void pFpdddd_32(x64emu_t *emu, uintptr_t fnc); void pFppipi_32(x64emu_t *emu, uintptr_t fnc); void pFppuup_32(x64emu_t *emu, uintptr_t fnc); @@ -1683,6 +1685,7 @@ void pFpiippp_32(x64emu_t *emu, uintptr_t fnc); void pFpipipL_32(x64emu_t *emu, uintptr_t fnc); void pFpipipp_32(x64emu_t *emu, uintptr_t fnc); void pFpipuii_32(x64emu_t *emu, uintptr_t fnc); +void pFpuuupu_32(x64emu_t *emu, uintptr_t fnc); void XFpppppp_32(x64emu_t *emu, uintptr_t fnc); void iFpupupbL__32(x64emu_t *emu, uintptr_t fnc); void iFpupbL_pp_32(x64emu_t *emu, uintptr_t fnc); @@ -1826,6 +1829,7 @@ void pFEpLiiiI_32(x64emu_t *emu, uintptr_t fnc); void pEEpLiiil_32(x64emu_t *emu, uintptr_t fnc); void pFEpXppip_32(x64emu_t *emu, uintptr_t fnc); void pFpipiupp_32(x64emu_t *emu, uintptr_t fnc); +void pFpuuupuu_32(x64emu_t *emu, uintptr_t fnc); void pFppppiii_32(x64emu_t *emu, uintptr_t fnc); void vFXLLiiibl__32(x64emu_t *emu, uintptr_t fnc); void iFppppppbp__32(x64emu_t *emu, uintptr_t fnc); @@ -1897,6 +1901,7 @@ void LFXLpuuLLu_32(x64emu_t *emu, uintptr_t fnc); void pFEXpLLppp_32(x64emu_t *emu, uintptr_t fnc); void iFXLLiippBL__32(x64emu_t *emu, uintptr_t fnc); void iFXLpppbL_pp_32(x64emu_t *emu, uintptr_t fnc); +void pFpuuuuupbp__32(x64emu_t *emu, uintptr_t fnc); void iFppppubpu_Iu_32(x64emu_t *emu, uintptr_t fnc); void iFpppbpu_ppuu_32(x64emu_t *emu, uintptr_t fnc); void vFppibLdd_ipiu_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedgbm.c b/src/wrapped32/wrappedgbm.c new file mode 100644 index 000000000..f9e2fe6b4 --- /dev/null +++ b/src/wrapped32/wrappedgbm.c @@ -0,0 +1,69 @@ +#include +#include +#include +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include + +#include "wrappedlibs.h" + +#include "debug.h" +#include "wrapper32.h" +#include "bridge.h" +#include "librarian/library_private.h" +#include "x64emu.h" +#include "emu/x64emu_private.h" +#include "callback.h" +#include "librarian.h" +#include "box32context.h" +#include "emu/x64emu_private.h" +#include "myalign32.h" + +static const char* gbmName = "libgbm.so.1"; +#define LIBNAME gbm + +#define ADDED_FUNCTIONS() \ + +#include "generated/wrappedgbmtypes32.h" + +#include "wrappercallback32.h" + +// utility functions +#define SUPER() \ +GO(0) \ +GO(1) \ +GO(2) \ +GO(3) \ +GO(4) + +// destroy_user_data +#define GO(A) \ +static uintptr_t my_destroy_user_data_fct_##A = 0; \ +static void my_destroy_user_data_##A(void* a, void* b) \ +{ \ + RunFunctionFmt(my_destroy_user_data_fct_##A, "pp", a, b); \ +} +SUPER() +#undef GO +static void* find_destroy_user_data_Fct(void* fct) +{ + if(!fct) return NULL; + void* p; + if((p = GetNativeFnc((uintptr_t)fct))) return p; + #define GO(A) if(my_destroy_user_data_fct_##A == (uintptr_t)fct) return my_destroy_user_data_##A; + SUPER() + #undef GO + #define GO(A) if(my_destroy_user_data_fct_##A == 0) {my_destroy_user_data_fct_##A = (uintptr_t)fct; return my_destroy_user_data_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libgbm destroy_user_data callback\n"); + return NULL; +} + +#undef SUPER + +EXPORT void my32_gbm_bo_set_user_data(x64emu_t* emu, void* bo, void* data, void *f) +{ + my->gbm_bo_set_user_data(bo, data, find_destroy_user_data_Fct(f)); +} + +#include "wrappedlib_init32.h" diff --git a/src/wrapped32/wrappedgbm_private.h b/src/wrapped32/wrappedgbm_private.h new file mode 100644 index 000000000..2ab093c94 --- /dev/null +++ b/src/wrapped32/wrappedgbm_private.h @@ -0,0 +1,42 @@ +#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) +#error Meh... +#endif + +GO(gbm_bo_create, pFpuuuu) +GO(gbm_bo_create_with_modifiers, pFpuuupu) +GO(gbm_bo_create_with_modifiers2, pFpuuupuu) +GO(gbm_bo_destroy, vFp) +GO(gbm_bo_get_bpp, uFp) +GO(gbm_bo_get_device, pFp) +GO(gbm_bo_get_fd, iFp) +GO(gbm_bo_get_fd_for_plane, iFpi) +GO(gbm_bo_get_format, uFp) +//GOS(gbm_bo_get_handle, pFpp) +//GOS(gbm_bo_get_handle_for_plane, pFppi) +GO(gbm_bo_get_height, uFp) +GO(gbm_bo_get_modifier, UFp) +GO(gbm_bo_get_offset, uFpi) +GO(gbm_bo_get_plane_count, iFp) +GO(gbm_bo_get_stride, uFp) +GO(gbm_bo_get_stride_for_plane, uFpi) +GO(gbm_bo_get_user_data, pFp) +GO(gbm_bo_get_width, uFp) +GO(gbm_bo_import, pFpupu) +GO(gbm_bo_map, pFpuuuuupbp_) +GOM(gbm_bo_set_user_data, vFEppp) +GO(gbm_bo_unmap, vFpp) +GO(gbm_bo_write, iFppL) +GO(gbm_create_device, pFi) +GO(gbm_device_destroy, vFp) +GO(gbm_device_get_backend_name, pFp) +GO(gbm_device_get_fd, iFp) +GO(gbm_device_get_format_modifier_plane_count, iFpuU) +GO(gbm_device_is_format_supported, iFpuu) +GO(gbm_format_get_name, pFup) +GO(gbm_surface_create, pFpuuuu) +GO(gbm_surface_create_with_modifiers, pFpuuupu) +GO(gbm_surface_create_with_modifiers2, pFpuuupuu) +GO(gbm_surface_destroy, vFp) +GO(gbm_surface_has_free_buffers, iFp) +GO(gbm_surface_lock_front_buffer, pFp) +GO(gbm_surface_release_buffer, vFpp)