Skip to content

Commit

Permalink
[BOX32][WRAPPER] Added some more libX11 and libc 32bits wrapped funct…
Browse files Browse the repository at this point in the history
…ion, and empty 32bits wrapped libXfixes, libXcursor, libXrender and libXrandr
  • Loading branch information
ptitSeb committed Sep 22, 2024
1 parent 8574c57 commit 5e49e3c
Show file tree
Hide file tree
Showing 30 changed files with 541 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,10 @@ if(BOX32)
"${BOX64_ROOT}/src/wrapped32/wrappedsdl1.c"
"${BOX64_ROOT}/src/wrapped32/wrappedlibasound.c"
"${BOX64_ROOT}/src/wrapped32/wrappedlibx11.c"
"${BOX64_ROOT}/src/wrapped32/wrappedlibxfixes.c"
"${BOX64_ROOT}/src/wrapped32/wrappedlibxrender.c"
"${BOX64_ROOT}/src/wrapped32/wrappedlibxcursor.c"
"${BOX64_ROOT}/src/wrapped32/wrappedlibxrandr.c"
)
endif()
string(REPLACE ".c" "_private.h" MODROOT ${BOX64_ROOT})
Expand Down
5 changes: 5 additions & 0 deletions src/library_list_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ GO("libSDL-1.2.so.0", sdl1)
GO("libasound.so.2", libasound)
GO("libasound.so", libasound)
GO("libX11.so.6", libx11)
GO("libXfixes.so.3", libxfixes)
GO("libXrender.so.1", libxrender)
GO("libXcursor.so.1", libxcursor)
GO("libXrandr.so.2", libxrandr)
GO("libxrandr.so.2", libxrandr)

