ACPI AML decompiler w/ CFG recovery and structured pseudocode
29

Configure Feed

Select the types of activity you want to include in your feed.

tobi / test / t_dc.c
1.8 kB 53 lines
1#include "t.h" 2 3#include "cf.h" 4#include "dc.h" 5#include "p.h" 6 7int t_dc(void) { 8 uint8_t m2[] = {0x14,0x20,'W','L','O','0',0x01,0x70,0x0a,0x03,0x60,0xa2,0x13,0x60,0xa0,0x06,0x68,0x70,0x0a,0x01,0x61,0xa1,0x05,0x70,0x0a,0x02,0x61,0x74,0x60,0x01,0x60,0xa4,0x61}; 9 tobi_parse_result r; 10 T_CHECK(tobi_parse(m2, sizeof(m2), 0, &r)); 11 (void)tobi_cf_recover(r.root, &r.diag); 12 char *s = tobi_dc_emit(r.root, &r.diag); 13 T_STR(s, "method WLO0(args=1"); 14 T_STR(s, "Local0 = 0x3"); 15 T_STR(s, "while (Local0)"); 16 T_STR(s, "if (Arg0)"); 17 T_STR(s, " while"); 18 T_STR(s, "return Local1"); 19 free(s); 20 tobi_parse_result_free(&r); 21 uint8_t bad[] = {0xfe}; 22 T_CHECK(tobi_parse(bad, sizeof(bad), 0, &r)); 23 s = tobi_dc_emit(r.root, &r.diag); 24 T_STR(s, "unknown opcode 0xfe at 0x0"); 25 free(s); 26 tobi_parse_result_free(&r); 27 uint8_t exprm[] = { 28 0x14,0x19,'E','X','P','R',0x02, 29 0x70,0x72,0x68,0x77,0x69,0x0a,0x02,0x60,0x61,0x62, 30 0xa4,0x91,0x95,0x60,0x61,0x93,0x62,0x0a,0x00 31 }; 32 T_CHECK(tobi_parse(exprm, sizeof(exprm), 0, &r)); 33 s = tobi_dc_emit(r.root, &r.diag); 34 T_STR(s, "Local2 = Arg0 + Arg1 * 0x2;"); 35 T_STR(s, "return Local0 < Local1 || Local2 == 0x0;"); 36 T_CHECK(strstr(s, "Arg0 + (Arg1 * 0x2)") == NULL); 37 free(s); 38 tobi_parse_result_free(&r); 39 uint8_t targets[] = { 40 0x80,0x00,0x60, 41 0x99,0x0d,'4','2',0x00,0x61, 42 0x9e,0x68,0x0a,0x01,0x0a,0x02,0x62 43 }; 44 T_CHECK(tobi_parse(targets, sizeof(targets), 0, &r)); 45 s = tobi_dc_emit(r.root, &r.diag); 46 T_STR(s, "Local0 = ~0x0;"); 47 T_STR(s, "Local1 = to_integer(\"42\");"); 48 T_STR(s, "Local2 = mid(Arg0, 0x1, 0x2);"); 49 T_CHECK(strstr(s, "not(0x0, Local0)") == NULL); 50 free(s); 51 tobi_parse_result_free(&r); 52 return 0; 53}