public static string CreateFullName(IFullName item) { if (item is MemberRef) { var memberRef = (MemberRef)item; if (memberRef.IsFieldRef) { return(CreateDisplayName((IField)memberRef, true)); } return(CreateDisplayName((IMethod)memberRef, true)); } if (item is IField) { return(CreateDisplayName((IField)item, true)); } if (item is IMethod) { return(CreateDisplayName((IMethod)item, true)); } if (item is IType) { return(CreateDisplayName((IType)item, true)); } if (item is IModule) { return(((IModule)item).ScopeName); } if (item is IAssembly) { return(((IAssembly)item).Name); } return(item.FullName); }
private int DecryptStrings(ModuleDef moduleDef, IMDTokenProvider decryptionMethod, IFullName declaringType) { var assembly = Assembly.LoadFile(moduleDef.Location); var decryptCount = 0; foreach (var type in moduleDef.Types) { foreach (var method in type.Methods) { if (!method.HasBody || !method.Body.HasInstructions) continue; var instructions = method.Body.Instructions; for (var i = 0; i < instructions.Count; i++) { if (instructions[i].OpCode != OpCodes.Ldstr) continue; if (instructions[i + 1].OpCode != OpCodes.Ldstr) continue; if (!instructions[i + 2].Operand.ToString(). Equals(decryptionMethod.ToString())) continue; var param1 = instructions[i].Operand.ToString(); var param2 = instructions[i + 1].Operand.ToString(); var methodType = assembly.GetType(declaringType.Name); if (methodType == null) continue; var metaData = decryptionMethod.MDToken.ToInt32(); var methodBase = methodType.Module.ResolveMethod(metaData); if (methodBase == null) continue; var parameters = methodBase.GetParameters(); if (parameters.Length == 0) continue; var result = methodBase.Invoke(null, new object[] { param1, param2 }); var body = method.Body; body.Instructions[i].OpCode = OpCodes.Ldstr; body.Instructions[i].Operand = result.ToString(); body.Instructions.RemoveAt(i + 1); body.Instructions.RemoveAt(i + 1); decryptCount++; } } } return decryptCount; }
private static bool IsEngineType(IFullName typeDef) { switch (typeDef.FullName) { case "UnityEngine.AnimationCurve": case "UnityEngine.Bounds": case "UnityEngine.BoundsInt": case "UnityEngine.Color": case "UnityEngine.Color32": case "UnityEngine.Gradient": case "UnityEngine.GUIStyle": case "UnityEngine.LayerMask": case "UnityEngine.Matrix4x4": case "UnityEngine.Quaternion": case "UnityEngine.Rect": case "UnityEngine.RectInt": case "UnityEngine.RectOffset": case "UnityEngine.Vector2": case "UnityEngine.Vector2Int": case "UnityEngine.Vector3": case "UnityEngine.Vector3Int": case "UnityEngine.Vector4": case "UnityEngine.PropertyName": return(true); default: return(false); } }
static IMemberDef SearchMethods(TypeDef implementing, IFullName decl) { var res = implementing.Methods.SingleOrDefault(m => m.Name == decl.Name); if (res != null) { return(res); } foreach (var method in implementing.Methods) { if (!method.HasOverrides) { continue; } foreach (var over in method.Overrides) { if (over.MethodDeclaration == decl) { return(method); } } } return(null); }
public AssemblyDetails(IFullName moduleDef) { var pattern = new Regex(@"(?<name>[^,]+), Version=(?<version>(\d+\.*)*)"); var result = pattern.Match(moduleDef.FullName); FullName = result.Groups["name"].Value; Version = result.Groups["version"].Value; }
public PassportIdentification(IFullName fullName, string nationality, DateTime dateOfBirth, bool isMale, string identificationNumber, string placeOfBirth) { FullName = fullName; Nationality = nationality; DateOfBirth = dateOfBirth; IsMale = isMale; IdentificationNumber = identificationNumber; PlaceOfBirth = placeOfBirth; }
private static string ResolveName(IFullName source, IReadOnlyDictionary <string, string>?generics) { // If the list of generics is not null and the source is known.. if (generics != null && generics.TryGetValue(source.FullName, out var result)) { // return the found result return(result); } // Otherwise return the full name return(source.FullName); }
private void DecodeSingle(IFullName param) { if (!RegexObfuscated.IsMatch(param.Name)) { return; } string text = _crypto.Decrypt(param.Name); SrcMap[param.Name] = text; if (param is TypeDef typeDef && text.Contains('.')) { typeDef.Namespace = text.Substring(0, text.LastIndexOf('.')); typeDef.Name = text.Substring(text.LastIndexOf('.') + 1); }
private static bool IsBaseType(IFullName typeDef) { switch (typeDef.FullName) { case "System.Boolean": case "System.Byte": case "System.SByte": case "System.Int16": case "System.UInt16": case "System.Int32": case "System.UInt32": case "System.Int64": case "System.UInt64": case "System.Single": case "System.Double": case "System.String": return(true); default: return(false); } }
private int ResolveDimension(IFullName source, IFullName array) {
public static IPassportIdentification CreateNewPassportIdentification(IFullName fullName, string nationality, DateTime dateOfBirth, bool isMale, string identificationNumber, string placeOfBirth) { return(new PassportIdentification(fullName, nationality, dateOfBirth, isMale, identificationNumber, placeOfBirth)); }
static void Main(string[] args) { try { var fileLog = ConfigurationManager.AppSettings["FileLog"]; var log = new ProgramLog(fileLog); } catch (DirectoryNotFoundException) { var exception = new ConfigurationDirectoryNotFoundException(ConfigurationManager.AppSettings["FileLog"]); Console.WriteLine(exception.Message); throw exception; } IAdress vasinAdress = ContactAddressInformation.CreateNewAdress("Belarus", "Grodno", "Kleckova", new Tuple <int, char, char>(12, '/', 'A'), 3); IList <int> vasinListNumbers = new List <int>(); vasinListNumbers.Add(654321); vasinListNumbers.Add(543210); IList <string> vasinListEmails = new List <string>(); vasinListEmails.Add("*****@*****.**"); vasinListEmails.Add("*****@*****.**"); IContactInforamtion vasinaContactInforamtion = ContactAddressInformation.CreateNewContacts(vasinListNumbers, vasinListEmails); IFullName vasyasFullName = PersonalIdentification.CreateNewFullName("Vasya", "Pupkin", "Ivanavich"); IPassportIdentification passportIdentification = PersonalIdentification.CreateNewPassportIdentification( vasyasFullName, "REPUBLIC OF BELARUS", new DateTime(1997, 10, 28), true, "3456797K000PB9", "REPUBLIC OF BELARUS"); IPassportData passportData = PersonalIdentification.CreateNewPassportData(passportIdentification, "KH248248", "MINISTRY OF INTERNAL AFFAIRS", new DateTime(2015, 10, 28), new DateTime(2025, 10, 28)); IInformationOfAnIndividual informationOfVasya = InformationProvided.CreateNewInformationOfAnIndividual(vasinAdress, vasinaContactInforamtion, passportData); Console.WriteLine(informationOfVasya.ToString()); // IBillingCompany billingCompany = CompanyManagement.CreateNewCompany("Company"); IAdress billingCompanyAdress = ContactAddressInformation.CreateNewAdress("Belarus", "Grodno", "Kleckova", new Tuple <int, char, char>(10, '/', '2'), 3); CompanyManagement.ChangeAdress(billingCompany, billingCompanyAdress); IList <int> companyListNumbers = new List <int>(); vasinListNumbers.Add(123456); vasinListNumbers.Add(234567); IList <string> companyListEmails = new List <string>(); vasinListEmails.Add("*****@*****.**"); vasinListEmails.Add("*****@*****.**"); IContactInforamtion companyContactInforamtion = ContactAddressInformation.CreateNewContacts(companyListNumbers, companyListEmails); CompanyManagement.ChangeContactInforamtion(billingCompany, companyContactInforamtion); CompanyManagement.ChangeAboutLegalEntity(billingCompany, "Some company"); StationManagment.CreateNewStation(billingCompany, CodecType.G711); try { StationManagment.AddPortRange(billingCompany.Stations[0], 2030, 2110); } catch (PortArgumentOutOfRangeException e) { Console.WriteLine(e.Message); } Console.WriteLine(StationManagment.OutputAllPorts(billingCompany.Stations[0])); IClient client = ContractManagement.CreateNewClient(informationOfVasya); IRate rate = ContractManagement.CreateNewRate("Tarif", 0.5); ISubscriberNumber subscriberNumber1 = ContractManagement.CreateNewSubscriberNumber(rate, 505050); ISubscriberNumber subscriberNumber2 = ContractManagement.CreateNewSubscriberNumber(rate, 525252); ContractManagement.MakeNewTerminalContract(billingCompany, client, subscriberNumber1); ContractManagement.MakeNewTerminalContract(billingCompany, client, subscriberNumber2); TerminalManagement.ConnectTerminal(billingCompany.Stations[0], client.Contracts[0].Terminal, 2030); Thread.Sleep(200); TerminalManagement.ConnectTerminal(billingCompany.Stations[0], client.Contracts[1].Terminal, 2100); Thread.Sleep(200); TerminalManagement.CallToSubscriber(billingCompany.Stations[0], client.Contracts[0].Terminal, client.Contracts[1].Terminal); Thread.Sleep(200); TerminalManagement.AnswerTheCall(billingCompany.Stations[0], client.Contracts[0].Terminal, client.Contracts[1].Terminal); Thread.Sleep(1200); TerminalManagement.CompleteCall(billingCompany.Stations[0], client.Contracts[0].Terminal, client.Contracts[1].Terminal); Thread.Sleep(200); TerminalManagement.DisconnectTerminal(billingCompany.Stations[0], client.Contracts[0].Terminal); Thread.Sleep(200); TerminalManagement.DisconnectTerminal(billingCompany.Stations[0], client.Contracts[1].Terminal); try { Console.WriteLine(CallManagement.ViewCallLog(client.Contracts[0].Terminal.SubscriberNumber, 30)); } catch (CallLogArgumentException e) { Console.WriteLine(e.Message); } }
private int DecryptStrings(ModuleDef moduleDef, IMDTokenProvider decryptionMethod, IFullName declaringType) { var assembly = Assembly.LoadFile(moduleDef.Location); var decryptCount = 0; foreach (var type in moduleDef.Types) { foreach (var method in type.Methods) { if (!method.HasBody || !method.Body.HasInstructions) { continue; } var instructions = method.Body.Instructions; for (var i = 0; i < instructions.Count; i++) { if (instructions[i].OpCode != OpCodes.Ldstr) { continue; } if (instructions[i + 1].OpCode != OpCodes.Ldstr) { continue; } if (!instructions[i + 2].Operand.ToString(). Equals(decryptionMethod.ToString())) { continue; } var param1 = instructions[i].Operand.ToString(); var param2 = instructions[i + 1].Operand.ToString(); var methodType = assembly.GetType(declaringType.Name); if (methodType == null) { continue; } var metaData = decryptionMethod.MDToken.ToInt32(); var methodBase = methodType.Module.ResolveMethod(metaData); if (methodBase == null) { continue; } var parameters = methodBase.GetParameters(); if (parameters.Length == 0) { continue; } var result = methodBase.Invoke(null, new object[] { param1, param2 }); var body = method.Body; body.Instructions[i].OpCode = OpCodes.Ldstr; body.Instructions[i].Operand = result.ToString(); body.Instructions.RemoveAt(i + 1); body.Instructions.RemoveAt(i + 1); decryptCount++; } } } return(decryptCount); }
public static bool IsCompilerGenerated(this IFullName name) => IsCompilerGenerated(name.Name);
public MultipleAnalysesModel(IFullName item, IAnalysis[] analyses) { this.analyses = analyses; Item = item; Text = Utils.EscapeString(DisplayNameCreator.CreateFullName(item), false); }
public AnalysisError(string message, IFullName errObj = null) { Message = message; ErrorObject = errObj; }
public static bool IsEazInternalName(this IFullName name) => IsEazInternalName(name.Name);
public static bool IsNameObfuscated(this IFullName name) => IsNameObfuscated(name.Name);
public static string CreateFullName(IFullName item) { if (item is MemberRef) { var memberRef = (MemberRef)item; if (memberRef.IsFieldRef) return CreateDisplayName((IField)memberRef, true); return CreateDisplayName((IMethod)memberRef, true); } if (item is IField) return CreateDisplayName((IField)item, true); if (item is IMethod) return CreateDisplayName((IMethod)item, true); if (item is IType) return CreateDisplayName((IType)item, true); if (item is IModule) return ((IModule)item).ScopeName; if (item is IAssembly) return ((IAssembly)item).Name; return item.FullName; }