-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ObfuscationPassManager (calls the obfuscation funcs based on attrs)
- Loading branch information
Showing
16 changed files
with
93 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
target_sources(ObfusC PRIVATE FuncAnnotationsParser.hpp) | ||
target_sources(ObfusC PRIVATE FuncAnnotationsParser.cpp) | ||
target_sources(ObfusC PRIVATE IObfuscationPass.hpp) | ||
target_sources(ObfusC PRIVATE IObfuscationPass.hpp) | ||
target_sources(ObfusC PRIVATE ObfuscationPassManager.hpp) | ||
target_sources(ObfusC PRIVATE ObfuscationPassManager.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "ObfuscationPassManager.hpp" | ||
#include "IObfuscationPass.hpp" | ||
#include "FuncAttributeStore.hpp" | ||
|
||
namespace obfusc { | ||
llvm::PreservedAnalyses ObfuscationPassManager::run(llvm::Module& mod, llvm::ModuleAnalysisManager&) { | ||
bool changed = false; | ||
for (auto& func : mod.getFunctionList()) { //Get all functions in module | ||
for (auto& attrs : func.getAttributes()) { //Get each attribute lists attached to function | ||
for (auto& attr : attrs) { //Get attributes one by one | ||
if (attr.isStringAttribute()) { //If attribute is a string | ||
IObfuscationPass* pass = FuncAttributeStore::GetInstance().GetAttrPass(llvm::StringRef(attr.getAsString().data())); //Check if attr is an obfuscation pass | ||
if (pass) { | ||
changed |= pass->obfuscate(mod, func); //Call obfuscate func | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (changed) { | ||
return llvm::PreservedAnalyses::none(); | ||
} | ||
return llvm::PreservedAnalyses::all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include <llvm/Passes/PassBuilder.h> | ||
|
||
namespace obfusc { | ||
struct ObfuscationPassManager : llvm::PassInfoMixin<ObfuscationPassManager> { | ||
// Takes IR unit to run the pass on Module and the corresponding manager | ||
llvm::PreservedAnalyses run(llvm::Module& mod, llvm::ModuleAnalysisManager&); | ||
|
||
// If false, pass is skipped for functions decorated with the optnone attribute (e.g. -O0). | ||
static bool isRequired() { return true; } | ||
}; | ||
} |