mirror of
https://github.com/ptitSeb/box64.git
synced 2024-11-23 18:04:16 +08:00
[BOX32] More work on 32bits wrapped functions
This commit is contained in:
parent
4c69bcd97a
commit
f073415510
33
src/core.c
33
src/core.c
@ -2388,6 +2388,22 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
|
||||
|
||||
// export symbols
|
||||
AddSymbols(my_context->maplib, elf_header);
|
||||
if(wine_preloaded) {
|
||||
uintptr_t wineinfo = 0;
|
||||
int ver = -1, veropt = 0;
|
||||
const char* vername = NULL;
|
||||
if(!ElfGetGlobalSymbolStartEnd(elf_header, &wineinfo, NULL, "wine_main_preload_info", &ver, &vername, 1, &veropt))
|
||||
if(!ElfGetWeakSymbolStartEnd(elf_header, &wineinfo, NULL, "wine_main_preload_info", &ver, &vername, 1, &veropt))
|
||||
ElfGetLocalSymbolStartEnd(elf_header, &wineinfo, NULL, "wine_main_preload_info", &ver, &vername, 1, &veropt);
|
||||
if(!wineinfo) {printf_log(LOG_NONE, "Warning, Symbol wine_main_preload_info not found\n");}
|
||||
else {
|
||||
*(void**)wineinfo = get_wine_prereserve();
|
||||
printf_log(LOG_DEBUG, "WINE wine_main_preload_info found and updated %p -> %p\n", get_wine_prereserve(), *(void**)wineinfo);
|
||||
}
|
||||
#ifdef DYNAREC
|
||||
dynarec_wine_prereserve();
|
||||
#endif
|
||||
}
|
||||
AddMainElfToLinkmap(elf_header);
|
||||
// pre-load lib if needed
|
||||
if(ld_preload.size) {
|
||||
@ -2421,23 +2437,6 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
|
||||
}
|
||||
// and handle PLT
|
||||
RelocateElfPlt(my_context->maplib, NULL, 0, 0, elf_header);
|
||||
// wine preload special case
|
||||
if(wine_preloaded) {
|
||||
uintptr_t wineinfo = 0;
|
||||
int ver = -1, veropt = 0;
|
||||
const char* vername = NULL;
|
||||
if(!ElfGetGlobalSymbolStartEnd(elf_header, &wineinfo, NULL, "wine_main_preload_info", &ver, &vername, 1, &veropt))
|
||||
if(!ElfGetWeakSymbolStartEnd(elf_header, &wineinfo, NULL, "wine_main_preload_info", &ver, &vername, 1, &veropt))
|
||||
ElfGetLocalSymbolStartEnd(elf_header, &wineinfo, NULL, "wine_main_preload_info", &ver, &vername, 1, &veropt);
|
||||
if(!wineinfo) {printf_log(LOG_NONE, "Warning, Symbol wine_main_preload_info not found\n");}
|
||||
else {
|
||||
printf_log(LOG_INFO, "WINE wine_main_preload_info found and updated %p -> %p\n", (void**)wineinfo, get_wine_prereserve());
|
||||
*(void**)wineinfo = get_wine_prereserve();
|
||||
}
|
||||
#ifdef DYNAREC
|
||||
dynarec_wine_prereserve();
|
||||
#endif
|
||||
}
|
||||
// deferred init
|
||||
setupTraceInit();
|
||||
RunDeferredElfInit(emu);
|
||||
|
@ -202,10 +202,8 @@ void CallAllCleanup(x64emu_t *emu)
|
||||
|
||||
static void internalFreeX64(x64emu_t* emu)
|
||||
{
|
||||
if(emu && emu->stack2free) {
|
||||
if(!internal_munmap(emu->stack2free, emu->size_stack))
|
||||
freeProtection((uintptr_t)emu->stack2free, emu->size_stack);
|
||||
}
|
||||
if(emu && emu->stack2free)
|
||||
!munmap(emu->stack2free, emu->size_stack);
|
||||
}
|
||||
|
||||
EXPORTDYN
|
||||
|
@ -370,6 +370,9 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr)
|
||||
} else if(!strcmp(s, "syscall")) {
|
||||
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, %p, %p...)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, *(int32_t*)from_ptr(R_ESP+4), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+12)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+16)));
|
||||
perr = 1;
|
||||
} else if(!strcmp(s, "snd_device_name_get_hint")) {
|
||||
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, from_ptrv(from_ptri(ptr_t, R_ESP+4)), from_ptrv(from_ptri(ptr_t, R_ESP+8)));
|
||||
post = 2;
|
||||
} else {
|
||||
snprintf(buff, 255, "%04d|%p: Calling %s (%08X, %08X, %08X...)", tid, from_ptrv(*(ptr_t*)from_ptr(R_ESP)), (char *)s, *(uint32_t*)from_ptr(R_ESP+4), *(uint32_t*)from_ptr(R_ESP+8), *(uint32_t*)from_ptr(R_ESP+12));
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ struct i386_robust_list_head {
|
||||
|
||||
typedef struct i386_stack_s i386_stack_t;
|
||||
|
||||
int32_t my32_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode);
|
||||
int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode);
|
||||
int32_t my32_execve(x64emu_t* emu, const char* path, char* const argv[], char* const envp[]);
|
||||
ssize_t my32_read(int fd, void* buf, size_t count);
|
||||
void* my32_mmap64(x64emu_t* emu, void *addr, size_t length, int prot, int flags, int fd, int64_t offset);
|
||||
@ -299,7 +299,7 @@ void EXPORT x86Syscall(x64emu_t *emu)
|
||||
case 5: // sys_open
|
||||
if(s==5) {printf_log(LOG_DEBUG, " => sys_open(\"%s\", %d, %d)", (char*)from_ptrv(R_EBX), of_convert32(R_ECX), R_EDX);};
|
||||
//S_EAX = open((void*)R_EBX, of_convert32(R_ECX), R_EDX);
|
||||
S_EAX = my32_open(emu, from_ptrv(R_EBX), of_convert32(R_ECX), R_EDX);
|
||||
S_EAX = my_open(emu, from_ptrv(R_EBX), of_convert32(R_ECX), R_EDX);
|
||||
break;
|
||||
case 6: // sys_close
|
||||
S_EAX = close((int)R_EBX);
|
||||
@ -448,7 +448,7 @@ uint32_t EXPORT my32_syscall(x64emu_t *emu, ptr_t* b)
|
||||
case 4: // sys_write
|
||||
return (uint32_t)to_long(write(i32(4), p(8), u32(12)));
|
||||
case 5: // sys_open
|
||||
return my32_open(emu, p(4), of_convert32(u32(8)), u32(12));
|
||||
return my_open(emu, p(4), of_convert32(u32(8)), u32(12));
|
||||
case 6: // sys_close
|
||||
return (uint32_t)close(i32(4));
|
||||
case 11: // execve
|
||||
|
@ -954,4 +954,11 @@ typedef struct my_XDevice_s {
|
||||
my_XInputClassInfo_t* classes;
|
||||
} my_XDevice_t;
|
||||
|
||||
typedef struct my_XcursorCursors_s {
|
||||
void* dpy; //Display*
|
||||
int ref;
|
||||
int ncursor;
|
||||
void* cursors; //Cursor*
|
||||
} my_XcursorCursors_t;
|
||||
|
||||
#endif//MY_X11_DEFS
|
@ -887,4 +887,11 @@ typedef struct __attribute__((packed, aligned(4))) my_XDevice_32_s {
|
||||
ptr_t classes; //my_XInputClassInfo_t*
|
||||
} my_XDevice_32_t;
|
||||
|
||||
typedef struct __attribute__((packed, aligned(4))) my_XcursorCursors_32_s {
|
||||
ptr_t dpy; //Display*
|
||||
int ref;
|
||||
int ncursor;
|
||||
ptr_t cursors; //Cursor*
|
||||
} my_XcursorCursors_32_t;
|
||||
|
||||
#endif//MY_X11_DEFS_32
|
@ -201,6 +201,7 @@ size_t myStackAlignScanf32(const char* fmt, uint32_t* st, uint64_t* mystack, siz
|
||||
case '#':
|
||||
case '+':
|
||||
case '-': ++p; break; // formating, ignored
|
||||
case '[': state += 60; ++p; break;
|
||||
case 'm': state = 0; ++p; break; // no argument
|
||||
case 'n':
|
||||
case 'p': state = 30; break; // pointers
|
||||
@ -251,6 +252,13 @@ size_t myStackAlignScanf32(const char* fmt, uint32_t* st, uint64_t* mystack, siz
|
||||
state = 0;
|
||||
++p;
|
||||
break;
|
||||
case 61:
|
||||
switch(*p) {
|
||||
case ']': state = 50; break;
|
||||
case '\\': ++p; if(*p) ++p; break;
|
||||
default: ++p; break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// whaaaat?
|
||||
state = 0;
|
||||
@ -321,6 +329,7 @@ void myStackAlignScanf32_final(const char* fmt, uint32_t* st, uint64_t* mystack,
|
||||
case '#':
|
||||
case '+':
|
||||
case '-': ++p; break; // formating, ignored
|
||||
case '[': state += 60; ++p; break;
|
||||
case 'm': state = 0; ++p; break; // no argument
|
||||
case 'n':
|
||||
case 'p': state = 30; break; // pointers
|
||||
@ -381,6 +390,13 @@ void myStackAlignScanf32_final(const char* fmt, uint32_t* st, uint64_t* mystack,
|
||||
++p;
|
||||
if(!--n) return;
|
||||
break;
|
||||
case 61:
|
||||
switch(*p) {
|
||||
case ']': state = 50; break;
|
||||
case '\\': ++p; if(*p) ++p; break;
|
||||
default: ++p; break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// whaaaat?
|
||||
state = 0;
|
||||
|
@ -166,7 +166,7 @@ void thread_set_emu(x64emu_t* emu)
|
||||
{
|
||||
emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key);
|
||||
if(!emu) {
|
||||
if(et) box_free(et);
|
||||
if(et) emuthread_destroy(et);
|
||||
pthread_setspecific(thread_key, NULL);
|
||||
return;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ static void emuthread_cancel(void* p)
|
||||
my32_longjmp(et->emu, ((i386_unwind_buff_t*)et->cancels[i])->__cancel_jmp_buf, 1);
|
||||
DynaRun(et->emu); // will return after a __pthread_unwind_next()
|
||||
}
|
||||
free(et->cancels);
|
||||
box_free(et->cancels);
|
||||
et->cancels=NULL;
|
||||
et->cancel_size = et->cancel_cap = 0;
|
||||
}
|
||||
@ -246,7 +246,7 @@ void* my32_prepare_thread(x64emu_t *emu, void* f, void* arg, int ssize, void** p
|
||||
int stacksize = (ssize)?ssize:(2*1024*1024); //default stack size is 2Mo
|
||||
//void* stack = malloc(stacksize);
|
||||
void* stack = mmap64(NULL, stacksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN|MAP_32BIT, -1, 0);
|
||||
emuthread_t *et = (emuthread_t*)calloc(1, sizeof(emuthread_t));
|
||||
emuthread_t *et = (emuthread_t*)box_calloc(1, sizeof(emuthread_t));
|
||||
x64emu_t *emuthread = NewX64Emu(emu->context, (uintptr_t)f, (uintptr_t)stack, stacksize, 1);
|
||||
SetupX64Emu(emuthread, emu);
|
||||
et->emu = emuthread;
|
||||
@ -271,7 +271,7 @@ EXPORT void my32___pthread_register_cancel(x64emu_t* emu, i386_unwind_buff_t* bu
|
||||
emuthread_t *et = (emuthread_t*)thread_get_et();
|
||||
if(et->cancel_cap == et->cancel_size) {
|
||||
et->cancel_cap+=8;
|
||||
et->cancels = realloc(et->cancels, sizeof(i386_unwind_buff_t*)*et->cancel_cap);
|
||||
et->cancels = box_realloc(et->cancels, sizeof(i386_unwind_buff_t*)*et->cancel_cap);
|
||||
}
|
||||
et->cancels[et->cancel_size++] = buff;
|
||||
}
|
||||
@ -456,7 +456,7 @@ static pthread_cond_t* add_cond(void* cond)
|
||||
if(!ret)
|
||||
c = kh_value(mapcond, k); // already there... reinit an existing one?
|
||||
else
|
||||
c = kh_value(mapcond, k) = (pthread_cond_t*)calloc(1, sizeof(pthread_cond_t));
|
||||
c = kh_value(mapcond, k) = (pthread_cond_t*)box_calloc(1, sizeof(pthread_cond_t));
|
||||
//*(ptr_t*)cond = to_ptrv(cond);
|
||||
mutex_unlock(&my_context->mutex_thread);
|
||||
return c;
|
||||
@ -471,7 +471,7 @@ static pthread_cond_t* get_cond(void* cond)
|
||||
khint_t k = kh_get(mapcond, mapcond, (uintptr_t)cond);
|
||||
if(k==kh_end(mapcond)) {
|
||||
printf_log(LOG_DEBUG, "BOX32: Note: phtread_cond not found, create a new empty one\n");
|
||||
ret = (pthread_cond_t*)calloc(1, sizeof(pthread_cond_t));
|
||||
ret = (pthread_cond_t*)box_calloc(1, sizeof(pthread_cond_t));
|
||||
k = kh_put(mapcond, mapcond, (uintptr_t)cond, &r);
|
||||
kh_value(mapcond, k) = ret;
|
||||
//*(ptr_t*)cond = to_ptrv(cond);
|
||||
@ -490,7 +490,7 @@ static void del_cond(void* cond)
|
||||
mutex_lock(&my_context->mutex_thread);
|
||||
khint_t k = kh_get(mapcond, mapcond, *(uintptr_t*)cond);
|
||||
if(k!=kh_end(mapcond)) {
|
||||
free(kh_value(mapcond, k));
|
||||
box_free(kh_value(mapcond, k));
|
||||
kh_del(mapcond, mapcond, k);
|
||||
}
|
||||
mutex_unlock(&my_context->mutex_thread);
|
||||
@ -715,7 +715,7 @@ EXPORT int my32_pthread_attr_setstackaddr(x64emu_t* emu, void* attr, void* p)
|
||||
EXPORT int my32_pthread_attr_setstacksize(x64emu_t* emu, void* attr, size_t p)
|
||||
{
|
||||
// PTHREAD_STACK_MIN on x86 might be lower than the current platform...
|
||||
if(p>=65536 && p<PTHREAD_STACK_MIN && !(p&4095))
|
||||
if(p>=0xc000 && p<PTHREAD_STACK_MIN && !(p&4095))
|
||||
p = PTHREAD_STACK_MIN;
|
||||
return pthread_attr_setstacksize(get_attr(attr), p);
|
||||
}
|
||||
@ -832,7 +832,7 @@ pthread_mutex_t* getAlignedMutex(pthread_mutex_t* m)
|
||||
pthread_rwlock_unlock(&m_lock);
|
||||
pthread_rwlock_wrlock(&m_lock);
|
||||
k = kh_put(mutex, unaligned_mutex, (uintptr_t)m, &r);
|
||||
ret = kh_value(unaligned_mutex, k) = (pthread_mutex_t*)calloc(1, sizeof(pthread_mutex_t));
|
||||
ret = kh_value(unaligned_mutex, k) = (pthread_mutex_t*)box_calloc(1, sizeof(pthread_mutex_t));
|
||||
memcpy(ret, m, 24);
|
||||
}
|
||||
pthread_rwlock_unlock(&m_lock);
|
||||
@ -847,7 +847,7 @@ EXPORT int my32_pthread_mutex_destroy(pthread_mutex_t *m)
|
||||
kh_del(mutex, unaligned_mutex, k);
|
||||
pthread_rwlock_unlock(&m_lock);
|
||||
int ret = pthread_mutex_destroy(n);
|
||||
free(n);
|
||||
box_free(n);
|
||||
return ret;
|
||||
}
|
||||
pthread_rwlock_unlock(&m_lock);
|
||||
@ -939,14 +939,14 @@ void fini_pthread_helper_32(box64context_t* context)
|
||||
pthread_cond_t *cond;
|
||||
kh_foreach_value(mapcond, cond,
|
||||
pthread_cond_destroy(cond);
|
||||
free(cond);
|
||||
box_free(cond);
|
||||
);
|
||||
kh_destroy(mapcond, mapcond);
|
||||
mapcond = NULL;
|
||||
pthread_mutex_t *m;
|
||||
kh_foreach_value(unaligned_mutex, m,
|
||||
pthread_mutex_destroy(m);
|
||||
free(m);
|
||||
box_free(m);
|
||||
);
|
||||
kh_destroy(mutex, unaligned_mutex);
|
||||
|
||||
|
@ -1246,6 +1246,7 @@
|
||||
#() vFXppiiii -> vFXppiiii
|
||||
#() iFEpLiipV -> iFEpLiipV
|
||||
#() iFEpLiLpV -> iFEpLiLpV
|
||||
#() iFEpppipp -> iFEpppipp
|
||||
#() iFEpppupp -> iFEpppupp
|
||||
#() iFEpppppp -> iFEpppppp
|
||||
#() iFEXLpiiL -> iFEXLpiiL
|
||||
@ -1272,7 +1273,6 @@
|
||||
#() pFEpLiiiI -> pFEpLiiiI
|
||||
#() pFEpLiiil -> pFEpLiiil
|
||||
#() vFXLLiiibl_ -> vFXLLiiiB
|
||||
#() iFEpppibL_p -> iFEpppiBp
|
||||
#() iFXiLibiip_ip -> iFXiLiBip
|
||||
#() iFXLibL_ubL_u -> iFXLiBuBu
|
||||
#() vFXLpiibpiip_i -> vFXLpiiBi
|
||||
@ -2052,13 +2052,14 @@ wrappedlibx11:
|
||||
- XSubImage
|
||||
- pFXpppp:
|
||||
- XCreateFontSet
|
||||
- iFpppipp:
|
||||
- XmbLookupString
|
||||
- Xutf8LookupString
|
||||
- iFXLpppp:
|
||||
- XQueryTree
|
||||
- iFXppppp:
|
||||
- XRegisterIMInstantiateCallback
|
||||
- XUnregisterIMInstantiateCallback
|
||||
- iFpppibL_p:
|
||||
- XmbLookupString
|
||||
- iFXLLLiipi:
|
||||
- XChangeProperty
|
||||
- pFXLiiuuLi:
|
||||
@ -2076,6 +2077,10 @@ wrappedlibx11:
|
||||
- XCreateWindow
|
||||
wrappedlibxcomposite:
|
||||
wrappedlibxcursor:
|
||||
- vFp:
|
||||
- XcursorCursorsDestroy
|
||||
- pFXi:
|
||||
- XcursorCursorsCreate
|
||||
wrappedlibxext:
|
||||
- vFp:
|
||||
- XdbeFreeVisualInfo
|
||||
|
@ -45,9 +45,9 @@ typedef int32_t (*iFXpiup_t)(void*, void*, int32_t, uint32_t, void*);
|
||||
typedef int32_t (*iFXpppp_t)(void*, void*, void*, void*, void*);
|
||||
typedef void* (*pFpiiuu_t)(void*, int32_t, int32_t, uint32_t, uint32_t);
|
||||
typedef void* (*pFXpppp_t)(void*, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFpppipp_t)(void*, void*, void*, int32_t, void*, void*);
|
||||
typedef int32_t (*iFXLpppp_t)(void*, uintptr_t, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFXppppp_t)(void*, void*, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFpppibL_p_t)(void*, void*, void*, int32_t, struct_L_t*, void*);
|
||||
typedef int32_t (*iFXLLLiipi_t)(void*, uintptr_t, uintptr_t, uintptr_t, int32_t, int32_t, void*, int32_t);
|
||||
typedef void* (*pFXLiiuuLi_t)(void*, uintptr_t, int32_t, int32_t, uint32_t, uint32_t, uintptr_t, int32_t);
|
||||
typedef void (*vFXLpppippp_t)(void*, uintptr_t, void*, void*, void*, int32_t, void*, void*, void*);
|
||||
@ -105,10 +105,11 @@ typedef uintptr_t (*LFXLiiuuuiupLp_t)(void*, uintptr_t, int32_t, int32_t, uint32
|
||||
GO(XQueryExtension, iFXpppp_t) \
|
||||
GO(XSubImage, pFpiiuu_t) \
|
||||
GO(XCreateFontSet, pFXpppp_t) \
|
||||
GO(XmbLookupString, iFpppipp_t) \
|
||||
GO(Xutf8LookupString, iFpppipp_t) \
|
||||
GO(XQueryTree, iFXLpppp_t) \
|
||||
GO(XRegisterIMInstantiateCallback, iFXppppp_t) \
|
||||
GO(XUnregisterIMInstantiateCallback, iFXppppp_t) \
|
||||
GO(XmbLookupString, iFpppibL_p_t) \
|
||||
GO(XChangeProperty, iFXLLLiipi_t) \
|
||||
GO(XGetImage, pFXLiiuuLi_t) \
|
||||
GO(XSetWMProperties, vFXLpppippp_t) \
|
||||
|
@ -11,7 +11,11 @@
|
||||
#define ADDED_FUNCTIONS()
|
||||
#endif
|
||||
|
||||
typedef void (*vFp_t)(void*);
|
||||
typedef void* (*pFXi_t)(void*, int32_t);
|
||||
|
||||
#define SUPER() ADDED_FUNCTIONS()
|
||||
#define SUPER() ADDED_FUNCTIONS() \
|
||||
GO(XcursorCursorsDestroy, vFp_t) \
|
||||
GO(XcursorCursorsCreate, pFXi_t)
|
||||
|
||||
#endif // __wrappedlibxcursorTYPES32_H_
|
||||
|
@ -1336,6 +1336,7 @@ typedef void (*vFXpiipii_t)(void*, void*, int32_t, int32_t, void*, int32_t, int3
|
||||
typedef void (*vFXppiiii_t)(void*, void*, void*, int32_t, int32_t, int32_t, int32_t);
|
||||
typedef int32_t (*iFEpLiipV_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, void*, void*);
|
||||
typedef int32_t (*iFEpLiLpV_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*);
|
||||
typedef int32_t (*iFEpppipp_t)(x64emu_t*, void*, void*, void*, int32_t, void*, void*);
|
||||
typedef int32_t (*iFEpppupp_t)(x64emu_t*, void*, void*, void*, uint32_t, void*, void*);
|
||||
typedef int32_t (*iFEpppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFEXLpiiL_t)(x64emu_t*, void*, uintptr_t, void*, int32_t, int32_t, uintptr_t);
|
||||
@ -1362,7 +1363,6 @@ typedef void* (*pFEpLiiii_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int3
|
||||
typedef void* (*pFEpLiiiI_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int32_t, int64_t);
|
||||
typedef void* (*pFEpLiiil_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t);
|
||||
typedef void (*vFXLLiiibl__t)(void*, uintptr_t, uintptr_t, int32_t, int32_t, int32_t, struct_l_t*);
|
||||
typedef int32_t (*iFEpppibL_p_t)(x64emu_t*, void*, void*, void*, int32_t, struct_L_t*, void*);
|
||||
typedef int32_t (*iFXiLibiip_ip_t)(void*, int32_t, uintptr_t, int32_t, struct_iip_t*, int32_t, void*);
|
||||
typedef int32_t (*iFXLibL_ubL_u_t)(void*, uintptr_t, int32_t, struct_L_t*, uint32_t, struct_L_t*, uint32_t);
|
||||
typedef void (*vFXLpiibpiip_i_t)(void*, uintptr_t, void*, int32_t, int32_t, struct_piip_t*, int32_t);
|
||||
@ -2811,6 +2811,7 @@ void vFXpiipii_32(x64emu_t *emu, uintptr_t fcn) { vFXpiipii_t fn = (vFXpiipii_t)
|
||||
void vFXppiiii_32(x64emu_t *emu, uintptr_t fcn) { vFXppiiii_t fn = (vFXppiiii_t)fcn; fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28)); }
|
||||
void iFEpLiipV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiipV_t fn = (iFEpLiipV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptrv(R_ESP + 24)); }
|
||||
void iFEpLiLpV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpV_t fn = (iFEpLiLpV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptriv(R_ESP + 20), from_ptrv(R_ESP + 24)); }
|
||||
void iFEpppipp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppipp_t fn = (iFEpppipp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
|
||||
void iFEpppupp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppupp_t fn = (iFEpppupp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
|
||||
void iFEpppppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppppp_t fn = (iFEpppppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
|
||||
void iFEXLpiiL_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpiiL_t fn = (iFEXLpiiL_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ulong(from_ptri(ulong_t, R_ESP + 24))); }
|
||||
@ -2837,7 +2838,6 @@ void pFEpLiiii_32(x64emu_t *emu, uintptr_t fcn) { pFEpLiiii_t fn = (pFEpLiiii_t)
|
||||
void pFEpLiiiI_32(x64emu_t *emu, uintptr_t fcn) { pFEpLiiiI_t fn = (pFEpLiiiI_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int64_t, R_ESP + 24))); }
|
||||
void pFEpLiiil_32(x64emu_t *emu, uintptr_t fcn) { pFEpLiiil_t fn = (pFEpLiiil_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_long(from_ptri(long_t, R_ESP + 24)))); }
|
||||
void vFXLLiiibl__32(x64emu_t *emu, uintptr_t fcn) { vFXLLiiibl__t fn = (vFXLLiiibl__t)fcn; struct_l_t arg_28={0}; if (*(ptr_t*)(from_ptr((R_ESP + 28)))) from_struct_l(&arg_28, *(ptr_t*)(from_ptr((R_ESP + 28)))); fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), *(ptr_t*)(from_ptr((R_ESP + 28))) ? &arg_28 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 28)))) to_struct_l(*(ptr_t*)(from_ptr((R_ESP + 28))), &arg_28); }
|
||||
void iFEpppibL_p_32(x64emu_t *emu, uintptr_t fcn) { iFEpppibL_p_t fn = (iFEpppibL_p_t)fcn; struct_L_t arg_20={0}; if (*(ptr_t*)(from_ptr((R_ESP + 20)))) from_struct_L(&arg_20, *(ptr_t*)(from_ptr((R_ESP + 20)))); R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), *(ptr_t*)(from_ptr((R_ESP + 20))) ? &arg_20 : NULL, from_ptriv(R_ESP + 24)); if (*(ptr_t*)(from_ptr((R_ESP + 20)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 20))), &arg_20); }
|
||||
void iFXiLibiip_ip_32(x64emu_t *emu, uintptr_t fcn) { iFXiLibiip_ip_t fn = (iFXiLibiip_ip_t)fcn; struct_iip_t arg_20={0}; if (*(ptr_t*)(from_ptr((R_ESP + 20)))) from_struct_iip(&arg_20, *(ptr_t*)(from_ptr((R_ESP + 20)))); R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptri(int32_t, R_ESP + 16), *(ptr_t*)(from_ptr((R_ESP + 20))) ? &arg_20 : NULL, from_ptri(int32_t, R_ESP + 24), from_ptriv(R_ESP + 28)); if (*(ptr_t*)(from_ptr((R_ESP + 20)))) to_struct_iip(*(ptr_t*)(from_ptr((R_ESP + 20))), &arg_20); }
|
||||
void iFXLibL_ubL_u_32(x64emu_t *emu, uintptr_t fcn) { iFXLibL_ubL_u_t fn = (iFXLibL_ubL_u_t)fcn; struct_L_t arg_16={0}; if (*(ptr_t*)(from_ptr((R_ESP + 16)))) from_struct_L(&arg_16, *(ptr_t*)(from_ptr((R_ESP + 16)))); struct_L_t arg_24={0}; if (*(ptr_t*)(from_ptr((R_ESP + 24)))) from_struct_L(&arg_24, *(ptr_t*)(from_ptr((R_ESP + 24)))); R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), *(ptr_t*)(from_ptr((R_ESP + 16))) ? &arg_16 : NULL, from_ptri(uint32_t, R_ESP + 20), *(ptr_t*)(from_ptr((R_ESP + 24))) ? &arg_24 : NULL, from_ptri(uint32_t, R_ESP + 28)); if (*(ptr_t*)(from_ptr((R_ESP + 16)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 16))), &arg_16); if (*(ptr_t*)(from_ptr((R_ESP + 24)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 24))), &arg_24); }
|
||||
void vFXLpiibpiip_i_32(x64emu_t *emu, uintptr_t fcn) { vFXLpiibpiip_i_t fn = (vFXLpiibpiip_i_t)fcn; struct_piip_t arg_24={0}; if (*(ptr_t*)(from_ptr((R_ESP + 24)))) from_struct_piip(&arg_24, *(ptr_t*)(from_ptr((R_ESP + 24)))); fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), *(ptr_t*)(from_ptr((R_ESP + 24))) ? &arg_24 : NULL, from_ptri(int32_t, R_ESP + 28)); if (*(ptr_t*)(from_ptr((R_ESP + 24)))) to_struct_piip(*(ptr_t*)(from_ptr((R_ESP + 24))), &arg_24); }
|
||||
|
@ -1287,6 +1287,7 @@ void vFXpiipii_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void vFXppiiii_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpLiipV_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpLiLpV_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpppipp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpppupp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpppppp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEXLpiiL_32(x64emu_t *emu, uintptr_t fnc);
|
||||
@ -1313,7 +1314,6 @@ void pFEpLiiii_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void pFEpLiiiI_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void pFEpLiiil_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void vFXLLiiibl__32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpppibL_p_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFXiLibiip_ip_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFXLibL_ubL_u_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void vFXLpiibpiip_i_32(x64emu_t *emu, uintptr_t fnc);
|
||||
|
@ -1401,45 +1401,7 @@ static int isProcSelf(const char *path, const char* w)
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT int32_t my32_readlink(x64emu_t* emu, void* path, void* buf, uint32_t sz)
|
||||
{
|
||||
if(isProcSelf((const char*)path, "exe")) {
|
||||
// special case for self...
|
||||
return strlen(strncpy((char*)buf, emu->context->fullpath, sz));
|
||||
}
|
||||
return readlink((const char*)path, (char*)buf, sz);
|
||||
}
|
||||
#ifndef NOALIGN
|
||||
|
||||
void CreateCPUInfoFile(int fd);
|
||||
int getNCpu();
|
||||
static int isCpuTopology(const char* p) {
|
||||
if(strstr(p, "/sys/devices/system/cpu/cpu")!=p)
|
||||
return -1; //nope
|
||||
if( FileExist(p, -1))
|
||||
return -1; //no need to fake it
|
||||
char buf[512];
|
||||
const char* p2 = p + strlen("/sys/devices/system/cpu/cpu");
|
||||
int n = 0;
|
||||
while(*p2>='0' && *p2<='9') {
|
||||
n = n*10+ *p2 - '0';
|
||||
++p2;
|
||||
}
|
||||
if(n>=getNCpu()) // filter for non existing cpu
|
||||
return -1;
|
||||
snprintf(buf, 512, "/sys/devices/system/cpu/cpu%d/topology/core_id", n);
|
||||
if(!strcmp(p, buf))
|
||||
return n;
|
||||
return -1;
|
||||
}
|
||||
static void CreateCPUTopologyCoreID(int fd, int cpu)
|
||||
{
|
||||
char buf[512];
|
||||
snprintf(buf, 512, "%d\n", cpu);
|
||||
size_t dummy = write(fd, buf, strlen(buf));
|
||||
(void)dummy;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
static int shm_open(const char *name, int oflag, mode_t mode) {
|
||||
@ -1449,68 +1411,7 @@ static int shm_unlink(const char *name) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#define TMP_CPUINFO "box32_tmpcpuinfo"
|
||||
#define TMP_CPUTOPO "box32_tmpcputopo%d"
|
||||
|
||||
#define TMP_MEMMAP "box32_tmpmemmap"
|
||||
#define TMP_CMDLINE "box32_tmpcmdline"
|
||||
EXPORT int32_t my32_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode)
|
||||
{
|
||||
if(isProcSelf((const char*) pathname, "cmdline")) {
|
||||
// special case for self command line...
|
||||
#if 0
|
||||
char tmpcmdline[200] = {0};
|
||||
char tmpbuff[100] = {0};
|
||||
sprintf(tmpbuff, "%s/cmdlineXXXXXX", getenv("TMP")?getenv("TMP"):".");
|
||||
int tmp = mkstemp(tmpbuff);
|
||||
int dummy;
|
||||
if(tmp<0) return open(pathname, flags, mode);
|
||||
dummy = write(tmp, emu->context->fullpath, strlen(emu->context->fullpath)+1);
|
||||
for (int i=1; i<emu->context->argc; ++i)
|
||||
dummy = write(tmp, emu->context->argv[i], strlen(emu->context->argv[i])+1);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
#else
|
||||
int tmp = shm_open(TMP_CMDLINE, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open(pathname, flags, mode);
|
||||
shm_unlink(TMP_CMDLINE); // remove the shm file, but it will still exist because it's currently in use
|
||||
int dummy = write(tmp, emu->context->fullpath, strlen(emu->context->fullpath)+1);
|
||||
(void)dummy;
|
||||
for (int i=1; i<emu->context->argc; ++i)
|
||||
dummy = write(tmp, emu->context->argv[i], strlen(emu->context->argv[i])+1);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
if(isProcSelf((const char*)pathname, "exe")) {
|
||||
return open(emu->context->fullpath, flags, mode);
|
||||
}
|
||||
#ifndef NOALIGN
|
||||
if(strcmp((const char*)pathname, "/proc/cpuinfo")==0) {
|
||||
// special case for cpuinfo
|
||||
int tmp = shm_open(TMP_CPUINFO, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open(pathname, flags, mode); // error fallback
|
||||
shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUInfoFile(tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
if(isCpuTopology((const char*)pathname)!=-1) {
|
||||
int n = isCpuTopology((const char*)pathname);
|
||||
char buf[512];
|
||||
snprintf(buf, 512, TMP_CPUTOPO, n);
|
||||
int tmp = shm_open(buf, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open(pathname, flags, mode); // error fallback
|
||||
shm_unlink(buf); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUTopologyCoreID(tmp, n);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
int ret = open(pathname, flags, mode);
|
||||
return ret;
|
||||
}
|
||||
EXPORT int32_t my32___open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode) __attribute__((alias("my32_open")));
|
||||
|
||||
#ifdef DYNAREC
|
||||
static int hasDBFromAddress(uintptr_t addr)
|
||||
@ -1543,143 +1444,6 @@ EXPORT ssize_t my32_read(int fd, void* buf, size_t count)
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT int32_t my32_open64(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode)
|
||||
{
|
||||
if(isProcSelf((const char*)pathname, "cmdline")) {
|
||||
// special case for self command line...
|
||||
int tmp = shm_open(TMP_CMDLINE, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open64(pathname, flags, mode);
|
||||
shm_unlink(TMP_CMDLINE); // remove the shm file, but it will still exist because it's currently in use
|
||||
int dummy = write(tmp, emu->context->fullpath, strlen(emu->context->fullpath)+1);
|
||||
(void)dummy;
|
||||
for (int i=1; i<emu->context->argc; ++i)
|
||||
dummy = write(tmp, emu->context->argv[i], strlen(emu->context->argv[i])+1);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
if(isProcSelf((const char*)pathname, "exe")) {
|
||||
return open64(emu->context->fullpath, flags, mode);
|
||||
}
|
||||
#ifndef NOALIGN
|
||||
if(strcmp((const char*)pathname, "/proc/cpuinfo")==0) {
|
||||
// special case for cpuinfo
|
||||
int tmp = shm_open(TMP_CPUINFO, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open64(pathname, flags, mode); // error fallback
|
||||
shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUInfoFile(tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
if(isCpuTopology((const char*)pathname)!=-1) {
|
||||
int n = isCpuTopology((const char*)pathname);
|
||||
char buf[512];
|
||||
snprintf(buf, 512, TMP_CPUTOPO, n);
|
||||
int tmp = shm_open(buf, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return open64(pathname, flags, mode); // error fallback
|
||||
shm_unlink(buf); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUTopologyCoreID(tmp, n);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
return open64(pathname, flags, mode);
|
||||
}
|
||||
|
||||
EXPORT FILE* my32_fopen(x64emu_t* emu, const char* path, const char* mode)
|
||||
{
|
||||
if(isProcSelf(path, "maps")) {
|
||||
// special case for self memory map
|
||||
int tmp = shm_open(TMP_MEMMAP, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen(path, mode); // error fallback
|
||||
shm_unlink(TMP_MEMMAP); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateMemorymapFile(emu->context, tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);
|
||||
}
|
||||
#ifndef NOALIGN
|
||||
if(strcmp(path, "/proc/cpuinfo")==0) {
|
||||
// special case for cpuinfo
|
||||
int tmp = shm_open(TMP_CPUINFO, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen(path, mode); // error fallback
|
||||
shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUInfoFile(tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);
|
||||
}
|
||||
if(isCpuTopology(path)!=-1) {
|
||||
int n = isCpuTopology(path);
|
||||
char buf[512];
|
||||
snprintf(buf, 512, TMP_CPUTOPO, n);
|
||||
int tmp = shm_open(buf, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen(path, mode); // error fallback
|
||||
shm_unlink(buf); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUTopologyCoreID(tmp, n);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);;
|
||||
}
|
||||
#endif
|
||||
if(isProcSelf(path, "exe")) {
|
||||
return fopen(emu->context->fullpath, mode);
|
||||
}
|
||||
return fopen(path, mode);
|
||||
}
|
||||
|
||||
EXPORT FILE* my32_fopen64(x64emu_t* emu, const char* path, const char* mode)
|
||||
{
|
||||
if(isProcSelf(path, "maps")) {
|
||||
// special case for self memory map
|
||||
int tmp = shm_open(TMP_MEMMAP, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen64(path, mode); // error fallback
|
||||
shm_unlink(TMP_MEMMAP); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateMemorymapFile(emu->context, tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);
|
||||
}
|
||||
#ifndef NOALIGN
|
||||
if(strcmp(path, "/proc/cpuinfo")==0) {
|
||||
// special case for cpuinfo
|
||||
int tmp = shm_open(TMP_CPUINFO, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen64(path, mode); // error fallback
|
||||
shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUInfoFile(tmp);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);
|
||||
}
|
||||
if(isCpuTopology(path)!=-1) {
|
||||
int n = isCpuTopology(path);
|
||||
char buf[512];
|
||||
snprintf(buf, 512, TMP_CPUTOPO, n);
|
||||
int tmp = shm_open(buf, O_RDWR | O_CREAT, S_IRWXU);
|
||||
if(tmp<0) return fopen(path, mode); // error fallback
|
||||
shm_unlink(buf); // remove the shm file, but it will still exist because it's currently in use
|
||||
CreateCPUTopologyCoreID(tmp, n);
|
||||
lseek(tmp, 0, SEEK_SET);
|
||||
return fdopen(tmp, mode);;
|
||||
}
|
||||
#endif
|
||||
if(isProcSelf(path, "exe")) {
|
||||
return fopen64(emu->context->fullpath, mode);
|
||||
}
|
||||
return fopen64(path, mode);
|
||||
}
|
||||
|
||||
#ifndef _SC_NPROCESSORS_ONLN
|
||||
#define _SC_NPROCESSORS_ONLN 84
|
||||
#endif
|
||||
#ifndef _SC_NPROCESSORS_CONF
|
||||
#define _SC_NPROCESSORS_CONF 83
|
||||
#endif
|
||||
EXPORT long my32_sysconf(x64emu_t* emu, int what) {
|
||||
if(what==_SC_NPROCESSORS_ONLN) {
|
||||
return getNCpu();
|
||||
}
|
||||
if(what==_SC_NPROCESSORS_CONF) {
|
||||
return getNCpu();
|
||||
}
|
||||
return sysconf(what);
|
||||
}
|
||||
EXPORT long my32___sysconf(x64emu_t* emu, int what) __attribute__((alias("my32_sysconf")));
|
||||
|
||||
#if 0
|
||||
EXPORT int my32_mkstemps64(x64emu_t* emu, char* template, int suffixlen)
|
||||
{
|
||||
|
@ -366,8 +366,8 @@ GOW(_flushlbf, vFv)
|
||||
//GO(fmemopen, pFpup)
|
||||
// fmtmsg
|
||||
GO(fnmatch, iFppi)
|
||||
GOM(fopen, SFEpp) //%%
|
||||
GOWM(fopen64, SFEpp) //%%
|
||||
GO2(fopen, SFEpp, my_fopen) //%%
|
||||
GOW2(fopen64, SFEpp, my_fopen64) //%%
|
||||
//GOM(fopencookie, pFEpppppp) //%% last 4p are a struct with 4 callbacks...
|
||||
GOWM(fork, iFEv) //%%
|
||||
GOM(__fork, iFEv) //%%
|
||||
@ -1199,10 +1199,10 @@ GOW(ntohs, WFW)
|
||||
// __obstack_vprintf_chk
|
||||
//GOWM(on_exit, iFEpp) //%%
|
||||
//GO2(__on_exit, iFEpp, my_on_exit) //%%
|
||||
GOWM(open, iFEpON) //%%
|
||||
//GOWM(__open, iFEpON) //%%
|
||||
GOW2(open, iFEpON, my_open) //%%
|
||||
GOW2(__open, iFEpON, my_open) //%%
|
||||
//GO(__open_2, iFpO)
|
||||
GOWM(open64, iFEpON) //%%
|
||||
GOW2(open64, iFEpON, my_open64) //%%
|
||||
// __open64 // Weak
|
||||
//GO(__open64_2, iFpO)
|
||||
//GOW(openat, iFipON)
|
||||
@ -1351,7 +1351,7 @@ GOM(read, lFipL) //%%,noE
|
||||
GOWM(readdir, pFEp) //%%
|
||||
GO(readdir64, pFp) // check if alignement is correct
|
||||
//GOM(readdir_r, iFEppp) //%% should also be weak
|
||||
GOM(readlink, lFEppL) //%%
|
||||
GO2(readlink, lFEppL, my_readlink) //%%
|
||||
GOM(readlinkat, iFEippL)
|
||||
// __readlinkat_chk
|
||||
// __readlink_chk
|
||||
@ -1768,8 +1768,8 @@ GO(sync, vFv)
|
||||
GO(syncfs, iFi)
|
||||
// sync_file_range
|
||||
GOM(syscall, lFEV) //%%
|
||||
GOWM(sysconf, lFEi)
|
||||
GOM(__sysconf, lFEi)
|
||||
GOW2(sysconf, lFEi, my_sysconf)
|
||||
GO2(__sysconf, lFEi, my_sysconf)
|
||||
// sysctl // Weak
|
||||
//GO(__sysctl, iFp)
|
||||
//DATA(_sys_errlist, 4)
|
||||
|
@ -2294,20 +2294,35 @@ EXPORT unsigned long my32_XLookupKeysym(x64emu_t* emu, my_XEvent_32_t* evt, int
|
||||
return my->XLookupKeysym(evt?(&event):NULL, index);
|
||||
}
|
||||
|
||||
EXPORT int my32_XLookupString(x64emu_t* emu, my_XEvent_32_t* evt, void* buff, int len, void* keysym, void* status)
|
||||
EXPORT int my32_XLookupString(x64emu_t* emu, my_XEvent_32_t* evt, void* buff, int len, ulong_t* keysym, void* status)
|
||||
{
|
||||
my_XEvent_t event = {0};
|
||||
XID keysym_l = 0;
|
||||
if(evt) unconvertXEvent(&event, evt);
|
||||
return my->XLookupString(evt?(&event):NULL, buff, len, keysym, status);
|
||||
int ret = my->XLookupString(evt?(&event):NULL, buff, len, keysym?(&keysym_l):NULL, status);
|
||||
if(keysym) *keysym = to_ulong(keysym_l);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT int my32_XmbLookupString(x64emu_t* emu, void* xic, my_XEvent_32_t* evt, void* buff, int len, void* keysym, void* status)
|
||||
EXPORT int my32_XmbLookupString(x64emu_t* emu, void* xic, my_XEvent_32_t* evt, void* buff, int len, ulong_t* keysym, void* status)
|
||||
{
|
||||
my_XEvent_t event = {0};
|
||||
XID keysym_l = 0;
|
||||
if(evt) unconvertXEvent(&event, evt);
|
||||
return my->XmbLookupString(xic, evt?(&event):NULL, buff, len, keysym, status);
|
||||
int ret = my->XmbLookupString(xic, evt?(&event):NULL, buff, len, keysym?(&keysym_l):NULL, status);
|
||||
if(keysym) *keysym = to_ulong(keysym_l);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT int my32_Xutf8LookupString(x64emu_t* emu, void* xic, my_XEvent_32_t* evt, void* buff, int len, ulong_t* keysym, void* status)
|
||||
{
|
||||
my_XEvent_t event = {0};
|
||||
XID keysym_l = 0;
|
||||
if(evt) unconvertXEvent(&event, evt);
|
||||
int ret = my->Xutf8LookupString(xic, evt?(&event):NULL, buff, len, keysym?(&keysym_l):NULL, status);
|
||||
if(keysym) *keysym = to_ulong(keysym_l);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT int my32_XSetWMProtocols(x64emu_t* emu, void* dpy, XID window, XID_32* protocol, int count)
|
||||
{
|
||||
|
@ -905,7 +905,7 @@ GO(XmbDrawText, vFXLpiibpiip_i)
|
||||
//GO(_XmbGenericTextExtents,
|
||||
//GO(_XmbGenericTextPerCharExtents,
|
||||
GO(_Xmblen, iFpi)
|
||||
GOM(XmbLookupString, iFEpppibL_p)
|
||||
GOM(XmbLookupString, iFEpppipp)
|
||||
GO(XmbResetIC, pFp)
|
||||
//GO(XmbSetWMProperties, vFpLpppippp)
|
||||
//GO(_Xmbstoutf8,
|
||||
@ -1182,7 +1182,7 @@ GO(Xutf8DrawText, vFXLpiibpiip_i)
|
||||
//GO(_Xutf8GenericTextEscapement,
|
||||
//GO(_Xutf8GenericTextExtents,
|
||||
//GO(_Xutf8GenericTextPerCharExtents,
|
||||
//GO(Xutf8LookupString, iFpbiLiXLLLLiiiiuui_pibL_p)
|
||||
GOM(Xutf8LookupString, iFEpppipp)
|
||||
GO(Xutf8ResetIC, pFp)
|
||||
GOM(Xutf8SetWMProperties, vFEXLpppippp) // Warning: failed to confirm
|
||||
GO(Xutf8TextEscapement, iFppi)
|
||||
|
@ -6,10 +6,16 @@
|
||||
|
||||
#include "wrappedlibs.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "wrapper32.h"
|
||||
#include "bridge.h"
|
||||
#include "librarian/library_private.h"
|
||||
#include "x64emu.h"
|
||||
#include "emu/x64emu_private.h"
|
||||
#include "callback.h"
|
||||
#include "librarian.h"
|
||||
#include "box32context.h"
|
||||
#include "emu/x64emu_private.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
static const char* libxcursorName = "libXcursor.so";
|
||||
@ -25,5 +31,51 @@
|
||||
#define NEEDED_LIBS "libX11.so.6", "libXfixes.so.3", "libXrender.so.1"
|
||||
#endif
|
||||
|
||||
#include "libtools/my_x11_defs.h"
|
||||
#include "libtools/my_x11_defs_32.h"
|
||||
|
||||
#include "generated/wrappedlibxcursortypes32.h"
|
||||
|
||||
#include "wrappercallback32.h"
|
||||
|
||||
void* getDisplay(void*);
|
||||
void* FindDisplay(void*);
|
||||
|
||||
void inplace_XcursorCursors_shrink(void* a)
|
||||
{
|
||||
if(!a) return;
|
||||
my_XcursorCursors_t* src = a;
|
||||
my_XcursorCursors_32_t* dst = a;
|
||||
|
||||
dst->dpy = to_ptrv(getDisplay(src->dpy));
|
||||
dst->ref = src->ref;
|
||||
dst->ncursor = src->ncursor;
|
||||
dst->cursors = to_ptrv(src->cursors);
|
||||
}
|
||||
void inplace_XcursorCursors_enlarge(void* a)
|
||||
{
|
||||
if(!a) return;
|
||||
my_XcursorCursors_32_t* src = a;
|
||||
my_XcursorCursors_t* dst = a;
|
||||
|
||||
dst->cursors = from_ptrv(src->cursors);
|
||||
dst->ncursor = src->ncursor;
|
||||
dst->ref = src->ref;
|
||||
dst->dpy = FindDisplay(from_ptrv(src->dpy));
|
||||
}
|
||||
|
||||
EXPORT void* my32_XcursorCursorsCreate(x64emu_t* emu, void* dpy, int n)
|
||||
{
|
||||
void* ret = my->XcursorCursorsCreate(dpy, n);
|
||||
inplace_XcursorCursors_shrink(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT void my32_XcursorCursorsDestroy(x64emu_t* emu, void* a)
|
||||
{
|
||||
inplace_XcursorCursors_enlarge(a);
|
||||
my->XcursorCursorsDestroy(a);
|
||||
}
|
||||
|
||||
#include "wrappedlib_init32.h"
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
//GO(XcursorCommentsDestroy, vFp)
|
||||
//GO(_XcursorCreateFontCursor,
|
||||
//GO(_XcursorCreateGlyphCursor,
|
||||
//GO(XcursorCursorsCreate, pFpi)
|
||||
//GO(XcursorCursorsDestroy, vFp)
|
||||
GOM(XcursorCursorsCreate, pFEXi)
|
||||
GOM(XcursorCursorsDestroy, vFEp)
|
||||
//GO(XcursorFileLoad, iFSpp)
|
||||
//GO(XcursorFileLoadAllImages, pFS)
|
||||
//GO(XcursorFileLoadImage, pFSi)
|
||||
|
Loading…
Reference in New Issue
Block a user