GO("crashhandler.so", crashhandler)
8 changes: 8 additions & 0 deletions src/wrapped32/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
#() pFEip -> pFEip
#() pFEpi -> pFEpi
#() pFEpp -> pFEpp
#() pFEpV -> pFEpV
#() pFipi -> pFipi
#() pFulu -> pFulu
#() pFpii -> pFpii
Expand Down Expand Up @@ -519,6 +520,7 @@
#() pFXiii -> pFXiii
#() pFXLLp -> pFXLLp
#() pFXppi -> pFXppi
#() pFXppp -> pFXppp
#() iFppbp_p -> iFppBp
#() iFBp_pui -> iFBpui
#() IFpBp_ii -> IFpBii
Expand Down Expand Up @@ -1299,6 +1301,8 @@ wrappedlibx11:
- XOpenDisplay
- iFXp:
- XNextEvent
- pFpV:
- XCreateIC
- LFXii:
- XGetPixel
- pFpiiuu:
Expand All @@ -1313,6 +1317,10 @@ wrappedlibx11:
- XGetSubImage
- LFXLiiuuuiupLp:
- XCreateWindow
wrappedlibxcursor:
wrappedlibxfixes:
wrappedlibxrandr:
wrappedlibxrender:
wrappedsdl1:
- vFv:
- SDL_Quit
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped32/generated/wrappedlibx11types32.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
typedef int32_t (*iFp_t)(void*);
typedef void* (*pFp_t)(void*);
typedef int32_t (*iFXp_t)(void*, void*);
typedef void* (*pFpV_t)(void*, ...);
typedef uintptr_t (*LFXii_t)(void*, int32_t, int32_t);
typedef void* (*pFpiiuu_t)(void*, int32_t, int32_t, uint32_t, uint32_t);
typedef void* (*pFXLiiuuLi_t)(void*, uintptr_t, int32_t, int32_t, uint32_t, uint32_t, uintptr_t, int32_t);
Expand All @@ -28,6 +29,7 @@ typedef uintptr_t (*LFXLiiuuuiupLp_t)(void*, uintptr_t, int32_t, int32_t, uint32
GO(_XInitImageFuncPtrs, iFp_t) \
GO(XOpenDisplay, pFp_t) \
GO(XNextEvent, iFXp_t) \
GO(XCreateIC, pFpV_t) \
GO(XGetPixel, LFXii_t) \
GO(XSubImage, pFpiiuu_t) \
GO(XGetImage, pFXLiiuuLi_t) \
Expand Down
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxcursordefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxcursorDEFS32_H_
#define __wrappedlibxcursorDEFS32_H_


#endif // __wrappedlibxcursorDEFS32_H_
17 changes: 17 additions & 0 deletions src/wrapped32/generated/wrappedlibxcursortypes32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxcursorTYPES32_H_
#define __wrappedlibxcursorTYPES32_H_

#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif


#define SUPER() ADDED_FUNCTIONS()

#endif // __wrappedlibxcursorTYPES32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxcursorundefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxcursorUNDEFS32_H_
#define __wrappedlibxcursorUNDEFS32_H_


#endif // __wrappedlibxcursorUNDEFS32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxfixesdefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxfixesDEFS32_H_
#define __wrappedlibxfixesDEFS32_H_


#endif // __wrappedlibxfixesDEFS32_H_
17 changes: 17 additions & 0 deletions src/wrapped32/generated/wrappedlibxfixestypes32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxfixesTYPES32_H_
#define __wrappedlibxfixesTYPES32_H_

#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif


#define SUPER() ADDED_FUNCTIONS()

#endif // __wrappedlibxfixesTYPES32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxfixesundefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxfixesUNDEFS32_H_
#define __wrappedlibxfixesUNDEFS32_H_


#endif // __wrappedlibxfixesUNDEFS32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxrandrdefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxrandrDEFS32_H_
#define __wrappedlibxrandrDEFS32_H_


#endif // __wrappedlibxrandrDEFS32_H_
17 changes: 17 additions & 0 deletions src/wrapped32/generated/wrappedlibxrandrtypes32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxrandrTYPES32_H_
#define __wrappedlibxrandrTYPES32_H_

#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif


#define SUPER() ADDED_FUNCTIONS()

#endif // __wrappedlibxrandrTYPES32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxrandrundefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxrandrUNDEFS32_H_
#define __wrappedlibxrandrUNDEFS32_H_


#endif // __wrappedlibxrandrUNDEFS32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxrenderdefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxrenderDEFS32_H_
#define __wrappedlibxrenderDEFS32_H_


#endif // __wrappedlibxrenderDEFS32_H_
17 changes: 17 additions & 0 deletions src/wrapped32/generated/wrappedlibxrendertypes32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxrenderTYPES32_H_
#define __wrappedlibxrenderTYPES32_H_

#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif


#define SUPER() ADDED_FUNCTIONS()

#endif // __wrappedlibxrenderTYPES32_H_
8 changes: 8 additions & 0 deletions src/wrapped32/generated/wrappedlibxrenderundefs32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/******************************************************************
* File automatically generated by rebuild_wrappers_32.py (v0.0.1.1) *
******************************************************************/
#ifndef __wrappedlibxrenderUNDEFS32_H_
#define __wrappedlibxrenderUNDEFS32_H_


#endif // __wrappedlibxrenderUNDEFS32_H_
4 changes: 4 additions & 0 deletions src/wrapped32/generated/wrapper32.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ typedef uintptr_t (*LFXCi_t)(void*, uint8_t, int32_t);
typedef void* (*pFEip_t)(x64emu_t*, int32_t, void*);
typedef void* (*pFEpi_t)(x64emu_t*, void*, int32_t);
typedef void* (*pFEpp_t)(x64emu_t*, void*, void*);
typedef void* (*pFEpV_t)(x64emu_t*, void*, void*);
typedef void* (*pFipi_t)(int32_t, void*, int32_t);
typedef void* (*pFulu_t)(uint32_t, intptr_t, uint32_t);
typedef void* (*pFpii_t)(void*, int32_t, int32_t);
Expand Down Expand Up @@ -608,6 +609,7 @@ typedef void* (*pFpppp_t)(void*, void*, void*, void*);
typedef void* (*pFXiii_t)(void*, int32_t, int32_t, int32_t);
typedef void* (*pFXLLp_t)(void*, uintptr_t, uintptr_t, void*);
typedef void* (*pFXppi_t)(void*, void*, void*, int32_t);
typedef void* (*pFXppp_t)(void*, void*, void*, void*);
typedef int32_t (*iFppbp_p_t)(void*, void*, struct_p_t*, void*);
typedef int32_t (*iFBp_pui_t)(struct_p_t*, void*, uint32_t, int32_t);
typedef int64_t (*IFpBp_ii_t)(void*, struct_p_t*, int32_t, int32_t);
Expand Down Expand Up @@ -1370,6 +1372,7 @@ void LFXCi_32(x64emu_t *emu, uintptr_t fcn) { LFXCi_t fn = (LFXCi_t)fcn; R_EAX =
void pFEip_32(x64emu_t *emu, uintptr_t fcn) { pFEip_t fn = (pFEip_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); }
void pFEpi_32(x64emu_t *emu, uintptr_t fcn) { pFEpi_t fn = (pFEpi_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8))); }
void pFEpp_32(x64emu_t *emu, uintptr_t fcn) { pFEpp_t fn = (pFEpp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8))); }
void pFEpV_32(x64emu_t *emu, uintptr_t fcn) { pFEpV_t fn = (pFEpV_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptrv(R_ESP + 8))); }
void pFipi_32(x64emu_t *emu, uintptr_t fcn) { pFipi_t fn = (pFipi_t)fcn; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); }
void pFulu_32(x64emu_t *emu, uintptr_t fcn) { pFulu_t fn = (pFulu_t)fcn; R_EAX = to_ptrv(fn(from_ptri(uint32_t, R_ESP + 4), to_long(from_ptri(long_t, R_ESP + 8)), from_ptri(uint32_t, R_ESP + 12))); }
void pFpii_32(x64emu_t *emu, uintptr_t fcn) { pFpii_t fn = (pFpii_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); }
Expand Down Expand Up @@ -1543,6 +1546,7 @@ void pFpppp_32(x64emu_t *emu, uintptr_t fcn) { pFpppp_t fn = (pFpppp_t)fcn; R_EA
void pFXiii_32(x64emu_t *emu, uintptr_t fcn) { pFXiii_t fn = (pFXiii_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16))); }
void pFXLLp_32(x64emu_t *emu, uintptr_t fcn) { pFXLLp_t fn = (pFXLLp_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16))); }
void pFXppi_32(x64emu_t *emu, uintptr_t fcn) { pFXppi_t fn = (pFXppi_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16))); }
void pFXppp_32(x64emu_t *emu, uintptr_t fcn) { pFXppp_t fn = (pFXppp_t)fcn; R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16))); }
void iFppbp_p_32(x64emu_t *emu, uintptr_t fcn) { iFppbp_p_t fn = (iFppbp_p_t)fcn; struct_p_t arg_12; from_struct_p(&arg_12, *(ptr_t*)(from_ptr((R_ESP + 12)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL, from_ptriv(R_ESP + 16)); if (*(ptr_t*)(from_ptr((R_ESP + 12)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 12))), &arg_12); }
void iFBp_pui_32(x64emu_t *emu, uintptr_t fcn) { iFBp_pui_t fn = (iFBp_pui_t)fcn; struct_p_t arg_4; R_EAX = fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL, from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); if (*(ptr_t*)(from_ptr((R_ESP + 4)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 4))), &arg_4); }
void IFpBp_ii_32(x64emu_t *emu, uintptr_t fcn) { IFpBp_ii_t fn = (IFpBp_ii_t)fcn; struct_p_t arg_8; ui64_t r; r.i = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); R_EAX = r.d[0]; R_EDX = r.d[1]; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped32/generated/wrapper32.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ void LFXCi_32(x64emu_t *emu, uintptr_t fnc);
void pFEip_32(x64emu_t *emu, uintptr_t fnc);
void pFEpi_32(x64emu_t *emu, uintptr_t fnc);
void pFEpp_32(x64emu_t *emu, uintptr_t fnc);
void pFEpV_32(x64emu_t *emu, uintptr_t fnc);
void pFipi_32(x64emu_t *emu, uintptr_t fnc);
void pFulu_32(x64emu_t *emu, uintptr_t fnc);
void pFpii_32(x64emu_t *emu, uintptr_t fnc);
Expand Down Expand Up @@ -560,6 +561,7 @@ void pFpppp_32(x64emu_t *emu, uintptr_t fnc);
void pFXiii_32(x64emu_t *emu, uintptr_t fnc);
void pFXLLp_32(x64emu_t *emu, uintptr_t fnc);
void pFXppi_32(x64emu_t *emu, uintptr_t fnc);
void pFXppp_32(x64emu_t *emu, uintptr_t fnc);
void iFppbp_p_32(x64emu_t *emu, uintptr_t fnc);
void iFBp_pui_32(x64emu_t *emu, uintptr_t fnc);
void IFpBp_ii_32(x64emu_t *emu, uintptr_t fnc);
Expand Down
11 changes: 1 addition & 10 deletions src/wrapped32/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,23 +688,14 @@ EXPORT int my32_printf(x64emu_t *emu, void* fmt, void* b) {
return vprintf((const char*)fmt, VARARGS_32);
}
EXPORT int my32___printf_chk(x64emu_t *emu, void* fmt, void* b) __attribute__((alias("my32_printf")));
#if 0

