mirror of
https://github.com/ptitSeb/box86.git
synced 2026-11-13 17:11:29 -10:00
Large rework on Symbol relocation/resolution. Plus a big bunch of wrapped functions
This commit is contained in:
1 parent
fbddeda48a
commit
a216bc3140
26 files changed
+618
-205
No files matched your search
Executable
+94
@@ -0,0 +1,94 @@
|
||||
#ifndef __CPU_INFO__H_
|
||||
#define __CPU_INFO__H_
|
||||
enum ProcessorVendors {
|
||||
VENDOR_INTEL = 1,
|
||||
VENDOR_AMD,
|
||||
VENDOR_OTHER,
|
||||
VENDOR_MAX
|
||||
};
|
||||
|
||||
enum ProcessorTypes {
|
||||
INTEL_ATOM = 1,
|
||||
INTEL_CORE2,
|
||||
INTEL_COREI7,
|
||||
AMDFAM10H,
|
||||
AMDFAM15H,
|
||||
INTEL_i386,
|
||||
INTEL_i486,
|
||||
INTEL_PENTIUM,
|
||||
INTEL_PENTIUM_PRO,
|
||||
INTEL_PENTIUM_II,
|
||||
INTEL_PENTIUM_III,
|
||||
INTEL_PENTIUM_IV,
|
||||
INTEL_PENTIUM_M,
|
||||
INTEL_CORE_DUO,
|
||||
INTEL_XEONPHI,
|
||||
INTEL_X86_64,
|
||||
INTEL_NOCONA,
|
||||
INTEL_PRESCOTT,
|
||||
AMD_i486,
|
||||
AMDPENTIUM,
|
||||
AMDATHLON,
|
||||
AMDFAM14H,
|
||||
AMDFAM16H,
|
||||
CPU_TYPE_MAX
|
||||
};
|
||||
|
||||
enum ProcessorSubtypes {
|
||||
INTEL_COREI7_NEHALEM = 1,
|
||||
INTEL_COREI7_WESTMERE,
|
||||
INTEL_COREI7_SANDYBRIDGE,
|
||||
AMDFAM10H_BARCELONA,
|
||||
AMDFAM10H_SHANGHAI,
|
||||
AMDFAM10H_ISTANBUL,
|
||||
AMDFAM15H_BDVER1,
|
||||
AMDFAM15H_BDVER2,
|
||||
INTEL_PENTIUM_MMX,
|
||||
INTEL_CORE2_65,
|
||||
INTEL_CORE2_45,
|
||||
INTEL_COREI7_IVYBRIDGE,
|
||||
INTEL_COREI7_HASWELL,
|
||||
INTEL_COREI7_BROADWELL,
|
||||
INTEL_COREI7_SKYLAKE,
|
||||
INTEL_COREI7_SKYLAKE_AVX512,
|
||||
INTEL_ATOM_BONNELL,
|
||||
INTEL_ATOM_SILVERMONT,
|
||||
INTEL_KNIGHTS_LANDING,
|
||||
AMDPENTIUM_K6,
|
||||
AMDPENTIUM_K62,
|
||||
AMDPENTIUM_K63,
|
||||
AMDPENTIUM_GEODE,
|
||||
AMDATHLON_TBIRD,
|
||||
AMDATHLON_MP,
|
||||
AMDATHLON_XP,
|
||||
AMDATHLON_K8SSE3,
|
||||
AMDATHLON_OPTERON,
|
||||
AMDATHLON_FX,
|
||||
AMDATHLON_64,
|
||||
AMD_BTVER1,
|
||||
AMD_BTVER2,
|
||||
AMDFAM15H_BDVER3,
|
||||
AMDFAM15H_BDVER4,
|
||||
CPU_SUBTYPE_MAX
|
||||
};
|
||||
|
||||
enum ProcessorFeatures {
|
||||
FEATURE_CMOV = 0,
|
||||
FEATURE_MMX,
|
||||
FEATURE_POPCNT,
|
||||
FEATURE_SSE,
|
||||
FEATURE_SSE2,
|
||||
FEATURE_SSE3,
|
||||
FEATURE_SSSE3,
|
||||
FEATURE_SSE4_1,
|
||||
FEATURE_SSE4_2,
|
||||
FEATURE_AVX,
|
||||
FEATURE_AVX2,
|
||||
FEATURE_AVX512,
|
||||
FEATURE_AVX512SAVE,
|
||||
FEATURE_MOVBE,
|
||||
FEATURE_ADX,
|
||||
FEATURE_EM64T
|
||||
};
|
||||
|
||||
#endif
|
||||
+79
-32
@@ -14,6 +14,8 @@
|
||||
#include "bridge.h"
|
||||
#include "wrapper.h"
|
||||
#include "box86context.h"
|
||||
#include "library.h"
|
||||
#include "x86emu.h"
|
||||
|
||||
void FreeElfHeader(elfheader_t** head)
|
||||
{
|
||||
@@ -148,32 +150,45 @@ int RelocateElfREL(lib_t *maplib, elfheader_t* head, int cnt, Elf32_Rel *rel)
|
||||
uintptr_t offs = 0;
|
||||
uint32_t sz = 0;
|
||||
uintptr_t end = 0;
|
||||
GetGlobalSymbolStartEnd(maplib, symname, &offs, &end, 0);
|
||||
int t = ELF32_R_TYPE(rel[i].r_info);
|
||||
switch(t) {
|
||||
case R_386_NONE:
|
||||
case R_386_PC32:
|
||||
// can be ignored
|
||||
printf_log(LOG_DEBUG, "Ignoring %s @%p (%p)\n", DumpRelType(t), p, (void*)(p?(*p):0));
|
||||
break;
|
||||
case R_386_PC32:
|
||||
offs = (*p) + (offs - (uintptr_t)p);
|
||||
printf_log(LOG_DEBUG, "Apply R_386_PC32 @%p with sym=%s (%p -> %p)\n", p, symname, *(void**)p, (void*)(*(uintptr_t*)p+offs));
|
||||
*p += offs;
|
||||
break;
|
||||
case R_386_GLOB_DAT:
|
||||
offs = FindGlobalSymbol(maplib, symname); // Data and not symbol
|
||||
printf_log(LOG_DEBUG, "Apply R_386_GLOB_DAT @%p (%p -> %p) on sym=%s\n", p, (void*)(p?(*p):0), (void*)offs, symname);
|
||||
*p = offs;
|
||||
|
||||
if (!offs) {
|
||||
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_GLOB_DAT @%p (%p)\n", symname, p, *(void**)p);
|
||||
// return -1;
|
||||
} else {
|
||||
printf_log(LOG_DEBUG, "Apply R_386_GLOB_DAT @%p (%p -> %p) on sym=%s\n", p, (void*)(p?(*p):0), (void*)offs, symname);
|
||||
*p = offs;
|
||||
}
|
||||
break;
|
||||
case R_386_RELATIVE:
|
||||
// is this correct????
|
||||
printf_log(LOG_DEBUG, "Apply R_386_RELATIVE @%p (%p -> %p)\n", p, *(void**)p, (void*)((*p)+(uintptr_t)head->memory - head->paddr));
|
||||
*p += (uintptr_t)head->memory - head->paddr;
|
||||
printf_log(LOG_DEBUG, "Apply R_386_RELATIVE @%p (%p -> %p)\n", p, *(void**)p, (void*)((*p)+head->delta));
|
||||
*p += head->delta;
|
||||
break;
|
||||
case R_386_32:
|
||||
printf_log(LOG_DEBUG, "Apply R_386_32 @%p with sym=%s (%p -> %p)\n", p, symname, *(void**)p, (void*)offs);
|
||||
*p = offs;
|
||||
if (!offs) {
|
||||
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_32 @%p (%p)\n", symname, p, *(void**)p);
|
||||
// return -1;
|
||||
} else {
|
||||
printf_log(LOG_DEBUG, "Apply R_386_32 @%p with sym=%s (%p -> %p)\n", p, symname, *(void**)p, (void*)offs);
|
||||
*p += offs;
|
||||
}
|
||||
break;
|
||||
//case R_386_TLS_DTPMOD32:
|
||||
// try to use _dl_next_tls_modid() ?
|
||||
case R_386_TLS_DTPOFF32:
|
||||
case R_386_JMP_SLOT:
|
||||
offs = FindGlobalSymbol(maplib, symname);
|
||||
if (!offs) {
|
||||
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_JMP_SLOT @%p (%p)\n", symname, p, *(void**)p);
|
||||
// return -1;
|
||||
@@ -187,10 +202,16 @@ int RelocateElfREL(lib_t *maplib, elfheader_t* head, int cnt, Elf32_Rel *rel)
|
||||
}
|
||||
break;
|
||||
case R_386_COPY:
|
||||
GetGlobalSymbolStartEnd(maplib, symname, &offs, &end);
|
||||
if(offs) {
|
||||
printf_log(LOG_DEBUG, "Apply R_386_COPY @%p with sym=%s, @%p size=%d\n", p, symname, (void*)offs, sym->st_size);
|
||||
GetGlobalSymbolStartEnd(maplib, symname, &offs, &end, 1); // get original copy if any
|
||||
printf_log(LOG_DEBUG, "Apply R_386_COPY @%p with sym=%s, @%p size=%d (", p, symname, (void*)offs, sym->st_size);
|
||||
memmove(p, (void*)offs, sym->st_size);
|
||||
if(LOG_DEBUG<=box86_log) {
|
||||
uint32_t*k = (uint32_t*)p;
|
||||
for (int i=0; i<sym->st_size; i+=4, ++k)
|
||||
printf("%s0x%08X", i?" ":"", *k);
|
||||
printf_log(LOG_DEBUG, ")\n");
|
||||
}
|
||||
} else {
|
||||
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_COPY @%p (%p)\n", symname, p, *(void**)p);
|
||||
}
|
||||
@@ -217,11 +238,11 @@ int RelocateElfRELA(lib_t *maplib, elfheader_t* head, int cnt, Elf32_Rela *rela)
|
||||
// can be ignored
|
||||
break;
|
||||
case R_386_COPY:
|
||||
GetGlobalSymbolStartEnd(maplib, symname, &offs, &end);
|
||||
GetGlobalSymbolStartEnd(maplib, symname, &offs, &end,1);
|
||||
if(offs) {
|
||||
// add r_addend to p?
|
||||
printf_log(LOG_DEBUG, "Apply R_386_COPY @%p with sym=%s, @%p size=%d\n", p, symname, (void*)offs, sym->st_size);
|
||||
memcpy(p, (void*)offs, sym->st_size);
|
||||
memcpy(p, (void*)(offs+rela[i].r_addend), sym->st_size);
|
||||
} else {
|
||||
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_COPY @%p (%p)\n", symname, p, *(void**)p);
|
||||
}
|
||||
@@ -348,38 +369,34 @@ void AddGlobalsSymbols(kh_mapsymbols_t* mapsymbols, elfheader_t* h)
|
||||
{
|
||||
printf_log(LOG_DUMP, "Will look for Symbol to add in SymTable(%d)\n", h->numSymTab);
|
||||
for (int i=0; i<h->numSymTab; ++i) {
|
||||
// TODO: this "17" & "18" is probably defined somewhere. 34 seems to be Weak function
|
||||
if(( (h->SymTab[i].st_info == 18)
|
||||
|| (h->SymTab[i].st_info == 17)
|
||||
|| (h->SymTab[i].st_info == 34)
|
||||
|| (h->SymTab[i].st_info == 33)
|
||||
|| (h->SymTab[i].st_info == 22)
|
||||
|| (h->SymTab[i].st_info == 2))
|
||||
const char * symname = h->StrTab+h->SymTab[i].st_name;
|
||||
if(((h->SymTab[i].st_info & 2) || (h->SymTab[i].st_info == 33) || (h->SymTab[i].st_info == 17)
|
||||
|| (h->SymTab[i].st_info == 161 && !FindSymbol(mapsymbols, symname)) )
|
||||
&& (h->SymTab[i].st_other==0) && (h->SymTab[i].st_shndx!=0)) {
|
||||
const char * symname = h->StrTab+h->SymTab[i].st_name;
|
||||
if(!h->SymTab[i].st_value && FindSymbol(mapsymbols, symname))
|
||||
break;
|
||||
uintptr_t offs = h->SymTab[i].st_value + h->delta;
|
||||
uint32_t sz = h->SymTab[i].st_size;
|
||||
printf_log(LOG_DUMP, "Adding Symbol \"%s\" with offset=%p sz=%d\n", symname, (void*)offs, sz);
|
||||
AddSymbol(mapsymbols, symname, offs, sz);
|
||||
}
|
||||
}
|
||||
|
||||
printf_log(LOG_DUMP, "Will look for Symbol to add in DynSym (%d)\n", h->numDynSym);
|
||||
for (int i=0; i<h->numDynSym; ++i) {
|
||||
// TODO: this "17" & "18" is probably defined somewhere. 34 seems to be Weak function
|
||||
if(( (h->DynSym[i].st_info == 18)
|
||||
|| (h->DynSym[i].st_info == 17)
|
||||
|| (h->DynSym[i].st_info == 34)
|
||||
|| (h->DynSym[i].st_info == 33)
|
||||
|| (h->DynSym[i].st_info == 22)
|
||||
|| (h->DynSym[i].st_info == 2))
|
||||
const char * symname = h->DynStr+h->DynSym[i].st_name;
|
||||
if(((h->DynSym[i].st_info & 2) || (h->DynSym[i].st_info == 33) || (h->DynSym[i].st_info == 17)
|
||||
|| (h->DynSym[i].st_info == 161 && !FindSymbol(mapsymbols, symname)))
|
||||
&& (h->DynSym[i].st_other==0) && (h->DynSym[i].st_shndx!=0 && h->DynSym[i].st_shndx<62521)) {
|
||||
const char * symname = h->DynStr+h->DynSym[i].st_name;
|
||||
if(!h->DynSym[i].st_value && FindSymbol(mapsymbols, symname))
|
||||
break;
|
||||
uintptr_t offs = h->DynSym[i].st_value + h->delta;
|
||||
uint32_t sz = h->DynSym[i].st_size;
|
||||
printf_log(LOG_DUMP, "Adding Symbol \"%s\" with offset=%p sz=%d\n", symname, (void*)offs, sz);
|
||||
AddSymbol(mapsymbols, symname, offs, sz);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -396,7 +413,7 @@ $PLATFORM – Expands to the processor type of the current machine (see the
|
||||
uname(1) man page description of the -i option). For more details of this token
|
||||
expansion, see “System Specific Shared Objects”
|
||||
*/
|
||||
int LoadNeededLib(elfheader_t* h, lib_t *maplib, box86context_t *box86, int pltNow)
|
||||
int LoadNeededLib(elfheader_t* h, lib_t *maplib, box86context_t *box86, x86emu_t* emu)
|
||||
{
|
||||
DumpDynamicNeeded(h);
|
||||
// reverse order on needed libs
|
||||
@@ -404,10 +421,40 @@ int LoadNeededLib(elfheader_t* h, lib_t *maplib, box86context_t *box86, int pltN
|
||||
if(h->Dynamic[i].d_tag==DT_NEEDED) {
|
||||
char *needed = h->DynStrTab+h->delta+h->Dynamic[i].d_un.d_val;
|
||||
// TODO: Add LD_LIBRARY_PATH and RPATH Handling
|
||||
if(AddNeededLib(maplib, needed, box86, pltNow)) {
|
||||
if(AddNeededLib(maplib, needed, box86, emu)) {
|
||||
printf_log(LOG_INFO, "Error loading needed lib: \"%s\"\n", needed);
|
||||
return 1; //error...
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RunElfInit(elfheader_t* h, x86emu_t *emu)
|
||||
{
|
||||
if(h->init_done || !h->initentry)
|
||||
return;
|
||||
uintptr_t p = h->initentry + h->delta;
|
||||
printf_log(LOG_DEBUG, "Calling Init for %s @%p\n", ElfName(h), (void*)p);
|
||||
EmuCall(emu, p);
|
||||
h->init_done = 1;
|
||||
return;
|
||||
}
|
||||
void RunElfFini(elfheader_t* h, x86emu_t *emu)
|
||||
{
|
||||
if(h->fini_done || !h->finientry)
|
||||
return;
|
||||
uintptr_t p = h->finientry + h->delta;
|
||||
printf_log(LOG_DEBUG, "Calling Fini for %s @%p\n", ElfName(h), (void*)p);
|
||||
EmuCall(emu, p);
|
||||
h->fini_done = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
uintptr_t GetElfInit(elfheader_t* h)
|
||||
{
|
||||
return h->initentry + h->delta;
|
||||
}
|
||||
uintptr_t GetElfFini(elfheader_t* h)
|
||||
{
|
||||
return h->finientry + h->delta;
|
||||
}
|
||||
+6
-1
@@ -6,6 +6,7 @@ typedef struct elfheader_s elfheader_t;
|
||||
typedef struct lib_s lib_t;
|
||||
typedef struct kh_mapsymbols_s kh_mapsymbols_t;
|
||||
typedef struct box86context_s box86context_t;
|
||||
typedef struct x86emu_s x86emu_t;
|
||||
|
||||
void* LoadAndCheckElfHeader(FILE* f, const char* name, int exec); // exec : 0 = lib, 1 = exec
|
||||
void FreeElfHeader(elfheader_t** head);
|
||||
@@ -22,6 +23,10 @@ void CalcStack(elfheader_t* h, uint32_t* stacksz, int* stackalign);
|
||||
uintptr_t GetEntryPoint(lib_t* maplib, elfheader_t* h);
|
||||
uintptr_t GetLastByte(elfheader_t* h);
|
||||
void AddGlobalsSymbols(kh_mapsymbols_t* mapsymbols, elfheader_t* h);
|
||||
int LoadNeededLib(elfheader_t* h, lib_t *maplib, box86context_t* box86, int pltNow);
|
||||
int LoadNeededLib(elfheader_t* h, lib_t *maplib, box86context_t* box86, x86emu_t* emu);
|
||||
uintptr_t GetElfInit(elfheader_t* h);
|
||||
uintptr_t GetElfFini(elfheader_t* h);
|
||||
void RunElfInit(elfheader_t* h, x86emu_t *emu);
|
||||
void RunElfFini(elfheader_t* h, x86emu_t *emu);
|
||||
|
||||
#endif //__ELF_LOADER_H_
|
||||
@@ -24,6 +24,8 @@ struct elfheader_s {
|
||||
intptr_t delta; // should be 0
|
||||
|
||||
uintptr_t entrypoint;
|
||||
uintptr_t initentry;
|
||||
uintptr_t finientry;
|
||||
|
||||
uintptr_t rel;
|
||||
int relsz;
|
||||
@@ -45,6 +47,9 @@ struct elfheader_s {
|
||||
uint32_t stacksz;
|
||||
int stackalign;
|
||||
|
||||
int init_done;
|
||||
int fini_done;
|
||||
|
||||
char* memory; // char* and not void* to allow math on memory pointer
|
||||
};
|
||||
|
||||
|
||||
@@ -250,6 +250,18 @@ void* LoadAndCheckElfHeader(FILE* f, const char* name, int exec)
|
||||
h->got = h->SHEntries[ii].sh_addr;
|
||||
printf_log(LOG_DEBUG, "The GOT Table is at address %p\n", (void*)h->got);
|
||||
}
|
||||
// look for .init entry point
|
||||
ii = FindSection(h->SHEntries, h->numSHEntries, h->SHStrTab, ".init");
|
||||
if(ii) {
|
||||
h->initentry = h->SHEntries[ii].sh_addr;
|
||||
printf_log(LOG_DEBUG, "The .init is at address %p\n", (void*)h->initentry);
|
||||
}
|
||||
// look for .fini entry point
|
||||
ii = FindSection(h->SHEntries, h->numSHEntries, h->SHStrTab, ".fini");
|
||||
if(ii) {
|
||||
h->finientry = h->SHEntries[ii].sh_addr;
|
||||
printf_log(LOG_DEBUG, "The .fini is at address %p\n", (void*)h->finientry);
|
||||
}
|
||||
|
||||
LoadNamedSection(f, h->SHEntries, h->numSHEntries, h->SHStrTab, ".dynstr", "DynSym Strings", SHT_STRTAB, (void**)&h->DynStr, NULL);
|
||||
LoadNamedSection(f, h->SHEntries, h->numSHEntries, h->SHStrTab, ".dynsym", "DynSym", SHT_DYNSYM, (void**)&h->DynSym, &h->numDynSym);
|
||||
|
||||
+24
-11
@@ -59,7 +59,7 @@ library_t* getLib(lib_t* maplib, const char* path)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int AddNeededLib(lib_t* maplib, const char* path, box86context_t* box86, int pltNow)
|
||||
int AddNeededLib(lib_t* maplib, const char* path, box86context_t* box86, x86emu_t* emu)
|
||||
{
|
||||
printf_log(LOG_DEBUG, "Trying to add \"%s\" to maplib\n", path);
|
||||
// first check if lib is already loaded
|
||||
@@ -82,7 +82,7 @@ int AddNeededLib(lib_t* maplib, const char* path, box86context_t* box86, int plt
|
||||
maplib->libraries[maplib->libsz].lib = lib;
|
||||
maplib->libraries[maplib->libsz].name = GetNameLib(lib);
|
||||
++maplib->libsz;
|
||||
if(FinalizeLibrary(lib, pltNow)) {
|
||||
if(FinalizeLibrary(lib, emu)) {
|
||||
printf_log(LOG_DEBUG, "Faillure to finalizing lib => fail\n");
|
||||
return 1; //Error
|
||||
}
|
||||
@@ -100,23 +100,34 @@ library_t* GetLib(lib_t* maplib, const char* name)
|
||||
uintptr_t FindGlobalSymbol(lib_t *maplib, const char* name)
|
||||
{
|
||||
uintptr_t start = 0, end = 0;
|
||||
if(GetSymbolStartEnd(maplib->mapsymbols, name, &start, &end)) // look in own symbols first
|
||||
if(GetGlobalSymbolStartEnd(maplib, name, &start, &end, 0))
|
||||
return start;
|
||||
for(int i=0; i<maplib->libsz; ++i) {
|
||||
if(GetLibSymbolStartEnd(maplib->libraries[i].lib, name, &start, &end))
|
||||
return start;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end)
|
||||
int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, int self)
|
||||
{
|
||||
if(GetSymbolStartEnd(maplib->mapsymbols, name, start, end)) // look in own symbols first
|
||||
return 1;
|
||||
if(!self)
|
||||
if(GetSymbolStartEnd(maplib->mapsymbols, name, start, end))
|
||||
if(*start)
|
||||
return 1;
|
||||
for(int i=0; i<maplib->libsz; ++i) {
|
||||
if(GetLibSymbolStartEnd(maplib->libraries[i].lib, name, start, end))
|
||||
return 1;
|
||||
if(*start)
|
||||
return 1;
|
||||
}
|
||||
if(self)
|
||||
if(GetSymbolStartEnd(maplib->mapsymbols, name, start, end))
|
||||
if(*start)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetLocalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end)
|
||||
{
|
||||
if(GetSymbolStartEnd(maplib->mapsymbols, name, start, end))
|
||||
if(*start)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -130,6 +141,8 @@ void AddSymbol(kh_mapsymbols_t *mapsymbols, const char* name, uintptr_t addr, ui
|
||||
uintptr_t FindSymbol(kh_mapsymbols_t *mapsymbols, const char* name)
|
||||
{
|
||||
khint_t k = kh_get(mapsymbols, mapsymbols, name);
|
||||
if(k==kh_end(mapsymbols))
|
||||
return 0;
|
||||
return kh_val(mapsymbols, k).offs;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -8,7 +8,7 @@ typedef struct library_s library_t;
|
||||
typedef struct kh_mapsymbols_s kh_mapsymbols_t;
|
||||
typedef struct dlprivate_s dlprivate_t;
|
||||
typedef struct box86context_s box86context_t;
|
||||
|
||||
typedef struct x86emu_s x86emu_t;
|
||||
|
||||
lib_t *NewLibrarian();
|
||||
void FreeLibrarian(lib_t **maplib);
|
||||
@@ -16,10 +16,11 @@ dlprivate_t *NewDLPrivate();
|
||||
void FreeDLPrivate(dlprivate_t **lib);
|
||||
|
||||
kh_mapsymbols_t* GetMapSymbol(lib_t* maplib);
|
||||
int AddNeededLib(lib_t* maplib, const char* path, box86context_t* box86, int pltNow); // 0=success, 1=error
|
||||
int AddNeededLib(lib_t* maplib, const char* path, box86context_t* box86, x86emu_t* emu); // 0=success, 1=error
|
||||
library_t* GetLib(lib_t* maplib, const char* name);
|
||||
uintptr_t FindGlobalSymbol(lib_t *maplib, const char* name);
|
||||
int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end);
|
||||
int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, int self);
|
||||
int GetLocalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end);
|
||||
|
||||
void AddSymbol(kh_mapsymbols_t *mapsymbols, const char* name, uintptr_t addr, uint32_t sz);
|
||||
uintptr_t FindSymbol(kh_mapsymbols_t *mapsymbols, const char* name);
|
||||
|
||||
+32
-4
@@ -195,14 +195,14 @@ library_t *NewLibrary(const char* path, box86context_t* context)
|
||||
|
||||
return lib;
|
||||
}
|
||||
int FinalizeLibrary(library_t* lib, int pltNow)
|
||||
int FinalizeLibrary(library_t* lib, x86emu_t* emu)
|
||||
{
|
||||
if(lib->type==1) {
|
||||
elfheader_t *elf_header = lib->context->elfs[lib->priv.n.elf_index];
|
||||
// add symbols
|
||||
AddGlobalsSymbols(lib->priv.n.mapsymbols, elf_header);
|
||||
// Call librarian to load all dependant elf
|
||||
if(LoadNeededLib(elf_header, lib->context->maplib, lib->context, pltNow)) {
|
||||
if(LoadNeededLib(elf_header, lib->context->maplib, lib->context, emu)) {
|
||||
printf_log(LOG_NONE, "Error: loading needed libs in elf %s\n", lib->name);
|
||||
return 1;
|
||||
}
|
||||
@@ -211,8 +211,8 @@ int FinalizeLibrary(library_t* lib, int pltNow)
|
||||
printf_log(LOG_NONE, "Error: relocating symbols in elf %s\n", lib->name);
|
||||
return 1;
|
||||
}
|
||||
if(pltNow)
|
||||
RelocateElfPlt(lib->context, lib->context->maplib, elf_header);
|
||||
RelocateElfPlt(lib->context, lib->context->maplib, elf_header);
|
||||
RunElfInit(elf_header, emu);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -238,6 +238,8 @@ void FreeLibrary(library_t **lib)
|
||||
kh_destroy(symbolmap, (*lib)->symbolmap);
|
||||
if((*lib)->datamap)
|
||||
kh_destroy(datamap, (*lib)->datamap);
|
||||
if((*lib)->mydatamap)
|
||||
kh_destroy(datamap, (*lib)->mydatamap);
|
||||
if((*lib)->mysymbolmap)
|
||||
kh_destroy(symbolmap, (*lib)->mysymbolmap);
|
||||
if((*lib)->symbol2map)
|
||||
@@ -292,6 +294,13 @@ int GetLibSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uin
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetElfIndex(library_t* lib)
|
||||
{
|
||||
if(!lib || lib->type!=1)
|
||||
return -1;
|
||||
return lib->priv.n.elf_index;
|
||||
}
|
||||
|
||||
int getSymbolInMaps(library_t*lib, const char* name, uintptr_t *addr, uint32_t *size)
|
||||
{
|
||||
khint_t k;
|
||||
@@ -308,6 +317,25 @@ int getSymbolInMaps(library_t*lib, const char* name, uintptr_t *addr, uint32_t *
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// check in mydatamap
|
||||
k = kh_get(datamap, lib->mydatamap, name);
|
||||
if (k!=kh_end(lib->mydatamap)) {
|
||||
char buff[200];
|
||||
if(lib->altmy)
|
||||
strcpy(buff, lib->altmy);
|
||||
else
|
||||
strcpy(buff, "my_");
|
||||
strcat(buff, name);
|
||||
symbol = dlsym(lib->priv.w.box86lib, buff);
|
||||
if(!symbol)
|
||||
printf_log(LOG_NONE, "Warning, data %s not found\n", buff);
|
||||
if(symbol) {
|
||||
// found!
|
||||
*addr = (uintptr_t)symbol;
|
||||
*size = kh_value(lib->mydatamap, k);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// check in mysymbolmap
|
||||
k = kh_get(symbolmap, lib->mysymbolmap, name);
|
||||
if (k!=kh_end(lib->mysymbolmap)) {
|
||||
|
||||
+4
-1
@@ -5,9 +5,10 @@
|
||||
typedef struct library_s library_t;
|
||||
typedef struct kh_symbolmap_s kh_symbolmap_t;
|
||||
typedef struct box86context_s box86context_t;
|
||||
typedef struct x86emu_s x86emu_t;
|
||||
|
||||
library_t *NewLibrary(const char* path, box86context_t* box86);
|
||||
int FinalizeLibrary(library_t* lib, int pltNow);
|
||||
int FinalizeLibrary(library_t* lib, x86emu_t* emu);
|
||||
void FreeLibrary(library_t **lib);
|
||||
|
||||
char* GetNameLib(library_t *lib);
|
||||
@@ -16,4 +17,6 @@ int GetLibSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uin
|
||||
kh_symbolmap_t * fillGLProcWrapper();
|
||||
void freeGLProcWrapper(kh_symbolmap_t** symbolmap);
|
||||
|
||||
int GetElfIndex(library_t* lib); // -1 if no elf (i.e. native)
|
||||
|
||||
#endif //__LIBRARY_H_
|
||||
@@ -59,6 +59,7 @@ typedef struct library_s {
|
||||
kh_symbolmap_t *mysymbolmap;
|
||||
kh_symbol2map_t *symbol2map;
|
||||
kh_datamap_t *datamap;
|
||||
kh_datamap_t *mydatamap;
|
||||
char *altmy; // to avoid duplicate symbol, like with SDL1/SDL2
|
||||
} library_t;
|
||||
|
||||
|
||||
+20
-20
@@ -222,30 +222,12 @@ int main(int argc, const char **argv, const char **env) {
|
||||
fclose(f);
|
||||
// export symbols
|
||||
AddGlobalsSymbols(GetMapSymbol(context->maplib), elf_header);
|
||||
// Call librarian to load all dependant elf
|
||||
if(LoadNeededLib(elf_header, context->maplib, context, 0)) {
|
||||
printf_log(LOG_NONE, "Error: loading needed libs in elf %s\n", context->argv[0]);
|
||||
FreeBox86Context(&context);
|
||||
return -1;
|
||||
}
|
||||
// finalize relocations
|
||||
if(RelocateElf(context->maplib, elf_header)) {
|
||||
printf_log(LOG_NONE, "Error: relocating symbols in elf %s\n", context->argv[0]);
|
||||
FreeBox86Context(&context);
|
||||
return -1;
|
||||
}
|
||||
// and handle PLT for all loaded Elf... (ignore error here)
|
||||
for(int i=0; i<context->elfsize; ++i)
|
||||
RelocateElfPlt(context, context->maplib, context->elfs[i]);
|
||||
|
||||
// get and alloc stack size and align
|
||||
if(CalcStackSize(context)) {
|
||||
printf_log(LOG_NONE, "Error: allocating stack\n");
|
||||
FreeBox86Context(&context);
|
||||
return -1;
|
||||
}
|
||||
// set entrypoint
|
||||
context->ep = GetEntryPoint(context->maplib, elf_header);
|
||||
// init x86 emu
|
||||
context->emu = NewX86Emu(context, context->ep, (uintptr_t)context->stack, context->stacksz);
|
||||
// stack setup is much more complicated then just that!
|
||||
@@ -254,7 +236,6 @@ int main(int argc, const char **argv, const char **env) {
|
||||
SetupX86Emu(context->emu, NULL, NULL);
|
||||
SetEAX(context->emu, context->argc);
|
||||
SetEBX(context->emu, (uint32_t)context->argv);
|
||||
|
||||
p = getenv("BOX86_TRACE");
|
||||
if(p) {
|
||||
setbuf(stdout, NULL);
|
||||
@@ -279,9 +260,28 @@ int main(int argc, const char **argv, const char **env) {
|
||||
}
|
||||
}
|
||||
|
||||
// Call librarian to load all dependant elf
|
||||
if(LoadNeededLib(elf_header, context->maplib, context, context->emu)) {
|
||||
printf_log(LOG_NONE, "Error: loading needed libs in elf %s\n", context->argv[0]);
|
||||
FreeBox86Context(&context);
|
||||
return -1;
|
||||
}
|
||||
if(RelocateElf(context->maplib, elf_header)) {
|
||||
printf_log(LOG_NONE, "Error: relocating symbols in elf %s\n", context->argv[0]);
|
||||
FreeBox86Context(&context);
|
||||
return -1;
|
||||
}
|
||||
// and handle PLT
|
||||
RelocateElfPlt(context, context->maplib, elf_header);
|
||||
// init...
|
||||
RunElfInit(elf_header, context->emu);
|
||||
|
||||
// get entrypoint
|
||||
context->ep = GetEntryPoint(context->maplib, elf_header);
|
||||
|
||||
// emulate!
|
||||
printf_log(LOG_DEBUG, "Start x86emu on Main\n");
|
||||
Run(context->emu);
|
||||
EmuCall(context->emu, context->ep);
|
||||
// Get EAX
|
||||
int ret = GetEAX(context->emu);
|
||||
printf_log(LOG_DEBUG, "Emulation finished, EAX=%d\n", ret);
|
||||
|
||||
@@ -78,6 +78,8 @@ int EXPORT my_pthread_key_create(x86emu_t* emu, void* key, void* dtor)
|
||||
emu->quit = 1;
|
||||
return -1;
|
||||
}
|
||||
EXPORT int my___pthread_key_create(x86emu_t* emu, void* key, void* dtor) __attribute__((alias("my_pthread_key_create")));
|
||||
|
||||
|
||||
KHASH_MAP_INIT_INT(once, int)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define DATA(N, S)
|
||||
#define DATAV(N, S)
|
||||
#define DATAB(N, S)
|
||||
#define DATAM(N, S)
|
||||
|
||||
// #define the 4 maps first
|
||||
#undef GO
|
||||
@@ -55,6 +56,17 @@ static const map_onesymbol2_t MAPNAME(symbol2map)[] = {
|
||||
static const map_onedata_t MAPNAME(datamap)[] = {
|
||||
#include PRIVATE(LIBNAME)
|
||||
};
|
||||
#undef DATA
|
||||
#undef DATAV
|
||||
#undef DATAB
|
||||
#define DATA(N, S)
|
||||
#define DATAV(N, S)
|
||||
#define DATAB(N, S)
|
||||
#undef DATAM
|
||||
#define DATAM(N, S) {#N, S, 0},
|
||||
static const map_onedata_t MAPNAME(mydatamap)[] = {
|
||||
#include PRIVATE(LIBNAME)
|
||||
};
|
||||
#include "wrappedlib_undefs.h"
|
||||
|
||||
|
||||
@@ -76,6 +88,7 @@ int FUNC(_init)(library_t* lib, box86context_t* box86)
|
||||
lib->mysymbolmap = kh_init(symbolmap);
|
||||
lib->symbol2map = kh_init(symbol2map);
|
||||
lib->datamap = kh_init(datamap);
|
||||
lib->mydatamap = kh_init(datamap);
|
||||
|
||||
khint_t k;
|
||||
int ret;
|
||||
@@ -103,6 +116,11 @@ int FUNC(_init)(library_t* lib, box86context_t* box86)
|
||||
k = kh_put(datamap, lib->datamap, MAPNAME(datamap)[i].name, &ret);
|
||||
kh_value(lib->datamap, k) = MAPNAME(datamap)[i].sz;
|
||||
}
|
||||
cnt = sizeof(MAPNAME(mydatamap))/sizeof(map_onedata_t);
|
||||
for (int i=0; i<cnt; ++i) {
|
||||
k = kh_put(datamap, lib->mydatamap, MAPNAME(datamap)[i].name, &ret);
|
||||
kh_value(lib->mydatamap, k) = MAPNAME(mydatamap)[i].sz;
|
||||
}
|
||||
#ifdef CUSTOM_INIT
|
||||
CUSTOM_INIT
|
||||
#endif
|
||||
|
||||
@@ -19,3 +19,5 @@
|
||||
// data, Uninitialized (type B)
|
||||
#undef DATAB
|
||||
|
||||
// data, "my_" type
|
||||
#undef DATAM
|
||||
@@ -73,6 +73,15 @@ int EXPORT my___cxa_atexit(x86emu_t* emu, void* p)
|
||||
{
|
||||
AddCleanup(emu, p);
|
||||
}
|
||||
void EXPORT my___cxa_finalize(x86emu_t* emu, void* p)
|
||||
{
|
||||
if(!p) {
|
||||
// p is null, call (and remove) all Cleanup functions
|
||||
CallAllCleanup(emu);
|
||||
} else {
|
||||
CallCleanup(emu, p);
|
||||
}
|
||||
}
|
||||
int EXPORT my_atexit(x86emu_t* emu, void *p)
|
||||
{
|
||||
AddCleanup(emu, p);
|
||||
@@ -213,6 +222,19 @@ EXPORT int my_sprintf(x86emu_t* emu, void* buff, void * fmt, void * b, va_list V
|
||||
}
|
||||
EXPORT int my___sprintf_chk(x86emu_t* emu, void* buff, void * fmt, void * b, va_list V) __attribute__((alias("my_sprintf")));
|
||||
|
||||
EXPORT int my_vsprintf(x86emu_t* emu, void* buff, void * fmt, void * b, va_list V) {
|
||||
#ifndef NOALIGN
|
||||
// need to align on arm
|
||||
myStackAlign((const char*)fmt, *(uint32_t**)b, emu->scratch);
|
||||
void* f = vsprintf;
|
||||
int r = ((iFppp_t)f)(buff, fmt, emu->scratch);
|
||||
return r;
|
||||
#else
|
||||
return vsprintf((char*)buff, (char*)fmt, V);
|
||||
#endif
|
||||
}
|
||||
EXPORT int my___vsprintf_chk(x86emu_t* emu, void* buff, void * fmt, void * b, va_list V) __attribute__((alias("my_vsprintf")));
|
||||
|
||||
EXPORT int my_vsnprintf(x86emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) {
|
||||
#ifndef NOALIGN
|
||||
// need to align on arm
|
||||
@@ -254,6 +276,9 @@ EXPORT void my__ITM_addUserCommitAction(x86emu_t* emu, void* cb, uint32_t b, voi
|
||||
printf("warning _ITM_addUserCommitAction called\n");
|
||||
#endif
|
||||
}
|
||||
EXPORT void my__ITM_registerTMCloneTable(x86emu_t* emu, void* p, uint32_t s) {}
|
||||
EXPORT void my__ITM_deregisterTMCloneTable(x86emu_t* emu, void* p) {}
|
||||
|
||||
|
||||
EXPORT int my___fxstat64(x86emu_t *emu, int vers, int fd, void* buf)
|
||||
{
|
||||
@@ -301,10 +326,13 @@ EXPORT int32_t my_execvp(x86emu_t* emu, void* a, void* b, va_list v)
|
||||
}
|
||||
EXPORT int32_t my_execlp(x86emu_t* emu, void* a, void* b, va_list v) __attribute__((alias("my_execvp")));
|
||||
|
||||
EXPORT void my__Jv_RegisterClasses() {}
|
||||
|
||||
#define LIBNAME libc
|
||||
const char* libcName = "libc.so.6";
|
||||
|
||||
#define CUSTOM_INIT \
|
||||
InitCpuModel(); \
|
||||
box86->libclib = lib; \
|
||||
lib->priv.w.p2 = getLIBCMy(lib); \
|
||||
lib->priv.w.needed = 1; \
|
||||
@@ -315,6 +343,29 @@ const char* libcName = "libc.so.6";
|
||||
freeLIBCMy(lib->priv.w.p2); \
|
||||
free(lib->priv.w.p2);
|
||||
|
||||
EXPORT struct __processor_model
|
||||
{
|
||||
unsigned int __cpu_vendor;
|
||||
unsigned int __cpu_type;
|
||||
unsigned int __cpu_subtype;
|
||||
unsigned int __cpu_features[1];
|
||||
} my___cpu_model;
|
||||
|
||||
#include "cpu_info.h"
|
||||
void InitCpuModel()
|
||||
{
|
||||
// some pseudo random cpu info...
|
||||
my___cpu_model.__cpu_vendor = VENDOR_INTEL;
|
||||
my___cpu_model.__cpu_type = INTEL_PENTIUM_M;
|
||||
my___cpu_model.__cpu_subtype = 0; // N/A
|
||||
my___cpu_model.__cpu_features[0] = (1<<FEATURE_CMOV)
|
||||
| (1<<FEATURE_MMX)
|
||||
| (1<<FEATURE_SSE)
|
||||
| (1<<FEATURE_SSE2)
|
||||
| (1<<FEATURE_MOVBE)
|
||||
| (1<<FEATURE_ADX);
|
||||
}
|
||||
|
||||
|
||||
// define all standard library functions
|
||||
#include "wrappedlib_init.h"
|
||||
|
||||
+25
-22
@@ -114,7 +114,7 @@ GOW(calloc, pFuu)
|
||||
// cfsetispeed
|
||||
// cfsetospeed
|
||||
// cfsetspeed
|
||||
// chdir // Weak
|
||||
GOW(chdir, iFp)
|
||||
DATA(__check_rhosts_file, 4)
|
||||
// chflags
|
||||
// __chk_fail
|
||||
@@ -166,7 +166,8 @@ GO(__ctype_toupper_loc, pFv)
|
||||
// cuserid
|
||||
GOM(__cxa_atexit, iFEp)
|
||||
GOM(atexit, iFEp) // just in case
|
||||
// __cxa_finalize
|
||||
GOM(__cxa_finalize, vFEp)
|
||||
DATAM(__cpu_model, 16)
|
||||
//__cxa_thread_atexit_impl // need GOM
|
||||
// __cyg_profile_func_enter
|
||||
// __cyg_profile_func_exit
|
||||
@@ -337,7 +338,7 @@ GO(fileno, iFp)
|
||||
// __flbf
|
||||
// flistxattr
|
||||
// flock // Weak
|
||||
// flockfile // Weak
|
||||
GOW(flockfile, vFp)
|
||||
// _flushlbf // Weak
|
||||
// fmemopen
|
||||
// fmtmsg
|
||||
@@ -402,7 +403,7 @@ GO(ftello64, Ifp)
|
||||
// ftok
|
||||
// ftruncate // Weak
|
||||
// ftruncate64 // Weak
|
||||
// ftrylockfile // Weak
|
||||
GOW(ftrylockfile, iFp)
|
||||
// fts_children
|
||||
// fts_close
|
||||
// fts_open
|
||||
@@ -410,7 +411,7 @@ GO(ftello64, Ifp)
|
||||
// fts_set
|
||||
// ftw
|
||||
// ftw64
|
||||
// funlockfile // Weak
|
||||
GOW(funlockfile, vFp)
|
||||
// futimens
|
||||
// futimes // Weak
|
||||
// futimesat
|
||||
@@ -1310,7 +1311,7 @@ GO(read, iFipu)
|
||||
// readahead // Weak
|
||||
// __read_chk
|
||||
GOW(readdir, pFp)
|
||||
// readdir64
|
||||
GO(readdir64, pFp) // check if alignement is correct
|
||||
// readdir64_r
|
||||
GOW(readdir_r, iFppp)
|
||||
// readlink // Weak
|
||||
@@ -1345,7 +1346,7 @@ GOW(recvmsg, iFipi)
|
||||
GO(remove, iFp)
|
||||
// removexattr
|
||||
// remque
|
||||
// rename
|
||||
GO(rename, iFpp)
|
||||
// renameat
|
||||
// _res // type B
|
||||
// re_search // Weak
|
||||
@@ -1398,10 +1399,10 @@ GO(sched_getaffinity, iFiup)
|
||||
// sched_getcpu
|
||||
// __sched_getparam
|
||||
// sched_getparam // Weak
|
||||
// __sched_get_priority_max
|
||||
// sched_get_priority_max // Weak
|
||||
// __sched_get_priority_min
|
||||
// sched_get_priority_min // Weak
|
||||
GO(__sched_get_priority_max, iFi)
|
||||
GOW(sched_get_priority_max, iFi)
|
||||
GO(__sched_get_priority_min, iFi)
|
||||
GOW(sched_get_priority_min, iFi)
|
||||
// __sched_getscheduler
|
||||
// sched_getscheduler // Weak
|
||||
// sched_rr_get_interval // Weak
|
||||
@@ -1409,8 +1410,8 @@ GO(sched_setaffinity, iFiup)
|
||||
// sched_setparam // Weak
|
||||
// __sched_setscheduler
|
||||
// sched_setscheduler // Weak
|
||||
// __sched_yield
|
||||
// sched_yield // Weak
|
||||
GO(__sched_yield, iFv)
|
||||
GOW(sched_yield, iFv)
|
||||
// __secure_getenv
|
||||
// seed48
|
||||
// seed48_r // Weak
|
||||
@@ -1848,8 +1849,8 @@ GOM(__vprintf_chk, iFEvpVV)
|
||||
GOM(vsnprintf, iFEpupVV) // Weak
|
||||
GOM(__vsnprintf, iFEpupVV) // Weak
|
||||
GOM(__vsnprintf_chk, iFEpuvvpVV)
|
||||
// vsprintf // Weak
|
||||
// __vsprintf_chk
|
||||
GOM(vsprintf, iFEppVV) // Weak
|
||||
GOM(__vsprintf_chk, iFEpvvpp)
|
||||
// vsscanf // Weak
|
||||
// __vsscanf // Weak
|
||||
GOM(vswprintf, iFEpupVV) // Weak
|
||||
@@ -1936,7 +1937,7 @@ GOW(wcsnrtombs, uFppuup)
|
||||
// __wcstoll_internal
|
||||
// __wcstoll_l
|
||||
// wcstoll_l // Weak
|
||||
// wcstombs
|
||||
GO(wcstombs, uFppu)
|
||||
// __wcstombs_chk
|
||||
// wcstoq // Weak
|
||||
// wcstoul
|
||||
@@ -2069,16 +2070,18 @@ GOM(__xstat64, iFEipp)
|
||||
// forcing a custom __gmon_start__ that does nothing
|
||||
GOM(__gmon_start__, vFv)
|
||||
|
||||
GOM(_Jv_RegisterClasses, vFv) // dummy
|
||||
|
||||
// not found (libitm???), but it seems OK to declare dummies:
|
||||
/*
|
||||
GOM(_ZGTtnaX, pFu)
|
||||
GOM(_ZGTtdlPv, vFp)
|
||||
|
||||
GOM(_ITM_RU1, uFp)
|
||||
GOM(_ITM_RU4, uFp)
|
||||
//GOM(_ITM_RU8, UFp)
|
||||
GOM(_ITM_memcpyRtWn, vFppu)
|
||||
GOM(_ITM_memcpyRnWt, vFppu)
|
||||
GOM(_ITM_memcpyRtWn, vFppu) // register(2)
|
||||
GOM(_ITM_memcpyRnWt, vFppu) // register(2)
|
||||
GOM(_ITM_addUserCommitAction, vFEpup)
|
||||
*/
|
||||
GOM(_ITM_registerTMCloneTable, vFEpu)
|
||||
GOM(_ITM_deregisterTMCloneTable, vFEp)
|
||||
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -52,7 +52,7 @@ void* my_dlopen(x86emu_t* emu, void *filename, int flag)
|
||||
return (void*)(i+1);
|
||||
}
|
||||
// Then open the lib
|
||||
if(AddNeededLib(emu->context->maplib, rfilename, emu->context, 1)) {
|
||||
if(AddNeededLib(emu->context->maplib, rfilename, emu->context, emu)) {
|
||||
printf_log(LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ GOW(expf, fFf)
|
||||
// feupdateenv
|
||||
// finite // Weak
|
||||
// __finite
|
||||
// finitef // Weak
|
||||
// __finitef
|
||||
GOW(finitef, iFf)
|
||||
GO(__finitef, iFf)
|
||||
// finitel // Weak
|
||||
// __finitel
|
||||
GOW(floor, dFd)
|
||||
|
||||
@@ -6,15 +6,43 @@
|
||||
|
||||
#include "wrappedlibs.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "wrapper.h"
|
||||
#include "bridge.h"
|
||||
#include "library_private.h"
|
||||
#include "x86emu.h"
|
||||
#include "x86emu_private.h"
|
||||
#include "box86context.h"
|
||||
#include "librarian.h"
|
||||
|
||||
int my_pthread_create(x86emu_t *emu, void* t, void* attr, void* start_routine, void* arg); //implemented in thread.c
|
||||
int my_pthread_key_create(x86emu_t* emu, void* key, void* dtor);
|
||||
int my___pthread_key_create(x86emu_t* emu, void* key, void* dtor);
|
||||
int my_pthread_once(x86emu_t* emu, void* once, void* cb);
|
||||
|
||||
typedef int (*iFpp_t)(void*, void*);
|
||||
typedef int (*iFppu_t)(void*, void*, uint32_t);
|
||||
EXPORT int my_pthread_setname_np(x86emu_t* emu, void* t, void* n)
|
||||
{
|
||||
library_t* lib = GetLib(emu->context->maplib, "libpthread.so.0");
|
||||
if(!lib) return 0;
|
||||
void* f = dlsym(lib->priv.w.lib, "pthread_setname_np");
|
||||
if(f)
|
||||
return ((iFpp_t)f)(t, n);
|
||||
return 0;
|
||||
}
|
||||
EXPORT int my_pthread_getname_np(x86emu_t* emu, void* t, void* n, uint32_t s)
|
||||
{
|
||||
library_t* lib = GetLib(emu->context->maplib, "libpthread.so.0");
|
||||
if(!lib) return 0;
|
||||
void* f = dlsym(lib->priv.w.lib, "pthread_getname_np");
|
||||
if(f)
|
||||
return ((iFppu_t)f)(t, n, s);
|
||||
else
|
||||
strncpy((char*)n, "dummy", s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* libpthreadName = "libpthread.so.0";
|
||||
#define LIBNAME libpthread
|
||||
|
||||
|
||||
@@ -46,10 +46,10 @@ GO(pthread_cancel, iFi)
|
||||
// _pthread_cleanup_push
|
||||
// _pthread_cleanup_push_defer
|
||||
// __pthread_cleanup_routine
|
||||
// pthread_condattr_destroy
|
||||
GO(pthread_condattr_destroy, iFp)
|
||||
// pthread_condattr_getclock
|
||||
// pthread_condattr_getpshared
|
||||
// pthread_condattr_init
|
||||
GO(pthread_condattr_init, iFp)
|
||||
// pthread_condattr_setclock
|
||||
// pthread_condattr_setpshared
|
||||
GO(pthread_cond_broadcast, iFp)
|
||||
@@ -69,22 +69,23 @@ GO(pthread_equal, iFuu)
|
||||
// pthread_getschedparam
|
||||
// __pthread_getspecific
|
||||
GO(pthread_getspecific, pFu)
|
||||
GOM(pthread_getname_np, iFEppu) //not present on Pandora
|
||||
// __pthread_initialize_minimal
|
||||
GO(pthread_join, iFup)
|
||||
// __pthread_key_create
|
||||
GOM(__pthread_key_create, iFEpp)
|
||||
GOM(pthread_key_create, iFEpp)
|
||||
GO(pthread_key_delete, iFu)
|
||||
// pthread_kill
|
||||
// pthread_kill_other_threads_np
|
||||
// __pthread_mutexattr_destroy
|
||||
// pthread_mutexattr_destroy
|
||||
GO(__pthread_mutexattr_destroy, iFp)
|
||||
GO(pthread_mutexattr_destroy, iFp)
|
||||
// pthread_mutexattr_getprioceiling
|
||||
// pthread_mutexattr_getprotocol
|
||||
// pthread_mutexattr_getpshared
|
||||
// pthread_mutexattr_getrobust_np
|
||||
GO(pthread_mutexattr_gettype, iFpp)
|
||||
// __pthread_mutexattr_init
|
||||
GO(pthread_mutexattr_init, iFpp)
|
||||
GO(__pthread_mutexattr_init, iFp)
|
||||
GO(pthread_mutexattr_init, iFp)
|
||||
// pthread_mutexattr_setprioceiling
|
||||
// pthread_mutexattr_setprotocol
|
||||
// pthread_mutexattr_setpshared
|
||||
@@ -92,11 +93,11 @@ GO(pthread_mutexattr_init, iFpp)
|
||||
GO(__pthread_mutexattr_settype, iFpi)
|
||||
GO(pthread_mutexattr_settype, iFpi)
|
||||
// pthread_mutex_consistent_np
|
||||
// __pthread_mutex_destroy
|
||||
GO(__pthread_mutex_destroy, iFp)
|
||||
GO(pthread_mutex_destroy, iFp)
|
||||
// pthread_mutex_getprioceiling
|
||||
// __pthread_mutex_init
|
||||
// pthread_mutex_init
|
||||
GO(__pthread_mutex_init, iFpp)
|
||||
GO(pthread_mutex_init, iFpp)
|
||||
GO(__pthread_mutex_lock, iFp)
|
||||
GO(pthread_mutex_lock, iFp)
|
||||
// pthread_mutex_setprioceiling
|
||||
@@ -133,6 +134,7 @@ GO(pthread_self, uFv)
|
||||
// pthread_setcancelstate
|
||||
// pthread_setcanceltype
|
||||
// pthread_setconcurrency
|
||||
GOM(pthread_setname_np, iFEpp) // not present on the Pandora
|
||||
// pthread_setschedparam
|
||||
// pthread_setschedprio
|
||||
// __pthread_setspecific
|
||||
@@ -150,18 +152,18 @@ GO(pthread_setspecific, iFup)
|
||||
// __pthread_unregister_cancel_restore
|
||||
// __pthread_unwind
|
||||
// __pthread_unwind_next
|
||||
// pthread_yield
|
||||
GO(pthread_yield, iFv)
|
||||
// raise
|
||||
// __res_state
|
||||
// sem_close
|
||||
// sem_destroy
|
||||
// sem_getvalue
|
||||
// sem_init
|
||||
// sem_open
|
||||
// sem_post
|
||||
GO(sem_close, iFp)
|
||||
GO(sem_destroy, iFp)
|
||||
GO(sem_getvalue, iFpp)
|
||||
GO(sem_init, iFpiu)
|
||||
GO(sem_open, pFpiuu) // there is 2 versions?
|
||||
GO(sem_post, iFp)
|
||||
GO(sem_timedwait, iFpp)
|
||||
GO(sem_trywait, iFp)
|
||||
// sem_unlink
|
||||
GO(sem_unlink, iFp)
|
||||
GO(sem_wait, iFp)
|
||||
// __sigaction
|
||||
// system
|
||||
|
||||
+43
-1
@@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <dlfcn.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wrappedlibs.h"
|
||||
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "x86emu_private.h"
|
||||
#include "box86context.h"
|
||||
#include "sdl2rwops.h"
|
||||
#include "myalign.h"
|
||||
|
||||
static int sdl_Yes() { return 1;}
|
||||
static int sdl_No() { return 0;}
|
||||
@@ -48,6 +50,8 @@ KHASH_MAP_INIT_INT(timercb, x86emu_t*)
|
||||
typedef void* (*pFpi_t)(void*, int32_t);
|
||||
typedef void* (*pFpp_t)(void*, void*);
|
||||
typedef int32_t (*iFppi_t)(void*, void*, int32_t);
|
||||
typedef int32_t (*iFpippi_t)(void*, int32_t, void*, void*, int32_t);
|
||||
typedef int32_t (*iFppp_t)(void*, void*, void*);
|
||||
typedef void* (*pFpippp_t)(void*, int32_t, void*, void*, void*);
|
||||
typedef void* (*Fpp_t)(void*, void*);
|
||||
typedef void (*vFp_t)(void*);
|
||||
@@ -65,6 +69,7 @@ typedef uint32_t (*uFpU_t)(void*, uint64_t);
|
||||
|
||||
typedef struct sdl2_my_s {
|
||||
iFpp_t SDL_OpenAudio;
|
||||
iFpippi_t SDL_OpenAudioDevice;
|
||||
pFpi_t SDL_LoadFile_RW;
|
||||
pFpi_t SDL_LoadBMP_RW;
|
||||
pFpi_t SDL_RWFromConstMem;
|
||||
@@ -109,6 +114,7 @@ void* getSDL2My(library_t* lib)
|
||||
sdl2_my_t* my = (sdl2_my_t*)calloc(1, sizeof(sdl2_my_t));
|
||||
#define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
|
||||
GO(SDL_OpenAudio, iFpp_t)
|
||||
GO(SDL_OpenAudioDevice, iFpippi_t)
|
||||
GO(SDL_LoadBMP_RW, pFpi_t)
|
||||
GO(SDL_RWFromConstMem, pFpi_t)
|
||||
GO(SDL_RWFromFP, pFpi_t)
|
||||
@@ -194,7 +200,7 @@ int32_t sdl2EvtFilterCallback(void *p)
|
||||
}
|
||||
|
||||
// TODO: track the memory for those callback
|
||||
int EXPORT my2_SDL_OpenAudio(x86emu_t* emu, void* d, void* o)
|
||||
int32_t EXPORT my2_SDL_OpenAudio(x86emu_t* emu, void* d, void* o)
|
||||
{
|
||||
SDL_AudioSpec *desired = (SDL_AudioSpec*)d;
|
||||
|
||||
@@ -220,6 +226,32 @@ int EXPORT my2_SDL_OpenAudio(x86emu_t* emu, void* d, void* o)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t EXPORT my2_SDL_OpenAudioDevice(x86emu_t* emu, void* device, int32_t iscapture, void* d, void* o, int32_t allowed)
|
||||
{
|
||||
SDL_AudioSpec *desired = (SDL_AudioSpec*)d;
|
||||
|
||||
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
|
||||
// create a callback
|
||||
void *fnc = (void*)desired->callback;
|
||||
void *olduser = desired->userdata;
|
||||
x86emu_t *cbemu = (desired->callback)?AddCallback(emu, (uintptr_t)fnc, 3, olduser, NULL, NULL, NULL):NULL;
|
||||
desired->callback = sdl2Callback;
|
||||
desired->userdata = cbemu;
|
||||
int ret = my->SDL_OpenAudioDevice(device, iscapture, desired, (SDL_AudioSpec*)o, allowed);
|
||||
if (ret!=0) {
|
||||
// error, clean the callback...
|
||||
desired->callback = fnc;
|
||||
desired->userdata = olduser;
|
||||
FreeCallback(cbemu);
|
||||
return ret;
|
||||
}
|
||||
// put back stuff in place?
|
||||
desired->callback = fnc;
|
||||
desired->userdata = olduser;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EXPORT *my2_SDL_LoadFile_RW(x86emu_t* emu, void* a, int b)
|
||||
{
|
||||
sdl2_my_t *my = (sdl2_my_t *)emu->context->sdl2lib->priv.w.p2;
|
||||
@@ -501,6 +533,16 @@ void EXPORT my2_SDL_KillThread(x86emu_t* emu, void* p)
|
||||
}
|
||||
}
|
||||
|
||||
int EXPORT my2_SDL_snprintf(x86emu_t* emu, void* buff, void * fmt, void * b, va_list V) {
|
||||
#ifndef NOALIGN
|
||||
// need to align on arm
|
||||
myStackAlign((const char*)fmt, b, emu->scratch);
|
||||
void* f = vsprintf;
|
||||
return ((iFppp_t)f)(buff, fmt, emu->scratch);
|
||||
#else
|
||||
return vsprintf((char*)buff, (char*)fmt, V);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* sdl2Name = "libSDL2-2.0.so";
|
||||
#define LIBNAME sdl2
|
||||
|
||||
+83
-83
@@ -2,23 +2,23 @@
|
||||
|
||||
// _fini
|
||||
// _init
|
||||
// SDL_abs
|
||||
// SDL_acos
|
||||
// SDL_acosf
|
||||
GO(SDL_abs, iFi)
|
||||
GO(SDL_acos, dFd)
|
||||
GO(SDL_acosf, fFf)
|
||||
// SDL_AddEventWatch
|
||||
// SDL_AddHintCallback
|
||||
GOM(SDL_AddTimer, pFEupp)
|
||||
// SDL_AllocFormat
|
||||
// SDL_AllocPalette
|
||||
// SDL_AllocRW
|
||||
// SDL_asin
|
||||
// SDL_asinf
|
||||
// SDL_atan
|
||||
// SDL_atan2
|
||||
// SDL_atan2f
|
||||
// SDL_atanf
|
||||
// SDL_atof
|
||||
// SDL_atoi
|
||||
GO(SDL_asin, dFd)
|
||||
GO(SDL_asinf, fFf)
|
||||
GO(SDL_atan, dFd)
|
||||
GO(SDL_atan2, dFdd)
|
||||
GO(SDL_atan2f, fFff)
|
||||
GO(SDL_atanf, fFf)
|
||||
GO(SDL_atof, dFp)
|
||||
GO(SDL_atoi, iFp)
|
||||
// SDL_AtomicAdd
|
||||
// SDL_AtomicCAS
|
||||
// SDL_AtomicCASPtr
|
||||
@@ -40,13 +40,13 @@ GOM(SDL_AddTimer, pFEupp)
|
||||
// SDL_CalculateGammaRamp
|
||||
// SDL_calloc
|
||||
// SDL_CaptureMouse
|
||||
// SDL_ceil
|
||||
// SDL_ceilf
|
||||
GO(SDL_ceil, dFd)
|
||||
GO(SDL_ceilf, fFf)
|
||||
// SDL_ClearError
|
||||
// SDL_ClearHints
|
||||
// SDL_ClearQueuedAudio
|
||||
// SDL_CloseAudio
|
||||
// SDL_CloseAudioDevice
|
||||
GO(SDL_CloseAudioDevice, vFi)
|
||||
// SDL_ComposeCustomBlendMode
|
||||
// SDL_CondBroadcast
|
||||
// SDL_CondSignal
|
||||
@@ -91,7 +91,7 @@ GO(SDL_Delay, vFu)
|
||||
// SDL_DestroyTexture
|
||||
GO(SDL_DestroyWindow, vFp)
|
||||
GO(SDL_DetachThread, vFp)
|
||||
// SDL_DisableScreenSaver
|
||||
GO(SDL_DisableScreenSaver, vFv)
|
||||
// SDL_DuplicateSurface
|
||||
// SDL_DYNAPI_entry
|
||||
// SDL_EnableScreenSaver
|
||||
@@ -111,7 +111,7 @@ GO(SDL_EventState, CFui)
|
||||
// SDL_FlushEvents
|
||||
// SDL_fmod
|
||||
// SDL_fmodf
|
||||
// SDL_free
|
||||
GO(SDL_free, vFp)
|
||||
// SDL_FreeAudioStream
|
||||
// SDL_FreeCursor
|
||||
// SDL_FreeFormat
|
||||
@@ -121,17 +121,17 @@ GO(SDL_FreeSurface, vFp)
|
||||
// SDL_FreeWAV
|
||||
// SDL_GameControllerAddMapping
|
||||
GOM(SDL_GameControllerAddMappingsFromRW, iFEpi)
|
||||
// SDL_GameControllerClose
|
||||
// SDL_GameControllerEventState
|
||||
GO(SDL_GameControllerClose, vFp)
|
||||
GO(SDL_GameControllerEventState, iFi)
|
||||
// SDL_GameControllerFromInstanceID
|
||||
// SDL_GameControllerGetAttached
|
||||
// SDL_GameControllerGetAxis
|
||||
GO(SDL_GameControllerGetAttached, iFp)
|
||||
GO(SDL_GameControllerGetAxis, iFpi)
|
||||
// SDL_GameControllerGetAxisFromString
|
||||
// SDL_GameControllerGetBindForAxis
|
||||
// SDL_GameControllerGetBindForButton
|
||||
// SDL_GameControllerGetButton
|
||||
GO(SDL_GameControllerGetButton, uFpi)
|
||||
// SDL_GameControllerGetButtonFromString
|
||||
// SDL_GameControllerGetJoystick
|
||||
GO(SDL_GameControllerGetJoystick, pFp)
|
||||
// SDL_GameControllerGetPlayerIndex
|
||||
// SDL_GameControllerGetProduct
|
||||
// SDL_GameControllerGetProductVersion
|
||||
@@ -145,7 +145,7 @@ GOM(SDL_GameControllerAddMappingsFromRW, iFEpi)
|
||||
// SDL_GameControllerName
|
||||
// SDL_GameControllerNameForIndex
|
||||
// SDL_GameControllerNumMappings
|
||||
// SDL_GameControllerOpen
|
||||
GO(SDL_GameControllerOpen, pFi)
|
||||
// SDL_GameControllerRumble
|
||||
// SDL_GameControllerUpdate
|
||||
// SDL_GetAssertionHandler
|
||||
@@ -154,7 +154,7 @@ GOM(SDL_GameControllerAddMappingsFromRW, iFEpi)
|
||||
// SDL_GetAudioDeviceStatus
|
||||
// SDL_GetAudioDriver
|
||||
// SDL_GetAudioStatus
|
||||
// SDL_GetBasePath
|
||||
GO(SDL_GetBasePath, pFv)
|
||||
// SDL_GetClipboardText
|
||||
// SDL_GetClipRect
|
||||
// SDL_GetClosestDisplayMode
|
||||
@@ -167,7 +167,7 @@ GO(SDL_GetCurrentDisplayMode, iFip)
|
||||
// SDL_GetCursor
|
||||
// SDL_GetDefaultAssertionHandler
|
||||
// SDL_GetDefaultCursor
|
||||
// SDL_GetDesktopDisplayMode
|
||||
GO(SDL_GetDesktopDisplayMode, iFip)
|
||||
// SDL_GetDisplayBounds
|
||||
// SDL_GetDisplayDPI
|
||||
// SDL_GetDisplayMode
|
||||
@@ -181,7 +181,7 @@ GO(SDL_GetError, pFv)
|
||||
// SDL_GetGrabbedWindow
|
||||
// SDL_GetHint
|
||||
// SDL_GetHintBoolean
|
||||
// SDL_GetKeyboardFocus
|
||||
GO(SDL_GetKeyboardFocus, pFv)
|
||||
// SDL_GetKeyboardState
|
||||
// SDL_GetKeyFromName
|
||||
// SDL_GetKeyFromScancode
|
||||
@@ -199,12 +199,12 @@ GO(SDL_GetMouseState, uFpp)
|
||||
// SDL_GetNumTouchFingers
|
||||
// SDL_GetNumVideoDisplays
|
||||
// SDL_GetNumVideoDrivers
|
||||
// SDL_GetPerformanceCounter
|
||||
// SDL_GetPerformanceFrequency
|
||||
GO(SDL_GetPerformanceCounter, UFv)
|
||||
GO(SDL_GetPerformanceFrequency, UFv)
|
||||
// SDL_GetPixelFormatName
|
||||
// SDL_GetPlatform
|
||||
// SDL_GetPowerInfo
|
||||
// SDL_GetPrefPath
|
||||
GO(SDL_GetPrefPath, pFpp)
|
||||
// SDL_GetQueuedAudioSize
|
||||
// SDL_GetRelativeMouseMode
|
||||
// SDL_GetRelativeMouseState
|
||||
@@ -266,10 +266,10 @@ GO(SDL_GL_DeleteContext, vFp)
|
||||
// SDL_GL_GetAttribute
|
||||
// SDL_GL_GetCurrentContext
|
||||
// SDL_GL_GetCurrentWindow
|
||||
// SDL_GL_GetDrawableSize
|
||||
GO(SDL_GL_GetDrawableSize, vFppp)
|
||||
// SDL_GL_GetProcAddress
|
||||
// SDL_GL_GetSwapInterval
|
||||
// SDL_GL_LoadLibrary
|
||||
GO(SDL_GL_LoadLibrary, iFp)
|
||||
GO(SDL_GL_MakeCurrent, iFpp)
|
||||
// SDL_GL_ResetAttributes
|
||||
GO(SDL_GL_SetAttribute, iFui)
|
||||
@@ -277,33 +277,33 @@ GO(SDL_GL_SetSwapInterval, iFi)
|
||||
GO(SDL_GL_SwapWindow, vFp)
|
||||
// SDL_GL_UnbindTexture
|
||||
// SDL_GL_UnloadLibrary
|
||||
// SDL_HapticClose
|
||||
// SDL_HapticDestroyEffect
|
||||
GO(SDL_HapticClose, vFp)
|
||||
GO(SDL_HapticDestroyEffect, vFpi)
|
||||
// SDL_HapticEffectSupported
|
||||
// SDL_HapticGetEffectStatus
|
||||
// SDL_HapticIndex
|
||||
// SDL_HapticName
|
||||
// SDL_HapticNewEffect
|
||||
GO(SDL_HapticNewEffect, iFpp)
|
||||
// SDL_HapticNumAxes
|
||||
// SDL_HapticNumEffects
|
||||
// SDL_HapticNumEffectsPlaying
|
||||
// SDL_HapticOpen
|
||||
// SDL_HapticOpened
|
||||
// SDL_HapticOpenFromJoystick
|
||||
GO(SDL_HapticOpenFromJoystick, pFp)
|
||||
// SDL_HapticOpenFromMouse
|
||||
// SDL_HapticPause
|
||||
// SDL_HapticQuery
|
||||
// SDL_HapticRumbleInit
|
||||
// SDL_HapticRumblePlay
|
||||
// SDL_HapticRumbleStop
|
||||
// SDL_HapticRumbleSupported
|
||||
// SDL_HapticRunEffect
|
||||
GO(SDL_HapticQuery, uFp)
|
||||
GO(SDL_HapticRumbleInit, iFp)
|
||||
GO(SDL_HapticRumblePlay, iFpfu)
|
||||
GO(SDL_HapticRumbleStop, iFp)
|
||||
GO(SDL_HapticRumbleSupported, iFp)
|
||||
GO(SDL_HapticRunEffect, iFpiu)
|
||||
// SDL_HapticSetAutocenter
|
||||
// SDL_HapticSetGain
|
||||
// SDL_HapticStopAll
|
||||
// SDL_HapticStopEffect
|
||||
GO(SDL_HapticStopEffect, iFpi)
|
||||
// SDL_HapticUnpause
|
||||
// SDL_HapticUpdateEffect
|
||||
GO(SDL_HapticUpdateEffect, iFpip)
|
||||
GOM(SDL_Has3DNow, iFv)
|
||||
GOM(SDL_HasAltiVec, iFv)
|
||||
GOM(SDL_HasAVX, iFv)
|
||||
@@ -333,7 +333,7 @@ GO(SDL_InitSubSystem, iFu)
|
||||
// SDL_IntersectRect
|
||||
// SDL_IntersectRectAndLine
|
||||
// SDL_isdigit
|
||||
// SDL_IsGameController
|
||||
GO(SDL_IsGameController, iFi)
|
||||
// SDL_IsScreenKeyboardShown
|
||||
// SDL_IsScreenSaverEnabled
|
||||
// SDL_IsShapedWindow
|
||||
@@ -367,7 +367,7 @@ GO(SDL_InitSubSystem, iFu)
|
||||
// SDL_JoystickGetType
|
||||
// SDL_JoystickGetVendor
|
||||
// SDL_JoystickInstanceID
|
||||
// SDL_JoystickIsHaptic
|
||||
GO(SDL_JoystickIsHaptic, iFp)
|
||||
// SDL_JoystickName
|
||||
// SDL_JoystickNameForIndex
|
||||
// SDL_JoystickNumAxes
|
||||
@@ -386,7 +386,7 @@ GOM(SDL_LoadFile_RW, pFEppi)
|
||||
// SDL_LoadObject
|
||||
GOM(SDL_LoadWAV_RW, pFEpippp)
|
||||
// SDL_LockAudio
|
||||
// SDL_LockAudioDevice
|
||||
GO(SDL_LockAudioDevice, vFi)
|
||||
// SDL_LockJoysticks
|
||||
// SDL_LockMutex
|
||||
// SDL_LockSurface
|
||||
@@ -423,19 +423,19 @@ GOM(SDL_LoadWAV_RW, pFEpippp)
|
||||
// SDL_memmove
|
||||
// SDL_MemoryBarrierAcquireFunction
|
||||
// SDL_MemoryBarrierReleaseFunction
|
||||
// SDL_memset
|
||||
GO(SDL_memset, pFpiu)
|
||||
// SDL_MinimizeWindow
|
||||
// SDL_MixAudio
|
||||
// SDL_MixAudioFormat
|
||||
// SDL_MouseIsHaptic
|
||||
// SDL_NewAudioStream
|
||||
// SDL_NumHaptics
|
||||
// SDL_NumJoysticks
|
||||
GO(SDL_NumJoysticks, iFv)
|
||||
// SDL_NumSensors
|
||||
GOM(SDL_OpenAudio, iFEpp)
|
||||
// SDL_OpenAudioDevice
|
||||
GOM(SDL_OpenAudioDevice, iFEpippi)
|
||||
// SDL_PauseAudio
|
||||
// SDL_PauseAudioDevice
|
||||
GO(SDL_PauseAudioDevice, vFii)
|
||||
// SDL_PeepEvents
|
||||
// SDL_PixelFormatEnumToMasks
|
||||
GO(SDL_PollEvent, iFp)
|
||||
@@ -579,38 +579,38 @@ GO(SDL_SetWindowSize, vFpii)
|
||||
// SDL_SetYUVConversionMode
|
||||
GO(SDL_ShowCursor, iFi)
|
||||
// SDL_ShowMessageBox
|
||||
// SDL_ShowSimpleMessageBox
|
||||
// SDL_ShowWindow
|
||||
// SDL_sin
|
||||
// SDL_sinf
|
||||
// SDL_snprintf
|
||||
GO(SDL_ShowSimpleMessageBox, iFuppp)
|
||||
GO(SDL_ShowWindow, vFp)
|
||||
GO(SDL_sin, dFd)
|
||||
GO(SDL_sinf, fFf)
|
||||
GOM(SDL_snprintf, iFEpupVV)
|
||||
// SDL_SoftStretch
|
||||
// SDL_sqrt
|
||||
// SDL_sqrtf
|
||||
GO(SDL_sqrt, dFd)
|
||||
GO(SDL_sqrtf, fFf)
|
||||
// SDL_sscanf
|
||||
GO(SDL_StartTextInput, vFv)
|
||||
GO(SDL_StopTextInput, vFv)
|
||||
// SDL_strcasecmp
|
||||
// SDL_strchr
|
||||
// SDL_strcmp
|
||||
// SDL_strdup
|
||||
// SDL_strlcat
|
||||
// SDL_strlcpy
|
||||
// SDL_strlen
|
||||
// SDL_strlwr
|
||||
// SDL_strncasecmp
|
||||
// SDL_strncmp
|
||||
// SDL_strrchr
|
||||
// SDL_strrev
|
||||
// SDL_strstr
|
||||
// SDL_strtod
|
||||
// SDL_strtol
|
||||
// SDL_strtoll
|
||||
// SDL_strtoul
|
||||
// SDL_strtoull
|
||||
// SDL_strupr
|
||||
// SDL_tan
|
||||
// SDL_tanf
|
||||
GO(SDL_strcasecmp, iFpp)
|
||||
GO(SDL_strchr, pFpi)
|
||||
GO(SDL_strcmp, iFpp)
|
||||
GO(SDL_strdup, pFp)
|
||||
GO(SDL_strlcat, uFppu)
|
||||
GO(SDL_strlcpy, uFppu)
|
||||
GO(SDL_strlen, uFp)
|
||||
GO(SDL_strlwr, pFp)
|
||||
GO(SDL_strncasecmp, iFppu)
|
||||
GO(SDL_strncmp, iFppu)
|
||||
GO(SDL_strrchr, pFpi)
|
||||
GO(SDL_strrev, pFp)
|
||||
GO(SDL_strstr, pFpp)
|
||||
GO(SDL_strtod, dFpp)
|
||||
GO(SDL_strtol, iFppi)
|
||||
GO(SDL_strtoll, IFppi)
|
||||
GO(SDL_strtoul, uFppi)
|
||||
GO(SDL_strtoull, UFppi)
|
||||
GO(SDL_strupr, pFp)
|
||||
GO(SDL_tan, dFd)
|
||||
GO(SDL_tanf, fFf)
|
||||
GO(SDL_ThreadID, uFv)
|
||||
// SDL_TLSCreate
|
||||
// SDL_TLSGet
|
||||
@@ -618,13 +618,13 @@ GO(SDL_ThreadID, uFv)
|
||||
// SDL_tolower
|
||||
// SDL_toupper
|
||||
// SDL_TryLockMutex
|
||||
// SDL_uitoa
|
||||
// SDL_ulltoa
|
||||
// SDL_ultoa
|
||||
GO(SDL_uitoa, pFupi)
|
||||
GO(SDL_ulltoa, pFUpi)
|
||||
GO(SDL_ultoa, pFupi)
|
||||
// SDL_UnionRect
|
||||
// SDL_UnloadObject
|
||||
// SDL_UnlockAudio
|
||||
// SDL_UnlockAudioDevice
|
||||
GO(SDL_UnlockAudioDevice, vFi)
|
||||
// SDL_UnlockJoysticks
|
||||
// SDL_UnlockMutex
|
||||
// SDL_UnlockSurface
|
||||
@@ -652,7 +652,7 @@ GO(SDL_ThreadID, uFv)
|
||||
GO(SDL_WaitThread, vFpp)
|
||||
// SDL_WarpMouseGlobal
|
||||
GO(SDL_WarpMouseInWindow, vFpii)
|
||||
// SDL_WasInit
|
||||
GO(SDL_WasInit, uFu)
|
||||
// SDL_wcscmp
|
||||
// SDL_wcsdup
|
||||
// SDL_wcslcat
|
||||
|
||||
@@ -28,6 +28,7 @@ typedef int32_t (*iFE_t)(x86emu_t*);
|
||||
typedef int32_t (*iFv_t)(void);
|
||||
typedef int32_t (*iFi_t)(int32_t);
|
||||
typedef int32_t (*iFu_t)(uint32_t);
|
||||
typedef int32_t (*iFf_t)(float);
|
||||
typedef int32_t (*iFd_t)(double);
|
||||
typedef int32_t (*iFp_t)(void*);
|
||||
typedef int64_t (*IFp_t)(void*);
|
||||
@@ -38,6 +39,7 @@ typedef uint32_t (*uPv_t)(void);
|
||||
typedef uint32_t (*uFi_t)(int32_t);
|
||||
typedef uint32_t (*uFu_t)(uint32_t);
|
||||
typedef uint32_t (*uFp_t)(void*);
|
||||
typedef uint64_t (*UFv_t)(void);
|
||||
typedef uint64_t (*UFp_t)(void*);
|
||||
typedef float (*fFf_t)(float);
|
||||
typedef double (*dFd_t)(double);
|
||||
@@ -114,6 +116,7 @@ typedef void* (*pFpi_t)(void*, int32_t);
|
||||
typedef void* (*pFpu_t)(void*, uint32_t);
|
||||
typedef void* (*pFpp_t)(void*, void*);
|
||||
typedef void (*vFEpi_t)(x86emu_t*, void*, int32_t);
|
||||
typedef void (*vFEpu_t)(x86emu_t*, void*, uint32_t);
|
||||
typedef void (*vFEpp_t)(x86emu_t*, void*, void*);
|
||||
typedef void (*vFiii_t)(int32_t, int32_t, int32_t);
|
||||
typedef void (*vFiip_t)(int32_t, int32_t, void*);
|
||||
@@ -173,6 +176,7 @@ typedef int32_t (*iFpip_t)(void*, int32_t, void*);
|
||||
typedef int32_t (*iFpIi_t)(void*, int64_t, int32_t);
|
||||
typedef int32_t (*iFpuu_t)(void*, uint32_t, uint32_t);
|
||||
typedef int32_t (*iFpup_t)(void*, uint32_t, void*);
|
||||
typedef int32_t (*iFpfu_t)(void*, float, uint32_t);
|
||||
typedef int32_t (*iFppi_t)(void*, void*, int32_t);
|
||||
typedef int32_t (*iFppI_t)(void*, void*, int64_t);
|
||||
typedef int32_t (*iFppu_t)(void*, void*, uint32_t);
|
||||
@@ -264,6 +268,7 @@ typedef void (*vFpppp_t)(void*, void*, void*, void*);
|
||||
typedef int32_t (*iFEiip_t)(x86emu_t*, int32_t, int32_t, void*);
|
||||
typedef int32_t (*iFEipp_t)(x86emu_t*, int32_t, void*, void*);
|
||||
typedef int32_t (*iFEppi_t)(x86emu_t*, void*, void*, int32_t);
|
||||
typedef int32_t (*iFEppu_t)(x86emu_t*, void*, void*, uint32_t);
|
||||
typedef int32_t (*iFEppp_t)(x86emu_t*, void*, void*, void*);
|
||||
typedef int32_t (*iFEpVV_t)(x86emu_t*, void*, void*, void*);
|
||||
typedef int32_t (*iFiiii_t)(int32_t, int32_t, int32_t, int32_t);
|
||||
@@ -275,6 +280,7 @@ typedef int32_t (*iFipui_t)(int32_t, void*, uint32_t, int32_t);
|
||||
typedef int32_t (*iFipuu_t)(int32_t, void*, uint32_t, uint32_t);
|
||||
typedef int32_t (*iFuipp_t)(uint32_t, int32_t, void*, void*);
|
||||
typedef int32_t (*iFuuff_t)(uint32_t, uint32_t, float, float);
|
||||
typedef int32_t (*iFuppp_t)(uint32_t, void*, void*, void*);
|
||||
typedef int32_t (*iFpiii_t)(void*, int32_t, int32_t, int32_t);
|
||||
typedef int32_t (*iFpiiu_t)(void*, int32_t, int32_t, uint32_t);
|
||||
typedef int32_t (*iFpiid_t)(void*, int32_t, int32_t, double);
|
||||
@@ -445,6 +451,7 @@ typedef void (*vFdddddd_t)(double, double, double, double, double, double);
|
||||
typedef void (*vFpdddii_t)(void*, double, double, double, int32_t, int32_t);
|
||||
typedef void (*vFppupii_t)(void*, void*, uint32_t, void*, int32_t, int32_t);
|
||||
typedef void (*vFpppppp_t)(void*, void*, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFEpippi_t)(x86emu_t*, void*, int32_t, void*, void*, int32_t);
|
||||
typedef int32_t (*iFEpupVV_t)(x86emu_t*, void*, uint32_t, void*, void*, void*);
|
||||
typedef int32_t (*iFiiiiip_t)(int32_t, int32_t, int32_t, int32_t, int32_t, void*);
|
||||
typedef int32_t (*iFiuiipi_t)(int32_t, uint32_t, int32_t, int32_t, void*, int32_t);
|
||||
@@ -627,6 +634,7 @@ void iFE(x86emu_t *emu, uintptr_t fcn) { iFE_t fn = (iFE_t)fcn; R_EAX=fn(emu); }
|
||||
void iFv(x86emu_t *emu, uintptr_t fcn) { iFv_t fn = (iFv_t)fcn; R_EAX=fn(); }
|
||||
void iFi(x86emu_t *emu, uintptr_t fcn) { iFi_t fn = (iFi_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4)); }
|
||||
void iFu(x86emu_t *emu, uintptr_t fcn) { iFu_t fn = (iFu_t)fcn; R_EAX=fn(*(uint32_t*)(R_ESP + 4)); }
|
||||
void iFf(x86emu_t *emu, uintptr_t fcn) { iFf_t fn = (iFf_t)fcn; R_EAX=fn(*(float*)(R_ESP + 4)); }
|
||||
void iFd(x86emu_t *emu, uintptr_t fcn) { iFd_t fn = (iFd_t)fcn; R_EAX=fn(*(double*)(R_ESP + 4)); }
|
||||
void iFp(x86emu_t *emu, uintptr_t fcn) { iFp_t fn = (iFp_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4)); }
|
||||
void IFp(x86emu_t *emu, uintptr_t fcn) { IFp_t fn = (IFp_t)fcn; ui64_t r; r.i=fn(*(void**)(R_ESP + 4)); R_EAX=r.d[0]; R_EDX=r.d[1]; }
|
||||
@@ -637,6 +645,7 @@ void uPv(x86emu_t *emu, uintptr_t fcn) { uPv_t fn = (uPv_t)fcn; R_EAX=(uint32_t)
|
||||
void uFi(x86emu_t *emu, uintptr_t fcn) { uFi_t fn = (uFi_t)fcn; R_EAX=(uint32_t)fn(*(int32_t*)(R_ESP + 4)); }
|
||||
void uFu(x86emu_t *emu, uintptr_t fcn) { uFu_t fn = (uFu_t)fcn; R_EAX=(uint32_t)fn(*(uint32_t*)(R_ESP + 4)); }
|
||||
void uFp(x86emu_t *emu, uintptr_t fcn) { uFp_t fn = (uFp_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4)); }
|
||||
void UFv(x86emu_t *emu, uintptr_t fcn) { UFv_t fn = (UFv_t)fcn; ui64_t r; r.u=(uint64_t)fn(); R_EAX=r.d[0]; R_EDX=r.d[1]; }
|
||||
void UFp(x86emu_t *emu, uintptr_t fcn) { UFp_t fn = (UFp_t)fcn; ui64_t r; r.u=(uint64_t)fn(*(void**)(R_ESP + 4)); R_EAX=r.d[0]; R_EDX=r.d[1]; }
|
||||
void fFf(x86emu_t *emu, uintptr_t fcn) { fFf_t fn = (fFf_t)fcn; float fl=fn(*(float*)(R_ESP + 4)); fpu_do_push(emu); ST0.d = fl; }
|
||||
void dFd(x86emu_t *emu, uintptr_t fcn) { dFd_t fn = (dFd_t)fcn; double db=fn(*(double*)(R_ESP + 4)); fpu_do_push(emu); ST0.d = db; }
|
||||
@@ -713,6 +722,7 @@ void pFpi(x86emu_t *emu, uintptr_t fcn) { pFpi_t fn = (pFpi_t)fcn; R_EAX=(uintpt
|
||||
void pFpu(x86emu_t *emu, uintptr_t fcn) { pFpu_t fn = (pFpu_t)fcn; R_EAX=(uintptr_t)fn(*(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8)); }
|
||||
void pFpp(x86emu_t *emu, uintptr_t fcn) { pFpp_t fn = (pFpp_t)fcn; R_EAX=(uintptr_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8)); }
|
||||
void vFEpi(x86emu_t *emu, uintptr_t fcn) { vFEpi_t fn = (vFEpi_t)fcn; fn(emu, *(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8)); }
|
||||
void vFEpu(x86emu_t *emu, uintptr_t fcn) { vFEpu_t fn = (vFEpu_t)fcn; fn(emu, *(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8)); }
|
||||
void vFEpp(x86emu_t *emu, uintptr_t fcn) { vFEpp_t fn = (vFEpp_t)fcn; fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8)); }
|
||||
void vFiii(x86emu_t *emu, uintptr_t fcn) { vFiii_t fn = (vFiii_t)fcn; fn(*(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12)); }
|
||||
void vFiip(x86emu_t *emu, uintptr_t fcn) { vFiip_t fn = (vFiip_t)fcn; fn(*(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(void**)(R_ESP + 12)); }
|
||||
@@ -772,6 +782,7 @@ void iFpip(x86emu_t *emu, uintptr_t fcn) { iFpip_t fn = (iFpip_t)fcn; R_EAX=fn(*
|
||||
void iFpIi(x86emu_t *emu, uintptr_t fcn) { iFpIi_t fn = (iFpIi_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(int64_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 16)); }
|
||||
void iFpuu(x86emu_t *emu, uintptr_t fcn) { iFpuu_t fn = (iFpuu_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(uint32_t*)(R_ESP + 12)); }
|
||||
void iFpup(x86emu_t *emu, uintptr_t fcn) { iFpup_t fn = (iFpup_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(void**)(R_ESP + 12)); }
|
||||
void iFpfu(x86emu_t *emu, uintptr_t fcn) { iFpfu_t fn = (iFpfu_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(float*)(R_ESP + 8), *(uint32_t*)(R_ESP + 12)); }
|
||||
void iFppi(x86emu_t *emu, uintptr_t fcn) { iFppi_t fn = (iFppi_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12)); }
|
||||
void iFppI(x86emu_t *emu, uintptr_t fcn) { iFppI_t fn = (iFppI_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int64_t*)(R_ESP + 12)); }
|
||||
void iFppu(x86emu_t *emu, uintptr_t fcn) { iFppu_t fn = (iFppu_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12)); }
|
||||
@@ -863,6 +874,7 @@ void vFpppp(x86emu_t *emu, uintptr_t fcn) { vFpppp_t fn = (vFpppp_t)fcn; fn(*(vo
|
||||
void iFEiip(x86emu_t *emu, uintptr_t fcn) { iFEiip_t fn = (iFEiip_t)fcn; R_EAX=fn(emu, *(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(void**)(R_ESP + 12)); }
|
||||
void iFEipp(x86emu_t *emu, uintptr_t fcn) { iFEipp_t fn = (iFEipp_t)fcn; R_EAX=fn(emu, *(int32_t*)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12)); }
|
||||
void iFEppi(x86emu_t *emu, uintptr_t fcn) { iFEppi_t fn = (iFEppi_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12)); }
|
||||
void iFEppu(x86emu_t *emu, uintptr_t fcn) { iFEppu_t fn = (iFEppu_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12)); }
|
||||
void iFEppp(x86emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12)); }
|
||||
void iFEpVV(x86emu_t *emu, uintptr_t fcn) { iFEpVV_t fn = (iFEpVV_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), (void*)(R_ESP + 8), (void*)(R_ESP + 8)); }
|
||||
void iFiiii(x86emu_t *emu, uintptr_t fcn) { iFiiii_t fn = (iFiiii_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
|
||||
@@ -874,6 +886,7 @@ void iFipui(x86emu_t *emu, uintptr_t fcn) { iFipui_t fn = (iFipui_t)fcn; R_EAX=f
|
||||
void iFipuu(x86emu_t *emu, uintptr_t fcn) { iFipuu_t fn = (iFipuu_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16)); }
|
||||
void iFuipp(x86emu_t *emu, uintptr_t fcn) { iFuipp_t fn = (iFuipp_t)fcn; R_EAX=fn(*(uint32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16)); }
|
||||
void iFuuff(x86emu_t *emu, uintptr_t fcn) { iFuuff_t fn = (iFuuff_t)fcn; R_EAX=fn(*(uint32_t*)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(float*)(R_ESP + 12), *(float*)(R_ESP + 16)); }
|
||||
void iFuppp(x86emu_t *emu, uintptr_t fcn) { iFuppp_t fn = (iFuppp_t)fcn; R_EAX=fn(*(uint32_t*)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16)); }
|
||||
void iFpiii(x86emu_t *emu, uintptr_t fcn) { iFpiii_t fn = (iFpiii_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
|
||||
void iFpiiu(x86emu_t *emu, uintptr_t fcn) { iFpiiu_t fn = (iFpiiu_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16)); }
|
||||
void iFpiid(x86emu_t *emu, uintptr_t fcn) { iFpiid_t fn = (iFpiid_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(double*)(R_ESP + 16)); }
|
||||
@@ -1044,6 +1057,7 @@ void vFdddddd(x86emu_t *emu, uintptr_t fcn) { vFdddddd_t fn = (vFdddddd_t)fcn; f
|
||||
void vFpdddii(x86emu_t *emu, uintptr_t fcn) { vFpdddii_t fn = (vFpdddii_t)fcn; fn(*(void**)(R_ESP + 4), *(double*)(R_ESP + 8), *(double*)(R_ESP + 16), *(double*)(R_ESP + 24), *(int32_t*)(R_ESP + 32), *(int32_t*)(R_ESP + 36)); }
|
||||
void vFppupii(x86emu_t *emu, uintptr_t fcn) { vFppupii_t fn = (vFppupii_t)fcn; fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(int32_t*)(R_ESP + 20), *(int32_t*)(R_ESP + 24)); }
|
||||
void vFpppppp(x86emu_t *emu, uintptr_t fcn) { vFpppppp_t fn = (vFpppppp_t)fcn; fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20), *(void**)(R_ESP + 24)); }
|
||||
void iFEpippi(x86emu_t *emu, uintptr_t fcn) { iFEpippi_t fn = (iFEpippi_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16), *(int32_t*)(R_ESP + 20)); }
|
||||
void iFEpupVV(x86emu_t *emu, uintptr_t fcn) { iFEpupVV_t fn = (iFEpupVV_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(void**)(R_ESP + 12), (void*)(R_ESP + 16), (void*)(R_ESP + 16)); }
|
||||
void iFiiiiip(x86emu_t *emu, uintptr_t fcn) { iFiiiiip_t fn = (iFiiiiip_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(int32_t*)(R_ESP + 20), *(void**)(R_ESP + 24)); }
|
||||
void iFiuiipi(x86emu_t *emu, uintptr_t fcn) { iFiuiipi_t fn = (iFiuiipi_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(void**)(R_ESP + 20), *(int32_t*)(R_ESP + 24)); }
|
||||
@@ -1215,6 +1229,7 @@ void vFuffiiffiiffiip(x86emu_t *emu, uintptr_t fcn) { vFuffiiffiiffiip_t fn = (v
|
||||
void vFuddiiddiiddiip(x86emu_t *emu, uintptr_t fcn) { vFuddiiddiiddiip_t fn = (vFuddiiddiiddiip_t)fcn; fn(*(uint32_t*)(R_ESP + 4), *(double*)(R_ESP + 8), *(double*)(R_ESP + 16), *(int32_t*)(R_ESP + 24), *(int32_t*)(R_ESP + 28), *(double*)(R_ESP + 32), *(double*)(R_ESP + 40), *(int32_t*)(R_ESP + 48), *(int32_t*)(R_ESP + 52), *(double*)(R_ESP + 56), *(double*)(R_ESP + 64), *(int32_t*)(R_ESP + 72), *(int32_t*)(R_ESP + 76), *(void**)(R_ESP + 80)); }
|
||||
void vFuuiiiiuuiiiiiii(x86emu_t *emu, uintptr_t fcn) { vFuuiiiiuuiiiiiii_t fn = (vFuuiiiiuuiiiiiii_t)fcn; fn(*(uint32_t*)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(int32_t*)(R_ESP + 20), *(int32_t*)(R_ESP + 24), *(uint32_t*)(R_ESP + 28), *(uint32_t*)(R_ESP + 32), *(int32_t*)(R_ESP + 36), *(int32_t*)(R_ESP + 40), *(int32_t*)(R_ESP + 44), *(int32_t*)(R_ESP + 48), *(int32_t*)(R_ESP + 52), *(int32_t*)(R_ESP + 56), *(int32_t*)(R_ESP + 60)); }
|
||||
void vFfffffffffffffff(x86emu_t *emu, uintptr_t fcn) { vFfffffffffffffff_t fn = (vFfffffffffffffff_t)fcn; fn(*(float*)(R_ESP + 4), *(float*)(R_ESP + 8), *(float*)(R_ESP + 12), *(float*)(R_ESP + 16), *(float*)(R_ESP + 20), *(float*)(R_ESP + 24), *(float*)(R_ESP + 28), *(float*)(R_ESP + 32), *(float*)(R_ESP + 36), *(float*)(R_ESP + 40), *(float*)(R_ESP + 44), *(float*)(R_ESP + 48), *(float*)(R_ESP + 52), *(float*)(R_ESP + 56), *(float*)(R_ESP + 60)); }
|
||||
void iFEpvvpp(x86emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20)); }
|
||||
void iFEvpVV(x86emu_t *emu, uintptr_t fcn) { iFEpVV_t fn = (iFEpVV_t)fcn; R_EAX=fn(emu, *(void**)(R_ESP + 8), (void*)(R_ESP + 12), (void*)(R_ESP + 12)); }
|
||||
void iFEv(x86emu_t *emu, uintptr_t fcn) { iFE_t fn = (iFE_t)fcn; R_EAX=fn(emu); }
|
||||
void pFEv(x86emu_t *emu, uintptr_t fcn) { pFE_t fn = (pFE_t)fcn; R_EAX=(uintptr_t)fn(emu); }
|
||||
|
||||
@@ -33,6 +33,7 @@ void iFE(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFv(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFi(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFu(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFf(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFd(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFp(x86emu_t *emu, uintptr_t fnc);
|
||||
void IFp(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -43,6 +44,7 @@ void uPv(x86emu_t *emu, uintptr_t fnc);
|
||||
void uFi(x86emu_t *emu, uintptr_t fnc);
|
||||
void uFu(x86emu_t *emu, uintptr_t fnc);
|
||||
void uFp(x86emu_t *emu, uintptr_t fnc);
|
||||
void UFv(x86emu_t *emu, uintptr_t fnc);
|
||||
void UFp(x86emu_t *emu, uintptr_t fnc);
|
||||
void fFf(x86emu_t *emu, uintptr_t fnc);
|
||||
void dFd(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -119,6 +121,7 @@ void pFpi(x86emu_t *emu, uintptr_t fnc);
|
||||
void pFpu(x86emu_t *emu, uintptr_t fnc);
|
||||
void pFpp(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFEpi(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFEpu(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFEpp(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFiii(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFiip(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -178,6 +181,7 @@ void iFpip(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpIi(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpuu(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpup(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpfu(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFppi(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFppI(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFppu(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -269,6 +273,7 @@ void vFpppp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEiip(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEipp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEppi(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEppu(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEppp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEpVV(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFiiii(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -280,6 +285,7 @@ void iFipui(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFipuu(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFuipp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFuuff(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFuppp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpiii(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpiiu(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFpiid(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -450,6 +456,7 @@ void vFdddddd(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFpdddii(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFppupii(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFpppppp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEpippi(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEpupVV(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFiiiiip(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFiuiipi(x86emu_t *emu, uintptr_t fnc);
|
||||
@@ -621,6 +628,7 @@ void vFuffiiffiiffiip(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFuddiiddiiddiip(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFuuiiiiuuiiiiiii(x86emu_t *emu, uintptr_t fnc);
|
||||
void vFfffffffffffffff(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEpvvpp(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEvpVV(x86emu_t *emu, uintptr_t fnc);
|
||||
void iFEv(x86emu_t *emu, uintptr_t fnc);
|
||||
void pFEv(x86emu_t *emu, uintptr_t fnc);
|
||||
|
||||
+36
-6
@@ -100,6 +100,34 @@ void AddCleanup(x86emu_t *emu, void *p)
|
||||
emu->cleanups[emu->clean_sz++] = p;
|
||||
}
|
||||
|
||||
void CallCleanup(x86emu_t *emu, void* p)
|
||||
{
|
||||
for(int i=0; i<emu->clean_sz; ++i) {
|
||||
if(p==emu->cleanups[i]) {
|
||||
printf_log(LOG_DEBUG, "Call cleanup #%d\n", i);
|
||||
PushExit(emu);
|
||||
emu->ip.dword[0] = (uintptr_t)(emu->cleanups[i]);
|
||||
Run(emu);
|
||||
// now remove the cleanup
|
||||
if(i!=emu->clean_sz-1)
|
||||
memmove(emu->cleanups+i, emu->cleanups+i+1, (emu->clean_sz-i-1)*sizeof(void*));
|
||||
--emu->clean_sz;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CallAllCleanup(x86emu_t *emu)
|
||||
{
|
||||
for(int i=0; i<emu->clean_sz; ++i) {
|
||||
printf_log(LOG_DEBUG, "Call cleanup #%d\n", i);
|
||||
PushExit(emu);
|
||||
emu->ip.dword[0] = (uintptr_t)(emu->cleanups[i]);
|
||||
Run(emu);
|
||||
}
|
||||
emu->clean_sz = 0;
|
||||
}
|
||||
|
||||
void FreeX86Emu(x86emu_t **emu)
|
||||
{
|
||||
if(!emu)
|
||||
@@ -110,12 +138,7 @@ void FreeX86Emu(x86emu_t **emu)
|
||||
DeleteX86TraceDecoder(&(*emu)->dec);
|
||||
(*emu)->dec = NULL;
|
||||
// call atexit and fini first!
|
||||
for(int i=0; i<(*emu)->clean_sz; ++i) {
|
||||
printf_log(LOG_DEBUG, "Call cleanup #%d\n", i);
|
||||
PushExit(*emu);
|
||||
(*emu)->ip.dword[0] = (uintptr_t)((*emu)->cleanups[i]);
|
||||
Run(*emu);
|
||||
}
|
||||
CallAllCleanup(*emu);
|
||||
free((*emu)->cleanups);
|
||||
if((*emu)->shared_global && !(*(*emu)->shared_global)--) {
|
||||
if((*emu)->globals)
|
||||
@@ -236,3 +259,10 @@ void UnimpOpcode(x86emu_t* emu)
|
||||
emu->quit=1;
|
||||
emu->error |= ERR_UNIMPL;
|
||||
}
|
||||
|
||||
void EmuCall(x86emu_t* emu, uintptr_t addr)
|
||||
{
|
||||
PushExit(emu);
|
||||
R_EIP = addr;
|
||||
Run(emu);
|
||||
}
|
||||
@@ -19,7 +19,10 @@ const char* DumpCPURegs(x86emu_t* emu);
|
||||
|
||||
void StopEmu(x86emu_t* emu, const char* reason);
|
||||
void PushExit(x86emu_t* emu);
|
||||
void EmuCall(x86emu_t* emu, uintptr_t addr);
|
||||
void AddCleanup(x86emu_t *emu, void *p);
|
||||
void CallCleanup(x86emu_t *emu, void* p);
|
||||
void CallAllCleanup(x86emu_t *emu);
|
||||
void UnimpOpcode(x86emu_t* emu);
|
||||
|
||||
double FromLD(void* ld); // long double (80bits pointer) -> double
|
||||
|
||||
Reference in new issue
Block a user