private void BuildAMD64(BuildEntry entry) { int methodRID = _state.MethodDefHash.IndexOf(entry.MethodSignature) + 1; // Add fixup entry var fixup = new VTableFixupEntry(); fixup.Type = VTableFixupType.SlotSize64Bit | VTableFixupType.FromUnmanaged; fixup.Add(MetadataToken.Get(MetadataTokenType.Method, methodRID)); _state.VTableFixupTable.Add(fixup); int pos = _codeBlob.Length; if (pos > 0) { pos = pos.Align(0x10); } PE.Fixups.Add(new AMD64Fixup(_codeBlob, pos, fixup)); // rex.w rex.b mov rax,[following address] _state.ExportTable.AddRVAEntry(entry.MethodName, _codeBlob, pos); _codeBlob.Write(ref pos, new byte[] { 0x48, 0xA1 }); // VA of method (through VTable) _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.DIR64); _codeBlob.Write(ref pos, (ulong)0); // jmp [rax] _codeBlob.Write(ref pos, new byte[] { 0xFF, 0xE0 }); }
private void BuildX86(BuildEntry entry) { int methodRID = _state.MethodDefHash.IndexOf(entry.MethodSignature) + 1; // Add fixup entry var fixup = new VTableFixupEntry(); fixup.Type = VTableFixupType.SlotSize32Bit | VTableFixupType.FromUnmanaged; fixup.Add(MetadataToken.Get(MetadataTokenType.Method, methodRID)); _state.VTableFixupTable.Add(fixup); int pos = _codeBlob.Length; if (pos > 0) { pos = pos.Align(0x10); } PE.Fixups.Add(new X86Fixup(_codeBlob, pos, fixup)); // jmp _state.ExportTable.AddRVAEntry(entry.MethodName, _codeBlob, pos); _codeBlob.Write(ref pos, new byte[] { 0xFF, 0x25 }); // VA of method (through VTable) _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.HIGHLOW); _codeBlob.Write(ref pos, (uint)0); }
public BuildEntry CreateBuild(string name) { var emptyBuild = new Build(); var entry = new BuildEntry { Build = emptyBuild, Name = name, PreviousName = string.Empty }; this.SaveBuild(entry); return(entry); }
public void SaveBuild(BuildEntry buildEntry) { var encodedBuild = this.EncodeTemplate(buildEntry.Build); if (string.IsNullOrWhiteSpace(buildEntry.PreviousName)) { File.Delete($"{BuildsPath}\\{buildEntry.PreviousName}.txt"); } File.WriteAllText($"{BuildsPath}\\{buildEntry.Name}.txt", encodedBuild); }
public void RemoveBuild(BuildEntry buildEntry) { if (File.Exists($"{BuildsPath}\\{buildEntry.Name}.txt")) { File.Delete($"{BuildsPath}\\{buildEntry.Name}.txt"); } if (File.Exists($"{BuildsPath}\\{buildEntry.PreviousName}.txt")) { File.Delete($"{BuildsPath}\\{buildEntry.PreviousName}.txt"); } }
private void BuildIA64(BuildEntry entry) { int methodRID = _state.MethodDefHash.IndexOf(entry.MethodSignature) + 1; // Add fixup entry var fixup = new VTableFixupEntry(); fixup.Type = VTableFixupType.SlotSize64Bit | VTableFixupType.FromUnmanaged; fixup.Add(MetadataToken.Get(MetadataTokenType.Method, methodRID)); _state.VTableFixupTable.Add(fixup); int pos = _codeBlob.Length; if (pos > 0) { pos = pos.Align(0x10); } PE.Fixups.Add(new IA64Fixup(_codeBlob, pos, fixup)); // IA64 stub // ld8 r9 = [gp] ;; // ld8 r10 = [r9],8 // nop.i ;; // ld8 gp = [r9] // mov b6 = r10 // br.cond.sptk.few b6 _codeBlob.Write(ref pos, new byte[] { 0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00, }); // VA of IA64 stub _state.ExportTable.AddRVAEntry(entry.MethodName, _codeBlob, pos); _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.DIR64); _codeBlob.Write(ref pos, (ulong)0); // VA of method (through VTable) _state.RelocTable.Add(_codeBlob, pos, BaseRelocationType.DIR64); _codeBlob.Write(ref pos, (ulong)0); }
private void LoadBuild() { this.suppressBuildChanged = true; var build = this.DataContext.As <BuildEntry>(); this.loadedBuild = build; this.PrimaryProfession = build.Build.Primary; this.SecondaryProfession = build.Build.Secondary; this.Skill0 = build.Build.Skills[0]; this.Skill1 = build.Build.Skills[1]; this.Skill2 = build.Build.Skills[2]; this.Skill3 = build.Build.Skills[3]; this.Skill4 = build.Build.Skills[4]; this.Skill5 = build.Build.Skills[5]; this.Skill6 = build.Build.Skills[6]; this.Skill7 = build.Build.Skills[7]; this.suppressBuildChanged = false; }
private void AddRows() { int newLength = Mathf.Min(_currIndex + 10, CSVLoader.buildentries.Count); for (int i = _currIndex; i < newLength; i++) { BuildEntry be = CSVLoader.buildentries[i]; if (be.MatchSearch(_search)) { StringBuilder sb = new StringBuilder(); int count = 0; foreach (string beTag in be.tags.Keys) { sb.Append(beTag); if (count != be.tags.Count - 1) { sb.Append(", "); } else { sb.Append(System.Environment.NewLine); } count++; } _loadedRow.SetChildrenData(be.sprite, be.displayName, be.description, sb.ToString()); Row newRow = Instantiate(_loadedRow); newRow.transform.localScale = new Vector3(.5f, .5f); newRow.transform.localPosition += new Vector3(0, -_displayedRows * 35, 0); newRow.transform.SetParent(transform, false); _displayedRows++; rows.Add(newRow); } else { newLength = Mathf.Min(newLength + 1, CSVLoader.buildentries.Count); } _currIndex++; } rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Mathf.Max(150, _displayedRows * 35)); }
void Refresh() { Clear(); Debug.Log("[BuildDisplayer] Refresh"); Game game = GameManager.instance.game; Player player = game.GetPlayer(); Faction faction = player.faction; foreach (StructureCreation structureCreation in faction.structures) { BuildEntry entry = Instantiate(entryPrefab); Structure structure = structureCreation.structure; bool canBuild = player.HasResources(structureCreation.cost); entry.Initalize(structure, () => { buildManager.StartBuild(structure); }); entry.SetActive(canBuild); entry.transform.SetParent(transform); } }
public BuildEntry CreateBuild() { var emptyBuild = new Build(); var builds = GetBuilds(); var baseName = "New build"; var name = baseName; int count = 0; while (builds.Where(b => b.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).Any()) { name = baseName + count; count++; } var entry = new BuildEntry { Build = emptyBuild, Name = name, PreviousName = string.Empty }; this.SaveBuild(entry); return(entry); }
private void BuildEntryTemplate_RemoveClicked(object sender, BuildEntry e) { this.buildTemplateManager.RemoveBuild(e); this.LoadBuilds(); }