박우진

make return obfuscation pass

...@@ -13,10 +13,6 @@ namespace { ...@@ -13,10 +13,6 @@ namespace {
13 ReturnObfuscation() : FunctionPass(ID) {} 13 ReturnObfuscation() : FunctionPass(ID) {}
14 bool runOnFunction(Function &F) override { 14 bool runOnFunction(Function &F) override {
15 Module* mod = F.getParent(); 15 Module* mod = F.getParent();
16 - /*
17 - if (!F.getName().contains("setup") && !F.getName().contains("test")) {
18 - return false;
19 - }*/
20 ArrayType* return_array = ArrayType::get(IntegerType::get(mod->getContext(), 8), 12); 16 ArrayType* return_array = ArrayType::get(IntegerType::get(mod->getContext(), 8), 12);
21 PointerType* return_array_ptr = PointerType::get(return_array, 0); 17 PointerType* return_array_ptr = PointerType::get(return_array, 0);
22 PointerType* ret_func_ptr = PointerType::get(IntegerType::get(mod->getContext(), 8), 0); 18 PointerType* ret_func_ptr = PointerType::get(IntegerType::get(mod->getContext(), 8), 0);
...@@ -66,7 +62,18 @@ namespace { ...@@ -66,7 +62,18 @@ namespace {
66 62
67 for (auto &BB : RetBlocks) { 63 for (auto &BB : RetBlocks) {
68 Constant* retBlockAddress = BlockAddress::get(BB); 64 Constant* retBlockAddress = BlockAddress::get(BB);
65 + Module* M = F.getParent();
69 66
67 + for (auto curFref = M->getFunctionList().begin(),
68 + endFref = M->getFunctionList().end();
69 + curFref != endFref; ++curFref) {
70 + for (auto& B: curFref->getBasicBlockList()) {
71 + StoreInst* asdf = new StoreInst(retBlockAddress, ptr_this_ret, false, &B);
72 + asdf->setAlignment(MaybeAlign(4));
73 + break;
74 + }
75 +
76 + }
70 BasicBlock* decrypt_start = BasicBlock::Create(mod->getContext(), "dec_start", &F, BB); 77 BasicBlock* decrypt_start = BasicBlock::Create(mod->getContext(), "dec_start", &F, BB);
71 for (BasicBlock* preds : predecessors(BB)) { 78 for (BasicBlock* preds : predecessors(BB)) {
72 preds->getTerminator()->eraseFromParent(); 79 preds->getTerminator()->eraseFromParent();
......