Add option to disable creating new ParamDefs when renaming

This commit is contained in:
de4dot 2012-12-01 02:22:59 +01:00
parent b3e06c4ce6
commit dcdbe25a0f
3 changed files with 11 additions and 1 deletions

View File

@ -39,6 +39,7 @@ namespace de4dot.code.renamer {
public bool RestorePropertiesFromNames { get; set; }
public bool RestoreEvents { get; set; }
public bool RestoreEventsFromNames { get; set; }
public bool DontCreateNewParamDefs { get; set; }
Modules modules;
MemberInfos memberInfos = new MemberInfos();
@ -321,7 +322,11 @@ namespace de4dot.code.renamer {
var paramInfo = memberInfos.param(param);
if (!paramInfo.gotNewName())
continue;
param.ParameterDef.CreateParamDef();
if (!param.ParameterDef.HasParamDef) {
if (DontCreateNewParamDefs)
continue;
param.ParameterDef.CreateParamDef();
}
param.ParameterDef.Name = paramInfo.newName;
if (isVerbose) {
if (param.IsReturnParameter)

View File

@ -135,6 +135,9 @@ namespace de4dot.cui {
}
}
}));
miscOptions.Add(new NoArgOption(null, "dont-create-params", "Don't create method params when renaming", () => {
filesOptions.DontCreateNewParamDefs = true;
}));
miscOptions.Add(new NoArgOption(null, "dont-restore-props", "Don't restore properties/events", () => {
filesOptions.RestorePropsEvents = false;
}));

View File

@ -38,6 +38,7 @@ namespace de4dot.cui {
public IList<IObfuscatedFile> Files { get; set; }
public IList<SearchDir> SearchDirs { get; set; }
public bool DetectObfuscators { get; set; }
public bool DontCreateNewParamDefs { get; set; }
public bool RenameNamespaces { get; set; }
public bool RenameTypes { get; set; }
public bool RenameProperties { get; set; }
@ -385,6 +386,7 @@ namespace de4dot.cui {
if (!options.RenameSymbols)
return;
var renamer = new Renamer(deobfuscatorContext, theFiles) {
DontCreateNewParamDefs = options.DontCreateNewParamDefs,
RenameNamespaces = options.RenameNamespaces,
RenameTypes = options.RenameTypes,
RenameProperties = options.RenameProperties,