我只想混淆选择器名称,但我不知道如何将Constant *转换为Value *:
void symObfs(Module &M) {
errs()<<"Start Obfuscating...\n";
srand (time(NULL));
//Objective-C Method ClassName Stuff
for(auto G=M.getGlobalList().begin();G!=M.getGlobalList().end();G++){
GlobalVariable &GL=*G;
if (GL.getName().str().find("OBJC_METH_VAR_NAME_")==0||GL.getName().str().find("OBJC_CLASS_NAME_")==0){
ConstantDataArray* Initializer=dyn_cast<ConstantDataArray>(GL.getInitializer ());
// string newName = fakeNameGenerator();
string newName = randomString(16);
Constant *Value =ConstantDataArray::getString(Initializer->getContext(),newName,true);
//GL.setInitializer(Value);
errs()<<"Selector Name: "<<Initializer->getAsCString ()<<" Obfuscated to: "<<newName<<"\n";
Initializer->Value::replaceAllUsesWith(Value);
}
}
}
谢谢!