Initial cross compiler work (things are messy)

This commit is contained in:
Cj 2024-06-18 20:42:58 -04:00
parent 2ea1cda886
commit 9eb3780eaa
11 changed files with 456 additions and 369 deletions

View File

@ -15,8 +15,8 @@
"state": {
"file": "Untitled.canvas",
"viewState": {
"x": -860.3333740234375,
"y": -352.333251953125,
"x": -1324.3333740234375,
"y": -365.66656494140625,
"zoom": 0
}
}

View File

@ -1,9 +1,7 @@
{
"nodes":[
{"id":"ffede66903965668","x":-1260,"y":-740,"width":660,"height":300,"color":"4","type":"text","text":"Targeted ReMap Assembly Patching (TRAP)\n\n- The ability to remap types on your own, get a remapped DLL to reference for your project, use it. Then patch your assembly back to original types, for testing/production.\n- This will allow for ultimate flexibility in being version agnostic as the manual re-mapper is able to find things between versions by creating patterns for it to match. It works in the same fashion as using LINQ at runtime, because that's essentially what it is.\n- Below is how your build process would be effected."},
{"id":"af0d96082e896559","x":-1260,"y":-360,"width":660,"height":300,"color":"3","type":"text","text":"1. Provide the target DLL we wish to modify\n3. Build your desired remaps for it in the GUI editor.\n4. Remap it\n5. Use the re-mapped DLL as a reference in your project (Im using stash search for testing as it has a ton of GClass references)\n6. Once you are ready to compile, you will compile the dll as normal and place ReCodeIt on your sys path somewhere, then run a post build command to have ReCodeit patch your assembly back to original Type data."}
{"id":"ffede66903965668","x":-1260,"y":-740,"width":660,"height":300,"color":"4","type":"text","text":"ReCodeIt Cross Compiler\n\n- "},
{"id":"4116b6bff3d9eb35","x":-2020,"y":-740,"width":250,"height":460,"type":"text","text":"ReCodeItCrossCompiler\n\n"}
],
"edges":[
{"id":"01d35c343c0509f1","fromNode":"ffede66903965668","fromSide":"bottom","toNode":"af0d96082e896559","toSide":"top"}
]
"edges":[]
}

View File

