@@ -148,7 +148,7 @@ namespace test{
148
148
nb += _assert (instr.type == ILInstructionType::LOAD_CST, " Failed to parse IL Instruction" );
149
149
nb += _assert (instr.args [PARAM_LOADCST_DST_REG] == X86_EAX, " Failed to parse IL Instruction" );
150
150
nb += _assert (instr.args [PARAM_LOADCST_SRC_ADDR_OFFSET] == 0xffffffff , " Failed to parse IL Instruction" );
151
-
151
+
152
152
// aload_cst
153
153
str = " edi ^= [0]" ;
154
154
instr = ILInstruction (arch, str);
@@ -360,6 +360,43 @@ namespace test{
360
360
361
361
return nb;
362
362
}
363
+
364
+ unsigned int il_parser64 (){
365
+ unsigned int nb = 0 ;
366
+ ArchX64 arch;
367
+
368
+ // parse_il_cst should work with both unsigned and signed constants
369
+ string str = " 1000( 0xffffffffffffffff, -1 )" ;
370
+ ILInstruction instr = ILInstruction (arch, str);
371
+ nb += _assert (instr.type == ILInstructionType::FUNCTION, " Failed to parse IL Instruction" );
372
+ nb += _assert (instr.args [PARAM_FUNCTION_ADDR] == 1000 , " Failed to parse IL Instruction" );
373
+ nb += _assert (instr.args [PARAM_FUNCTION_ARGS+0 ] == (cst_t )0xffffffffffffffff , " Failed to parse IL Instruction" );
374
+ nb += _assert (instr.args_type [PARAM_FUNCTION_ARGS+0 ] == IL_FUNC_ARG_CST, " Failed to parse IL Instruction" );
375
+ nb += _assert (instr.args [PARAM_FUNCTION_ARGS+1 ] == -1 , " Failed to parse IL Instruction" );
376
+ nb += _assert (instr.args_type [PARAM_FUNCTION_ARGS+1 ] == IL_FUNC_ARG_CST, " Failed to parse IL Instruction" );
377
+
378
+ str = " rax= [0x7000000000000000]" ;
379
+ instr = ILInstruction (arch, str);
380
+ nb += _assert (instr.type == ILInstructionType::LOAD_CST, " Failed to parse IL Instruction" );
381
+ nb += _assert (instr.args [PARAM_LOADCST_DST_REG] == X64_RAX, " Failed to parse IL Instruction" );
382
+ nb += _assert (instr.args [PARAM_LOADCST_SRC_ADDR_OFFSET] == (cst_t )0x7000000000000000 , " Failed to parse IL Instruction" );
383
+
384
+ // 0xffffffffffffffff == -1
385
+ str = " rdx= 0xffffffffffffffff" ;
386
+ instr = ILInstruction (arch, str);
387
+ nb += _assert (instr.type == ILInstructionType::MOV_CST, " Failed to parse IL Instruction" );
388
+ nb += _assert (instr.args [PARAM_MOVCST_DST_REG] == X64_RDX, " Failed to parse IL Instruction" );
389
+ nb += _assert (instr.args [PARAM_MOVCST_SRC_CST] == -1 , " Failed to parse IL Instruction" );
390
+
391
+ // Edge case: -0xffffffffffffffff == -(0xffffffffffffffff) == -(-1) == 1
392
+ str = " rcx= -0xffffffffffffffff" ;
393
+ instr = ILInstruction (arch, str);
394
+ nb += _assert (instr.type == ILInstructionType::MOV_CST, " Failed to parse IL Instruction" );
395
+ nb += _assert (instr.args [PARAM_MOVCST_DST_REG] == X64_RCX, " Failed to parse IL Instruction" );
396
+ nb += _assert (instr.args [PARAM_MOVCST_SRC_CST] == 1 , " Failed to parse IL Instruction" );
397
+
398
+ return nb;
399
+ }
363
400
}
364
401
}
365
402
@@ -374,6 +411,7 @@ void test_il(){
374
411
// Start testing
375
412
cout << bold << " [" << green << " +" << def << bold << " ]" << def << std::left << std::setw (34 ) << " Testing il module... " << std::flush;
376
413
total += il_parser ();
414
+ total += il_parser64 ();
377
415
// Return res
378
416
cout << " \t " << total << " /" << total << green << " \t\t OK" << def << endl;
379
417
}
0 commit comments