GUI: Add JSON output support
This commit is contained in:
@@ -366,7 +366,7 @@
|
|||||||
<!-- IDAPython script -->
|
<!-- IDAPython script -->
|
||||||
<RadioButton GroupName="grpOutputType" Name="rdoOutputIDA" VerticalContentAlignment="Center" FontSize="18" Foreground="{StaticResource MicrosoftGreen}">IDAPython script</RadioButton>
|
<RadioButton GroupName="grpOutputType" Name="rdoOutputIDA" VerticalContentAlignment="Center" FontSize="18" Foreground="{StaticResource MicrosoftGreen}">IDAPython script</RadioButton>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<ComboBox Name="cboUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
<ComboBox Name="cboIdaUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||||
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
@@ -385,6 +385,16 @@
|
|||||||
</ComboBox>
|
</ComboBox>
|
||||||
<Label DockPanel.Dock="Left" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left">Target C++ compiler for output:</Label>
|
<Label DockPanel.Dock="Left" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left">Target C++ compiler for output:</Label>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
|
<Separator Margin="5,15,5,15"/>
|
||||||
|
|
||||||
|
<!-- JSON metadata -->
|
||||||
|
<RadioButton GroupName="grpOutputType" Name="rdoOutputJSON" VerticalContentAlignment="Center" FontSize="18" Foreground="{StaticResource MicrosoftGreen}">JSON metadata</RadioButton>
|
||||||
|
<DockPanel>
|
||||||
|
<ComboBox Name="cboJsonUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||||
|
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|||||||
@@ -215,19 +215,24 @@ namespace Il2CppInspectorGUI
|
|||||||
trvNamespaces.ItemsSource = namespaceTree;
|
trvNamespaces.ItemsSource = namespaceTree;
|
||||||
|
|
||||||
// Populate Unity version combo boxes
|
// Populate Unity version combo boxes
|
||||||
var prevSelection = cboUnityVersion.SelectedItem;
|
var prevIdaSelection = cboIdaUnityVersion.SelectedItem;
|
||||||
var prevCppSelection = cboCppUnityVersion.SelectedItem;
|
var prevCppSelection = cboCppUnityVersion.SelectedItem;
|
||||||
cboUnityVersion.Items.Clear();
|
var prevJsonSelection = cboJsonUnityVersion.SelectedItem;
|
||||||
|
cboIdaUnityVersion.Items.Clear();
|
||||||
cboCppUnityVersion.Items.Clear();
|
cboCppUnityVersion.Items.Clear();
|
||||||
|
cboJsonUnityVersion.Items.Clear();
|
||||||
foreach (var version in UnityHeaders.GuessHeadersForBinary(model.Package.Binary)) {
|
foreach (var version in UnityHeaders.GuessHeadersForBinary(model.Package.Binary)) {
|
||||||
cboUnityVersion.Items.Add(version);
|
cboIdaUnityVersion.Items.Add(version);
|
||||||
cboCppUnityVersion.Items.Add(version);
|
cboCppUnityVersion.Items.Add(version);
|
||||||
|
cboJsonUnityVersion.Items.Add(version);
|
||||||
}
|
}
|
||||||
cboUnityVersion.SelectedIndex = cboUnityVersion.Items.Count - 1;
|
cboIdaUnityVersion.SelectedIndex = cboIdaUnityVersion.Items.Count - 1;
|
||||||
cboCppUnityVersion.SelectedIndex = cboCppUnityVersion.Items.Count - 1;
|
cboCppUnityVersion.SelectedIndex = cboCppUnityVersion.Items.Count - 1;
|
||||||
if (prevSelection != null) {
|
cboJsonUnityVersion.SelectedIndex = cboJsonUnityVersion.Items.Count - 1;
|
||||||
cboUnityVersion.SelectedItem = prevSelection;
|
if (prevIdaSelection != null) {
|
||||||
|
cboIdaUnityVersion.SelectedItem = prevIdaSelection;
|
||||||
cboCppUnityVersion.SelectedItem = prevCppSelection;
|
cboCppUnityVersion.SelectedItem = prevCppSelection;
|
||||||
|
cboJsonUnityVersion.SelectedItem = prevJsonSelection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,26 +412,26 @@ namespace Il2CppInspectorGUI
|
|||||||
// IDA Python script
|
// IDA Python script
|
||||||
case { rdoOutputIDA: var r } when r.IsChecked == true:
|
case { rdoOutputIDA: var r } when r.IsChecked == true:
|
||||||
|
|
||||||
var scriptSaveFileDialog = new SaveFileDialog {
|
var idaSaveFileDialog = new SaveFileDialog {
|
||||||
Filter = "Python scripts (*.py)|*.py|All files (*.*)|*.*",
|
Filter = "Python scripts (*.py)|*.py|All files (*.*)|*.*",
|
||||||
FileName = "ida.py",
|
FileName = "ida.py",
|
||||||
CheckFileExists = false,
|
CheckFileExists = false,
|
||||||
OverwritePrompt = true
|
OverwritePrompt = true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (scriptSaveFileDialog.ShowDialog() == false)
|
if (idaSaveFileDialog.ShowDialog() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var outFile = scriptSaveFileDialog.FileName;
|
var idaOutFile = idaSaveFileDialog.FileName;
|
||||||
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
var selectedVersion = ((UnityHeaders) cboUnityVersion.SelectedItem)?.VersionRange.Min;
|
var selectedIdaUnityVersion = ((UnityHeaders) cboIdaUnityVersion.SelectedItem)?.VersionRange.Min;
|
||||||
await Task.Run(() => {
|
await Task.Run(() => {
|
||||||
OnStatusUpdate(this, "Building C++ application model");
|
OnStatusUpdate(this, "Building C++ application model");
|
||||||
model.Build(selectedVersion, CppCompilerType.GCC);
|
model.Build(selectedIdaUnityVersion, CppCompilerType.GCC);
|
||||||
|
|
||||||
OnStatusUpdate(this, "Generating IDAPython script");
|
OnStatusUpdate(this, "Generating IDAPython script");
|
||||||
new IDAPythonScript(model).WriteScriptToFile(outFile);
|
new IDAPythonScript(model).WriteScriptToFile(idaOutFile);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -454,6 +459,32 @@ namespace Il2CppInspectorGUI
|
|||||||
new CppScaffolding(model).Write(cppOutPath);
|
new CppScaffolding(model).Write(cppOutPath);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// JSON metadata
|
||||||
|
case { rdoOutputJSON: var r } when r.IsChecked == true:
|
||||||
|
|
||||||
|
var jsonSaveFileDialog = new SaveFileDialog {
|
||||||
|
Filter = "JSON files (*.json)|*.json|All files (*.*)|*.*",
|
||||||
|
FileName = "metadata.json",
|
||||||
|
CheckFileExists = false,
|
||||||
|
OverwritePrompt = true
|
||||||
|
};
|
||||||
|
|
||||||
|
if (jsonSaveFileDialog.ShowDialog() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var jsonOutFile = jsonSaveFileDialog.FileName;
|
||||||
|
|
||||||
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
|
var selectedJsonUnityVersion = ((UnityHeaders) cboJsonUnityVersion.SelectedItem)?.VersionRange.Min;
|
||||||
|
await Task.Run(() => {
|
||||||
|
OnStatusUpdate(this, "Building C++ application model");
|
||||||
|
model.Build(selectedJsonUnityVersion, CppCompilerType.GCC);
|
||||||
|
|
||||||
|
OnStatusUpdate(this, "Generating JSON metadata file");
|
||||||
|
new JSONMetadata(model).Write(jsonOutFile);
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
|||||||
Reference in New Issue
Block a user