Showing
4 changed files
with
19 additions
and
15 deletions
... | @@ -14,32 +14,36 @@ namespace { | ... | @@ -14,32 +14,36 @@ namespace { |
14 | static char ID; | 14 | static char ID; |
15 | 15 | ||
16 | PreProcess() : FunctionPass(ID) { } | 16 | PreProcess() : FunctionPass(ID) { } |
17 | - bool runOnFunction(Function &F) override { | 17 | + bool runOnFunction(Function &F) override { |
18 | Module* mod = F.getParent(); | 18 | Module* mod = F.getParent(); |
19 | std::vector<Instruction *> instructions; | 19 | std::vector<Instruction *> instructions; |
20 | std::vector<BasicBlock *> RetBlocks; | 20 | std::vector<BasicBlock *> RetBlocks; |
21 | bool inserted = false; | 21 | bool inserted = false; |
22 | std::ofstream functionFile("functions.txt", std::ios_base::app); | 22 | std::ofstream functionFile("functions.txt", std::ios_base::app); |
23 | if (functionFile.is_open()) { | 23 | if (functionFile.is_open()) { |
24 | - functionFile << F.getName().str() << "\n"; | 24 | + if (!F.getName().contains("__cxx") && !F.getName().contains("_GLOBAL")) |
25 | + functionFile << F.getName().str() << "\n"; | ||
25 | functionFile.close(); | 26 | functionFile.close(); |
26 | } | 27 | } |
27 | - for (auto &BB : F) { | 28 | + if (!F.getName().contains("__cxx") && !F.getName().contains("_GLOBAL")) { |
28 | - for (auto &I : BB) { | 29 | + for (auto &BB : F) { |
29 | - if (I.getOpcode() == Instruction::Ret) { | 30 | + for (auto &I : BB) { |
30 | - instructions.push_back(&I); | 31 | + if (I.getOpcode() == Instruction::Ret) { |
32 | + instructions.push_back(&I); | ||
33 | + } | ||
31 | } | 34 | } |
32 | } | 35 | } |
33 | - } | 36 | + for (auto &I : instructions) { |
34 | - for (auto &I : instructions) { | 37 | + BasicBlock *BB = I->getParent(); |
35 | - BasicBlock *BB = I->getParent(); | 38 | + // One Instruction Basic Block has only one ret instructions |
36 | - // One Instruction Basic Block has only one ret instructions | 39 | + if (!BB->size() < 2) |
37 | - if (!BB->size() < 2) | 40 | + { |
38 | - { | 41 | + BasicBlock *retblock = BB->splitBasicBlock(I->getIterator(), "obfuscatedreturn"); |
39 | - BasicBlock *retblock = BB->splitBasicBlock(I->getIterator(), "obfuscatedreturn"); | 42 | + } else { |
40 | - } else { | 43 | + BB->setName("obfuscatedreturn"); |
41 | - BB->setName("obfuscatedreturn"); | 44 | + } |
42 | } | 45 | } |
46 | + | ||
43 | } | 47 | } |
44 | return true; | 48 | return true; |
45 | } | 49 | } | ... | ... |
This diff is collapsed. Click to expand it.
No preview for this file type
No preview for this file type
-
Please register or login to post a comment