forked from ptitSeb/box86
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added wrapped libexpat (minium symbols for torchlight2)
- Loading branch information
Showing
6 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/***************************************************************** | ||
* File automatically generated by rebuild_wrappers.py (v1.2.0.09) | ||
*****************************************************************/ | ||
#ifndef __wrappedexpatTYPES_H_ | ||
#define __wrappedexpatTYPES_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 (*vFpp_t)(void*, void*); | ||
typedef void (*vFppp_t)(void*, void*, void*); | ||
|
||
#define SUPER() ADDED_FUNCTIONS() \ | ||
GO(XML_SetCharacterDataHandler, vFpp_t) \ | ||
GO(XML_SetElementHandler, vFppp_t) | ||
|
||
#endif // __wrappedexpatTYPES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#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 "callback.h" | ||
#include "librarian.h" | ||
#include "box86context.h" | ||
#include "emu/x86emu_private.h" | ||
#include "myalign.h" | ||
|
||
const char* expatName = "libexpat.so.1"; | ||
#define LIBNAME expat | ||
static library_t* my_lib = NULL; | ||
|
||
#include "generated/wrappedexpattypes.h" | ||
|
||
typedef struct expat_my_s { | ||
// functions | ||
#define GO(A, B) B A; | ||
SUPER() | ||
#undef GO | ||
} expat_my_t; | ||
|
||
void* getExpatMy(library_t* lib) | ||
{ | ||
expat_my_t* my = (expat_my_t*)calloc(1, sizeof(expat_my_t)); | ||
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A); | ||
SUPER() | ||
#undef GO | ||
return my; | ||
} | ||
#undef SUPER | ||
|
||
void freeExpatMy(void* lib) | ||
{ | ||
//expat_my_t *my = (expat_my_t *)lib; | ||
} | ||
|
||
#define SUPER() \ | ||
GO(0) \ | ||
GO(1) \ | ||
GO(2) \ | ||
GO(3) \ | ||
GO(4) | ||
|
||
// Start ... | ||
#define GO(A) \ | ||
static uintptr_t my_Start_fct_##A = 0; \ | ||
static void* my_Start_##A(void* data, void* name, void* attr) \ | ||
{ \ | ||
return (void*)RunFunction(my_context, my_Start_fct_##A, 3, data, name, attr); \ | ||
} | ||
SUPER() | ||
#undef GO | ||
static void* find_Start_Fct(void* fct) | ||
{ | ||
if(!fct) return fct; | ||
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); | ||
#define GO(A) if(my_Start_fct_##A == (uintptr_t)fct) return my_Start_##A; | ||
SUPER() | ||
#undef GO | ||
#define GO(A) if(my_Start_fct_##A == 0) {my_Start_fct_##A = (uintptr_t)fct; return my_Start_##A; } | ||
SUPER() | ||
#undef GO | ||
printf_log(LOG_NONE, "Warning, no more slot for expat Start callback\n"); | ||
return NULL; | ||
} | ||
// End ... | ||
#define GO(A) \ | ||
static uintptr_t my_End_fct_##A = 0; \ | ||
static void my_End_##A(void* data, void* name) \ | ||
{ \ | ||
RunFunction(my_context, my_End_fct_##A, 2, data, name);\ | ||
} | ||
SUPER() | ||
#undef GO | ||
static void* find_End_Fct(void* fct) | ||
{ | ||
if(!fct) return fct; | ||
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); | ||
#define GO(A) if(my_End_fct_##A == (uintptr_t)fct) return my_End_##A; | ||
SUPER() | ||
#undef GO | ||
#define GO(A) if(my_End_fct_##A == 0) {my_End_fct_##A = (uintptr_t)fct; return my_End_##A; } | ||
SUPER() | ||
#undef GO | ||
printf_log(LOG_NONE, "Warning, no more slot for expat End callback\n"); | ||
return NULL; | ||
} | ||
// CharData ... | ||
#define GO(A) \ | ||
static uintptr_t my_CharData_fct_##A = 0; \ | ||
static void my_CharData_##A(void* data, void* s, int l) \ | ||
{ \ | ||
RunFunction(my_context, my_CharData_fct_##A, 3, data, s, l);\ | ||
} | ||
SUPER() | ||
#undef GO | ||
static void* find_CharData_Fct(void* fct) | ||
{ | ||
if(!fct) return fct; | ||
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); | ||
#define GO(A) if(my_CharData_fct_##A == (uintptr_t)fct) return my_CharData_##A; | ||
SUPER() | ||
#undef GO | ||
#define GO(A) if(my_CharData_fct_##A == 0) {my_CharData_fct_##A = (uintptr_t)fct; return my_CharData_##A; } | ||
SUPER() | ||
#undef GO | ||
printf_log(LOG_NONE, "Warning, no more slot for expat CharData callback\n"); | ||
return NULL; | ||
} | ||
#undef SUPER | ||
|
||
EXPORT void my_XML_SetElementHandler(x86emu_t* emu, void* p, void* start, void* end) | ||
{ | ||
expat_my_t *my = (expat_my_t*)my_lib->priv.w.p2; | ||
my->XML_SetElementHandler(p, find_Start_Fct(start), find_End_Fct(end)); | ||
} | ||
|
||
EXPORT void my_XML_SetCharacterDataHandler(x86emu_t* emu, void* p, void* h) | ||
{ | ||
expat_my_t *my = (expat_my_t*)my_lib->priv.w.p2; | ||
my->XML_SetCharacterDataHandler(p, find_CharData_Fct(h)); | ||
} | ||
|
||
#define CUSTOM_INIT \ | ||
lib->priv.w.p2 = getExpatMy(lib); \ | ||
my_lib = lib; | ||
|
||
#define CUSTOM_FINI \ | ||
freeExpatMy(lib->priv.w.p2); \ | ||
free(lib->priv.w.p2); \ | ||
my_lib = NULL; | ||
|
||
#include "wrappedlib_init.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) | ||
#error meh! | ||
#endif | ||
|
||
//GO(_INTERNAL_trim_to_complete_utf8_characters, | ||
//GO(XML_DefaultCurrent, | ||
GO(XML_ErrorString, pFi) | ||
//GO(XML_ExpatVersion, | ||
//GO(XML_ExpatVersionInfo, | ||
//GO(XML_ExternalEntityParserCreate, | ||
//GO(XML_FreeContentModel, | ||
//GO(XML_GetBase, | ||
//GO(XML_GetBuffer, | ||
//GO(XML_GetCurrentByteCount, | ||
//GO(XML_GetCurrentByteIndex, | ||
//GO(XML_GetCurrentColumnNumber, | ||
GO(XML_GetCurrentLineNumber, iFp) | ||
GO(XML_GetErrorCode, iFp) | ||
//GO(XML_GetFeatureList, | ||
//GO(XML_GetIdAttributeIndex, | ||
//GO(XML_GetInputContext, | ||
//GO(XML_GetParsingStatus, | ||
//GO(XML_GetSpecifiedAttributeCount, | ||
//GO(XML_MemFree, | ||
//GO(XML_MemMalloc, | ||
//GO(XML_MemRealloc, | ||
GO(XML_Parse, iFppii) | ||
//GO(XML_ParseBuffer, | ||
GO(XML_ParserCreate, pFp) | ||
//GO(XML_ParserCreate_MM, | ||
//GO(XML_ParserCreateNS, | ||
GO(XML_ParserFree, vFp) | ||
//GO(XML_ParserReset, | ||
//GO(XML_ResumeParser, | ||
//GO(XML_SetAttlistDeclHandler, | ||
//GO(XML_SetBase, | ||
//GO(XML_SetCdataSectionHandler, | ||
GOM(XML_SetCharacterDataHandler, vFEpp) | ||
//GO(XML_SetCommentHandler, | ||
//GO(XML_SetDefaultHandler, | ||
//GO(XML_SetDefaultHandlerExpand, | ||
//GO(XML_SetDoctypeDeclHandler, | ||
//GO(XML_SetElementDeclHandler, | ||
GOM(XML_SetElementHandler, vFEppp) | ||
//GO(XML_SetEncoding, | ||
//GO(XML_SetEndCdataSectionHandler, | ||
//GO(XML_SetEndDoctypeDeclHandler, | ||
//GO(XML_SetEndElementHandler, | ||
//GO(XML_SetEndNamespaceDeclHandler, | ||
//GO(XML_SetEntityDeclHandler, | ||
//GO(XML_SetExternalEntityRefHandler, | ||
//GO(XML_SetExternalEntityRefHandlerArg, | ||
//GO(XML_SetHashSalt, | ||
//GO(XML_SetNamespaceDeclHandler, | ||
//GO(XML_SetNotationDeclHandler, | ||
//GO(XML_SetNotStandaloneHandler, | ||
//GO(XML_SetParamEntityParsing, | ||
//GO(XML_SetProcessingInstructionHandler, | ||
//GO(XML_SetReturnNSTriplet, | ||
//GO(XML_SetSkippedEntityHandler, | ||
//GO(XML_SetStartCdataSectionHandler, | ||
//GO(XML_SetStartDoctypeDeclHandler, | ||
//GO(XML_SetStartElementHandler, | ||
//GO(XML_SetStartNamespaceDeclHandler, | ||
//GO(XML_SetUnknownEncodingHandler, | ||
//GO(XML_SetUnparsedEntityDeclHandler, | ||
GO(XML_SetUserData, vFpp) | ||
//GO(XML_SetXmlDeclHandler, | ||
//GO(XML_StopParser, | ||
//GO(XML_UseForeignDTD, | ||
//GO(XML_UseParserAsHandlerArg, |