about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xrebuild_wrappers.py43
-rw-r--r--src/wrapped/generated/functions_list.txt3
-rw-r--r--src/wrapped/generated/wrappeddbustypes.h4
-rw-r--r--src/wrapped/generated/wrapper.c2
-rw-r--r--src/wrapped/generated/wrapper.h2
-rwxr-xr-xsrc/wrapped/wrappeddbus_private.h2
6 files changed, 34 insertions, 22 deletions
diff --git a/rebuild_wrappers.py b/rebuild_wrappers.py
index 5eea0ea3..e9cc1c58 100755
--- a/rebuild_wrappers.py
+++ b/rebuild_wrappers.py
@@ -41,7 +41,7 @@ import os
 import sys
 
 class FunctionType(str):
-	values: List[str] = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'l', 'L', 'p', 'V', 'O', 'S', 'N', 'M', 'H', 'P']
+	values: List[str] = ['E', 'e', 'v', 'c', 'w', 'i', 'I', 'C', 'W', 'u', 'U', 'f', 'd', 'D', 'K', 'l', 'L', 'p', 'V', 'O', 'S', 'N', 'M', 'H', 'P', 'A']
 	
 	@staticmethod
 	def validate(s: str, post: str) -> bool:
@@ -511,7 +511,7 @@ def main(root: str, files: Sequence[Filename], ver: str):
 	allowed_fpr   : str = "fd"
 	
 	# Sanity checks
-	forbidden_simple: str = "EeDKVOSNMHP"
+	forbidden_simple: str = "EeDKVOSNMHPA"
 	assert(len(allowed_simply) + len(allowed_regs) + len(allowed_fpr) + len(forbidden_simple) == len(FunctionType.values))
 	assert(all(c not in allowed_regs for c in allowed_simply))
 	assert(all(c not in allowed_simply + allowed_regs for c in allowed_fpr))
@@ -609,6 +609,7 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
 // N = ... automatically sending 1 arg
 // M = ... automatically sending 2 args
 // H = Huge 128bits value/struct
