diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-09-14 16:46:13 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-09-14 16:46:13 +0200 |
| commit | f2397256e2942500f6a7577c103bdb6fb3a98ac7 (patch) | |
| tree | dae3d5743d02cfe9219a96ec115fd75d1be40688 /src | |
| parent | e5ad7c36ecba49d39150530f792cf3be4d122df1 (diff) | |
| download | box64-f2397256e2942500f6a7577c103bdb6fb3a98ac7.tar.gz box64-f2397256e2942500f6a7577c103bdb6fb3a98ac7.zip | |
[BOX32][WRAPPER] Added more 32bits sdl1 and libc symbols
Diffstat (limited to 'src')
| -rw-r--r-- | src/include/sdl1align32.h | 50 | ||||
| -rw-r--r-- | src/libtools/sdl1align32.c | 28 | ||||
| -rw-r--r-- | src/wrapped32/generated/functions_list.txt | 24 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedlibctypes32.h | 8 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedsdl1types32.h | 12 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.c | 17 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.h | 8 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc.c | 50 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc_private.h | 19 | ||||
| -rw-r--r-- | src/wrapped32/wrappedsdl1.c | 87 | ||||
| -rw-r--r-- | src/wrapped32/wrappedsdl1_private.h | 40 |
11 files changed, 277 insertions, 66 deletions
diff --git a/src/include/sdl1align32.h b/src/include/sdl1align32.h index 3dd3aa1d..ec05f604 100644 --- a/src/include/sdl1align32.h +++ b/src/include/sdl1align32.h @@ -495,4 +495,54 @@ typedef union my_SDL_Event_32_s void convert_SDL_Event_to_32(void* dst, const void* src); +// simplified RWops +typedef struct my_SDL_RWops_s { + void* seek; //sdl1_seek + void* read; //sdl1_read + void* write; //sdl1_write + void* close; //sdl1_close + uint32_t type; + void* hidden[3]; // not converting hidden, just moving it +} my_SDL_RWops_t; + +typedef struct my_SDL_RWops_32_s { + ptr_t seek; //sdl1_seek + ptr_t read; //sdl1_read + ptr_t write; //sdl1_write + ptr_t close; //sdl1_close + uint32_t type; + void* hidden[3]; // not converting hidden, just moving it +} my_SDL_RWops_32_t; + +void inplace_SDL_RWops_to_64(void* a); +void inplace_SDL_RWops_to_32(void* a); + +typedef struct my_SDL_VideoInfo_s { + uint32_t hw_available:1; + uint32_t wm_available:1; + uint32_t blit_hw:1; + uint32_t blit_hw_CC:1; + uint32_t blit_hw_A:1; + uint32_t blit_sw:1; + uint32_t blit_sw_CC:1; + uint32_t blit_sw_A:1; + uint32_t blit_fill; + uint32_t video_mem; + my_SDL_PixelFormat_t *vfmt; +} my_SDL_VideoInfo_t; + +typedef struct my_SDL_VideoInfo_32_s { + uint32_t hw_available:1; + uint32_t wm_available:1; + uint32_t blit_hw:1; + uint32_t blit_hw_CC:1; + uint32_t blit_hw_A:1; + uint32_t blit_sw:1; + uint32_t blit_sw_CC:1; + uint32_t blit_sw_A:1; + uint32_t blit_fill; + uint32_t video_mem; + ptr_t vfmt; // my_SDL_PixelFormat_t * +} my_SDL_VideoInfo_32_t; + #endif//__MY_SDL1ALIGN32_H_ \ No newline at end of file diff --git a/src/libtools/sdl1align32.c b/src/libtools/sdl1align32.c index d1d28e28..8fd2cddc 100644 --- a/src/libtools/sdl1align32.c +++ b/src/libtools/sdl1align32.c @@ -162,4 +162,30 @@ void convert_SDL_Event_to_32(void* dst_, const void* src_) printf_log(LOG_INFO, "Warning, unsuported SDL1.2 event %d\n", src->type); memcpy(dst, src, sizeof(my_SDL_Event_32_t)); } -} \ No newline at end of file +} + +void inplace_SDL_RWops_to_64(void* a) +{ + if(!a) return; + my_SDL_RWops_32_t* src = a; + my_SDL_RWops_t* dst = a; + memmove(&dst->hidden, &src->hidden, sizeof(dst->hidden)); + dst->type = src->type; + dst->close = from_ptrv(src->close); + dst->write = from_ptrv(src->write); + dst->read = from_ptrv(src->read); + dst->seek = from_ptrv(src->seek); + +} +void inplace_SDL_RWops_to_32(void* a) +{ + if(!a) return; + my_SDL_RWops_t* src = a; + my_SDL_RWops_32_t* dst = a; + dst->seek = to_ptrv(src->seek); + dst->read = to_ptrv(src->read); + dst->write = to_ptrv(src->write); + dst->close = to_ptrv(src->close); + dst->type = src->type; + memmove(&dst->hidden, &src->hidden, sizeof(dst->hidden)); +} diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 1d5bfd38..056141ea 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -26,6 +26,7 @@ #() IFd -> IFd #() IFp -> IFp #() IFS -> IFS +#() CFv -> CFv #() CFu -> CFu #() CFU -> CFU #() CFl -> CFl @@ -62,6 +63,7 @@ #() LFrL_ -> LFB #() pFrL_ -> pFB #() LFriiiiiiiiilt_ -> LFB +#() pFriiiiiiiiilt_ -> pFB #() vFEv -> vFEv #() vFEp -> vFEp #() vFcc -> vFcc @@ -94,6 +96,7 @@ #() vFlu -> vFlu #() vFlp -> vFlp #() vFpp -> vFpp +#() vFSp -> vFSp #() wFpi -> wFpi #() iFEv -> iFEv #() iFEi -> iFEi @@ -122,6 +125,7 @@ #() iFhh -> iFhh #() IFII -> IFII #() CFip -> CFip +#() CFCi -> CFCi #() CFuu -> CFuu #() CFuU -> CFuU #() CFpi -> CFpi @@ -146,6 +150,7 @@ #() dFdd -> dFdd #() dFdD -> dFdD #() dFdp -> dFdp +#() dFLL -> dFLL #() lFui -> lFui #() LFpL -> LFpL #() LFpp -> LFpp @@ -423,6 +428,7 @@ #() iFEhup -> iFEhup #() iFESpp -> iFESpp #() iFESpV -> iFESpV +#() iFiiiu -> iFiiiu #() iFiiip -> iFiiip #() iFiiiN -> iFiiiN #() iFiill -> iFiill @@ -549,6 +555,7 @@ #() vFupupp -> vFupupp #() vFuplii -> vFuplii #() vFuppip -> vFuppip +#() vFupppp -> vFupppp #() vFfffff -> vFfffff #() vFluipp -> vFluipp #() vFpilpp -> vFpilpp @@ -654,7 +661,6 @@ #() vFdddddd -> vFdddddd #() vFppiiii -> vFppiiii #() vFppupii -> vFppupii -#() iFEpLppp -> iFEpLppp #() iFpiiipp -> iFpiiipp #() iFpiippp -> iFpiippp #() iFppiiii -> iFppiiii @@ -924,6 +930,9 @@ wrappedlibc: - iFiiN: - iFipp: - iFpLi: +- iFppi: + - wcstol + - wcstoul - iFppL: - iFppp: - vswscanf @@ -963,13 +972,14 @@ wrappedlibc: - iFSvpV: - LFppiv: - iFpvvpV: -- iFpLppp: - pFpLLiN: - iFpLvvpp: - iFpLiipV: - pFpLiiii: - pFpLiiiI: - iFpippppp: +- pFiiiiiiiiilt: + - asctime wrappedlibdl: - iFp: - dlclose @@ -1192,13 +1202,23 @@ wrappedsdl1: - SDL_Flip - SDL_LockSurface - SDL_PollEvent +- pFv: + - SDL_GetVideoInfo + - SDL_GetVideoSurface - pFp: - SDL_GL_GetProcAddress - SDL_LoadObject +- vFpp: + - SDL_WM_SetIcon - iFpp: - SDL_OpenAudio +- pFpi: + - SDL_LoadBMP_RW - pFpp: - SDL_CreateThread - SDL_LoadFunction + - SDL_RWFromFile - pFiiiu: - SDL_SetVideoMode +- vFupppp: + - SDL_GetRGB diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h index 1301852f..a61653ef 100644 --- a/src/wrapped32/generated/wrappedlibctypes32.h +++ b/src/wrapped32/generated/wrappedlibctypes32.h @@ -52,6 +52,7 @@ typedef int32_t (*iFiip_t)(int32_t, int32_t, void*); typedef int32_t (*iFiiN_t)(int32_t, int32_t, ...); typedef int32_t (*iFipp_t)(int32_t, void*, void*); typedef int32_t (*iFpLi_t)(void*, uintptr_t, int32_t); +typedef int32_t (*iFppi_t)(void*, void*, int32_t); typedef int32_t (*iFppL_t)(void*, void*, uintptr_t); typedef int32_t (*iFppp_t)(void*, void*, void*); typedef int32_t (*iFppV_t)(void*, void*, ...); @@ -81,13 +82,13 @@ typedef int32_t (*iFSvpp_t)(void*, void, void*, void*); typedef int32_t (*iFSvpV_t)(void*, void, void*, ...); typedef uintptr_t (*LFppiv_t)(void*, void*, int32_t, void); typedef int32_t (*iFpvvpV_t)(void*, void, void, void*, ...); -typedef int32_t (*iFpLppp_t)(void*, uintptr_t, void*, void*, void*); typedef void* (*pFpLLiN_t)(void*, uintptr_t, uintptr_t, int32_t, ...); typedef int32_t (*iFpLvvpp_t)(void*, uintptr_t, void, void, void*, void*); typedef int32_t (*iFpLiipV_t)(void*, uintptr_t, int32_t, int32_t, void*, ...); typedef void* (*pFpLiiii_t)(void*, uintptr_t, int32_t, int32_t, int32_t, int32_t); typedef void* (*pFpLiiiI_t)(void*, uintptr_t, int32_t, int32_t, int32_t, int64_t); typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void*); +typedef void* (*pFiiiiiiiiilt_t)(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, intptr_t, char*); #define SUPER() ADDED_FUNCTIONS() \ GO(freeaddrinfo, vFp_t) \ @@ -121,6 +122,8 @@ typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void* GO(gmtime_r, pFpp_t) \ GO(localtime_r, pFpp_t) \ GO(_ITM_addUserCommitAction, vFpup_t) \ + GO(wcstol, iFppi_t) \ + GO(wcstoul, iFppi_t) \ GO(vswscanf, iFppp_t) \ GO(swscanf, iFppV_t) \ GO(fscanf, iFSpV_t) \ @@ -130,6 +133,7 @@ typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void* GO(sendmsg, lFipi_t) \ GO(__realpath_chk, pFppv_t) \ GO(__libc_init, vFpppp_t) \ - GO(getaddrinfo, iFpppp_t) + GO(getaddrinfo, iFpppp_t) \ + GO(asctime, pFiiiiiiiiilt_t) #endif // __wrappedlibcTYPES32_H_ diff --git a/src/wrapped32/generated/wrappedsdl1types32.h b/src/wrapped32/generated/wrappedsdl1types32.h index 411e0fda..ad3f83ab 100644 --- a/src/wrapped32/generated/wrappedsdl1types32.h +++ b/src/wrapped32/generated/wrappedsdl1types32.h @@ -15,10 +15,14 @@ typedef void (*vFv_t)(void); typedef void (*vFp_t)(void*); typedef int32_t (*iFv_t)(void); typedef int32_t (*iFp_t)(void*); +typedef void* (*pFv_t)(void); typedef void* (*pFp_t)(void*); +typedef void (*vFpp_t)(void*, void*); typedef int32_t (*iFpp_t)(void*, void*); +typedef void* (*pFpi_t)(void*, int32_t); typedef void* (*pFpp_t)(void*, void*); typedef void* (*pFiiiu_t)(int32_t, int32_t, int32_t, uint32_t); +typedef void (*vFupppp_t)(uint32_t, void*, void*, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ GO(SDL_Quit, vFv_t) \ @@ -35,11 +39,17 @@ typedef void* (*pFiiiu_t)(int32_t, int32_t, int32_t, uint32_t); GO(SDL_Flip, iFp_t) \ GO(SDL_LockSurface, iFp_t) \ GO(SDL_PollEvent, iFp_t) \ + GO(SDL_GetVideoInfo, pFv_t) \ + GO(SDL_GetVideoSurface, pFv_t) \ GO(SDL_GL_GetProcAddress, pFp_t) \ GO(SDL_LoadObject, pFp_t) \ + GO(SDL_WM_SetIcon, vFpp_t) \ GO(SDL_OpenAudio, iFpp_t) \ + GO(SDL_LoadBMP_RW, pFpi_t) \ GO(SDL_CreateThread, pFpp_t) \ GO(SDL_LoadFunction, pFpp_t) \ - GO(SDL_SetVideoMode, pFiiiu_t) + GO(SDL_RWFromFile, pFpp_t) \ + GO(SDL_SetVideoMode, pFiiiu_t) \ + GO(SDL_GetRGB, vFupppp_t) #endif // __wrappedsdl1TYPES32_H_ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index fdb0fdcc..91efdd8e 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -113,6 +113,7 @@ typedef int64_t (*IFf_t)(float); typedef int64_t (*IFd_t)(double); typedef int64_t (*IFp_t)(void*); typedef int64_t (*IFS_t)(void*); +typedef uint8_t (*CFv_t)(void); typedef uint8_t (*CFu_t)(uint32_t); typedef uint8_t (*CFU_t)(uint64_t); typedef uint8_t (*CFl_t)(intptr_t); @@ -149,6 +150,7 @@ typedef char* (*tFp_t)(void*); typedef uintptr_t (*LFrL__t)(struct_L_t*); typedef void* (*pFrL__t)(struct_L_t*); typedef uintptr_t (*LFriiiiiiiiilt__t)(struct_iiiiiiiiilt_t*); +typedef void* (*pFriiiiiiiiilt__t)(struct_iiiiiiiiilt_t*); typedef void (*vFEv_t)(x64emu_t*); typedef void (*vFEp_t)(x64emu_t*, void*); typedef void (*vFcc_t)(int8_t, int8_t); @@ -181,6 +183,7 @@ typedef void (*vFdd_t)(double, double); typedef void (*vFlu_t)(intptr_t, uint32_t); typedef void (*vFlp_t)(intptr_t, void*); typedef void (*vFpp_t)(void*, void*); +typedef void (*vFSp_t)(void*, void*); typedef int16_t (*wFpi_t)(void*, int32_t); typedef int32_t (*iFEv_t)(x64emu_t*); typedef int32_t (*iFEi_t)(x64emu_t*, int32_t); @@ -209,6 +212,7 @@ typedef int32_t (*iFhp_t)(uintptr_t, void*); typedef int32_t (*iFhh_t)(uintptr_t, uintptr_t); typedef int64_t (*IFII_t)(int64_t, int64_t); typedef uint8_t (*CFip_t)(int32_t, void*); +typedef uint8_t (*CFCi_t)(uint8_t, int32_t); typedef uint8_t (*CFuu_t)(uint32_t, uint32_t); typedef uint8_t (*CFuU_t)(uint32_t, uint64_t); typedef uint8_t (*CFpi_t)(void*, int32_t); @@ -233,6 +237,7 @@ typedef double (*dFdi_t)(double, int32_t); typedef double (*dFdd_t)(double, double); typedef double (*dFdD_t)(double, long double); typedef double (*dFdp_t)(double, void*); +typedef double (*dFLL_t)(uintptr_t, uintptr_t); typedef intptr_t (*lFui_t)(uint32_t, int32_t); typedef uintptr_t (*LFpL_t)(void*, uintptr_t); typedef uintptr_t (*LFpp_t)(void*, void*); @@ -510,6 +515,7 @@ typedef int32_t (*iFEpOu_t)(x64emu_t*, void*, int32_t, uint32_t); typedef int32_t (*iFEhup_t)(x64emu_t*, uintptr_t, uint32_t, void*); typedef int32_t (*iFESpp_t)(x64emu_t*, void*, void*, void*); typedef int32_t (*iFESpV_t)(x64emu_t*, void*, void*, void*); +typedef int32_t (*iFiiiu_t)(int32_t, int32_t, int32_t, uint32_t); typedef int32_t (*iFiiip_t)(int32_t, int32_t, int32_t, void*); typedef int32_t (*iFiiiN_t)(int32_t, int32_t, int32_t, ...); typedef int32_t (*iFiill_t)(int32_t, int32_t, intptr_t, intptr_t); @@ -636,6 +642,7 @@ typedef void (*vFupupi_t)(uint32_t, void*, uint32_t, void*, int32_t); typedef void (*vFupupp_t)(uint32_t, void*, uint32_t, void*, void*); typedef void (*vFuplii_t)(uint32_t, void*, intptr_t, int32_t, int32_t); typedef void (*vFuppip_t)(uint32_t, void*, void*, int32_t, void*); +typedef void (*vFupppp_t)(uint32_t, void*, void*, void*, void*); typedef void (*vFfffff_t)(float, float, float, float, float); typedef void (*vFluipp_t)(intptr_t, uint32_t, int32_t, void*, void*); typedef void (*vFpilpp_t)(void*, int32_t, intptr_t, void*, void*); @@ -741,7 +748,6 @@ typedef void (*vFffffff_t)(float, float, float, float, float, float); typedef void (*vFdddddd_t)(double, double, double, double, double, double); typedef void (*vFppiiii_t)(void*, void*, int32_t, int32_t, int32_t, int32_t); typedef void (*vFppupii_t)(void*, void*, uint32_t, void*, int32_t, int32_t); -typedef int32_t (*iFEpLppp_t)(x64emu_t*, void*, uintptr_t, void*, void*, void*); typedef int32_t (*iFpiiipp_t)(void*, int32_t, int32_t, int32_t, void*, void*); typedef int32_t (*iFpiippp_t)(void*, int32_t, int32_t, void*, void*, void*); typedef int32_t (*iFppiiii_t)(void*, void*, int32_t, int32_t, int32_t, int32_t); @@ -961,6 +967,7 @@ void IFf_32(x64emu_t *emu, uintptr_t fcn) { IFf_t fn = (IFf_t)fcn; ui64_t r; r.i void IFd_32(x64emu_t *emu, uintptr_t fcn) { IFd_t fn = (IFd_t)fcn; ui64_t r; r.i = fn(from_ptri(double, R_ESP + 4)); R_EAX = r.d[0]; R_EDX = r.d[1]; } void IFp_32(x64emu_t *emu, uintptr_t fcn) { IFp_t fn = (IFp_t)fcn; ui64_t r; r.i = fn(from_ptriv(R_ESP + 4)); R_EAX = r.d[0]; R_EDX = r.d[1]; } void IFS_32(x64emu_t *emu, uintptr_t fcn) { IFS_t fn = (IFS_t)fcn; ui64_t r; r.i = fn(io_convert32(from_ptriv(R_ESP + 4))); R_EAX = r.d[0]; R_EDX = r.d[1]; } +void CFv_32(x64emu_t *emu, uintptr_t fcn) { CFv_t fn = (CFv_t)fcn; R_EAX = (unsigned char)fn(); } void CFu_32(x64emu_t *emu, uintptr_t fcn) { CFu_t fn = (CFu_t)fcn; R_EAX = (unsigned char)fn(from_ptri(uint32_t, R_ESP + 4)); } void CFU_32(x64emu_t *emu, uintptr_t fcn) { CFU_t fn = (CFU_t)fcn; R_EAX = (unsigned char)fn(from_ptri(uint64_t, R_ESP + 4)); } void CFl_32(x64emu_t *emu, uintptr_t fcn) { CFl_t fn = (CFl_t)fcn; R_EAX = (unsigned char)fn(to_long(from_ptri(long_t, R_ESP + 4))); } @@ -997,6 +1004,7 @@ void tFp_32(x64emu_t *emu, uintptr_t fcn) { tFp_t fn = (tFp_t)fcn; R_EAX = to_cs void LFrL__32(x64emu_t *emu, uintptr_t fcn) { LFrL__t fn = (LFrL__t)fcn; struct_L_t arg_4; from_struct_L(&arg_4, *(ptr_t*)(from_ptr((R_ESP + 4)))); R_EAX = to_ulong(fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL)); } void pFrL__32(x64emu_t *emu, uintptr_t fcn) { pFrL__t fn = (pFrL__t)fcn; struct_L_t arg_4; from_struct_L(&arg_4, *(ptr_t*)(from_ptr((R_ESP + 4)))); R_EAX = to_ptrv(fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL)); } void LFriiiiiiiiilt__32(x64emu_t *emu, uintptr_t fcn) { LFriiiiiiiiilt__t fn = (LFriiiiiiiiilt__t)fcn; struct_iiiiiiiiilt_t arg_4; from_struct_iiiiiiiiilt(&arg_4, *(ptr_t*)(from_ptr((R_ESP + 4)))); R_EAX = to_ulong(fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL)); } +void pFriiiiiiiiilt__32(x64emu_t *emu, uintptr_t fcn) { pFriiiiiiiiilt__t fn = (pFriiiiiiiiilt__t)fcn; struct_iiiiiiiiilt_t arg_4; from_struct_iiiiiiiiilt(&arg_4, *(ptr_t*)(from_ptr((R_ESP + 4)))); R_EAX = to_ptrv(fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL)); } void vFEv_32(x64emu_t *emu, uintptr_t fcn) { vFEv_t fn = (vFEv_t)fcn; fn(emu); } void vFEp_32(x64emu_t *emu, uintptr_t fcn) { vFEp_t fn = (vFEp_t)fcn; fn(emu, from_ptriv(R_ESP + 4)); } void vFcc_32(x64emu_t *emu, uintptr_t fcn) { vFcc_t fn = (vFcc_t)fcn; fn(from_ptri(int8_t, R_ESP + 4), from_ptri(int8_t, R_ESP + 8)); } @@ -1029,6 +1037,7 @@ void vFdd_32(x64emu_t *emu, uintptr_t fcn) { vFdd_t fn = (vFdd_t)fcn; fn(from_pt void vFlu_32(x64emu_t *emu, uintptr_t fcn) { vFlu_t fn = (vFlu_t)fcn; fn(to_long(from_ptri(long_t, R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8)); } void vFlp_32(x64emu_t *emu, uintptr_t fcn) { vFlp_t fn = (vFlp_t)fcn; fn(to_long(from_ptri(long_t, R_ESP + 4)), from_ptriv(R_ESP + 8)); } void vFpp_32(x64emu_t *emu, uintptr_t fcn) { vFpp_t fn = (vFpp_t)fcn; fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8)); } +void vFSp_32(x64emu_t *emu, uintptr_t fcn) { vFSp_t fn = (vFSp_t)fcn; fn(io_convert32(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8)); } void wFpi_32(x64emu_t *emu, uintptr_t fcn) { wFpi_t fn = (wFpi_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); } void iFEv_32(x64emu_t *emu, uintptr_t fcn) { iFEv_t fn = (iFEv_t)fcn; R_EAX = fn(emu); } void iFEi_32(x64emu_t *emu, uintptr_t fcn) { iFEi_t fn = (iFEi_t)fcn; R_EAX = fn(emu, from_ptri(int32_t, R_ESP + 4)); } @@ -1057,6 +1066,7 @@ void iFhp_32(x64emu_t *emu, uintptr_t fcn) { iFhp_t fn = (iFhp_t)fcn; R_EAX = fn void iFhh_32(x64emu_t *emu, uintptr_t fcn) { iFhh_t fn = (iFhh_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_hash(from_ptri(ptr_t, R_ESP + 8))); } void IFII_32(x64emu_t *emu, uintptr_t fcn) { IFII_t fn = (IFII_t)fcn; ui64_t r; r.i = fn(from_ptri(int64_t, R_ESP + 4), from_ptri(int64_t, R_ESP + 12)); R_EAX = r.d[0]; R_EDX = r.d[1]; } void CFip_32(x64emu_t *emu, uintptr_t fcn) { CFip_t fn = (CFip_t)fcn; R_EAX = (unsigned char)fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8)); } +void CFCi_32(x64emu_t *emu, uintptr_t fcn) { CFCi_t fn = (CFCi_t)fcn; R_EAX = (unsigned char)fn(from_ptri(uint8_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); } void CFuu_32(x64emu_t *emu, uintptr_t fcn) { CFuu_t fn = (CFuu_t)fcn; R_EAX = (unsigned char)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8)); } void CFuU_32(x64emu_t *emu, uintptr_t fcn) { CFuU_t fn = (CFuU_t)fcn; R_EAX = (unsigned char)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint64_t, R_ESP + 8)); } void CFpi_32(x64emu_t *emu, uintptr_t fcn) { CFpi_t fn = (CFpi_t)fcn; R_EAX = (unsigned char)fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); } @@ -1081,6 +1091,7 @@ void dFdi_32(x64emu_t *emu, uintptr_t fcn) { dFdi_t fn = (dFdi_t)fcn; double db void dFdd_32(x64emu_t *emu, uintptr_t fcn) { dFdd_t fn = (dFdd_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12)); fpu_do_push(emu); ST0val = db; } void dFdD_32(x64emu_t *emu, uintptr_t fcn) { dFdD_t fn = (dFdD_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), LD2localLD(from_ptrv(R_ESP + 12))); fpu_do_push(emu); ST0val = db; } void dFdp_32(x64emu_t *emu, uintptr_t fcn) { dFdp_t fn = (dFdp_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), from_ptriv(R_ESP + 12)); fpu_do_push(emu); ST0val = db; } +void dFLL_32(x64emu_t *emu, uintptr_t fcn) { dFLL_t fn = (dFLL_t)fcn; double db = fn(to_ulong(from_ptri(ulong_t, R_ESP + 4)), to_ulong(from_ptri(ulong_t, R_ESP + 8))); fpu_do_push(emu); ST0val = db; } void lFui_32(x64emu_t *emu, uintptr_t fcn) { lFui_t fn = (lFui_t)fcn; R_EAX = to_long(fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8))); } void LFpL_32(x64emu_t *emu, uintptr_t fcn) { LFpL_t fn = (LFpL_t)fcn; R_EAX = to_ulong(fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)))); } void LFpp_32(x64emu_t *emu, uintptr_t fcn) { LFpp_t fn = (LFpp_t)fcn; R_EAX = to_ulong(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8))); } @@ -1358,6 +1369,7 @@ void iFEpOu_32(x64emu_t *emu, uintptr_t fcn) { iFEpOu_t fn = (iFEpOu_t)fcn; R_EA void iFEhup_32(x64emu_t *emu, uintptr_t fcn) { iFEhup_t fn = (iFEhup_t)fcn; R_EAX = fn(emu, from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); } void iFESpp_32(x64emu_t *emu, uintptr_t fcn) { iFESpp_t fn = (iFESpp_t)fcn; R_EAX = fn(emu, io_convert32(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); } void iFESpV_32(x64emu_t *emu, uintptr_t fcn) { iFESpV_t fn = (iFESpV_t)fcn; R_EAX = fn(emu, io_convert32(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptrv(R_ESP + 12)); } +void iFiiiu_32(x64emu_t *emu, uintptr_t fcn) { iFiiiu_t fn = (iFiiiu_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16)); } void iFiiip_32(x64emu_t *emu, uintptr_t fcn) { iFiiip_t fn = (iFiiip_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16)); } void iFiiiN_32(x64emu_t *emu, uintptr_t fcn) { iFiiiN_t fn = (iFiiiN_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16)); } void iFiill_32(x64emu_t *emu, uintptr_t fcn) { iFiill_t fn = (iFiill_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), to_long(from_ptri(long_t, R_ESP + 12)), to_long(from_ptri(long_t, R_ESP + 16))); } @@ -1484,6 +1496,7 @@ void vFupupi_32(x64emu_t *emu, uintptr_t fcn) { vFupupi_t fn = (vFupupi_t)fcn; f void vFupupp_32(x64emu_t *emu, uintptr_t fcn) { vFupupp_t fn = (vFupupp_t)fcn; fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } void vFuplii_32(x64emu_t *emu, uintptr_t fcn) { vFuplii_t fn = (vFuplii_t)fcn; fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), to_long(from_ptri(long_t, R_ESP + 12)), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20)); } void vFuppip_32(x64emu_t *emu, uintptr_t fcn) { vFuppip_t fn = (vFuppip_t)fcn; fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20)); } +void vFupppp_32(x64emu_t *emu, uintptr_t fcn) { vFupppp_t fn = (vFupppp_t)fcn; fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } void vFfffff_32(x64emu_t *emu, uintptr_t fcn) { vFfffff_t fn = (vFfffff_t)fcn; fn(from_ptri(float, R_ESP + 4), from_ptri(float, R_ESP + 8), from_ptri(float, R_ESP + 12), from_ptri(float, R_ESP + 16), from_ptri(float, R_ESP + 20)); } void vFluipp_32(x64emu_t *emu, uintptr_t fcn) { vFluipp_t fn = (vFluipp_t)fcn; fn(to_long(from_ptri(long_t, R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } void vFpilpp_32(x64emu_t *emu, uintptr_t fcn) { vFpilpp_t fn = (vFpilpp_t)fcn; fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), to_long(from_ptri(long_t, R_ESP + 12)), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } @@ -1589,7 +1602,6 @@ void vFffffff_32(x64emu_t *emu, uintptr_t fcn) { vFffffff_t fn = (vFffffff_t)fcn void vFdddddd_32(x64emu_t *emu, uintptr_t fcn) { vFdddddd_t fn = (vFdddddd_t)fcn; fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptri(double, R_ESP + 20), from_ptri(double, R_ESP + 28), from_ptri(double, R_ESP + 36), from_ptri(double, R_ESP + 44)); } void vFppiiii_32(x64emu_t *emu, uintptr_t fcn) { vFppiiii_t fn = (vFppiiii_t)fcn; fn(from_ptriv(R_ESP + 4), from_ptriv(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_ptri(int32_t, R_ESP + 24)); } void vFppupii_32(x64emu_t *emu, uintptr_t fcn) { vFppupii_t fn = (vFppupii_t)fcn; fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24)); } -void iFEpLppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpLppp_t fn = (iFEpLppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } void iFpiiipp_32(x64emu_t *emu, uintptr_t fcn) { iFpiiipp_t fn = (iFpiiipp_t)fcn; R_EAX = fn(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), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); } void iFpiippp_32(x64emu_t *emu, uintptr_t fcn) { iFpiippp_t fn = (iFpiippp_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); } void iFppiiii_32(x64emu_t *emu, uintptr_t fcn) { iFppiiii_t fn = (iFppiiii_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(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_ptri(int32_t, R_ESP + 24)); } @@ -1806,6 +1818,7 @@ int isRetX87Wrapper32(wrapper_t fun) { if (fun == &dFdd_32) return 1; if (fun == &dFdD_32) return 1; if (fun == &dFdp_32) return 1; + if (fun == &dFLL_32) return 1; if (fun == &fFpBp__32) return 1; if (fun == &dFpBp__32) return 1; if (fun == &fFuii_32) return 1; diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index c28315f2..a533aa6e 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -66,6 +66,7 @@ void IFf_32(x64emu_t *emu, uintptr_t fnc); void IFd_32(x64emu_t *emu, uintptr_t fnc); void IFp_32(x64emu_t *emu, uintptr_t fnc); void IFS_32(x64emu_t *emu, uintptr_t fnc); +void CFv_32(x64emu_t *emu, uintptr_t fnc); void CFu_32(x64emu_t *emu, uintptr_t fnc); void CFU_32(x64emu_t *emu, uintptr_t fnc); void CFl_32(x64emu_t *emu, uintptr_t fnc); @@ -102,6 +103,7 @@ void tFp_32(x64emu_t *emu, uintptr_t fnc); void LFrL__32(x64emu_t *emu, uintptr_t fnc); void pFrL__32(x64emu_t *emu, uintptr_t fnc); void LFriiiiiiiiilt__32(x64emu_t *emu, uintptr_t fnc); +void pFriiiiiiiiilt__32(x64emu_t *emu, uintptr_t fnc); void vFEv_32(x64emu_t *emu, uintptr_t fnc); void vFEp_32(x64emu_t *emu, uintptr_t fnc); void vFcc_32(x64emu_t *emu, uintptr_t fnc); @@ -134,6 +136,7 @@ void vFdd_32(x64emu_t *emu, uintptr_t fnc); void vFlu_32(x64emu_t *emu, uintptr_t fnc); void vFlp_32(x64emu_t *emu, uintptr_t fnc); void vFpp_32(x64emu_t *emu, uintptr_t fnc); +void vFSp_32(x64emu_t *emu, uintptr_t fnc); void wFpi_32(x64emu_t *emu, uintptr_t fnc); void iFEv_32(x64emu_t *emu, uintptr_t fnc); void iFEi_32(x64emu_t *emu, uintptr_t fnc); @@ -162,6 +165,7 @@ void iFhp_32(x64emu_t *emu, uintptr_t fnc); void iFhh_32(x64emu_t *emu, uintptr_t fnc); void IFII_32(x64emu_t *emu, uintptr_t fnc); void CFip_32(x64emu_t *emu, uintptr_t fnc); +void CFCi_32(x64emu_t *emu, uintptr_t fnc); void CFuu_32(x64emu_t *emu, uintptr_t fnc); void CFuU_32(x64emu_t *emu, uintptr_t fnc); void CFpi_32(x64emu_t *emu, uintptr_t fnc); @@ -186,6 +190,7 @@ void dFdi_32(x64emu_t *emu, uintptr_t fnc); void dFdd_32(x64emu_t *emu, uintptr_t fnc); void dFdD_32(x64emu_t *emu, uintptr_t fnc); void dFdp_32(x64emu_t *emu, uintptr_t fnc); +void dFLL_32(x64emu_t *emu, uintptr_t fnc); void lFui_32(x64emu_t *emu, uintptr_t fnc); void LFpL_32(x64emu_t *emu, uintptr_t fnc); void LFpp_32(x64emu_t *emu, uintptr_t fnc); @@ -463,6 +468,7 @@ void iFEpOu_32(x64emu_t *emu, uintptr_t fnc); void iFEhup_32(x64emu_t *emu, uintptr_t fnc); void iFESpp_32(x64emu_t *emu, uintptr_t fnc); void iFESpV_32(x64emu_t *emu, uintptr_t fnc); +void iFiiiu_32(x64emu_t *emu, uintptr_t fnc); void iFiiip_32(x64emu_t *emu, uintptr_t fnc); void iFiiiN_32(x64emu_t *emu, uintptr_t fnc); void iFiill_32(x64emu_t *emu, uintptr_t fnc); @@ -589,6 +595,7 @@ void vFupupi_32(x64emu_t *emu, uintptr_t fnc); void vFupupp_32(x64emu_t *emu, uintptr_t fnc); void vFuplii_32(x64emu_t *emu, uintptr_t fnc); void vFuppip_32(x64emu_t *emu, uintptr_t fnc); +void vFupppp_32(x64emu_t *emu, uintptr_t fnc); void vFfffff_32(x64emu_t *emu, uintptr_t fnc); void vFluipp_32(x64emu_t *emu, uintptr_t fnc); void vFpilpp_32(x64emu_t *emu, uintptr_t fnc); @@ -694,7 +701,6 @@ void vFffffff_32(x64emu_t *emu, uintptr_t fnc); void vFdddddd_32(x64emu_t *emu, uintptr_t fnc); void vFppiiii_32(x64emu_t *emu, uintptr_t fnc); void vFppupii_32(x64emu_t *emu, uintptr_t fnc); -void iFEpLppp_32(x64emu_t *emu, uintptr_t fnc); void iFpiiipp_32(x64emu_t *emu, uintptr_t fnc); void iFpiippp_32(x64emu_t *emu, uintptr_t fnc); void iFppiiii_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c index 459c1fd4..e4b1ed82 100755 --- a/src/wrapped32/wrappedlibc.c +++ b/src/wrapped32/wrappedlibc.c @@ -728,19 +728,13 @@ EXPORT int my32_fprintf(x64emu_t *emu, void* F, void* fmt, void* V) { return vfprintf(F, fmt, VARARGS_32); } EXPORT int my32___fprintf_chk(x64emu_t *emu, void* F, void* fmt, void* V) __attribute__((alias("my32_fprintf"))); -#if 0 EXPORT int my32_wprintf(x64emu_t *emu, void* fmt, void* V) { - #ifndef NOALIGN // need to align on arm - myStackAlignW((const char*)fmt, V, emu->scratch); + myStackAlignW32((const char*)fmt, V, emu->scratch); PREPARE_VALIST_32; - void* f = vwprintf; - return ((iFpp_t)f)(fmt, VARARGS_32); - #else - // other platform don't need that - return vwprintf((const wchar_t*)fmt, (va_list)V); - #endif + return vwprintf(fmt, VARARGS_32); } +#if 0 EXPORT int my32___wprintf_chk(x64emu_t *emu, int flag, void* fmt, void* V) { #ifndef NOALIGN // need to align on arm @@ -923,14 +917,14 @@ EXPORT int my32___asprintf_chk(x64emu_t* emu, void* result_ptr, int flags, void* #endif } #endif -EXPORT int my32_vswprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) { +EXPORT int my32_vswprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, uint32_t * b) { // need to align on arm - myStackAlignW32((const char*)fmt, (uint32_t*)b, emu->scratch); + myStackAlignW32((const char*)fmt, b, emu->scratch); PREPARE_VALIST_32; int r = vswprintf(buff, s, fmt, VARARGS_32); return r; } -EXPORT int my32___vswprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) __attribute__((alias("my32_vswprintf"))); +EXPORT int my32___vswprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, uint32_t* b) __attribute__((alias("my32_vswprintf"))); #if 0 EXPORT int my32___vswprintf_chk(x64emu_t* emu, void* buff, size_t s, int flags, size_t m, void * fmt, void * b, va_list V) { #ifndef NOALIGN @@ -2073,6 +2067,15 @@ EXPORT void* my32_gmtime_r(x64emu_t* emu, void* t, void* res) return NULL; } +EXPORT void* my32_asctime(void* t) +{ + static char ret[200]; + char* r = asctime(t); + if(!r) return NULL; + strncpy(ret, r, sizeof(ret)-1); + return &ret; +} + #if 0 EXPORT int32_t my32_getrandom(x64emu_t* emu, void* buf, uint32_t buflen, uint32_t flags) { @@ -2922,6 +2925,29 @@ EXPORT unsigned long my32_strtoul(const char* s, char** endp, int base) return ret; } +EXPORT long my32_wcstol(const wchar_t* s, wchar_t** endp, int base) +{ + long ret = wcstol(s, endp, base); + if (ret<INT_MIN) { + ret = INT_MIN; + errno = ERANGE; + } else if(ret>INT_MAX) { + ret = INT_MAX; + errno = ERANGE; + } + return ret; +} + +EXPORT unsigned long my32_wcstoul(const wchar_t* s, wchar_t** endp, int base) +{ + unsigned long ret = wcstoul(s, endp, base); + if(ret>UINT_MAX) { + ret = UINT_MAX; + errno = ERANGE; + } + return ret; +} + // wrapped malloc using calloc, it seems x86 malloc set alloc'd block to zero somehow EXPORT void* my32_malloc(unsigned long size) { diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index 0e52f679..ad2694f1 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -72,7 +72,7 @@ GOM(alphasort64, iFEpp) // argz_replace // Weak // __argz_stringify //GOW(argz_stringify, vFpLi) -//GO(asctime, pFp) +GOM(asctime, pFriiiiiiiiilt_) //%noE GOW(asctime_r, pFriiiiiiiiilt_p) //GOWM(asprintf, iFEppV) //%% //GOM(__asprintf, iFEppV) //%% @@ -203,7 +203,7 @@ DATAV(daylight, 4) // des_setparity GOW(dgettext, pFpp) GO(__dgettext, pFpp) -//GO(difftime, dFuu) +GO(difftime, dFLL) //GO(dirfd, iFp) //GO(dirname, pFp) GOS(div, pFpii) //%%,noE @@ -507,8 +507,8 @@ GOM(getifaddrs, iFEbp_) // get_kernel_syms // Weak //GOW(getline, iFppp) //GO(getloadavg, iFpi) -//GO(getlogin, pFv) -//GO(getlogin_r, iFpu) +GO(getlogin, pFv) +GO(getlogin_r, iFpu) // __getlogin_r_chk GOM(getmntent, pFES) // __getmntent_r @@ -1468,7 +1468,7 @@ GOWM(sendmsg, lFEipi) //GOM(__sendmmsg, iFEipuu) //%% actual __sendmmsg is glibc 2.14+. The syscall is Linux 3.0+, so use syscall... GOW(sendto, lFipLipu) // setaliasent -//GOW(setbuf, vFpp) +GOW(setbuf, vFSp) //GOW(setbuffer, vFppL) GOM(setcontext, iFEp) //%% // setdomainname @@ -1903,7 +1903,8 @@ GOM(__vsnprintf_chk, iFEpLvvpp) //%% //GOM(__vsprintf_chk, iFEpiLpp) //%% //GOM(vsscanf, iFEppp) //%% // __vsscanf // Weak -GOWM(vswprintf, iFEpLppp) //%% +GOWM(vswprintf, iFEpLpp) //%% +GOWM(__vswprintf, iFEpLpp) //%% //GOWM(__vswprintf_chk, iFEpLiLppp) //%% GOM(vswscanf, iFEppp) //GO(vsyslog, vFipp) @@ -1975,7 +1976,7 @@ GO(wcsstr, pFpp) // wcstof_l // Weak // wcstoimax //GO(wcstok, pFppp) -GO(wcstol, iFpBp_i) +GOM(wcstol, iFpBp_i) //%noE //GO(wcstold, DFpp) // __wcstold_internal // __wcstold_l @@ -1990,7 +1991,7 @@ GO(wcstoll, IFpBp_i) GO(wcstombs, LFppL) // __wcstombs_chk // wcstoq // Weak -//GO(wcstoul, iFppi) +GOM(wcstoul, iFpBp_i) //%noE //GO(__wcstoul_internal, LFppii) GO(wcstoull, UFpBp_i) // __wcstoul_l @@ -2028,7 +2029,7 @@ GO(wmemset, pFpuL) //GO(wordexp, iFppi) //GO(wordfree, vFp) // __woverflow -//GOM(wprintf, iFEpV) //%% +GOM(wprintf, iFEpV) //%% //GOM(__wprintf_chk, iFEipV) //%% GOW(write, lFipL) //GOW(__write, lFipL) diff --git a/src/wrapped32/wrappedsdl1.c b/src/wrapped32/wrappedsdl1.c index f7fe2c80..fa6d92c1 100644 --- a/src/wrapped32/wrappedsdl1.c +++ b/src/wrapped32/wrappedsdl1.c @@ -194,14 +194,18 @@ EXPORT int my32_SDL_OpenAudio(x64emu_t* emu, void* d, void* o) return ret; } -//EXPORT void *my32_SDL_LoadBMP_RW(x64emu_t* emu, void* a, int b) -//{ -// SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a); -// void* r = my->SDL_LoadBMP_RW(rw, b); -// if(b==0) -// RWNativeEnd(rw); -// return r; -//} +EXPORT void *my32_SDL_LoadBMP_RW(x64emu_t* emu, void* a, int b) +{ + inplace_SDL_RWops_to_64(a); + SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a); + void* r = my->SDL_LoadBMP_RW(rw, b); + if(b==0) { + RWNativeEnd(rw); + inplace_SDL_RWops_to_32(a); + } + inplace_SDL_Surface_to_32(r); + return r; +} //EXPORT int32_t my32_SDL_SaveBMP_RW(x64emu_t* emu, void* a, void* b, int c) //{ // SDL1_RWops_t* rw = RWNativeStart(emu, (SDL1_RWops_t*)a); @@ -316,19 +320,64 @@ EXPORT int my32_SDL_OpenAudio(x64emu_t* emu, void* d, void* o) // RWSetType(r, 2); // return AddNativeRW(emu, r); //} -//EXPORT void *my32_SDL_RWFromFile(x64emu_t* emu, void* a, void* b) -//{ -// SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromFile(a, b); -// RWSetType(r, 2); -// return AddNativeRW(emu, r); -//} +EXPORT void *my32_SDL_RWFromFile(x64emu_t* emu, void* a, void* b) +{ + SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromFile(a, b); + RWSetType(r, 2); + void* ret = AddNativeRW(emu, r); + inplace_SDL_RWops_to_32(ret); + return ret; +} //EXPORT void *my32_SDL_RWFromMem(x64emu_t* emu, void* a, int b) //{ // SDL1_RWops_t* r = (SDL1_RWops_t*)my->SDL_RWFromMem(a, b); // RWSetType(r, 4); // return AddNativeRW(emu, r); //} -// + +EXPORT void my32_SDL_WM_SetIcon(void* s, void* mask) +{ + inplace_SDL_Surface_to_64(s); + my->SDL_WM_SetIcon(s, mask); + inplace_SDL_Surface_to_32(s); +} + +EXPORT void my32_SDL_GetRGB(uint32_t pixel, void* format, void* r, void* g, void* b) +{ + inplace_SDL_PixelFormat_to_64(format); + my->SDL_GetRGB(pixel, format, r, g, b); + inplace_SDL_PixelFormat_to_32(format); +} + +EXPORT void* my32_SDL_GetVideoInfo() +{ + static my_SDL_Palette_t vm_palette; + static my_SDL_PixelFormat_t vm_format; + static my_SDL_VideoInfo_32_t vm = {0}; + my_SDL_VideoInfo_t* r = my->SDL_GetVideoInfo(); + if(!r) return NULL; + vm.hw_available = r->hw_available; + vm.wm_available = r->wm_available; + vm.blit_hw = r->blit_hw; + vm.blit_hw_CC = r->blit_hw_CC; + vm.blit_hw_A = r->blit_hw_A; + vm.blit_sw = r->blit_sw; + vm.blit_sw_CC = r->blit_sw_CC; + vm.blit_sw_A = r->blit_sw_A; + vm.blit_fill = r->blit_fill; + vm.video_mem = r->video_mem; + if(r->vfmt) { + vm.vfmt = to_ptrv(&vm_format); + memcpy(&vm_format, r->vfmt, sizeof(vm_format)); + if(r->vfmt->palette) { + vm_format.palette = &vm_palette; + memcpy(&vm_palette, r->vfmt->palette, sizeof(vm_palette)); + } + } else vm.vfmt = 0; + inplace_SDL_PixelFormat_to_32(&vm); + return &vm; +} + //EXPORT void *my32_SDL_AddTimer(x64emu_t* emu, uint32_t a, void* cb, void* p) //{ // return my->SDL_AddTimer(a, find_TimerCallback_Fct(cb), p); @@ -436,7 +485,7 @@ static void* wrapSurface(void* s) static void* unwrapSurface(void* s) { if(!s) return s; - if(s==&sdl_vm_surface) { + if(s==&sdl_vm_surface || s==sdl1_videomode_org) { my_SDL_Surface_32_t* dst = s; // refressh surface... dst->h = sdl1_videomode_org->h; @@ -503,6 +552,12 @@ EXPORT int my32_SDL_Flip(void* s) return ret; } +EXPORT void* my32_SDL_GetVideoSurface() +{ + void* ret = my->SDL_GetVideoSurface(); + return unwrapSurface(ret); +} + EXPORT int my32_SDL_PollEvent(my_SDL_Event_32_t* evt) { my_SDL_Event_t event; diff --git a/src/wrapped32/wrappedsdl1_private.h b/src/wrapped32/wrappedsdl1_private.h index c2931582..d50a7c8f 100644 --- a/src/wrapped32/wrappedsdl1_private.h +++ b/src/wrapped32/wrappedsdl1_private.h @@ -31,20 +31,20 @@ GO(SDL_CreateSemaphore, pFu) GOM(SDL_CreateThread, pFEpp) //GO(SDL_CreateYUVOverlay, pFiiup) -//GO(SDL_Delay, vFu) +GO(SDL_Delay, vFu) //GO(SDL_DestroyCond, vFp) //GO(SDL_DestroyMutex, vFp) //GO(SDL_DestroySemaphore, vFp) //GO(SDL_DisplayFormat, pFp) //GO(SDL_DisplayFormatAlpha, pFp) //GO(SDL_DisplayYUVOverlay, iFpp) -//GO(SDL_EnableKeyRepeat, iFii) -//GO(SDL_EnableUNICODE, iFi) -//GO(SDL_Error, vFu) -//GO(SDL_EventState, CFCi) +GO(SDL_EnableKeyRepeat, iFii) +GO(SDL_EnableUNICODE, iFi) +GO(SDL_Error, vFu) +GO(SDL_EventState, CFCi) //GO(SDL_FillRect, iFppu) GOM(SDL_Flip, iFp) //%noE -//GO(SDL_FreeCursor, vFp) +GO(SDL_FreeCursor, vFp) //GO(SDL_FreeRW, vFp) //GO(SDL_FreeSurface, vFp) //GO(SDL_FreeYUVOverlay, vFp) @@ -54,26 +54,26 @@ GO(SDL_GL_LoadLibrary, iFp) GO(SDL_GL_Lock, vFv) GO(SDL_GL_SetAttribute, iFui) GO(SDL_GL_SwapBuffers, vFv) -//GO(SDL_GL_Unlock, vFv) +GO(SDL_GL_Unlock, vFv) //GO(SDL_GL_UpdateRects, vFip) -//GO(SDL_GetAppState, CFv) +GO(SDL_GetAppState, CFv) //GO(SDL_GetClipRect, vFpp) //GO(SDL_GetCursor, pFv) -//GO(SDL_GetError, pFv) +GO(SDL_GetError, pFv) //GOM(SDL_GetEventFilter, pFEv) //GO(SDL_GetGammaRamp, iFppp) -//GO(SDL_GetKeyName, pFu) +GO(SDL_GetKeyName, pFu) //GO(SDL_GetKeyRepeat, vFpp) GO(SDL_GetKeyState, pFp) //GO(SDL_GetModState, uFv) -//GO(SDL_GetMouseState, uFpp) -//GO(SDL_GetRGB, vFupppp) +GO(SDL_GetMouseState, uFpp) +GOM(SDL_GetRGB, vFupppp) //%noE //GO(SDL_GetRGBA, vFuppppp) //GO(SDL_GetRelativeMouseState, CFpp) //GO(SDL_GetThreadID, uFp) GO(SDL_GetTicks, uFv) -//GO(SDL_GetVideoInfo, pFv) -//GO(SDL_GetVideoSurface, pFv) +GOM(SDL_GetVideoInfo, pFv) //%noE +GOM(SDL_GetVideoSurface, pFv) //%noE //GOM(SDL_GetWMInfo, iFEp) GOM(SDL_Has3DNow, iFv) //%noE GOM(SDL_Has3DNowExt, iFv) //%noE @@ -104,7 +104,7 @@ GO(SDL_JoystickUpdate, vFv) GOM(SDL_KillThread, vFEp) //GO(SDL_Linked_Version, pFv) //GO(SDL_ListModes, pFpu) -//GOM(SDL_LoadBMP_RW, pFEpi) +GOM(SDL_LoadBMP_RW, pFEpi) GOM(SDL_LoadFunction, pFEpp) GOM(SDL_LoadObject, pFEp) GOM(SDL_LockSurface, iFp) //%noE @@ -121,7 +121,7 @@ GOM(SDL_Quit, vFv) //%noE GO(SDL_QuitSubSystem, vFu) //GOM(SDL_RWFromConstMem, pFEpi) //GOM(SDL_RWFromFP, pFEpi) -//GOM(SDL_RWFromFile, pFEpp) +GOM(SDL_RWFromFile, pFEpp) //GOM(SDL_RWFromMem, pFEpi) //GOM(SDL_ReadBE16, uFEp) //GOM(SDL_ReadBE32, uFEp) @@ -153,23 +153,23 @@ GO(SDL_SetModState, vFu) GOM(SDL_SetVideoMode, pFiiiu) //%noE GO(SDL_ShowCursor, iFi) //GO(SDL_SoftStretch, iFpppp) -//GO(SDL_ThreadID, uFv) +GO(SDL_ThreadID, uFv) //GOM(SDL_UnloadObject, vFEp) GOM(SDL_UnlockSurface, vFp) //%noE //GO(SDL_UnlockYUVOverlay, vFp) -//GO(SDL_UnregisterApp, vFv) +GO(SDL_UnregisterApp, vFv) //GO(SDL_UpdateRect, vFpiiuu) //GO(SDL_UpdateRects, vFpip) //GO(SDL_UpperBlit, iFpppp) //GO(SDL_VideoDriverName, pFpi) //GO(SDL_VideoInit, iFpu) -//GO(SDL_VideoModeOK, iFiiiu) +GO(SDL_VideoModeOK, iFiiiu) GO(SDL_VideoQuit, vFv) //GO(SDL_WM_GetCaption, vFpp) GO(SDL_WM_GrabInput, iFi) GO(SDL_WM_IconifyWindow, iFv) GO(SDL_WM_SetCaption, vFpp) -//GO(SDL_WM_SetIcon, vFpp) +GOM(SDL_WM_SetIcon, vFpp) //%noE //GO(SDL_WM_ToggleFullScreen, iFp) //GO(SDL_WaitEvent, iFp) //GO(SDL_WaitThread, vFpp) |