@ -31,6 +31,7 @@ partial class ReCodeItForm
TabPageRemapper = new TabPage();
RemapTreeView = new TreeView();
groupBox1 = new GroupBox();
ActiveProjectMappingsCheckbox = new CheckBox();
LoadedMappingFilePath = new TextBox();
RemapperUseForceRename = new CheckBox();
RemapperUnseal = new CheckBox();
@ -140,24 +141,26 @@ partial class ReCodeItForm
AutoMapperTypesExcludeBox = new ListBox();
tabPage5 = new TabPage();
groupBox4 = new GroupBox();
label4 = new Label();
CCMappingTreeView = new TreeView();
CrossPatchRunButton = new Button();
groupBox3 = new GroupBox();
CCLoadProjButton = new Button();
CCRemappedOutputButton = new Button();
CCRemappedOutputText = new TextBox();
CCOriginalAssemblyText = new TextBox();
CCVisualStudioProjDirText = new TextBox();
CrossCompilerNewProjectButton = new Button();
CrossPatchRemapOutputButton = new Button();
CrossMapperReferencePath = new TextBox();
CrossMapperOriginalAssembly = new TextBox();
CrossMapperProjectBuildPath = new TextBox();
CrossPatchingProjectBuildDirButton = new Button();
CrossPatchingOrigAssemblyButton = new Button();
CrossMapperProjTargetAssembly = new TextBox();
CrossMappingOutputChooseButton = new Button();
CCVisualStudioProjDirButton = new Button();
CCBuildDirButton = new Button();
CCOriginalAssemblyButton = new Button();
CCBuildDirText = new TextBox();
CrossPatchRemapButton = new Button();
SettingsTab = new TabPage();
groupBox2 = new GroupBox();
SilentModeCheckbox = new CheckBox();
DebugLoggingCheckbox = new CheckBox();
CrossCompilerProjectComboBox = new ComboBox();
label1 = new Label();
CCAutoLoadLastProj = new CheckBox();
TabPageRemapper.SuspendLayout();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)ConstuctorCountUpDown).BeginInit();
@ -203,6 +206,7 @@ partial class ReCodeItForm
//
// groupBox1
//
groupBox1.Controls.Add(ActiveProjectMappingsCheckbox);
groupBox1.Controls.Add(LoadedMappingFilePath);
groupBox1.Controls.Add(RemapperUseForceRename);
groupBox1.Controls.Add(RemapperUnseal);
@ -249,6 +253,16 @@ partial class ReCodeItForm
groupBox1.TabStop = false;
groupBox1.Text = "Remap Editor";
//
// ActiveProjectMappingsCheckbox
//
ActiveProjectMappingsCheckbox.AutoSize = true;
ActiveProjectMappingsCheckbox.Location = new Point(448, 479);
ActiveProjectMappingsCheckbox.Name = "ActiveProjectMappingsCheckbox";
ActiveProjectMappingsCheckbox.Size = new Size(264, 29);
ActiveProjectMappingsCheckbox.TabIndex = 39;
ActiveProjectMappingsCheckbox.Text = "Use Active Project Mappings";
ActiveProjectMappingsCheckbox.UseVisualStyleBackColor = true;
//
// LoadedMappingFilePath
//
LoadedMappingFilePath.BackColor = SystemColors.ScrollBar;
@ -1407,6 +1421,8 @@ partial class ReCodeItForm
//
// groupBox4
//
groupBox4.Controls.Add(label4);
groupBox4.Controls.Add(CCMappingTreeView);
groupBox4.Controls.Add(CrossPatchRunButton);
groupBox4.Controls.Add(groupBox3);
groupBox4.Controls.Add(CrossPatchRemapButton);
@ -1416,6 +1432,24 @@ partial class ReCodeItForm
groupBox4.TabIndex = 22;
groupBox4.TabStop = false;
groupBox4.Text = "Cross Compiler";
groupBox4.Enter += groupBox4_Enter;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(786, 27);
label4.Name = "label4";
label4.Size = new Size(446, 25);
label4.TabIndex = 26;
label4.Text = "Project Mappings (Double click to edit in remap editor)";
//
// CCMappingTreeView
//
CCMappingTreeView.BackColor = Color.Gray;
CCMappingTreeView.Location = new Point(786, 60);
CCMappingTreeView.Name = "CCMappingTreeView";
CCMappingTreeView.Size = new Size(472, 825);
CCMappingTreeView.TabIndex = 25;
//
// CrossPatchRunButton
//
@ -1429,17 +1463,17 @@ partial class ReCodeItForm
//
// groupBox3
//
groupBox3.Controls.Add(label1);
groupBox3.Controls.Add(CrossCompilerProjectComboBox);
groupBox3.Controls.Add(CCAutoLoadLastProj);
groupBox3.Controls.Add(CCLoadProjButton);
groupBox3.Controls.Add(CCRemappedOutputButton);
groupBox3.Controls.Add(CCRemappedOutputText);
groupBox3.Controls.Add(CCOriginalAssemblyText);
groupBox3.Controls.Add(CCVisualStudioProjDirText);
groupBox3.Controls.Add(CrossCompilerNewProjectButton);
groupBox3.Controls.Add(CrossPatchRemapOutputButton);
groupBox3.Controls.Add(CrossMapperReferencePath);
groupBox3.Controls.Add(CrossMapperOriginalAssembly);
groupBox3.Controls.Add(CrossMapperProjectBuildPath);
groupBox3.Controls.Add(CrossPatchingProjectBuildDirButton);
groupBox3.Controls.Add(CrossPatchingOrigAssemblyButton);
groupBox3.Controls.Add(CrossMapperProjTargetAssembly);
groupBox3.Controls.Add(CrossMappingOutputChooseButton);
groupBox3.Controls.Add(CCVisualStudioProjDirButton);
groupBox3.Controls.Add(CCBuildDirButton);
groupBox3.Controls.Add(CCOriginalAssemblyButton);
groupBox3.Controls.Add(CCBuildDirText);
groupBox3.Location = new Point(6, 30);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(631, 287);
@ -1447,9 +1481,56 @@ partial class ReCodeItForm
groupBox3.TabStop = false;
groupBox3.Text = "ReCodeIt Proj Settings";
//
// CCLoadProjButton
//
CCLoadProjButton.Location = new Point(475, 247);
CCLoadProjButton.Name = "CCLoadProjButton";
CCLoadProjButton.Size = new Size(150, 34);
CCLoadProjButton.TabIndex = 33;
CCLoadProjButton.Text = "Load Project";
CCLoadProjButton.UseVisualStyleBackColor = true;
CCLoadProjButton.Click += CCLoadProjButton_Click;
//
// CCRemappedOutputButton
//
CCRemappedOutputButton.Location = new Point(513, 66);
CCRemappedOutputButton.Name = "CCRemappedOutputButton";
CCRemappedOutputButton.Size = new Size(112, 34);
CCRemappedOutputButton.TabIndex = 32;
CCRemappedOutputButton.Text = "Choose";
CCRemappedOutputButton.UseVisualStyleBackColor = true;
CCRemappedOutputButton.Click += CCRemappedOutputButton_Click;
//
// CCRemappedOutputText
//
CCRemappedOutputText.Location = new Point(6, 68);
CCRemappedOutputText.Name = "CCRemappedOutputText";
CCRemappedOutputText.PlaceholderText = "Remapped Assembly Output (Assembly-CSharp-Remapped)";
CCRemappedOutputText.ReadOnly = true;
CCRemappedOutputText.Size = new Size(501, 31);
CCRemappedOutputText.TabIndex = 26;
//
// CCOriginalAssemblyText
//
CCOriginalAssemblyText.Location = new Point(6, 30);
CCOriginalAssemblyText.Name = "CCOriginalAssemblyText";
CCOriginalAssemblyText.PlaceholderText = "Original Input Target Assembly (Assembly-CSharp)";
CCOriginalAssemblyText.ReadOnly = true;
CCOriginalAssemblyText.Size = new Size(501, 31);
CCOriginalAssemblyText.TabIndex = 25;
//
// CCVisualStudioProjDirText
//
CCVisualStudioProjDirText.Location = new Point(6, 105);
CCVisualStudioProjDirText.Name = "CCVisualStudioProjDirText";
CCVisualStudioProjDirText.PlaceholderText = "Visual studio solution directory";
CCVisualStudioProjDirText.ReadOnly = true;
CCVisualStudioProjDirText.Size = new Size(501, 31);
CCVisualStudioProjDirText.TabIndex = 27;
//
// CrossCompilerNewProjectButton
//
CrossCompilerNewProjectButton.Location = new Point(475, 238);
CrossCompilerNewProjectButton.Location = new Point(319, 247);
CrossCompilerNewProjectButton.Name = "CrossCompilerNewProjectButton";
CrossCompilerNewProjectButton.Size = new Size(150, 34);
CrossCompilerNewProjectButton.TabIndex = 25;
@ -1457,81 +1538,44 @@ partial class ReCodeItForm
CrossCompilerNewProjectButton.UseVisualStyleBackColor = true;
CrossCompilerNewProjectButton.Click += CrossCompilerNewProjectButton_Click;
//
// CrossPatchRemapOutputButton
// CCVisualStudioProjDirButton
//
CrossPatchRemapOutputButton.Location = new Point(513, 75);
CrossPatchRemapOutputButton.Name = "CrossPatchRemapOutputButton";
CrossPatchRemapOutputButton.Size = new Size(112, 34);
CrossPatchRemapOutputButton.TabIndex = 23;
CrossPatchRemapOutputButton.Text = "Choose";
CrossPatchRemapOutputButton.UseVisualStyleBackColor = true;
CrossPatchRemapOutputButton.Click += CrossPatchingProjectReferncePath_Click;
CCVisualStudioProjDirButton.Location = new Point(513, 102);
CCVisualStudioProjDirButton.Name = "CCVisualStudioProjDirButton";
CCVisualStudioProjDirButton.Size = new Size(112, 34);
CCVisualStudioProjDirButton.TabIndex = 31;
CCVisualStudioProjDirButton.Text = "Choose";
CCVisualStudioProjDirButton.UseVisualStyleBackColor = true;
CCVisualStudioProjDirButton.Click += CCVisualStudioProjDirButton_Click;
//
// CrossMapperReferencePath
// CCBuildDirButton
//
CrossMapperReferencePath.Location = new Point(6, 77);
CrossMapperReferencePath.Name = "CrossMapperReferencePath";
CrossMapperReferencePath.PlaceholderText = "Remapped Assembly Output (Assembly-CSharp-Remapped)";
CrossMapperReferencePath.ReadOnly = true;
CrossMapperReferencePath.Size = new Size(501, 31);
CrossMapperReferencePath.TabIndex = 14;
CCBuildDirButton.Location = new Point(513, 141);
CCBuildDirButton.Name = "CCBuildDirButton";
CCBuildDirButton.Size = new Size(112, 34);
CCBuildDirButton.TabIndex = 29;
CCBuildDirButton.Text = "Choose";
CCBuildDirButton.UseVisualStyleBackColor = true;
CCBuildDirButton.Click += CCBuildDirButton_Click;
//
// CrossMapperOriginalAssembly
// CCOriginalAssemblyButton
//
CrossMapperOriginalAssembly.Location = new Point(6, 39);
CrossMapperOriginalAssembly.Name = "CrossMapperOriginalAssembly";
CrossMapperOriginalAssembly.PlaceholderText = "Original Input Target Assembly (Assembly-CSharp)";
CrossMapperOriginalAssembly.ReadOnly = true;
CrossMapperOriginalAssembly.Size = new Size(501, 31);
CrossMapperOriginalAssembly.TabIndex = 13;
CCOriginalAssemblyButton.Location = new Point(513, 28);
CCOriginalAssemblyButton.Name = "CCOriginalAssemblyButton";
CCOriginalAssemblyButton.Size = new Size(112, 34);
CCOriginalAssemblyButton.TabIndex = 28;
CCOriginalAssemblyButton.Text = "Choose";
CCOriginalAssemblyButton.UseVisualStyleBackColor = true;
CCOriginalAssemblyButton.Click += CCOriginalAssemblyButton_Click;
//
// CrossMapperProjectBuildPath
// CCBuildDirText
//
CrossMapperProjectBuildPath.Location = new Point(6, 114);
CrossMapperProjectBuildPath.Name = "CrossMapperProjectBuildPath";
CrossMapperProjectBuildPath.PlaceholderText = "Visual studio solution directory";
CrossMapperProjectBuildPath.ReadOnly = true;
CrossMapperProjectBuildPath.Size = new Size(501, 31);
CrossMapperProjectBuildPath.TabIndex = 15;
//
// CrossPatchingProjectBuildDirButton
//
CrossPatchingProjectBuildDirButton.Location = new Point(513, 111);
CrossPatchingProjectBuildDirButton.Name = "CrossPatchingProjectBuildDirButton";
CrossPatchingProjectBuildDirButton.Size = new Size(112, 34);
CrossPatchingProjectBuildDirButton.TabIndex = 20;
CrossPatchingProjectBuildDirButton.Text = "Choose";
CrossPatchingProjectBuildDirButton.UseVisualStyleBackColor = true;
CrossPatchingProjectBuildDirButton.Click += CrossPatchingProjectBuildDirButton_Click;
//
// CrossPatchingOrigAssemblyButton
//
CrossPatchingOrigAssemblyButton.Location = new Point(513, 37);
CrossPatchingOrigAssemblyButton.Name = "CrossPatchingOrigAssemblyButton";
CrossPatchingOrigAssemblyButton.Size = new Size(112, 34);
CrossPatchingOrigAssemblyButton.TabIndex = 16;
CrossPatchingOrigAssemblyButton.Text = "Choose";
CrossPatchingOrigAssemblyButton.UseVisualStyleBackColor = true;
CrossPatchingOrigAssemblyButton.Click += CrossPatchingOrigAssemblyButton_Click;
//
// CrossMapperProjTargetAssembly
//
CrossMapperProjTargetAssembly.Location = new Point(6, 151);
CrossMapperProjTargetAssembly.Name = "CrossMapperProjTargetAssembly";
CrossMapperProjTargetAssembly.PlaceholderText = "Build Directory";
CrossMapperProjTargetAssembly.ReadOnly = true;
CrossMapperProjTargetAssembly.Size = new Size(501, 31);
CrossMapperProjTargetAssembly.TabIndex = 19;
//
// CrossMappingOutputChooseButton
//
CrossMappingOutputChooseButton.Location = new Point(513, 150);
CrossMappingOutputChooseButton.Name = "CrossMappingOutputChooseButton";
CrossMappingOutputChooseButton.Size = new Size(112, 34);
CrossMappingOutputChooseButton.TabIndex = 17;
CrossMappingOutputChooseButton.Text = "Choose";
CrossMappingOutputChooseButton.UseVisualStyleBackColor = true;
CrossMappingOutputChooseButton.Click += CrossMappingOutputChooseButton_Click;
CCBuildDirText.Location = new Point(6, 142);
CCBuildDirText.Name = "CCBuildDirText";
CCBuildDirText.PlaceholderText = "Build Directory";
CCBuildDirText.ReadOnly = true;
CCBuildDirText.Size = new Size(501, 31);
CCBuildDirText.TabIndex = 30;
//
// CrossPatchRemapButton
//
@ -1588,23 +1632,15 @@ partial class ReCodeItForm
DebugLoggingCheckbox.UseVisualStyleBackColor = true;
DebugLoggingCheckbox.CheckedChanged += DebugLoggingCheckbox_CheckedChanged;
//
// CrossCompilerProjectComboBox
// CCAutoLoadLastProj
//
CrossCompilerProjectComboBox.FormattingEnabled = true;
CrossCompilerProjectComboBox.Location = new Point(6, 238);
CrossCompilerProjectComboBox.Name = "CrossCompilerProjectComboBox";
CrossCompilerProjectComboBox.Size = new Size(194, 33);
CrossCompilerProjectComboBox.TabIndex = 26;
CrossCompilerProjectComboBox.SelectedIndexChanged += CrossCompilerProjectComboBox_SelectedIndexChanged;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(206, 243);
label1.Name = "label1";
label1.Size = new Size(150, 25);
label1.TabIndex = 27;
label1.Text = "Available Projects";
CCAutoLoadLastProj.AutoSize = true;
CCAutoLoadLastProj.Location = new Point(6, 247);
CCAutoLoadLastProj.Name = "CCAutoLoadLastProj";
CCAutoLoadLastProj.Size = new Size(259, 29);
CCAutoLoadLastProj.TabIndex = 34;
CCAutoLoadLastProj.Text = "Auto load last active project";
CCAutoLoadLastProj.UseVisualStyleBackColor = true;
//
// ReCodeItForm
//
@ -1640,6 +1676,7 @@ partial class ReCodeItForm
((System.ComponentModel.ISupportInitialize)AutoMapperRequiredMatchesUpDown).EndInit();
tabPage5.ResumeLayout(false);
groupBox4.ResumeLayout(false);
groupBox4.PerformLayout();
groupBox3.ResumeLayout(false);
groupBox3.PerformLayout();
SettingsTab.ResumeLayout(false);
@ -1750,13 +1787,6 @@ partial class ReCodeItForm
private TabPage tabPage5;
private Button PickNameMangledPathButton;
private TextBox NameMangledAssemblyTextBox;
private Button CrossPatchingProjectBuildDirButton;
private TextBox CrossMapperProjTargetAssembly;
private Button CrossMappingOutputChooseButton;
private Button CrossPatchingOrigAssemblyButton;
private TextBox CrossMapperProjectBuildPath;
private TextBox CrossMapperReferencePath;
private TextBox CrossMapperOriginalAssembly;
private GroupBox groupBox3;
private Button CrossPatchRemapButton;
private CheckBox UnsealCheckbox;
@ -1781,11 +1811,21 @@ partial class ReCodeItForm
private CheckBox AutoMapperPublicize;
private CheckBox AutoMapperRenameProps;
private CheckBox AutoMapperRenameFields;
private Button CrossPatchRemapOutputButton;
private Button CrossPatchRunButton;
private GroupBox groupBox4;
private TextBox LoadedMappingFilePath;
private Button CrossCompilerNewProjectButton;
private ComboBox CrossCompilerProjectComboBox;
private Label label1;
private Button CCRemappedOutputButton;
private TextBox CCRemappedOutputText;
private TextBox CCOriginalAssemblyText;
private TextBox CCVisualStudioProjDirText;
private Button CCVisualStudioProjDirButton;
private Button CCOriginalAssemblyButton;
private TextBox CCBuildDirText;
private Button CCBuildDirButton;
private CheckBox ActiveProjectMappingsCheckbox;
private Label label4;
private TreeView CCMappingTreeView;
private Button CCLoadProjButton;
private CheckBox CCAutoLoadLastProj;
}

