diff options
| author | Leslie Zhai <zhaixiang@loongson.cn> | 2025-07-05 21:31:12 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-05 15:31:12 +0200 |
| commit | 1ed7609fe95fab8afb0669daffd63223ea665788 (patch) | |
| tree | cb69c56cebd01f8212e6d10fdc46a5da054043bc /src/wrapped | |
| parent | 04396f421e11b305f4e34da4f59d19458b109506 (diff) | |
| download | box64-1ed7609fe95fab8afb0669daffd63223ea665788.tar.gz box64-1ed7609fe95fab8afb0669daffd63223ea665788.zip | |
[WRAPPER] Wrapper xmlMemGet and xmlMemSetup (#2799)
* [WRAPPER] Wrapper xmlMemGet and xmlMemSetup * [WRAPPER] Change GOM to GO for xmlMemGet
Diffstat (limited to 'src/wrapped')
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 1 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedxml2types.h | 1 | ||||
| -rw-r--r-- | src/wrapped/wrappedxml2.c | 98 | ||||
| -rw-r--r-- | src/wrapped/wrappedxml2_private.h | 4 |
4 files changed, 102 insertions, 2 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index ad4fef3c..128e86c9 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -6367,6 +6367,7 @@ wrappedxml2: - iFpppp: - xmlHashRemoveEntry2 - xmlHashUpdateEntry + - xmlMemSetup - xmlRegisterInputCallbacks - xmlRegisterOutputCallbacks - iFpppV: diff --git a/src/wrapped/generated/wrappedxml2types.h b/src/wrapped/generated/wrappedxml2types.h index f52aeea3..68a4a552 100644 --- a/src/wrapped/generated/wrappedxml2types.h +++ b/src/wrapped/generated/wrappedxml2types.h @@ -54,6 +54,7 @@ typedef void* (*pFppppppi_t)(void*, void*, void*, void*, void*, void*, int32_t); GO(xmlSchemaSetValidErrors, vFpppp_t) \ GO(xmlHashRemoveEntry2, iFpppp_t) \ GO(xmlHashUpdateEntry, iFpppp_t) \ + GO(xmlMemSetup, iFpppp_t) \ GO(xmlRegisterInputCallbacks, iFpppp_t) \ GO(xmlRegisterOutputCallbacks, iFpppp_t) \ GO(xmlTextWriterWriteFormatAttribute, iFpppV_t) \ diff --git a/src/wrapped/wrappedxml2.c b/src/wrapped/wrappedxml2.c index 8c52e0b0..d0161a1d 100644 --- a/src/wrapped/wrappedxml2.c +++ b/src/wrapped/wrappedxml2.c @@ -1235,6 +1235,98 @@ static void* find_xmlTextReaderErrorFunc_Fct(void* fct) // this one have a VAArg return NULL; } +// xmlFreeFunc ... +#define GO(A) \ +static uintptr_t my_xmlFreeFunc_fct_##A = 0; \ +static void my_xmlFreeFunc_##A(void* a) \ +{ \ + return (void)RunFunctionFmt(my_xmlFreeFunc_fct_##A, "p", a); \ +} +SUPER() +#undef GO +static void* find_xmlFreeFunc_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_xmlFreeFunc_fct_##A == (uintptr_t)fct) return my_xmlFreeFunc_##A; + SUPER() + #undef GO + #define GO(A) if(my_xmlFreeFunc_fct_##A == 0) {my_xmlFreeFunc_fct_##A = (uintptr_t)fct; return my_xmlFreeFunc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libxml2 xmlFreeFunc callback\n"); + return NULL; +} + +// xmlMallocFunc ... +#define GO(A) \ +static uintptr_t my_xmlMallocFunc_fct_##A = 0; \ +static void* my_xmlMallocFunc_##A(size_t a) \ +{ \ + return (void*)RunFunctionFmt(my_xmlMallocFunc_fct_##A, "L", a); \ +} +SUPER() +#undef GO +static void* find_xmlMallocFunc_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_xmlMallocFunc_fct_##A == (uintptr_t)fct) return my_xmlMallocFunc_##A; + SUPER() + #undef GO + #define GO(A) if(my_xmlMallocFunc_fct_##A == 0) {my_xmlMallocFunc_fct_##A = (uintptr_t)fct; return my_xmlMallocFunc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libxml2 xmlMallocFunc callback\n"); + return NULL; +} + +// xmlReallocFunc ... +#define GO(A) \ +static uintptr_t my_xmlReallocFunc_fct_##A = 0; \ +static void* my_xmlReallocFunc_##A(void* a, size_t b) \ +{ \ + return (void*)RunFunctionFmt(my_xmlReallocFunc_fct_##A, "pL", a, b); \ +} +SUPER() +#undef GO +static void* find_xmlReallocFunc_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_xmlReallocFunc_fct_##A == (uintptr_t)fct) return my_xmlReallocFunc_##A; + SUPER() + #undef GO + #define GO(A) if(my_xmlReallocFunc_fct_##A == 0) {my_xmlReallocFunc_fct_##A = (uintptr_t)fct; return my_xmlReallocFunc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libxml2 xmlReallocFunc callback\n"); + return NULL; +} + +// xmlStrdupFunc ... +#define GO(A) \ +static uintptr_t my_xmlStrdupFunc_fct_##A = 0; \ +static char* my_xmlStrdupFunc_##A(char* a) \ +{ \ + return (char*)RunFunctionFmt(my_xmlStrdupFunc_fct_##A, "p", a); \ +} +SUPER() +#undef GO +static void* find_xmlStrdupFunc_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_xmlStrdupFunc_fct_##A == (uintptr_t)fct) return my_xmlStrdupFunc_##A; + SUPER() + #undef GO + #define GO(A) if(my_xmlStrdupFunc_fct_##A == 0) {my_xmlStrdupFunc_fct_##A = (uintptr_t)fct; return my_xmlStrdupFunc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libxml2 xmlStrdupFunc callback\n"); + return NULL; +} + #undef SUPER EXPORT void* my_xmlHashCopy(x64emu_t* emu, void* table, void* f) @@ -1491,4 +1583,10 @@ EXPORT void* my_xmlCtxtReadIO(x64emu_t* emu, void* ctxt, void* ioread, void* ioc return my->xmlCtxtReadIO(ctxt, find_xmlInputReadCallback_Fct(ioread), find_xmlInputCloseCallback_Fct(ioclose), ioctx, url, encoding, options); } +EXPORT int my_xmlMemSetup(x64emu_t* emu, void* v1, void* v2, void* v3, void* v4) +{ + int ret = my->xmlMemSetup(find_xmlFreeFunc_Fct(v1), find_xmlMallocFunc_Fct(v2), find_xmlReallocFunc_Fct(v3), find_xmlStrdupFunc_Fct(v4)); + return ret; +} + #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedxml2_private.h b/src/wrapped/wrappedxml2_private.h index 2f6a4b36..68d04802 100644 --- a/src/wrapped/wrappedxml2_private.h +++ b/src/wrapped/wrappedxml2_private.h @@ -519,12 +519,12 @@ GO(xmlLoadExternalEntity, pFppp) //GO(xmlMemDisplay, //GO(xmlMemDisplayLast, //GO(xmlMemFree, -//GO(xmlMemGet, +GO(xmlMemGet, iFpppp) //GO(xmlMemMalloc, //GO(xmlMemoryDump, //GO(xmlMemoryStrdup, //GO(xmlMemRealloc, -//GO(xmlMemSetup, +GOM(xmlMemSetup, iFEpppp) //GO(xmlMemShow, //GO(xmlMemStrdupLoc, //GO(xmlMemUsed, |