public void GetMethodInfo(ModuleTokenId key, out Parameter[] parameters, out Local[] locals, out SourceLocal[] decompilerLocals) { parameters = null; locals = null; decompilerLocals = null; foreach (var tab in documentTabService.VisibleFirstTabs) { if (parameters != null && decompilerLocals != null) break; var uiContext = tab.UIContext as IDocumentViewer; var methodDebugService = uiContext.TryGetMethodDebugService(); if (methodDebugService == null) continue; var info = methodDebugService.TryGetMethodDebugInfo(key); if (info == null) continue; var method = info.Method; if (info.Locals.Length != 0 && method.Body != null) { locals = method.Body.Variables.ToArray(); decompilerLocals = new SourceLocal[method.Body.Variables.Count]; foreach (var v in info.Locals) { if ((uint)v.Local.Index >= decompilerLocals.Length) continue; decompilerLocals[v.Local.Index] = v; } } parameters = method.Parameters.ToArray(); } }
public Local Update(Local local) { DbEntityEntry entry = context.Entry(local); entry.State = EntityState.Modified; context.SaveChanges(); return local; }
public string Encrypt(string msg, int key, Local local) { SetLocal(local); var stringBuilder = new StringBuilder(msg.Length); int n = _abc.Length / 2; foreach (var item in msg) { var k = _abc.IndexOf(item); if (k != -1) { k = (k + key) % n; if (char.IsLower(item)) { k += n; } stringBuilder.Append(_abc[k]); } else { stringBuilder.Append(item); } } return stringBuilder.ToString(); }
public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src) { var ret = new List<Instruction>(); var codeGen = new CodeGen(dst, src, method, ret); codeGen.GenerateCIL(derivation); codeGen.Commit(method.Body); return ret; }
public void InitSettings(Local.Settings settings) { this.Settings = settings; this.SniffDirectoryListPanel.UpdateViewer(); this.SniffListPanel.UpdateViewer(); }
public EditVariableForm(Local local) { InitializeComponent(); cbTypeSpecification.SelectedIndex = 0; RestoreVariable(local); }
public void GetMethodInfo(MethodKey key, out Parameter[] parameters, out Local[] locals, out ILVariable[] decLocals) { parameters = null; locals = null; decLocals = null; foreach (var textView in MainWindow.Instance.AllTextViews) { if (parameters != null && decLocals != null) break; var cm = textView.CodeMappings; if (cm == null) continue; MemberMapping mapping; if (!cm.TryGetValue(key, out mapping)) continue; var method = mapping.MethodDefinition; if (mapping.LocalVariables != null && method.Body != null) { locals = method.Body.Variables.ToArray(); decLocals = new ILVariable[method.Body.Variables.Count]; foreach (var v in mapping.LocalVariables) { if (v.IsGenerated) continue; if (v.OriginalVariable == null) continue; if ((uint)v.OriginalVariable.Index >= decLocals.Length) continue; decLocals[v.OriginalVariable.Index] = v; } } parameters = method.Parameters.ToArray(); } }
public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src) { for (int i = 0; i < 0x10; i++) { yield return Instruction.Create(OpCodes.Ldloc, dst); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldloc, dst); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldelem_U4); yield return Instruction.Create(OpCodes.Ldloc, src); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldelem_U4); switch (i % 3) { case 0: yield return Instruction.Create(OpCodes.Xor); break; case 1: yield return Instruction.Create(OpCodes.Mul); break; case 2: yield return Instruction.Create(OpCodes.Add); break; } yield return Instruction.Create(OpCodes.Stelem_I4); } }
public void CreateRoom(string TilemapName) { uint entityID = Entity.NextEntity(); /*Texture2D spriteSheet = game.Content.Load<Texture2D>(""); spriteSheet.Name = "";*/ Position position = new Position() { EntityID = entityID, // Center and Radius TBD Later Center = new Vector2(0, 0), Radius = 32f, }; game.PositionComponent[entityID] = position; Local local = new Local() { EntityID = entityID, }; game.LocalComponent[entityID] = local; Room room = new Room() { EntityID = entityID, Tilemap = TilemapName, }; game.RoomComponent[entityID] = room; }
public void GetMethodInfo(SerializedDnToken key, out Parameter[] parameters, out Local[] locals, out IILVariable[] decLocals) { parameters = null; locals = null; decLocals = null; foreach (var tab in fileTabManager.VisibleFirstTabs) { if (parameters != null && decLocals != null) break; var uiContext = tab.UIContext as ITextEditorUIContext; var cm = uiContext.TryGetCodeMappings(); if (cm == null) continue; var mapping = cm.TryGetMapping(key); if (mapping == null) continue; var method = mapping.Method; if (mapping.LocalVariables != null && method.Body != null) { locals = method.Body.Variables.ToArray(); decLocals = new IILVariable[method.Body.Variables.Count]; foreach (var v in mapping.LocalVariables) { if (v.GeneratedByDecompiler) continue; if (v.OriginalVariable == null) continue; if ((uint)v.OriginalVariable.Index >= decLocals.Length) continue; decLocals[v.OriginalVariable.Index] = v; } } parameters = method.Parameters.ToArray(); } }
public Local Update(Local local) { Validator.Validate(local); var updatedLocal = _localRepository.Update(local); return updatedLocal; }
public Local Create(Local local) { Validator.Validate(local); var savedLocal = _localRepository.Save(local); return savedLocal; }
/// <summary> /// Constructor /// </summary> /// <param name="local">Local</param> /// <param name="name">Name used by the decompiler</param> public SourceLocal(Local local, string name) { if (local == null) throw new ArgumentNullException(nameof(local)); if (name == null) throw new ArgumentNullException(nameof(name)); Local = local; Name = name; }
protected virtual Local Var(Variable var) { Local ret; if (!localMap.TryGetValue(var.Name, out ret)) { ret = new Local(Method.Module.CorLibTypes.UInt32); ret.Name = var.Name; localMap[var.Name] = ret; } return ret; }
public void Init(CilBody body) { if (inited) return; stateVar = new Local(ctx.Method.Module.CorLibTypes.Int32); body.Variables.Add(stateVar); body.InitLocals = true; Compile(body); inited = true; }
public uint CreateDoor(uint roomId, string destinationRoom, string destinationSpawn, Rectangle rectangle) { uint entityID = Entity.NextEntity(); /*Texture2D spriteSheet = game.Content.Load<Texture2D>(""); spriteSheet.Name = "";*/ Position position = new Position() { EntityID = entityID, // Center and Radius TBD Later Center = new Vector2(rectangle.Left, rectangle.Top), Radius = 32f, RoomID = roomId }; game.PositionComponent[entityID] = position; Collideable collideable = new Collideable() { EntityID = entityID, RoomID = position.RoomID, Bounds = new RectangleBounds(rectangle.Left,rectangle.Top,rectangle.Width,rectangle.Height), // Center and Radius TBD Later }; game.CollisionComponent[entityID] = collideable; Local local = new Local() { EntityID = entityID, }; game.LocalComponent[entityID] = local; Door door = new Door() { EntityID = entityID, DestinationRoom = destinationRoom, DestinationSpawnName = destinationSpawn, Locked = false, Closed = false, }; game.DoorComponent[entityID] = door; /*Sprite sprite = new Sprite() { EntityID = entityID, // TODO: SpriteSheet and SpriteBounds need a sprite and its bounds. I'm // waiting to see what the dungeons look like before choosing a sprite // so that the door sprite matches the dungeon theme. SpriteSheet = null, SpriteBounds = new Rectangle(0, 0, 0, 0), }; game.SpriteComponent[entityID] = sprite;*/ return entityID; }
protected virtual int GetLocalVarIndex(Local/*!*/ loc) { object index = this.localsIndex[loc.UniqueKey]; if (index is int) return (int)index; Type ltype = loc.Type == null ? null : loc.Type.GetRuntimeType(); if (ltype == null) { Debug.Fail(""); return 0; } LocalBuilder locb = this.ILGenerator.DeclareLocal(ltype, loc.Pinned); int i = this.locals.Count; this.locals.Add(locb); this.localsIndex[loc.UniqueKey] = i; return i; }
public IEnumerable<Instruction> EmitDecrypt(MethodDef init, REContext ctx, Local block, Local key) { for (int i = 0; i < 0x10; i++) { yield return Instruction.Create(OpCodes.Ldloc, block); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldloc, block); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldelem_U4); yield return Instruction.Create(OpCodes.Ldloc, key); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldelem_U4); yield return Instruction.Create(OpCodes.Xor); yield return Instruction.Create(OpCodes.Stelem_I4); } }
public Local.SniffDirectory View(Local.Settings settings, Local.SniffDirectory sniffDirectory) { this.sniffDirectory = sniffDirectory.Clone(); this.settings = settings; UpdateViewer(); var result = this.ShowDialog(); if (result == DialogResult.OK) return this.sniffDirectory; else return null; }
public void AddOrUpdateItem(Local.SniffDirectory sniffDirectory) { if (this.InvokeRequired) { this.Invoke(new DelegateManager.DelegateAddOrUpdateItem<Local.SniffDirectory>(AddOrUpdateItem), sniffDirectory); } else { lstView.BeginUpdate(); var key = sniffDirectory.Directory; ListViewItem listviewitem = null; if (!lstView.Items.ContainsKey(key)) { listviewitem = lstView.Items.Add(key, sniffDirectory.Directory, 0); listviewitem.SubItems.Add(sniffDirectory.SearchPattern); listviewitem.SubItems.Add(sniffDirectory.Recursive.BoolValueYesNo()); listviewitem.SubItems.Add(sniffDirectory.GetFiles().Count.ToString()); } else { listviewitem = lstView.Items[key]; listviewitem.SubItems[0].Text = sniffDirectory.Directory; listviewitem.SubItems[1].Text = sniffDirectory.SearchPattern; listviewitem.SubItems[2].Text = sniffDirectory.Recursive.BoolValueYesNo(); listviewitem.SubItems[3].Text = sniffDirectory.GetFiles().Count.ToString(); } listviewitem.Checked = sniffDirectory.Include; listviewitem.Tag = (Guid?)sniffDirectory.DataObjectGUID; if (sniffDirectory.Include) { listviewitem.BackColor = !sniffDirectory.DirectoryExists() ? Color.Salmon : Color.LightGreen; listviewitem.ForeColor = SystemColors.ControlText; } else { listviewitem.BackColor = Color.White; listviewitem.ForeColor = Color.LightGray; } lstView.EndUpdate(); } }
public static Local GetLocal() { Customer customer = new Customer(); customer.Nome = "Vinícius Oliveira"; customer.Telefone = "4999517803"; customer.Endereco = "João Severiano Waltrick"; customer.Cidade = "Lages"; Local local = new Local(); local.Entrada = DateTime.Now; local.Saida = DateTime.Now.AddDays(2); local.Salario = 900; local.Customer = customer; return local; }
static FieldDef GetStoreField(MethodDef method, int startIndex, Local local) { var instrs = method.Body.Instructions; for (int i = 0; i < instrs.Count - 1; i++) { var ldloc = instrs[i]; if (!ldloc.IsLdloc()) continue; if (ldloc.GetLocal(method.Body.Variables) != local) continue; var stsfld = instrs[i + 1]; if (stsfld.OpCode.Code != Code.Stsfld) continue; return stsfld.Operand as FieldDef; } return null; }
public IEnumerable<Instruction> EmitDecrypt(MethodDef init, CEContext ctx, Local block, Local key) { StatementBlock encrypt, decrypt; ctx.DynCipher.GenerateCipherPair(ctx.Random, out encrypt, out decrypt); var ret = new List<Instruction>(); var codeGen = new CodeGen(block, key, init, ret); codeGen.GenerateCIL(decrypt); codeGen.Commit(init.Body); var dmCodeGen = new DMCodeGen(typeof(void), new[] { Tuple.Create("{BUFFER}", typeof(uint[])), Tuple.Create("{KEY}", typeof(uint[])) }); dmCodeGen.GenerateCIL(encrypt); encryptFunc = dmCodeGen.Compile<Action<uint[], uint[]>>(); return ret; }
public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src) { var state = seed; for (int i = 0; i < 0x10; i++) { yield return Instruction.Create(OpCodes.Ldloc, dst); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldloc, dst); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldelem_U4); yield return Instruction.Create(OpCodes.Ldloc, src); yield return Instruction.Create(OpCodes.Ldc_I4, i); yield return Instruction.Create(OpCodes.Ldelem_U4); switch (state % 3) { case 0: yield return Instruction.Create(OpCodes.Xor); break; case 1: yield return Instruction.Create(OpCodes.Mul); break; case 2: yield return Instruction.Create(OpCodes.Add); break; } state = (state * state) % 0x2E082D35; switch (state % 3) { case 0: yield return Instruction.Create(OpCodes.Ldc_I4, (int)k1); yield return Instruction.Create(OpCodes.Add); break; case 1: yield return Instruction.Create(OpCodes.Ldc_I4, (int)k2); yield return Instruction.Create(OpCodes.Xor); break; case 2: yield return Instruction.Create(OpCodes.Ldc_I4, (int)k3); yield return Instruction.Create(OpCodes.Mul); break; } state = (state * state) % 0x2E082D35; yield return Instruction.Create(OpCodes.Stelem_I4); } }
public void CreateDoor(uint room1, uint room2) { uint entityID = Entity.NextEntity(); /*Texture2D spriteSheet = game.Content.Load<Texture2D>(""); spriteSheet.Name = "";*/ Position position = new Position() { EntityID = entityID, // Center and Radius TBD Later Center = new Vector2(0, 0), Radius = 32f, }; game.PositionComponent[entityID] = position; Local local = new Local() { EntityID = entityID, }; game.LocalComponent[entityID] = local; Sprite sprite = new Sprite() { EntityID = entityID, // TODO: SpriteSheet and SpriteBounds need a sprite and its bounds. I'm // waiting to see what the dungeons look like before choosing a sprite // so that the door sprite matches the dungeon theme. SpriteSheet = null, SpriteBounds = new Rectangle(0, 0, 0, 0), }; game.SpriteComponent[entityID] = sprite; Door door = new Door() { EntityID = entityID, Room1 = room1, Room2 = room2, }; game.DoorComponent[entityID] = door; }
private void btnOk_Click(object sender, EventArgs e) { var variable = new Local(cbVariableType.SelectedItem as TypeSig); if (variable.Type == null) return; while (variable.Type.Next != null && ((variable.Type.IsArray || variable.Type.IsByRef || variable.Type.IsPointer || variable.Type.IsSZArray))) { variable.Type = variable.Type.Next; } switch (cbTypeSpecification.SelectedItem.ToString()) { case "Array": variable.Type = new SZArraySig(variable.Type); break; case "Multi-dimensional array": variable.Type = new ArraySig(variable.Type); break; case "Reference": variable.Type = new ByRefSig(variable.Type); break; case "Pointer": variable.Type = new PtrSig(variable.Type); break; } if (!string.IsNullOrWhiteSpace(txtVariableName.Text)) { variable.Name = txtVariableName.Text; } MainForm.NewVariable = variable; Close(); }
public uint CreateWall(uint roomId, Rectangle bounds) { uint entityID = Entity.NextEntity(); /*Texture2D spriteSheet = game.Content.Load<Texture2D>(""); spriteSheet.Name = "";*/ //It's assumed in collisions that anything in position/collideable but not in other // components is a static object (like a wall) Position position = new Position() { EntityID = entityID, // Center and Radius TBD Later Center = new Vector2(bounds.Left, bounds.Top), Radius = 1, RoomID = roomId, }; game.PositionComponent[entityID] = position; Collideable collideable = new Collideable() { EntityID = entityID, RoomID = position.RoomID, Bounds = new RectangleBounds(bounds.Left,bounds.Top, bounds.Width, bounds.Height), // Center and Radius TBD Later }; game.CollisionComponent[entityID] = collideable; Local local = new Local() { EntityID = entityID, }; game.LocalComponent[entityID] = local; return entityID; }
public uint CreateRoom(string TilemapName, int width, int height, int tileWidth, int tileHeight, int wallWidth, string name) { uint entityID = Entity.NextEntity(); Position position = new Position() { EntityID = entityID, // Center and Radius TBD Later Center = new Vector2(0, 0), Radius = 32f, }; game.PositionComponent[entityID] = position; Local local = new Local() { EntityID = entityID, }; game.LocalComponent[entityID] = local; Room room = new Room() { EntityID = entityID, Tilemap = TilemapName, Width = width, Height = height, TileWidth = tileWidth, TileHeight = tileHeight, WallWidth = wallWidth, roomName = name, }; room.idMap = new Dictionary<string,uint>(); room.targetTypeMap= new Dictionary<string, string>(); room.playerSpawns = new Dictionary<string, Vector2>(); game.RoomComponent[entityID] = room; return entityID; }
static Instruction OptimizeLocalInstr(Instr instr, Local local, uint newIndex) { switch (instr.OpCode.Code) { case Code.Ldloc: case Code.Ldloc_S: case Code.Ldloc_0: case Code.Ldloc_1: case Code.Ldloc_2: case Code.Ldloc_3: if (newIndex == 0) return OpCodes.Ldloc_0.ToInstruction(); if (newIndex == 1) return OpCodes.Ldloc_1.ToInstruction(); if (newIndex == 2) return OpCodes.Ldloc_2.ToInstruction(); if (newIndex == 3) return OpCodes.Ldloc_3.ToInstruction(); if (newIndex <= 0xFF) return OpCodes.Ldloc_S.ToInstruction(local); return OpCodes.Ldloc.ToInstruction(local); case Code.Stloc: case Code.Stloc_S: case Code.Stloc_0: case Code.Stloc_1: case Code.Stloc_2: case Code.Stloc_3: if (newIndex == 0) return OpCodes.Stloc_0.ToInstruction(); if (newIndex == 1) return OpCodes.Stloc_1.ToInstruction(); if (newIndex == 2) return OpCodes.Stloc_2.ToInstruction(); if (newIndex == 3) return OpCodes.Stloc_3.ToInstruction(); if (newIndex <= 0xFF) return OpCodes.Stloc_S.ToInstruction(local); return OpCodes.Stloc.ToInstruction(local); case Code.Ldloca_S: case Code.Ldloca: if (newIndex <= 0xFF) return OpCodes.Ldloca_S.ToInstruction(local); return OpCodes.Ldloca.ToInstruction(local); default: throw new ApplicationException("Invalid ld/st local instruction"); } }
public SystemException() : base(Local.GetText("A system exception has occurred.")) { HResult = Result; }
bool GetLocalVariableValue(Local variable, out object value) { if (variableValues == null) variableValues = new VariableValues(theMethod.Body.Variables, allBlocks); var val = variableValues.GetValue(variable); if (!val.IsValid()) { value = null; return false; } value = val.Value; return true; }