Browse Source

[ilib] fix reading some unmanaged calls

k 6 years ago
parent
commit
bf83e24099
1 changed files with 7 additions and 24 deletions
  1. 7 24
      libs/ilib/ilMetaReader.ml

+ 7 - 24
libs/ilib/ilMetaReader.ml

@@ -270,7 +270,7 @@ let param_flags_of_int i =
 
 
 let null_param_flags = param_flags_of_int 0
 let null_param_flags = param_flags_of_int 0
 
 
-let callconv_of_int i =
+let callconv_of_int ?match_generic_inst:(match_generic_inst=false) i =
 	let basic = match i land 0xF with
 	let basic = match i land 0xF with
 		| 0x0 -> CallDefault (* 0x0 *)
 		| 0x0 -> CallDefault (* 0x0 *)
 		| 0x1 -> CallCDecl
 		| 0x1 -> CallCDecl
@@ -282,6 +282,7 @@ let callconv_of_int i =
 		| 0x7 -> CallLocal (* 0x7 *)
 		| 0x7 -> CallLocal (* 0x7 *)
 		| 0x8 -> CallProp (* 0x8 *)
 		| 0x8 -> CallProp (* 0x8 *)
 		| 0x9 -> CallUnmanaged (* 0x9 *)
 		| 0x9 -> CallUnmanaged (* 0x9 *)
+		| 0xa when match_generic_inst -> CallGenericInst (* 0xA *)
 		| i -> printf "error 0x%x\n\n" i; assert false
 		| i -> printf "error 0x%x\n\n" i; assert false
 	in
 	in
 	match i land 0x20 with
 	match i land 0x20 with
@@ -566,30 +567,12 @@ let read_sguid_idx ctx pos =
 
 
 let read_callconv ctx s pos =
 let read_callconv ctx s pos =
 	let pos, conv = read_compressed_i32 s pos in
 	let pos, conv = read_compressed_i32 s pos in
-	let basic = match conv land 0xF with
-		| 0x0 -> CallDefault (* 0x0 *)
-		| 0x5 -> CallVararg (* 0x5 *)
-		| 0x6 -> CallField (* 0x6 *)
-		| 0x7 -> CallLocal (* 0x7 *)
-		| 0x8 -> CallProp (* 0x8 *)
-		| 0x9 -> CallUnmanaged (* 0x9 *)
-		| 0xa -> CallGenericInst (* 0xA *)
-		| i -> printf "error 0x%x\n" i; assert false
+	let callconv = callconv_of_int conv ~match_generic_inst:true in
+	let pos = match conv land 0x10 with
+		| 0x10 -> fst (read_compressed_i32 s pos)
+		| _ -> pos
 	in
 	in
-	let basic = [basic] in
-	let pos, c = match conv land 0x10 with
-		| 0x10 ->
-			let pos, nparams = read_compressed_i32 s pos in
-			pos, CallGeneric nparams :: basic
-		| _ ->
-			pos, basic
-	in
-	match conv land 0x20 with
-		| 0x20 ->
-			pos, CallHasThis :: basic
-		| _ when conv land 0x40 = 0x40 ->
-			pos, CallExplicitThis :: basic
-		| _ -> pos, basic
+	pos, callconv
 
 
 let read_constant ctx with_type s pos =
 let read_constant ctx with_type s pos =
 	match with_type with
 	match with_type with