View File

@ -1,5 +1,7 @@
/// This entire file is fucked beyond belief, its just hacked together to make things work for now
using ReCodeIt.AutoMapper;
using ReCodeIt.CrossPatcher;
using ReCodeIt.CrossCompiler;
using ReCodeIt.Enums;
using ReCodeIt.Models;
using ReCodeIt.ReMapper;
@ -12,7 +14,7 @@ public partial class ReCodeItForm : Form
public static ReCodeItRemapper Remapper { get; private set; } = new();
public static ReCodeItAutoMapper AutoMapper { get; private set; } = new();
public static ReCodeItCrossCompiler CrossPatcher { get; private set; } = new();
public static ReCodeItCrossCompiler CrossCompiler { get; private set; }
private RemapModel CurrentRemap { get; set; }
@ -21,6 +23,9 @@ public partial class ReCodeItForm : Form
public ReCodeItForm()
{
InitializeComponent();
CrossCompiler = new();
DataProvider.LoadMappingFile(DataProvider.Settings.Remapper.MappingPath);
LoadedMappingFilePath.Text = DataProvider.Settings.Remapper.MappingPath;
PopulateDomainUpDowns();
@ -636,101 +641,108 @@ public partial class ReCodeItForm : Form
#region CROSS_COMPILER
/// <summary>
/// Remapper Input
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CrossPatchingOrigAssemblyButton_Click(object sender, EventArgs e)
private void RefreshCrossPatchPage()
{
var result = GUIHelpers.OpenFileDialog("Select the original assembly",
if (CrossCompiler.ActiveProject == null)
{
return;
}
var activeProj = CrossCompiler.ActiveProject;
CCOriginalAssemblyText.Text = activeProj.OriginalAssemblyPath;
CCRemappedOutputText.Text = activeProj.RemappedAssemblyPath;
CCVisualStudioProjDirText.Text = activeProj.VisualStudioSolutionPath;
CCBuildDirText.Text = activeProj.BuildDirectory;
}
private void CCOriginalAssemblyButton_Click(object sender, EventArgs e)
{
var result = GUIHelpers.OpenFileDialog("Select a DLL file",
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
if (result != string.Empty)
{
DataProvider.Settings.CrossCompiler.OriginalAssemblyPath = result;
CrossMapperOriginalAssembly.Text = result;
CCOriginalAssemblyText.Text = result;
DataProvider.SaveAppSettings();
}
}
/// <summary>
/// Remapper Output
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CrossPatchingProjectReferncePath_Click(object sender, EventArgs e)
private void CCRemappedOutputButton_Click(object sender, EventArgs e)
{
var result = GUIHelpers.OpenFileDialog("Output path of the Remapped assembly",
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
var result = GUIHelpers.OpenFolderDialog("Select a Folder for the remapped reference dll");
if (result != string.Empty)
{
DataProvider.Settings.CrossCompiler.RemappedOutput = result;
CrossMapperReferencePath.Text = result;
CCRemappedOutputText.Text = result;
DataProvider.SaveAppSettings();
}
}
/// <summary>
/// Reverse Patch Input - The input path of the assembly referenced by the remapped dll
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CrossPatchingProjectBuildDirButton_Click(object sender, EventArgs e)
private void CCVisualStudioProjDirButton_Click(object sender, EventArgs e)
{
var result = GUIHelpers.OpenFolderDialog("Select your visual studio solution directory");
var result = GUIHelpers.OpenFolderDialog("Select your visual studio project directory");
if (result != string.Empty)
{
DataProvider.Settings.CrossCompiler.VisualStudioSolutionDirectory = result;
CrossMapperProjectBuildPath.Text = result;
DataProvider.Settings.CrossCompiler.VisualStudioSolutionPath = result;
CCVisualStudioProjDirText.Text = result;
DataProvider.SaveAppSettings();
}
}
/// <summary>
/// Reverse Patch output
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CrossMappingOutputChooseButton_Click(object sender, EventArgs e)
private void CCBuildDirButton_Click(object sender, EventArgs e)
{
var result = GUIHelpers.OpenFolderDialog("Select your final build directory");
var result = GUIHelpers.OpenFolderDialog("Select where you want to final dll built at");
if (result != string.Empty)
{
DataProvider.Settings.CrossCompiler.BuildDirectory = result;
CrossMapperProjTargetAssembly.Text = result;
DataProvider.Settings.CrossCompiler.BuildPath = result;
CCBuildDirText.Text = result;
DataProvider.SaveAppSettings();
}
}
private void CrossPatchRemapButton_Click(object sender, EventArgs e)
{
CrossPatcher.StartRemap();
CrossCompiler.StartRemap();
}
private void CrossPatchRunButton_Click(object sender, EventArgs e)
{
CrossPatcher.StartCrossCompile();
}
private void RefreshCrossPatchPage()
{
CrossMapperOriginalAssembly.Text = DataProvider.Settings.CrossCompiler.OriginalAssemblyPath;
CrossMapperReferencePath.Text = DataProvider.Settings.CrossCompiler.RemappedOutput;
CrossMapperProjectBuildPath.Text = DataProvider.Settings.CrossCompiler.VisualStudioSolutionDirectory;
CrossMapperProjTargetAssembly.Text = DataProvider.Settings.CrossCompiler.BuildDirectory;
CrossCompiler.StartCrossCompile();
}
private void CrossCompilerNewProjectButton_Click(object sender, EventArgs e)
{
CrossPatcher.CreateProject();
if (CCOriginalAssemblyText.Text == string.Empty
|| CCRemappedOutputText.Text == string.Empty
|| CCVisualStudioProjDirText.Text == string.Empty
|| CCBuildDirText.Text == string.Empty)
{
// Dont create a project if any required fields are empty
MessageBox.Show("Cannot create a project without setting all paths in the project settings");
return;
}
ProjectManager.CreateProject(
CCOriginalAssemblyText.Text,
CCRemappedOutputText.Text,
CCVisualStudioProjDirText.Text,
CCBuildDirText.Text);
}
private void CrossCompilerProjectComboBox_SelectedIndexChanged(object sender, EventArgs e)
private void CCLoadProjButton_Click(object sender, EventArgs e)
{
var result = GUIHelpers.OpenFileDialog("select a ReCodeItProj.json File",
"JSON Files (*.json)|*.json|JSONC Files (*.jsonc)|*.jsonc|All Files (*.*)|*.*");
if (result != string.Empty)
{
ProjectManager.LoadProject(result);
}
}
#endregion CROSS_COMPILER
@ -916,4 +928,8 @@ public partial class ReCodeItForm : Form
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(remap, this));
}
}
private void groupBox4_Enter(object sender, EventArgs e)
{
}
}