+// A = va_list
 
 """,
 		"fntypes.h": """/*******************************************************************
@@ -638,16 +639,16 @@ int isSimpleWrapper(wrapper_t fun);
 	}
 	
 	# Rewrite the wrapper.c file:
+	# i and u should only be 32 bits
+	#            E            e             v       c         w          i          I          C          W           u           U           f        d         D              K         l           L            p        V        O          S        N      M      H                    P        A
+	td_types = ["x64emu_t*", "x64emu_t**", "void", "int8_t", "int16_t", "int64_t", "int64_t", "uint8_t", "uint16_t", "uint64_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t", "void*", "...", "...", "unsigned __int128", "void*", "void*"]
+	if len(FunctionType.values) != len(td_types):
+		raise NotImplementedError("len(values) = {lenval} != len(td_types) = {lentypes}".format(lenval=len(FunctionType.values), lentypes=len(td_types)))
+	
 	def generate_typedefs(arr: Sequence[FunctionType], file) -> None:
-		# i and u should only be 32 bits
-		#         E            e             v       c         w          i          I          C          W           u           U           f        d         D              K         l           L            p        V        O          S        N      M      H                    P
-		types = ["x64emu_t*", "x64emu_t**", "void", "int8_t", "int16_t", "int64_t", "int64_t", "uint8_t", "uint16_t", "uint64_t", "uint64_t", "float", "double", "long double", "double", "intptr_t", "uintptr_t", "void*", "void*", "int32_t", "void*", "...", "...", "unsigned __int128", "void*"]
-		if len(FunctionType.values) != len(types):
-			raise NotImplementedError("len(values) = {lenval} != len(types) = {lentypes}".format(lenval=len(FunctionType.values), lentypes=len(types)))
-		
 		for v in arr:
-			file.write("typedef " + types[FunctionType.values.index(v[0])] + " (*" + v + "_t)"
-				+ "(" + ', '.join(types[FunctionType.values.index(t)] for t in v[2:]) + ");\n")
+			file.write("typedef " + td_types[FunctionType.values.index(v[0])] + " (*" + v + "_t)"
+				+ "(" + ', '.join(td_types[FunctionType.values.index(t)] for t in v[2:]) + ");\n")
 	
 	with open(os.path.join(root, "src", "wrapped", "generated", "wrapper.c"), 'w') as file:
 		file.write(files_header["wrapper.c"].format(lbr="{", rbr="}", version=ver))
@@ -691,22 +692,23 @@ int isSimpleWrapper(wrapper_t fun);
 			"\n#error Invalid return type: ... with 2 args\n",         # M
 			"unsigned __int128 u128 = fn({0}); R_RAX=(u128&0xFFFFFFFFFFFFFFFFL); R_RDX=(u128>>64)&0xFFFFFFFFFFFFFFFFL;", # H
 			"\n#error Invalid return type: pointer in the stack\n",    # P
+			"\n#error Invalid return type: va_list\n",                 # A
 		]
 		
 		# Name of the registers
 		reg_arg = ["R_RDI", "R_RSI", "R_RDX", "R_RCX", "R_R8", "R_R9"]
 		# vreg: value is in a general register
-		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P
-		vreg   = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 2, 2, 0]
+		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P  A
+		vreg   = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 2, 2, 0, 1]
 		# vxmm: value is in a XMM register
-		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P
-		vxmm   = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P  A
+		vxmm   = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 		# vother: value is elsewere
-		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P
-		vother = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0]
+		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P  A
+		vother = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0]
 		# vstack: value is on the stack (or out of register)
-		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P
-		vstack = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 2, 2, 1]
+		#         E  e  v  c  w  i  I  C  W  u  U  f  d  D  K  l  L  p  V  O  S  N  M  H  P  A
+		vstack = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 2, 2, 1, 1]
 		arg_r = [
 			"",                            # E
 			"",                            # e
@@ -733,6 +735,7 @@ int isSimpleWrapper(wrapper_t fun);
 			"(void*){p}, ",                # M
 			"\n#error Use pp instead\n",   # H
 			"",                            # P
+			"(void*){p}, ",                # A
 		]
 		arg_x = [
 			"",                      # E
@@ -760,6 +763,7 @@ int isSimpleWrapper(wrapper_t fun);
 			"",                      # M
 			"",                      # H
 			"",                      # P
+			"",                      # A
 		]
 		arg_o = [
 			"emu, ",                   # E
@@ -787,6 +791,7 @@ int isSimpleWrapper(wrapper_t fun);
 			"",                        # M
 			"",                        # H
 			"",                        # P
+			"",                      # A
 		]
 		arg_s = [
 			"",                                         # E
@@ -814,6 +819,7 @@ int isSimpleWrapper(wrapper_t fun);
 			"*(void**)(R_RSP + {p}),*(void**)(R_RSP + {p} + 8), ", # M
 			"*(unsigned __int128)(R_RSP + {p}), ",      # H
 			"*(void**)(R_RSP + {p}), ",                 # P
+			"*(void**)(R_RSP + {p}), ",                 # A
 		]
 
 		# Asserts
@@ -935,6 +941,7 @@ int isSimpleWrapper(wrapper_t fun);
 		file.write(files_guard["wrapper.h"].format(lbr="{", rbr="}", version=ver))
 	
 	# Rewrite the *types.h files:
+	td_types[FunctionType.values.index('A')] = "va_list"
 	for fn in mytypedefs:
 		with open(os.path.join(root, "src", "wrapped", "generated", fn + "types.h"), 'w') as file:
 			file.write(files_header["fntypes.h"].format(lbr="{", rbr="}", version=ver, filename=fn))
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index fc3754b4..a86bb76c 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -716,6 +716,7 @@
 #() iFEppii
 #() iFEppip
 #() iFEppiV
+#() iFEppiA
 #() iFEpplp
 #() iFEpppp
 #() iFEpppV
@@ -1337,7 +1338,7 @@ wrappeddbus:
   - dbus_connection_set_data
   - dbus_message_set_data
   - dbus_pending_call_set_data
-- iFppip:
+- iFppiA:
   - dbus_message_get_args_valist
 - iFpppp:
   - dbus_connection_add_filter
diff --git a/src/wrapped/generated/wrappeddbustypes.h b/src/wrapped/generated/wrappeddbustypes.h
index 2f304395..b4a2c73b 100644
--- a/src/wrapped/generated/wrappeddbustypes.h
+++ b/src/wrapped/generated/wrappeddbustypes.h
@@ -14,7 +14,7 @@
 typedef void (*vFppp_t)(void*, void*, void*);
 typedef void (*vFpppp_t)(void*, void*, void*, void*);
 typedef int64_t (*iFpipp_t)(void*, int64_t, void*, void*);
-typedef int64_t (*iFppip_t)(void*, void*, int64_t, void*);
+typedef int64_t (*iFppiA_t)(void*, void*, int64_t, va_list);
 typedef int64_t (*iFpppp_t)(void*, void*, void*, void*);
 typedef int64_t (*iFppppp_t)(void*, void*, void*, void*, void*);
 typedef int64_t (*iFpppppp_t)(void*, void*, void*, void*, void*, void*);
@@ -28,7 +28,7 @@ typedef int64_t (*iFpppppp_t)(void*, void*, void*, void*, void*, void*);
 	GO(dbus_connection_set_data, iFpipp_t) \
 	GO(dbus_message_set_data, iFpipp_t) \
 	GO(dbus_pending_call_set_data, iFpipp_t) \
-	GO(dbus_message_get_args_valist, iFppip_t) \
+	GO(dbus_message_get_args_valist, iFppiA_t) \
 	GO(dbus_connection_add_filter, iFpppp_t) \
 	GO(dbus_pending_call_set_notify, iFpppp_t) \
 	GO(dbus_connection_try_register_fallback, iFppppp_t) \
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index d8af237e..4df2b8ad 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -750,6 +750,7 @@ typedef int64_t (*iFEpLpV_t)(x64emu_t*, void*, uintptr_t, void*, void*);
 typedef int64_t (*iFEppii_t)(x64emu_t*, void*, void*, int64_t, int64_t);
 typedef int64_t (*iFEppip_t)(x64emu_t*, void*, void*, int64_t, void*);
 typedef int64_t (*iFEppiV_t)(x64emu_t*, void*, void*, int64_t, void*);
+typedef int64_t (*iFEppiA_t)(x64emu_t*, void*, void*, int64_t, void*);
 typedef int64_t (*iFEpplp_t)(x64emu_t*, void*, void*, intptr_t, void*);
 typedef int64_t (*iFEpppp_t)(x64emu_t*, void*, void*, void*, void*);
 typedef int64_t (*iFEpppV_t)(x64emu_t*, void*, void*, void*, void*);
@@ -2042,6 +2043,7 @@ void iFEpLpV(x64emu_t *emu, uintptr_t fcn) { iFEpLpV_t fn = (iFEpLpV_t)fcn; R_RA
 void iFEppii(x64emu_t *emu, uintptr_t fcn) { iFEppii_t fn = (iFEppii_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); }
 void iFEppip(x64emu_t *emu, uintptr_t fcn) { iFEppip_t fn = (iFEppip_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX); }
 void iFEppiV(x64emu_t *emu, uintptr_t fcn) { iFEppiV_t fn = (iFEppiV_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)(R_RSP + 8)); }
+void iFEppiA(x64emu_t *emu, uintptr_t fcn) { iFEppiA_t fn = (iFEppiA_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX); }
 void iFEpplp(x64emu_t *emu, uintptr_t fcn) { iFEpplp_t fn = (iFEpplp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (intptr_t)R_RDX, (void*)R_RCX); }
 void iFEpppp(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); }
 void iFEpppV(x64emu_t *emu, uintptr_t fcn) { iFEpppV_t fn = (iFEpppV_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)(R_RSP + 8)); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index d7bfca86..b784d479 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -26,6 +26,7 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc);
 // N = ... automatically sending 1 arg
 // M = ... automatically sending 2 args
 // H = Huge 128bits value/struct
+// A = va_list
 
 void vFE(x64emu_t *emu, uintptr_t fnc);
 void vFv(x64emu_t *emu, uintptr_t fnc);
@@ -745,6 +746,7 @@ void iFEpLpV(x64emu_t *emu, uintptr_t fnc);
 void iFEppii(x64emu_t *emu, uintptr_t fnc);
 void iFEppip(x64emu_t *emu, uintptr_t fnc);
 void iFEppiV(x64emu_t *emu, uintptr_t fnc);
+void iFEppiA(x64emu_t *emu, uintptr_t fnc);
 void iFEpplp(x64emu_t *emu, uintptr_t fnc);
 void iFEpppp(x64emu_t *emu, uintptr_t fnc);
 void iFEpppV(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappeddbus_private.h b/src/wrapped/wrappeddbus_private.h
index 006874d3..3827fb50 100755
--- a/src/wrapped/wrappeddbus_private.h
+++ b/src/wrapped/wrappeddbus_private.h
@@ -100,7 +100,7 @@ GO(dbus_message_demarshal, pFpip)
 GO(dbus_message_demarshal_bytes_needed, iFpi)
 GO(dbus_message_free_data_slot, vFp)
 //GOM(dbus_message_get_args, iFEppiV)
-GOM(dbus_message_get_args_valist, iFEppip)
+GOM(dbus_message_get_args_valist, iFEppiA)
 GO(dbus_message_get_auto_start, iFp)
 GO(dbus_message_get_data, pFpi)
 GO(dbus_message_get_destination, pFp)