void DetectHandlers(List <TypeDef> handlerTypes, CsvmInfo csvmInfo) { opCodeHandlers = new List <OpCodeHandler>(); var detected = new List <OpCodeHandler>(); foreach (var handlersList in OpCodeHandlers.Handlers) { opCodeHandlers.Clear(); foreach (var handlerType in handlerTypes) { var info = new UnknownHandlerInfo(handlerType, csvmInfo); detected.Clear(); foreach (var opCodeHandler in handlersList) { if (opCodeHandler.Detect(info)) { detected.Add(opCodeHandler); } } if (detected.Count != 1) { goto next; } opCodeHandlers.Add(detected[0]); } if (new List <OpCodeHandler>(Utils.Unique(opCodeHandlers)).Count == opCodeHandlers.Count) { return; } next :; } throw new ApplicationException("Could not detect all VM opcode handlers"); }
internal CsvmInfo CreateCsvmInfo() { var csvmInfo = new CsvmInfo(); csvmInfo.StackValue = FindStackValueType(); csvmInfo.Stack = FindStackType(csvmInfo.StackValue); InitStackTypeMethods(csvmInfo); return csvmInfo; }
internal CsvmInfo CreateCsvmInfo() { var csvmInfo = new CsvmInfo(); csvmInfo.StackValue = FindStackValueType(); csvmInfo.Stack = FindStackType(csvmInfo.StackValue); InitStackTypeMethods(csvmInfo); return(csvmInfo); }
public UnknownHandlerInfo(TypeDef type, CsvmInfo csvmInfo) { this.type = type; this.csvmInfo = csvmInfo; fieldsInfo = new FieldsInfo(GetFields(type)); CountMethods(); FindOverrideMethods(); executeMethodThrows = CountThrows(executeMethod); executeMethodPops = CountPops(executeMethod); }
void InitStackTypeMethods(CsvmInfo csvmInfo) { foreach (var method in csvmInfo.Stack.Methods) { var sig = method.MethodSig; if (sig != null && sig.Params.Count == 0 && sig.RetType.TryGetTypeDef() == csvmInfo.StackValue) { if (HasAdd(method)) { csvmInfo.PopMethod = method; } else { csvmInfo.PeekMethod = method; } } } }
void DetectHandlers(List<TypeDef> handlerTypes, CsvmInfo csvmInfo) { opCodeHandlers = new List<OpCodeHandler>(); var detected = new List<OpCodeHandler>(); foreach (var handlersList in OpCodeHandlers.Handlers) { opCodeHandlers.Clear(); foreach (var handlerType in handlerTypes) { var info = new UnknownHandlerInfo(handlerType, csvmInfo); detected.Clear(); foreach (var opCodeHandler in handlersList) { if (opCodeHandler.Detect(info)) detected.Add(opCodeHandler); } if (detected.Count != 1) goto next; opCodeHandlers.Add(detected[0]); } if (new List<OpCodeHandler>(Utils.Unique(opCodeHandlers)).Count == opCodeHandlers.Count) return; next: ; } throw new ApplicationException("Could not detect all VM opcode handlers"); }
void InitStackTypeMethods(CsvmInfo csvmInfo) { foreach (var method in csvmInfo.Stack.Methods) { var sig = method.MethodSig; if (sig != null && sig.Params.Count == 0 && sig.RetType.TryGetTypeDef() == csvmInfo.StackValue) { if (HasAdd(method)) csvmInfo.PopMethod = method; else csvmInfo.PeekMethod = method; } } }