View File

@ -0,0 +1,168 @@
using Newtonsoft.Json;
using ReCodeIt.Models;
using ReCodeIt.Utils;
namespace ReCodeIt.CrossCompiler;
public static class ProjectManager
{
/// <summary>
/// Key: Path of the project, Value: Project file
/// </summary>
public static Dictionary<string, CrossCompilerProjectModel> Projects { get; private set; } = [];
public static CrossCompilerProjectModel ActiveProject { get; private set; }
private static CrossCompilerSettings Settings => DataProvider.Settings.CrossCompiler;
private static HashSet<string> CopyIgnoreDirectories { get; } =
[
".vs",
".git"
];
public static void CreateProject(
string OrigAssemblyPath,
string RemappedAssemblyOutputPath,
string VSSolutionDirPath,
string BuildPath)
{
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
Logger.Log($"Generating Cross Compiler project", ConsoleColor.Yellow);
Logger.Log($"Original Assembly Path {OrigAssemblyPath}", ConsoleColor.Yellow);
Logger.Log($"Remapped Assembly Path: {RemappedAssemblyOutputPath}", ConsoleColor.Yellow);
Logger.Log($"Visual Studio Solution Directory: {VSSolutionDirPath}", ConsoleColor.Yellow);
Logger.Log($"Build Path: {BuildPath}", ConsoleColor.Yellow);
// Build the project model
ActiveProject = new CrossCompilerProjectModel
{
OriginalAssemblyPath = OrigAssemblyPath,
RemappedAssemblyPath = RemappedAssemblyOutputPath,
VisualStudioSolutionPath = VSSolutionDirPath,
BuildDirectory = BuildPath,
OriginalAssemblyHash = HashUtil.GetFileHash(OrigAssemblyPath),
RemappedAssemblyHash = "",
ChangedTypes = [],
RemapModels = []
};
// Now copy over the visual studio project
CopyVisualStudioProject(ActiveProject);
// Now save the project json inside the original solution directory
SaveCrossCompilerProjectModel(ActiveProject);
Logger.Log($"Found Solution: {ActiveProject.SolutionName}", ConsoleColor.Yellow);
Logger.Log($"Original Assembly Checksum: {ActiveProject.OriginalAssemblyHash}", ConsoleColor.Yellow);
Logger.Log($"Project Generated to: {DataProvider.Settings.CrossCompiler.LastActiveProjectPath}", ConsoleColor.Green);
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
}
public static void LoadProject(string path)
{
ActiveProject = LoadCrossCompilerProjModel(path);
CopyVisualStudioProject(ActiveProject);
Logger.Log($"Found and Loaded ReCodeIt Project at {path}");
}
private static void CopyVisualStudioProject(CrossCompilerProjectModel proj)
{
var solutionDirPath = proj.VisualStudioSolutionPath;
var solutionFiles = Directory.GetFiles(solutionDirPath, "*.sln", SearchOption.AllDirectories);
var solutionFile = string.Empty;
if (solutionFiles.Length > 1)
{
Logger.Log("ERROR More than one solution in a directory is not supported, Why tho?", ConsoleColor.Red);
return;
}
foreach (var file in solutionFiles)
{
solutionFile = file;
}
var solutionName = Path.GetFileNameWithoutExtension(solutionFile);
var destination = Path.Combine(DataProvider.ReCodeItProjectsPath, solutionName);
proj.ReCodeItProjectPath = destination;
proj.SolutionName = solutionName;
Logger.Log($"Copying solution: {solutionName} to {destination}", ConsoleColor.Yellow);
CopyProjectRecursive(solutionDirPath, destination);
}
private static void CopyProjectRecursive(string sourceDirPath, string destinationDirPath)
{
DirectoryInfo sourceDir = new DirectoryInfo(sourceDirPath);
if (!sourceDir.Exists)
{
throw new DirectoryNotFoundException(
"Solution directory does not exist or could not be found: "
+ sourceDirPath);
}
DirectoryInfo[] dirs = sourceDir.GetDirectories();
// If the destination directory doesn't exist, create it.
Directory.CreateDirectory(destinationDirPath);
// Get the files in the directory and copy them to the new location.
FileInfo[] files = sourceDir.GetFiles();
foreach (FileInfo file in files)
{
string tempPath = Path.Combine(destinationDirPath, file.Name);
file.CopyTo(tempPath, true);
}
foreach (DirectoryInfo subdir in dirs)
{
if (CopyIgnoreDirectories.Contains(subdir.Name)) { continue; }
string tempPath = Path.Combine(destinationDirPath, subdir.Name);
CopyProjectRecursive(subdir.FullName, tempPath);
}
}
private static void SaveCrossCompilerProjectModel(CrossCompilerProjectModel model)
{
var path = Path.Combine(model.VisualStudioSolutionPath, "ReCodeItProj.json");
JsonSerializerSettings settings = new()
{
Formatting = Formatting.Indented
};
var jsonText = JsonConvert.SerializeObject(model, settings);
File.WriteAllText(path, jsonText);
DataProvider.Settings.CrossCompiler.LastActiveProjectPath = path;
DataProvider.SaveAppSettings();
Logger.Log($"Cross Compiler project json generated to {path}", ConsoleColor.Green);
}
private static CrossCompilerProjectModel LoadCrossCompilerProjModel(string path)
{
if (!File.Exists(path))
{
Logger.Log($"Error loading cache model from `{path}`", ConsoleColor.Red);
}
var jsonText = File.ReadAllText(path);
var model = JsonConvert.DeserializeObject<CrossCompilerProjectModel>(jsonText);
DataProvider.Settings.CrossCompiler.LastActiveProjectPath = path;
DataProvider.SaveAppSettings();
Logger.Log($"Loaded Cross Compiler Project: {model?.RemappedAssemblyPath}");
return model!;
}
}

