mirror of
https://github.com/Perfare/Il2CppDumper.git
synced 2025-01-26 02:33:01 -03:00
Add config to control whether json values are escaped
This commit is contained in:
parent
4741d46ba9
commit
1d31daac3f
4 changed files with 9 additions and 3 deletions
|
@ -17,5 +17,6 @@
|
||||||
public double ForceVersion { get; set; } = 24.3;
|
public double ForceVersion { get; set; } = 24.3;
|
||||||
public bool ForceDump { get; set; } = false;
|
public bool ForceDump { get; set; } = false;
|
||||||
public bool NoRedirectedPointer { get; set; } = false;
|
public bool NoRedirectedPointer { get; set; } = false;
|
||||||
|
public bool EscapeJsonValues { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Il2CppDumper
|
||||||
il2Cpp = il2CppExecutor.il2Cpp;
|
il2Cpp = il2CppExecutor.il2Cpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteScript(string outputDir)
|
public void WriteScript(string outputDir, bool escapeJsonValues)
|
||||||
{
|
{
|
||||||
var json = new ScriptJson();
|
var json = new ScriptJson();
|
||||||
// 生成唯一名称
|
// 生成唯一名称
|
||||||
|
@ -373,6 +373,10 @@ namespace Il2CppDumper
|
||||||
address = $"0x{x.Address:X}"
|
address = $"0x{x.Address:X}"
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
var jsonOptions = new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true };
|
var jsonOptions = new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true };
|
||||||
|
if (!escapeJsonValues)
|
||||||
|
{
|
||||||
|
jsonOptions.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping;
|
||||||
|
}
|
||||||
File.WriteAllText(outputDir + "stringliteral.json", JsonSerializer.Serialize(stringLiterals, jsonOptions), new UTF8Encoding(false));
|
File.WriteAllText(outputDir + "stringliteral.json", JsonSerializer.Serialize(stringLiterals, jsonOptions), new UTF8Encoding(false));
|
||||||
//写入文件
|
//写入文件
|
||||||
File.WriteAllText(outputDir + "script.json", JsonSerializer.Serialize(json, jsonOptions));
|
File.WriteAllText(outputDir + "script.json", JsonSerializer.Serialize(json, jsonOptions));
|
||||||
|
|
|
@ -262,7 +262,7 @@ namespace Il2CppDumper
|
||||||
{
|
{
|
||||||
Console.WriteLine("Generate struct...");
|
Console.WriteLine("Generate struct...");
|
||||||
var scriptGenerator = new StructGenerator(executor);
|
var scriptGenerator = new StructGenerator(executor);
|
||||||
scriptGenerator.WriteScript(outputDir);
|
scriptGenerator.WriteScript(outputDir, config.EscapeJsonValues);
|
||||||
Console.WriteLine("Done!");
|
Console.WriteLine("Done!");
|
||||||
}
|
}
|
||||||
if (config.GenerateDummyDll)
|
if (config.GenerateDummyDll)
|
||||||
|
|
|
@ -13,5 +13,6 @@
|
||||||
"ForceIl2CppVersion": false,
|
"ForceIl2CppVersion": false,
|
||||||
"ForceVersion": 16,
|
"ForceVersion": 16,
|
||||||
"ForceDump": false,
|
"ForceDump": false,
|
||||||
"NoRedirectedPointer": false
|
"NoRedirectedPointer": false,
|
||||||
|
"EscapeJsonValues": true
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue