Wrapped libxslt (should help #259)

This commit is contained in:
ptitSeb 2020-11-30 20:02:57 +01:00
parent 754859d28a
commit 54ce6deb1c
7 changed files with 386 additions and 0 deletions

View File

@ -330,6 +330,7 @@ set(WRAPPEDS
"${BOX86_ROOT}/src/wrapped/wrappedvulkan.c"
"${BOX86_ROOT}/src/wrapped/wrappedwaylandclient.c"
"${BOX86_ROOT}/src/wrapped/wrappedxml2.c"
"${BOX86_ROOT}/src/wrapped/wrappedxslt.c"
"${BOX86_ROOT}/src/wrapped/wrappedldlinux.c"
)

View File

@ -129,5 +129,6 @@ GO("libvulkan.so.1", vulkan)
GO("libvulkan.so", vulkan)
GO("libwayland-client.so.0", waylandclient)
GO("libxml2.so.2", xml2)
GO("libxslt.so.1", xslt)
GO("ld-linux.so.2", ldlinux)

View File

@ -5,6 +5,7 @@
#() vFu
#() vFf
#() vFd
#() vFl
#() vFL
#() vFp
#() vFS
@ -692,6 +693,7 @@
#() iFppui
#() iFppuu
#() iFppup
#() iFppdp
#() iFppll
#() iFpplp
#() iFppLi

View File

@ -76,6 +76,7 @@ typedef void (*vFi_t)(int32_t);
typedef void (*vFu_t)(uint32_t);
typedef void (*vFf_t)(float);
typedef void (*vFd_t)(double);
typedef void (*vFl_t)(intptr_t);
typedef void (*vFL_t)(uintptr_t);
typedef void (*vFp_t)(void*);
typedef void (*vFS_t)(void*);
@ -763,6 +764,7 @@ typedef int32_t (*iFppuw_t)(void*, void*, uint32_t, int16_t);
typedef int32_t (*iFppui_t)(void*, void*, uint32_t, int32_t);
typedef int32_t (*iFppuu_t)(void*, void*, uint32_t, uint32_t);
typedef int32_t (*iFppup_t)(void*, void*, uint32_t, void*);
typedef int32_t (*iFppdp_t)(void*, void*, double, void*);
typedef int32_t (*iFppll_t)(void*, void*, intptr_t, intptr_t);
typedef int32_t (*iFpplp_t)(void*, void*, intptr_t, void*);
typedef int32_t (*iFppLi_t)(void*, void*, uintptr_t, int32_t);
@ -1914,6 +1916,7 @@ void vFi(x86emu_t *emu, uintptr_t fcn) { vFi_t fn = (vFi_t)fcn; fn(*(int32_t*)(R
void vFu(x86emu_t *emu, uintptr_t fcn) { vFu_t fn = (vFu_t)fcn; fn(*(uint32_t*)(R_ESP + 4)); }
void vFf(x86emu_t *emu, uintptr_t fcn) { vFf_t fn = (vFf_t)fcn; fn(*(float*)(R_ESP + 4)); }
void vFd(x86emu_t *emu, uintptr_t fcn) { vFd_t fn = (vFd_t)fcn; fn(*(double*)(R_ESP + 4)); }
void vFl(x86emu_t *emu, uintptr_t fcn) { vFl_t fn = (vFl_t)fcn; fn(*(intptr_t*)(R_ESP + 4)); }
void vFL(x86emu_t *emu, uintptr_t fcn) { vFL_t fn = (vFL_t)fcn; fn(*(uintptr_t*)(R_ESP + 4)); }
void vFp(x86emu_t *emu, uintptr_t fcn) { vFp_t fn = (vFp_t)fcn; fn(*(void**)(R_ESP + 4)); }
void vFS(x86emu_t *emu, uintptr_t fcn) { vFS_t fn = (vFS_t)fcn; fn(io_convert(*(void**)(R_ESP + 4))); }
@ -2601,6 +2604,7 @@ void iFppuw(x86emu_t *emu, uintptr_t fcn) { iFppuw_t fn = (iFppuw_t)fcn; R_EAX=f
void iFppui(x86emu_t *emu, uintptr_t fcn) { iFppui_t fn = (iFppui_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
void iFppuu(x86emu_t *emu, uintptr_t fcn) { iFppuu_t fn = (iFppuu_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16)); }
void iFppup(x86emu_t *emu, uintptr_t fcn) { iFppup_t fn = (iFppup_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void iFppdp(x86emu_t *emu, uintptr_t fcn) { iFppdp_t fn = (iFppdp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(double*)(R_ESP + 12), *(void**)(R_ESP + 20)); }
void iFppll(x86emu_t *emu, uintptr_t fcn) { iFppll_t fn = (iFppll_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(intptr_t*)(R_ESP + 12), *(intptr_t*)(R_ESP + 16)); }
void iFpplp(x86emu_t *emu, uintptr_t fcn) { iFpplp_t fn = (iFpplp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(intptr_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void iFppLi(x86emu_t *emu, uintptr_t fcn) { iFppLi_t fn = (iFppLi_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uintptr_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }

View File

@ -35,6 +35,7 @@ void vFi(x86emu_t *emu, uintptr_t fnc);
void vFu(x86emu_t *emu, uintptr_t fnc);
void vFf(x86emu_t *emu, uintptr_t fnc);
void vFd(x86emu_t *emu, uintptr_t fnc);
void vFl(x86emu_t *emu, uintptr_t fnc);
void vFL(x86emu_t *emu, uintptr_t fnc);
void vFp(x86emu_t *emu, uintptr_t fnc);
void vFS(x86emu_t *emu, uintptr_t fnc);
@ -722,6 +723,7 @@ void iFppuw(x86emu_t *emu, uintptr_t fnc);
void iFppui(x86emu_t *emu, uintptr_t fnc);
void iFppuu(x86emu_t *emu, uintptr_t fnc);
void iFppup(x86emu_t *emu, uintptr_t fnc);
void iFppdp(x86emu_t *emu, uintptr_t fnc);
void iFppll(x86emu_t *emu, uintptr_t fnc);
void iFpplp(x86emu_t *emu, uintptr_t fnc);
void iFppLi(x86emu_t *emu, uintptr_t fnc);

129
src/wrapped/wrappedxslt.c Executable file
View File

@ -0,0 +1,129 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x86emu.h"
#include "emu/x86emu_private.h"
#include "box86context.h"
#include "librarian.h"
#include "callback.h"
const char* xsltName = "libxslt.so.1";
#define LIBNAME xslt
static library_t *my_lib = NULL;
typedef void (*vFp_t) (void*);
typedef int (*iFppp_t) (void*, void*, void*);
#define SUPER() \
GO(xsltRegisterExtModuleFunction, iFppp_t) \
GO(xsltSetLoaderFunc, vFp_t) \
typedef struct xslt_my_s {
// functions
#define GO(A, B) B A;
SUPER()
#undef GO
} xslt_my_t;
void* getXsltMy(library_t* lib)
{
xslt_my_t* my = (xslt_my_t*)calloc(1, sizeof(xslt_my_t));
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
SUPER()
#undef GO
return my;
}
#undef SUPER
void freeXsltMy(void* lib)
{
//xslt_my_t *my = (xslt_my_t *)lib;
}
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4)
// xmlXPathFunction ...
#define GO(A) \
static uintptr_t my_xmlXPathFunction_fct_##A = 0; \
static void my_xmlXPathFunction_##A(void* a, int b) \
{ \
RunFunction(my_context, my_xmlXPathFunction_fct_##A, 2, a, b); \
}
SUPER()
#undef GO
static void* find_xmlXPathFunction_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_xmlXPathFunction_fct_##A == (uintptr_t)fct) return my_xmlXPathFunction_##A;
SUPER()
#undef GO
#define GO(A) if(my_xmlXPathFunction_fct_##A == 0) {my_xmlXPathFunction_fct_##A = (uintptr_t)fct; return my_xmlXPathFunction_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libxslt xmlXPathFunction callback\n");
return NULL;
}
// xsltDocLoaderFunc ...
#define GO(A) \
static uintptr_t my_xsltDocLoaderFunc_fct_##A = 0; \
static void* my_xsltDocLoaderFunc_##A(void* a, void* b, int c, void* d, int e) \
{ \
return (void*)RunFunction(my_context, my_xsltDocLoaderFunc_fct_##A, 5, a, b, c, d, e); \
}
SUPER()
#undef GO
static void* find_xsltDocLoaderFunc_Fct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_xsltDocLoaderFunc_fct_##A == (uintptr_t)fct) return my_xsltDocLoaderFunc_##A;
SUPER()
#undef GO
#define GO(A) if(my_xsltDocLoaderFunc_fct_##A == 0) {my_xsltDocLoaderFunc_fct_##A = (uintptr_t)fct; return my_xsltDocLoaderFunc_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libxslt xsltDocLoaderFunc callback\n");
return NULL;
}
#undef SUPER
EXPORT int my_xsltRegisterExtModuleFunction(x86emu_t* emu, void* name, void* URI, void* f)
{
xslt_my_t* my = (xslt_my_t*)my_lib->priv.w.p2;
return my->xsltRegisterExtModuleFunction(name, URI, find_xmlXPathFunction_Fct(f));
}
EXPORT void my_xsltSetLoaderFunc(x86emu_t* emu, void* f)
{
xslt_my_t* my = (xslt_my_t*)my_lib->priv.w.p2;
my->xsltSetLoaderFunc(find_xsltDocLoaderFunc_Fct(f));
}
#define CUSTOM_INIT \
lib->priv.w.p2 = getXsltMy(lib); \
my_lib = lib;
#define CUSTOM_FINI \
freeXsltMy(lib->priv.w.p2); \
free(lib->priv.w.p2); \
my_lib = NULL;
#include "wrappedlib_init.h"

247
src/wrapped/wrappedxslt_private.h Executable file
View File

@ -0,0 +1,247 @@
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
#error meh!
#endif
GO(xslAddCall, iFpp)
GO(xslDropCall, vFv)
GO(xslHandleDebugger, vFpppp)
//GO(xsltAddKey,
GO(xsltAddStackElemList, iFpp)
//GO(xsltAddTemplate,
GO(xsltAllocateExtra, iFp)
GO(xsltAllocateExtraCtxt, iFp)
//GO(xsltApplyAttributeSet,
GO(xsltApplyImports, vFpppp)
GO(xsltApplyOneTemplate, vFppppp)
GO(xsltApplyStripSpaces, vFpp)
GO(xsltApplyStylesheet, pFppp)
GO(xsltApplyStylesheetUser, pFpppppp)
GO(xsltApplyTemplates, vFpppp)
GO(xsltAttribute, vFpppp)
//GO(xsltAttrListTemplateProcess,
//GO(xsltAttrTemplateProcess,
//GO(xsltAttrTemplateValueProcess,
//GO(xsltAttrTemplateValueProcessNode,
GO(xsltCalibrateAdjust, vFl)
GO(xsltCallTemplate, vFpppp)
GO(xsltCheckExtPrefix, iFpp)
GO(xsltCheckExtURI, iFpp)
//GO(xsltCheckRead,
//GO(xsltCheckWrite,
GO(xsltChoose, vFpppp)
GO(xsltCleanupGlobals, vFv)
//GO(xsltCleanupTemplates,
GO(xsltComment, vFpppp)
GO(xsltCompileAttr, vFpp)
//GO(xsltCompilePattern,
GO(xsltComputeSortResult, pFpp)
GO(xsltCopy, vFpppp)
//GO(xsltCopyNamespace,
//GO(xsltCopyNamespaceList,
GO(xsltCopyOf, vFpppp)
GO(xsltCopyTextString, pFpppi)
//GO(xsltCopyTree,
GO(xsltCreateRVT, pFp)
GO(xsltDebug, vFpppp)
GO(xsltDebugDumpExtensions, vFp)
GO(xsltDebugGetDefaultTrace, iFv)
GO(xsltDebugSetDefaultTrace, vFi)
GO(xsltDecimalFormatGetByName, pFpp)
GO(xsltDecimalFormatGetByQName, pFppp)
GO(xsltDefaultSortFunction, vFppi)
//GO(xsltDocumentComp,
GO(xsltDocumentElem, vFpppp)
//GO(xsltDocumentFunction,
GO(xsltDocumentSortFunction, vFp)
GO(xsltDoSortFunction, vFppi)
GO(xsltElement, vFpppp)
//GO(xsltElementAvailableFunction,
//GO(xsltEvalAttrValueTemplate,
GO(xsltEvalAVT, pFppp)
GO(xsltEvalGlobalVariables, iFp)
GO(xsltEvalOneUserParam, iFppp)
//GO(xsltEvalStaticAttrValueTemplate,
//GO(xsltEvalTemplateString,
GO(xsltEvalUserParams, iFpp)
//GO(xsltEvalXPathPredicate,
//GO(xsltEvalXPathString,
//GO(xsltEvalXPathStringNs,
//GOM(xsltExtElementLookup, BFEppp)
GO(xsltExtensionInstructionResultFinalize, iFp)
GO(xsltExtensionInstructionResultRegister, iFpp)
//GOM(xsltExtModuleElementLookup, BFEpp)
//GOM(xsltExtModuleElementPreComputeLookup, BFEpp)
//GOM(xsltExtModuleFunctionLookup, BFEpp)
//GOM(xsltExtModuleTopLevelLookup, BFEpp)
GO(xsltFindDocument, pFpp)
GO(xsltFindElemSpaceHandling, iFpp)
GO(xsltFindTemplate, pFppp)
GO(xsltFlagRVTs, iFppp)
GO(xsltForEach, vFpppp)
GO(xsltFormatNumberConversion, iFppdp)
//GO(xsltFormatNumberFunction,
//GO(xsltFreeAttributeSetsHashes,
GO(xsltFreeAVTList, vFp)
//GO(xsltFreeCompMatchList,
GO(xsltFreeCtxtExts, vFp)
//GO(xsltFreeDocumentKeys,
GO(xsltFreeDocuments, vFp)
GO(xsltFreeExts, vFp)
GO(xsltFreeGlobalVariables, vFp)
//GO(xsltFreeKeys,
//GO(xsltFreeLocale,
//GO(xsltFreeNamespaceAliasHashes,
GO(xsltFreeRVTs, vFp)
//GO(xsltFreeSecurityPrefs,
GO(xsltFreeStackElemList, vFp)
GO(xsltFreeStyleDocuments, vFp)
//GO(xsltFreeStylePreComps,
GO(xsltFreeStylesheet, vFp)
//GO(xsltFreeTemplateHashes,
GO(xsltFreeTransformContext, vFp)
//GO(xsltFunctionAvailableFunction,
GO(xsltFunctionNodeSet, vFpi)
//GO(xsltGenerateIdFunction,
GO(xsltGetCNsProp, pFpppp)
GO(xsltGetDebuggerStatus, iFv)
//GO(xsltGetDefaultSecurityPrefs,
GO(xsltGetExtData, pFpp)
GO(xsltGetExtInfo, pFpp)
//GO(xsltGetKey,
//GO(xsltGetNamespace,
GO(xsltGetNsProp, pFppp)
//GO(xsltGetPlainNamespace,
GO(xsltGetProfileInformation, pFp)
GO(xsltGetQNameURI, pFpp)
GO(xsltGetQNameURI2, pFppp)
//GO(xsltGetSecurityPrefs,
//GO(xsltGetSpecialNamespace,
//GO(xsltGetTemplate,
GO(xsltGetUTF8Char, iFpp)
GO(xsltGetXIncludeDefault, iFv)
GO(xsltIf, vFpppp)
GO(xsltInit, vFv)
GO(xsltInitAllDocKeys, iFp)
GO(xsltInitCtxtExts, iFp)
//GO(xsltInitCtxtKey,
//GO(xsltInitCtxtKeys,
//GOM(xsltInitElemPreComp, vFEpppBB)
GO(xsltInitGlobals, vFv)
GO(xsltIsBlank, iFp)
//GO(xsltKeyFunction,
GO(xsltLoadDocument, pFpp)
GO(xsltLoadStyleDocument, pFpp)
GO(xsltLoadStylesheetPI, pFp)
//GO(xsltLocaleStrcmp,
GO(xsltLocalVariablePop, vFpii)
GO(xsltLocalVariablePush, iFppi)
GO(xsltMessage, vFppp)
//GO(xsltNamespaceAlias,
GO(xsltNeedElemSpaceHandling, iFp)
GO(xsltNewDocument, pFpp)
//GOM(xsltNewElemPreComp, pFEppB)
//GO(xsltNewLocale,
//GO(xsltNewSecurityPrefs,
GO(xsltNewStyleDocument, pFpp)
GO(xsltNewStylesheet, pFv)
GO(xsltNewTransformContext, pFpp)
GO(xsltNextImport, pFp)
//GO(xsltNormalizeCompSteps,
GO(xsltNumber, vFpppp)
GO(xsltNumberFormat, vFppp)
GO(xsltParseAnyXSLTElem, iFpp)
GO(xsltParseGlobalParam, vFpp)
GO(xsltParseGlobalVariable, vFpp)
GO(xsltParseSequenceConstructor, vFpp)
//GO(xsltParseStylesheetAttributeSet,
GO(xsltParseStylesheetCallerParam, pFpp)
GO(xsltParseStylesheetDoc, pFp)
GO(xsltParseStylesheetFile, pFp)
GO(xsltParseStylesheetImport, iFpp)
GO(xsltParseStylesheetImportedDoc, pFpp)
GO(xsltParseStylesheetInclude, iFpp)
GO(xsltParseStylesheetOutput, vFpp)
GO(xsltParseStylesheetParam, vFpp)
GO(xsltParseStylesheetProcess, pFpp)
GO(xsltParseStylesheetVariable, vFpp)
//GO(xsltParseTemplateContent,
GO(xsltPointerListAddSize, iFppi)
GO(xsltPointerListClear, vFp)
GO(xsltPointerListCreate, pFi)
GO(xsltPointerListFree, vFp)
GO(xsltPreComputeExtModuleElement, pFpp)
GO(xsltPrintErrorContext, vFppp)
GO(xsltProcessingInstruction, vFpppp)
GO(xsltProcessOneNode, vFppp)
GO(xsltProfileStylesheet, pFpppp)
GO(xsltQuoteOneUserParam, iFppp)
GO(xsltQuoteUserParams, iFpp)
GO(xsltRegisterAllElement, vFp)
GO(xsltRegisterAllExtras, vFv)
//GO(xsltRegisterAllFunctions,
//GOM(xsltRegisterExtElement, iFEpppB)
//GOM(xsltRegisterExtFunction, iFEpppB)
//GOM(xsltRegisterExtModule, iFEpBB)
//GOM(xsltRegisterExtModuleElement, iFEppBB)
//GOM(xsltRegisterExtModuleFull, iFEpBBBB)
GOM(xsltRegisterExtModuleFunction, iFEppp)
//GOM(xsltRegisterExtModuleTopLevel, iFEppB)
GO(xsltRegisterExtPrefix, iFppp)
GO(xsltRegisterExtras, vFp)
GO(xsltRegisterLocalRVT, iFpp)
GO(xsltRegisterPersistRVT, iFpp)
GO(xsltRegisterTestModule, vFv)
GO(xsltRegisterTmpRVT, iFpp)
GO(xsltReleaseRVT, vFpp)
//GO(xsltResolveStylesheetAttributeSet,
GO(xsltRestoreDocumentNamespaces, iFpp)
GO(xsltRunStylesheet, iFpppppp)
GO(xsltRunStylesheetUser, iFpppppppp)
GO(xsltSaveProfiling, vFpp)
GO(xsltSaveResultTo, iFppp)
GO(xsltSaveResultToFd, iFipp)
GO(xsltSaveResultToFile, iFppp)
GO(xsltSaveResultToFilename, iFpppi)
GO(xsltSaveResultToString, iFpppp)
//GO(xsltSecurityAllow,
//GO(xsltSecurityForbid,
GO(xsltSetCtxtParseOptions, iFpi)
//GO(xsltSetCtxtSecurityPrefs,
//GOM(xsltSetCtxtSortFunc, vFEpB)
//GOM(xsltSetDebuggerCallbacks, iFip)
GO(xsltSetDebuggerStatus, vFi)
//GO(xsltSetDefaultSecurityPrefs,
//GOM(xsltSetGenericDebugFunc, vFEpB)
//GOM(xsltSetGenericErrorFunc, vFEpB)
GOM(xsltSetLoaderFunc, vFEp)
//GO(xsltSetSecurityPrefs,
//GOM(xsltSetSortFunc, vFEp)
//GO(MxsltSetTransformErrorFunc, vFEppB)
GO(xsltSetXIncludeDefault, vFi)
GO(xsltShutdownCtxtExts, vFp)
GO(xsltShutdownExts, vFp)
GO(xsltSort, vFpppp)
GO(xsltSplitQName, pFppp)
//GO(xsltStrxfrm,
GO(xsltStyleGetExtData, pFpp)
//GO(xsltStylePreCompute,
GO(xsltStyleStylesheetLevelGetExtData, pFpp)
//GO(xsltSystemPropertyFunction,
//GO(xsltTemplateProcess,
//GO(xsltTestCompMatchList,
GO(xsltText, vFpppp)
GO(xsltTimestamp, lFv)
GO(xsltTransformError, vFpppppppppppppppp) //vaarg
GO(xsltUninit, vFv)
//GO(xsltUnparsedEntityURIFunction,
GO(xsltUnregisterExtModule, iFp)
GO(xsltUnregisterExtModuleElement, iFpp)
GO(xsltUnregisterExtModuleFunction, iFpp)
GO(xsltUnregisterExtModuleTopLevel, iFpp)
GO(xsltValueOf, vFpppp)
GO(xsltVariableLookup, pFppp)
GO(xsltXPathCompile, pFpp)
GO(xsltXPathCompileFlags, pFppi)
GO(xsltXPathFunctionLookup, pFppp)
GO(xsltXPathGetTransformContext, pFp)
//GO(xsltXPathVariableLookup,