View File

@ -2,77 +2,37 @@
using ReCodeIt.ReMapper;
using ReCodeIt.Utils;
namespace ReCodeIt.CrossPatcher;
namespace ReCodeIt.CrossCompiler;
public class ReCodeItCrossCompiler
{
public ReCodeItCrossCompiler()
{
Remapper = new(this);
FindProjects();
}
private ReCodeItRemapper Remapper { get; }
private CrossCompilerSettings Settings => DataProvider.Settings.CrossCompiler;
public List<string> ProjectPaths { get; private set; } = [];
public CrossCompilerSettings Settings => DataProvider.Settings.CrossCompiler;
public CrossCompilerProjectModel ActiveProject => ProjectManager.ActiveProject;
/// <summary>
/// Key: Remapped name, value: old name
/// </summary>
public Dictionary<string, string> ChangedTypes { get; set; } = [];
private CrossCompilerProjectModel Cache;
private static HashSet<string> CopyIgnoreDirectories { get; } =
[
".vs",
".git"
];
public void CreateProject()
{
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
Logger.Log($"Generating Cross Compiler project", ConsoleColor.Yellow);
Logger.Log($"Original Assembly Path {Settings.OriginalAssemblyPath}", ConsoleColor.Yellow);
Logger.Log($"Remapped Assembly Path: {Settings.RemappedOutput}", ConsoleColor.Yellow);
Logger.Log($"Visual Studio Solution Directory: {Settings.VisualStudioSolutionDirectory}", ConsoleColor.Yellow);
// Build the cache model
Cache = new CrossCompilerProjectModel
{
OriginalAssemblyPath = Settings.OriginalAssemblyPath,
RemappedAssemblyPath = Settings.RemappedOutput,
VisualStudioSolutionDirectory = Settings.VisualStudioSolutionDirectory,
OriginalAssemblyHash = HashUtil.GetFileHash(Settings.OriginalAssemblyPath),
RemappedAssemblyHash = "",
ChangedTypes = [],
RemapModels = []
};
// Now copy over the visual studio project
CopyVisualStudioProject(Cache);
// Now save the cache object inside the copied directory
DataProvider.SaveCrossCompilerProjectModel(Cache);
Logger.Log($"Found Solution: {Cache.SolutionPath}", ConsoleColor.Yellow);
Logger.Log($"Original Assembly Checksum: {Cache.OriginalAssemblyHash}", ConsoleColor.Yellow);
Logger.Log($"Project Generated to: {Cache.ReCodeItProjectDir}", ConsoleColor.Green);
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
}
public void StartRemap()
{
ChangedTypes.Clear();
Remapper.InitializeRemap(Settings.OriginalAssemblyPath, Settings.RemappedOutput, true);
if (Cache == null)
if (ActiveProject == null)
{
Logger.Log("ERROR: No Cross Compiler Project is loaded, create or load one first.", ConsoleColor.Red);
return;
}
if (Cache.ReCodeItProjectDir == string.Empty)
if (ActiveProject.ReCodeItProjectPath == string.Empty)
{
Logger.Log("ERROR: No ReCodeIt Project directory is set. (Project Creation Failed)", ConsoleColor.Red);
return;
@ -81,10 +41,10 @@ public class ReCodeItCrossCompiler
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
Logger.Log($"Cross patch remap result", ConsoleColor.Yellow);
Logger.Log($"Changed {ChangedTypes.Count} types", ConsoleColor.Yellow);
Logger.Log($"Original assembly path: {Cache.OriginalAssemblyPath}", ConsoleColor.Yellow);
Logger.Log($"Original assembly hash: {Cache.OriginalAssemblyHash}", ConsoleColor.Yellow);
Logger.Log($"Original patched assembly path: {Cache.RemappedAssemblyPath}", ConsoleColor.Yellow);
Logger.Log($"Original patched assembly hash: {Cache.RemappedAssemblyHash}", ConsoleColor.Yellow);
Logger.Log($"Original assembly path: {ActiveProject.OriginalAssemblyPath}", ConsoleColor.Yellow);
Logger.Log($"Original assembly hash: {ActiveProject.OriginalAssemblyHash}", ConsoleColor.Yellow);
Logger.Log($"Original patched assembly path: {ActiveProject.RemappedAssemblyPath}", ConsoleColor.Yellow);
Logger.Log($"Original patched assembly hash: {ActiveProject.RemappedAssemblyHash}", ConsoleColor.Yellow);
Logger.Log("-----------------------------------------------", ConsoleColor.Yellow);
}
@ -92,86 +52,4 @@ public class ReCodeItCrossCompiler
{
//CopyVisualStudioProject();
}
private void CopyVisualStudioProject(CrossCompilerProjectModel cache)
{
var solutionDirPath = Settings.VisualStudioSolutionDirectory;
var solutionFiles = Directory.GetFiles(solutionDirPath, "*.sln", SearchOption.AllDirectories);
var solutionFile = string.Empty;
if (solutionFiles.Length > 1)
{
Logger.Log("ERROR More than one solution in a directory is not supported, Why tho?", ConsoleColor.Red);
return;
}
foreach (var file in solutionFiles)
{
solutionFile = file;
}
var solutionName = Path.GetFileNameWithoutExtension(solutionFile);
var destination = Path.Combine(DataProvider.ProjectPath, solutionName);
cache.ReCodeItProjectDir = destination;
cache.SolutionPath = solutionFile;
Logger.Log($"Copying solution: {solutionName} to {destination}", ConsoleColor.Yellow);
CopyProjectRecursive(solutionDirPath, destination);
}
private void CopyProjectRecursive(string sourceDirPath, string destinationDirPath)
{
DirectoryInfo sourceDir = new DirectoryInfo(sourceDirPath);
if (!sourceDir.Exists)
{
throw new DirectoryNotFoundException(
"Solution directory does not exist or could not be found: "
+ sourceDirPath);
}
DirectoryInfo[] dirs = sourceDir.GetDirectories();
// If the destination directory doesn't exist, create it.
Directory.CreateDirectory(destinationDirPath);
// Get the files in the directory and copy them to the new location.
FileInfo[] files = sourceDir.GetFiles();
foreach (FileInfo file in files)
{
string tempPath = Path.Combine(destinationDirPath, file.Name);
file.CopyTo(tempPath, true);
}
foreach (DirectoryInfo subdir in dirs)
{
if (CopyIgnoreDirectories.Contains(subdir.Name)) { continue; }
string tempPath = Path.Combine(destinationDirPath, subdir.Name);
CopyProjectRecursive(subdir.FullName, tempPath);
}
}
private void FindProjects()
{
DirectoryInfo sourceDir = new DirectoryInfo(DataProvider.ProjectPath);
// Only search top level directories here
foreach (var directory in sourceDir.GetDirectories())
{
var files = directory.GetFiles();
foreach (var file in files)
{
if (file.Name == "ReCodeItProj.json")
{
ProjectPaths.Add(file.FullName);
Logger.Log($"Found ReCodeIt Project at {file.FullName}");
}
}
}
}
}

View File

@ -105,25 +105,9 @@ public class AutoMapperSettings
public class CrossCompilerSettings
{
/// <summary>
/// The path to the original assembly to use as a reference, for unity games its
/// 'Assembly-CSharp.dll' from the games Data/Managed Folder
/// Last Loaded Project Path
/// </summary>
public string OriginalAssemblyPath { get; set; }
/// <summary>
/// The output path of the remapped assembly
/// </summary>
public string RemappedOutput { get; set; }
/// <summary>
/// The path to the solution directory of the project
/// </summary>
public string VisualStudioSolutionDirectory { get; set; }
/// <summary>
/// Where should the de-patched dll be placed? (This is the one you test/distribute with)
/// </summary>
public string BuildDirectory { get; set; }
public string LastActiveProjectPath { get; set; }
}
/// <summary>

View File

@ -2,18 +2,56 @@
public class CrossCompilerProjectModel
{
#region REQUIRED_ON_CREATION
/// <summary>
/// The path of the original assembly
///
/// (Required on creation)
/// </summary>
public string OriginalAssemblyPath { get; set; }
public string OriginalAssemblyHash { get; set; }
public string VisualStudioSolutionDirectory { get; set; }
public string SolutionPath { get; set; }
public string ReCodeItProjectDir { get; set; }
/// <summary>
/// Remapped output path
///
/// (Required on creation)
/// </summary>
public string RemappedAssemblyPath { get; set; }
/// <summary>
/// The path to the working directory vs project
///
/// (Required on creation)
/// </summary>
public string VisualStudioSolutionPath { get; set; }
/// <summary>
/// This is where the final dll is built to
///
/// (Required on creation)
/// </summary>
public string BuildDirectory { get; set; }
#endregion REQUIRED_ON_CREATION
/// <summary>
/// Name of the solution
/// </summary>
public string SolutionName { get; set; }
/// <summary>
/// The ReCodeIt.json path
/// </summary>
public string ReCodeItProjectPath { get; set; }
/// <summary>
/// Remapped output hash
/// </summary>
public string OriginalAssemblyHash { get; set; }
/// <summary>
/// Remapped output hash
/// </summary>
public string RemappedAssemblyHash { get; set; }
/// <summary>

View File

@ -1,5 +1,5 @@
using Mono.Cecil;
using ReCodeIt.CrossPatcher;
using ReCodeIt.CrossCompiler;
using ReCodeIt.Enums;
using ReCodeIt.Models;
using ReCodeIt.ReMapper.Search;

View File

@ -8,15 +8,15 @@ public static class DataProvider
{
static DataProvider()
{
if (!Directory.Exists(ProjectPath))
if (!Directory.Exists(ReCodeItProjectsPath))
{
Directory.CreateDirectory(ProjectPath);
Directory.CreateDirectory(ReCodeItProjectsPath);
}
}
public static readonly string DataPath = Path.Combine(AppContext.BaseDirectory, "Data");
public static readonly string ProjectPath = Path.Combine(AppContext.BaseDirectory, "Projects");
public static readonly string ReCodeItProjectsPath = Path.Combine(AppContext.BaseDirectory, "Projects");
public static List<RemapModel> Remaps { get; private set; } = [];
@ -158,38 +158,6 @@ public static class DataProvider
Logger.Log($"Mapping file saved to {path}");
}
public static void SaveCrossCompilerProjectModel(CrossCompilerProjectModel model)
{
var path = Path.Combine(model.ReCodeItProjectDir, "ReCodeItProj.json");
JsonSerializerSettings settings = new()
{
Formatting = Formatting.Indented
};
var jsonText = JsonConvert.SerializeObject(model, settings);
File.WriteAllText(path, jsonText);
Logger.Log($"Cross Compiler project json generated to {path}", ConsoleColor.Green);
}
public static CrossCompilerProjectModel LoadCrossCompilerCacheModel(string path)
{
if (!File.Exists(path))
{
Logger.Log($"Error loading cache model from `{path}`", ConsoleColor.Red);
}
var jsonText = File.ReadAllText(path);
var model = JsonConvert.DeserializeObject<CrossCompilerProjectModel>(jsonText);
Logger.Log($"Loaded Cross Compiler Project: {model?.RemappedAssemblyPath}");
return model!;
}
public static void LoadAssemblyDefinition(string path)
{
AssemblyDefinition = null;

View File

@ -66,9 +66,6 @@
]
},
"CrossCompiler": {
"OriginalAssemblyPath": "G:\\3.8.0 - Dev\\EscapeFromTarkov_Data\\Managed\\Assembly-CSharp.dll", // INPUT: The path to the original assembly to use as a reference, for unity games its 'Assembly-CSharp.dll' from the games Data/Managed Folder
"RemappedOutput": "G:\\development\\SPT-MODS\\StashSearch\\dependencies\\Assembly-CSharp.dll", // OUTPUT: The output path of the remapped assembly
"VisualStudioSolutionDirectory": "G:\\development\\SPT-MODS\\StashSearch", // INPUT: This is your solution directory of the project
"BuildDirectory": "G:\\development\\SPT-MODS\\StashSearch\\Build" // OUTPUT/TEST/PROD: This is the final build location of your dll
"LastLoadedProject": "" // Last loaded project path
}
}