diff --git a/Il2CppDumper/Outputs/StructGenerator.cs b/Il2CppDumper/Outputs/StructGenerator.cs index dea8d7a..9accd56 100644 --- a/Il2CppDumper/Outputs/StructGenerator.cs +++ b/Il2CppDumper/Outputs/StructGenerator.cs @@ -375,7 +375,10 @@ public void WriteScript(string outputDir) var jsonOptions = new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true }; File.WriteAllText(outputDir + "stringliteral.json", JsonSerializer.Serialize(stringLiterals, jsonOptions), new UTF8Encoding(false)); //写入文件 - File.WriteAllText(outputDir + "script.json", JsonSerializer.Serialize(json, jsonOptions)); + using (var stream = new FileStream(outputDir + "script.json",FileMode.Create)) + { + JsonSerializer.Serialize(stream, json, jsonOptions); + } //il2cpp.h for (int i = 0; i < genericClassList.Count; i++) { @@ -428,7 +431,21 @@ public void WriteScript(string outputDir) sb.Append(headerStruct); sb.Append(arrayClassHeader); sb.Append(methodInfoHeader); - File.WriteAllText(outputDir + "il2cpp.h", sb.ToString()); + int bufferSize = 4096; + using (StreamWriter writer = new StreamWriter(outputDir + "il2cpp.h", false, Encoding.UTF8, bufferSize)) + { + int index = 0; + int length = sb.Length; + char[] buffer = new char[bufferSize]; + + while (index < length) + { + int count = Math.Min(bufferSize, length - index); + sb.CopyTo(index, buffer, 0, count); + writer.Write(buffer, 0, count); + index += count; + } + } } private void AddMetadataUsageTypeInfo(ScriptJson json, uint index, ulong address)