Added l and L in wrapper definition (to handle signed and unsigned long)

This commit is contained in:
ptitSeb 2019-12-04 14:45:20 +01:00
parent b1958a81a3
commit 3eacb55dbc
4 changed files with 37 additions and 19 deletions

View File

@ -4,7 +4,7 @@ import os
import glob
import sys
values = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'p', 'V', "O"]
values = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'l', 'L', 'p', 'V', "O"]
def splitchar(s):
ret = [len(s)]
i = 0
@ -246,6 +246,7 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
// list of defined wrapper
// v = void, i = int32, u = uint32, U/I= (u)int64
// l = signed long, L = unsigned long (long is an int with the size of a pointer)
// p = pointer, P = callback
// f = float, d = double, D = long double, K = fake long double
// V = vaargs, E = current x86emu struct, e = ref to current x86emu struct
@ -297,8 +298,8 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
# First part: typedefs
for v in gbl["()"]:
# E e v c w i I C W u U f d D K p V A
types = ["x86emu_t*", "x86emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "void*", "void*", "int32_t"]
# E e v c w i I C W u U f d D K l L p V A
types = ["x86emu_t*", "x86emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t"]
if len(values) != len(types):
raise NotImplementedError("len(values) = {lenval} != len(types) = {lentypes}".format(lenval=len(values), lentypes=len(types)))
@ -308,8 +309,8 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
if k != "()":
file.write("\n#if " + k + "\n")
for v in gbl[k]:
# E e v c w i I C W u U f d D K p V A
types = ["x86emu_t*", "x86emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "void*", "void*", "int32_t"]
# E e v c w i I C W u U f d D K l L p V A
types = ["x86emu_t*", "x86emu_t**", "void", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t"]
if len(values) != len(types):
raise NotImplementedError("len(values) = {lenval} != len(types) = {lentypes}".format(lenval=len(values), lentypes=len(types)))
@ -348,12 +349,14 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
"*(double*)(R_ESP + {p}), ", # d
"*(long double*)(R_ESP + {p}), ", # D
"FromLD((void*)(R_ESP + {p})), ", # K
"*(intptr_t*)(R_ESP + {p}), ", # l
"*(uintptr_t*)(R_ESP + {p}), ", # L
"*(void**)(R_ESP + {p}), ", # p
"(void*)(R_ESP + {p}), ", # V
"of_convert(*(int32_t*)(R_ESP + {p})), ", # O
]
# E e v c w i I C W u U f d D K p V O
deltas = [0, 0, 4, 4, 4, 4, 8, 4, 4, 4, 8, 4, 8, 12, 12, 4, 0, 4]
# E e v c w i I C W u U f d D K l L p V O
deltas = [0, 0, 4, 4, 4, 4, 8, 4, 4, 4, 8, 4, 8, 12, 12, 4, 4, 4, 0, 4]
if len(values) != len(arg):
raise NotImplementedError("len(values) = {lenval} != len(arg) = {lenarg}".format(lenval=len(values), lenarg=len(arg)))
if len(values) != len(deltas):
@ -378,6 +381,8 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
"double db=fn({0}); fpu_do_push(emu); ST0val = db;", # d
"long double ld=fn({0}); fpu_do_push(emu); ST0val = ld;", # D
"double db=fn({0}); fpu_do_push(emu); ST0val = db;", # K
"R_EAX=(intptr_t)fn({0});", # l
"R_EAX=(uintptr_t)fn({0});", # L
"R_EAX=(uintptr_t)fn({0});", # p
"\n#error Invalid return type: va_list\n", # V
"\n#error Invalid return type: at_flags\n", # O
@ -409,6 +414,6 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
return 0
if __name__ == '__main__':
if main(sys.argv[1], sys.argv[2:], "1.1.1.04") != 0:
if main(sys.argv[1], sys.argv[2:], "1.1.1.05") != 0:
exit(2)
exit(0)

View File

@ -1,5 +1,5 @@
/*****************************************************************
* File automatically generated by rebuild_wrappers.py (v1.1.1.04)
* File automatically generated by rebuild_wrappers.py (v1.1.1.05)
*****************************************************************/
#include <stdio.h>
#include <stdlib.h>
@ -263,6 +263,8 @@ typedef float (*fFppu_t)(void*, void*, uint32_t);
typedef float (*fFppp_t)(void*, void*, void*);
typedef double (*dFppu_t)(void*, void*, uint32_t);
typedef double (*dFppp_t)(void*, void*, void*);
typedef intptr_t (*lFppi_t)(void*, void*, int32_t);
typedef uintptr_t (*LFppi_t)(void*, void*, int32_t);
typedef void* (*pFEip_t)(x86emu_t*, int32_t, void*);
typedef void* (*pFEpi_t)(x86emu_t*, void*, int32_t);
typedef void* (*pFEpp_t)(x86emu_t*, void*, void*);
@ -418,7 +420,6 @@ typedef uint32_t (*uFpuip_t)(void*, uint32_t, int32_t, void*);
typedef uint32_t (*uFpuuu_t)(void*, uint32_t, uint32_t, uint32_t);
typedef uint32_t (*uFpuup_t)(void*, uint32_t, uint32_t, void*);
typedef uint32_t (*uFpupp_t)(void*, uint32_t, void*, void*);
typedef uint32_t (*uFppii_t)(void*, void*, int32_t, int32_t);
typedef uint32_t (*uFppip_t)(void*, void*, int32_t, void*);
typedef uint32_t (*uFppup_t)(void*, void*, uint32_t, void*);
typedef uint32_t (*uFpppi_t)(void*, void*, void*, int32_t);
@ -426,6 +427,8 @@ typedef uint32_t (*uFpppp_t)(void*, void*, void*, void*);
typedef uint64_t (*UFpUii_t)(void*, uint64_t, int32_t, int32_t);
typedef uint64_t (*UFppii_t)(void*, void*, int32_t, int32_t);
typedef uint64_t (*UFppip_t)(void*, void*, int32_t, void*);
typedef uintptr_t (*LFppii_t)(void*, void*, int32_t, int32_t);
typedef uintptr_t (*LFppip_t)(void*, void*, int32_t, void*);
typedef void* (*pFEupp_t)(x86emu_t*, uint32_t, void*, void*);
typedef void* (*pFEpii_t)(x86emu_t*, void*, int32_t, int32_t);
typedef void* (*pFEpip_t)(x86emu_t*, void*, int32_t, void*);
@ -576,6 +579,7 @@ typedef uint32_t (*uFppiip_t)(void*, void*, int32_t, int32_t, void*);
typedef uint32_t (*uFppipp_t)(void*, void*, int32_t, void*, void*);
typedef uint32_t (*uFppuup_t)(void*, void*, uint32_t, uint32_t, void*);
typedef uint32_t (*uFppppp_t)(void*, void*, void*, void*, void*);
typedef intptr_t (*lFppiip_t)(void*, void*, int32_t, int32_t, void*);
typedef void* (*pFEpiii_t)(x86emu_t*, void*, int32_t, int32_t, int32_t);
typedef void* (*pFEppii_t)(x86emu_t*, void*, void*, int32_t, int32_t);
typedef void* (*pFipipu_t)(int32_t, void*, int32_t, void*, uint32_t);
@ -1195,6 +1199,8 @@ void fFppu(x86emu_t *emu, uintptr_t fcn) { fFppu_t fn = (fFppu_t)fcn; float fl=f
void fFppp(x86emu_t *emu, uintptr_t fcn) { fFppp_t fn = (fFppp_t)fcn; float fl=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12)); fpu_do_push(emu); ST0val = fl; }
void dFppu(x86emu_t *emu, uintptr_t fcn) { dFppu_t fn = (dFppu_t)fcn; double db=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12)); fpu_do_push(emu); ST0val = db; }
void dFppp(x86emu_t *emu, uintptr_t fcn) { dFppp_t fn = (dFppp_t)fcn; double db=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12)); fpu_do_push(emu); ST0val = db; }
void lFppi(x86emu_t *emu, uintptr_t fcn) { lFppi_t fn = (lFppi_t)fcn; R_EAX=(intptr_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12)); }
void LFppi(x86emu_t *emu, uintptr_t fcn) { LFppi_t fn = (LFppi_t)fcn; R_EAX=(uintptr_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12)); }
void pFEip(x86emu_t *emu, uintptr_t fcn) { pFEip_t fn = (pFEip_t)fcn; R_EAX=(uintptr_t)fn(emu, *(int32_t*)(R_ESP + 4), *(void**)(R_ESP + 8)); }
void pFEpi(x86emu_t *emu, uintptr_t fcn) { pFEpi_t fn = (pFEpi_t)fcn; R_EAX=(uintptr_t)fn(emu, *(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8)); }
void pFEpp(x86emu_t *emu, uintptr_t fcn) { pFEpp_t fn = (pFEpp_t)fcn; R_EAX=(uintptr_t)fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8)); }
@ -1350,7 +1356,6 @@ void uFpuip(x86emu_t *emu, uintptr_t fcn) { uFpuip_t fn = (uFpuip_t)fcn; R_EAX=(
void uFpuuu(x86emu_t *emu, uintptr_t fcn) { uFpuuu_t fn = (uFpuuu_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16)); }
void uFpuup(x86emu_t *emu, uintptr_t fcn) { uFpuup_t fn = (uFpuup_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void uFpupp(x86emu_t *emu, uintptr_t fcn) { uFpupp_t fn = (uFpupp_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(uint32_t*)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void uFppii(x86emu_t *emu, uintptr_t fcn) { uFppii_t fn = (uFppii_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
void uFppip(x86emu_t *emu, uintptr_t fcn) { uFppip_t fn = (uFppip_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void uFppup(x86emu_t *emu, uintptr_t fcn) { uFppup_t fn = (uFppup_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void uFpppi(x86emu_t *emu, uintptr_t fcn) { uFpppi_t fn = (uFpppi_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
@ -1358,6 +1363,8 @@ void uFpppp(x86emu_t *emu, uintptr_t fcn) { uFpppp_t fn = (uFpppp_t)fcn; R_EAX=(
void UFpUii(x86emu_t *emu, uintptr_t fcn) { UFpUii_t fn = (UFpUii_t)fcn; ui64_t r; r.u=(uint64_t)fn(*(void**)(R_ESP + 4), *(uint64_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 16), *(int32_t*)(R_ESP + 20)); R_EAX=r.d[0]; R_EDX=r.d[1]; }
void UFppii(x86emu_t *emu, uintptr_t fcn) { UFppii_t fn = (UFppii_t)fcn; ui64_t r; r.u=(uint64_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); R_EAX=r.d[0]; R_EDX=r.d[1]; }
void UFppip(x86emu_t *emu, uintptr_t fcn) { UFppip_t fn = (UFppip_t)fcn; ui64_t r; r.u=(uint64_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); R_EAX=r.d[0]; R_EDX=r.d[1]; }
void LFppii(x86emu_t *emu, uintptr_t fcn) { LFppii_t fn = (LFppii_t)fcn; R_EAX=(uintptr_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
void LFppip(x86emu_t *emu, uintptr_t fcn) { LFppip_t fn = (LFppip_t)fcn; R_EAX=(uintptr_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(void**)(R_ESP + 16)); }
void pFEupp(x86emu_t *emu, uintptr_t fcn) { pFEupp_t fn = (pFEupp_t)fcn; R_EAX=(uintptr_t)fn(emu, *(uint32_t*)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12)); }
void pFEpii(x86emu_t *emu, uintptr_t fcn) { pFEpii_t fn = (pFEpii_t)fcn; R_EAX=(uintptr_t)fn(emu, *(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12)); }
void pFEpip(x86emu_t *emu, uintptr_t fcn) { pFEpip_t fn = (pFEpip_t)fcn; R_EAX=(uintptr_t)fn(emu, *(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(void**)(R_ESP + 12)); }
@ -1508,6 +1515,7 @@ void uFppiip(x86emu_t *emu, uintptr_t fcn) { uFppiip_t fn = (uFppiip_t)fcn; R_EA
void uFppipp(x86emu_t *emu, uintptr_t fcn) { uFppipp_t fn = (uFppipp_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20)); }
void uFppuup(x86emu_t *emu, uintptr_t fcn) { uFppuup_t fn = (uFppuup_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(uint32_t*)(R_ESP + 12), *(uint32_t*)(R_ESP + 16), *(void**)(R_ESP + 20)); }
void uFppppp(x86emu_t *emu, uintptr_t fcn) { uFppppp_t fn = (uFppppp_t)fcn; R_EAX=(uint32_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(void**)(R_ESP + 12), *(void**)(R_ESP + 16), *(void**)(R_ESP + 20)); }
void lFppiip(x86emu_t *emu, uintptr_t fcn) { lFppiip_t fn = (lFppiip_t)fcn; R_EAX=(intptr_t)fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(void**)(R_ESP + 20)); }
void pFEpiii(x86emu_t *emu, uintptr_t fcn) { pFEpiii_t fn = (pFEpiii_t)fcn; R_EAX=(uintptr_t)fn(emu, *(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
void pFEppii(x86emu_t *emu, uintptr_t fcn) { pFEppii_t fn = (pFEppii_t)fcn; R_EAX=(uintptr_t)fn(emu, *(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16)); }
void pFipipu(x86emu_t *emu, uintptr_t fcn) { pFipipu_t fn = (pFipipu_t)fcn; R_EAX=(uintptr_t)fn(*(int32_t*)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(void**)(R_ESP + 16), *(uint32_t*)(R_ESP + 20)); }

View File

@ -1,5 +1,5 @@
/*****************************************************************
* File automatically generated by rebuild_wrappers.py (v1.1.1.04)
* File automatically generated by rebuild_wrappers.py (v1.1.1.05)
*****************************************************************/
#ifndef __WRAPPER_H_
#define __WRAPPER_H_
@ -12,6 +12,7 @@ typedef void (*wrapper_t)(x86emu_t* emu, uintptr_t fnc);
// list of defined wrapper
// v = void, i = int32, u = uint32, U/I= (u)int64
// l = signed long, L = unsigned long (long is an int with the size of a pointer)
// p = pointer, P = callback
// f = float, d = double, D = long double, K = fake long double
// V = vaargs, E = current x86emu struct, e = ref to current x86emu struct
@ -259,6 +260,8 @@ void fFppu(x86emu_t *emu, uintptr_t fnc);
void fFppp(x86emu_t *emu, uintptr_t fnc);
void dFppu(x86emu_t *emu, uintptr_t fnc);
void dFppp(x86emu_t *emu, uintptr_t fnc);
void lFppi(x86emu_t *emu, uintptr_t fnc);
void LFppi(x86emu_t *emu, uintptr_t fnc);
void pFEip(x86emu_t *emu, uintptr_t fnc);
void pFEpi(x86emu_t *emu, uintptr_t fnc);
void pFEpp(x86emu_t *emu, uintptr_t fnc);
@ -414,7 +417,6 @@ void uFpuip(x86emu_t *emu, uintptr_t fnc);
void uFpuuu(x86emu_t *emu, uintptr_t fnc);
void uFpuup(x86emu_t *emu, uintptr_t fnc);
void uFpupp(x86emu_t *emu, uintptr_t fnc);
void uFppii(x86emu_t *emu, uintptr_t fnc);
void uFppip(x86emu_t *emu, uintptr_t fnc);
void uFppup(x86emu_t *emu, uintptr_t fnc);
void uFpppi(x86emu_t *emu, uintptr_t fnc);
@ -422,6 +424,8 @@ void uFpppp(x86emu_t *emu, uintptr_t fnc);
void UFpUii(x86emu_t *emu, uintptr_t fnc);
void UFppii(x86emu_t *emu, uintptr_t fnc);
void UFppip(x86emu_t *emu, uintptr_t fnc);
void LFppii(x86emu_t *emu, uintptr_t fnc);
void LFppip(x86emu_t *emu, uintptr_t fnc);
void pFEupp(x86emu_t *emu, uintptr_t fnc);
void pFEpii(x86emu_t *emu, uintptr_t fnc);
void pFEpip(x86emu_t *emu, uintptr_t fnc);
@ -572,6 +576,7 @@ void uFppiip(x86emu_t *emu, uintptr_t fnc);
void uFppipp(x86emu_t *emu, uintptr_t fnc);
void uFppuup(x86emu_t *emu, uintptr_t fnc);
void uFppppp(x86emu_t *emu, uintptr_t fnc);
void lFppiip(x86emu_t *emu, uintptr_t fnc);
void pFEpiii(x86emu_t *emu, uintptr_t fnc);
void pFEppii(x86emu_t *emu, uintptr_t fnc);
void pFipipu(x86emu_t *emu, uintptr_t fnc);

View File

@ -1680,19 +1680,19 @@ GOW(strtold_l, DFppu)
GO2(__strtold_l, KFppip, __strtod_l)
GO2(strtold_l, KFppu, strtod_l)
#endif
GO(__strtol_internal, iFppi)
GO(__strtol_internal, lFppi)
GO(strtoll, IFppi)
GO(__strtol_l, iFppiip)
GOW(strtol_l, iFppiip)
GO(__strtol_l, lFppiip)
GOW(strtol_l, lFppiip)
GO(__strtoll_internal, IFppii)
GO(__strtoll_l, IFppip)
GOW(strtoll_l, IFppip)
// strtoq // Weak
GO(strtoul, uFppi)
GO(__strtoul_internal, uFppii)
GO(strtoul, LFppi)
GO(__strtoul_internal, LFppii)
GO(strtoull, UFppi)
GO(__strtoul_l, uFppip)
GOW(strtoul_l, uFppip)
GOW(strtoul_l, LFppip)
GO(__strtoull_internal, UFppii)
GO(__strtoull_l, UFppip)
GOW(strtoull_l, UFppip)