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_cf.c
1.5 kB 37 lines
1#include "t.h" 2 3#include "cf.h" 4#include "p.h" 5 6int t_cf(void) { 7 uint8_t ifelse[] = {0x14,0x15,'I','F','E','0',0x01,0xa0,0x06,0x68,0x70,0x0a,0x01,0x60,0xa1,0x05,0x70,0x0a,0x02,0x60,0xa4,0x60}; 8 tobi_parse_result r; 9 T_CHECK(tobi_parse(ifelse, sizeof(ifelse), 0, &r)); 10 T_CHECK(tobi_cf_recover(r.root, &r.diag)); 11 tobi_ir *ifn = r.root->child[0]->child[0]->child[0]; 12 T_CHECK(ifn->kind == TOBI_IR_IF && ifn->child_len == 3); 13 char *dot = tobi_cf_dot(r.root); 14 T_STR(dot, "digraph tobi_cfg"); 15 T_STR(dot, "then"); 16 T_STR(dot, "else"); 17 free(dot); 18 tobi_parse_result_free(&r); 19 20 uint8_t wh[] = {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}; 21 T_CHECK(tobi_parse(wh, sizeof(wh), 0, &r)); 22 T_CHECK(tobi_cf_recover(r.root, &r.diag)); 23 tobi_ir *while_n = r.root->child[0]->child[0]->child[1]; 24 T_CHECK(while_n->kind == TOBI_IR_WHILE); 25 T_CHECK(while_n->child[1]->child[0]->kind == TOBI_IR_IF); 26 tobi_parse_result_free(&r); 27 28 uint8_t amb[] = {0xa0,0x03,0x01,0xa1}; 29 T_CHECK(tobi_parse(amb, sizeof(amb), 0, &r)); 30 T_CHECK(r.root->child_len == 1); 31 T_CHECK(r.root->child[0]->kind == TOBI_IR_IF); 32 T_CHECK(tobi_ir_find_child(r.root->child[0]->child[1], TOBI_IR_UNKNOWN) != NULL); 33 T_CHECK(tobi_cf_recover(r.root, &r.diag)); 34 T_CHECK(tobi_ir_find_child(r.root->child[0]->child[1], TOBI_IR_DIAG) != NULL); 35 tobi_parse_result_free(&r); 36 return 0; 37}