EXPORT int my32_vprintf(x64emu_t *emu, void* fmt, void* b) {
#ifndef NOALIGN
// need to align on arm
myStackAlign32((const char*)fmt, b, emu->scratch);
PREPARE_VALIST_32;
void* f = vprintf;
return ((iFpp_t)f)(fmt, VARARGS_32);
#else
// other platform don't need that
return vprintf(fmt, b);
#endif
return vprintf(fmt, VARARGS_32);
}
EXPORT int my32___vprintf_chk(x64emu_t *emu, void* fmt, void* b) __attribute__((alias("my32_vprintf")));

#endif
EXPORT int my32_vfprintf(x64emu_t *emu, void* F, void* fmt, void* b) {
// need to align on arm
myStackAlign32((const char*)fmt, b, emu->scratch);
Expand Down
8 changes: 4 additions & 4 deletions src/wrapped32/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ GO(endspent, vFv)
// endusershell
GOW(endutent, vFv)
// endutxent
//DATAM(environ, 4)
//DATAM(_environ, 4)
DATAM(environ, 4)
DATAM(_environ, 4)
DATAM(__environ, 4) // type B
// envz_add
// envz_entry
Expand Down Expand Up @@ -1082,7 +1082,7 @@ GO(mbstowcs, LFppL)
// _mcleanup
//GOWM(mcount, vFpp) //%%,noE
// _mcount
//GOW(memalign, pFLL)
GOW(memalign, pFLL)
//DATAV(__memalign_hook, 4)
//GOW(memccpy, pFppiL)
GO(memchr, pFpiL)
Expand Down Expand Up @@ -1893,7 +1893,7 @@ GOM(__vfprintf_chk, iFESvpp) //%%
// vhangup
// vlimit
// vmsplice
//GOM(vprintf, iFEpp) //%%
GOM(vprintf, iFEpp) //%%
//GOM(__vprintf_chk, iFEvpp) //%%
// vscanf // Weak
GOWM(vsnprintf, iFEpLpp) //%%
Expand Down
Loading

0 comments on commit 5e49e3c

Please sign in to comment.