static UPackage_Info LoadInfo_fromFile(string file_path) { var pkg = UnrealLoader.LoadFullPackage(file_path); var _R = new UPackage_Info(); var imp = new List <UPortedItem_Info>(); foreach (var v in pkg.Imports) { UPortedItem_Info upi; if (Get_UPIInfo(v.ClassName, v.OuterName, v.ObjectName, out upi, _R)) { imp.Add(upi); } } var exp = new List <UPortedItem_Info>(); foreach (var v in pkg.Exports) { UPortedItem_Info upi; if (Get_UPIInfo(v.ClassName, v.OuterName, v.ObjectName, out upi, _R)) { exp.Add(upi); } } _R.PackageName = Get_PkgName(file_path).ToLower(); _R.Imports = imp; _R.Exports = exp; return(_R); }
private static void PreloadBasicPackages(string baseFolder) { var basicPackageNames = new List <string>() { "Core.upk", "Engine.upk", "ProjectX.upk", "AkAudio.upk", "TAGame.upk" }; foreach (var packageName in basicPackageNames) { try { Console.WriteLine($"Preloading {packageName}"); string packagePath = Path.Combine(baseFolder, packageName); UnrealLoader.LoadFullPackage(packagePath, System.IO.FileAccess.Read); } catch (FileNotFoundException e) { Console.WriteLine( $"Did not find {packageName} in the current directory." + "This is optional, but recommended. " + "Preloading this package improves type recognition."); } } }
public string TryDetectCI(string packageName) { try { using (var pkg = UnrealLoader.LoadFullPackage(Path.Combine(GetContentDir(), packageName + ".upk"), FileAccess.Read)) { foreach (var obj in pkg.Objects) { if (obj.Class.Name == "Hat_ChapterInfo") { if (obj.Outer == null) { return($"{obj.Package.PackageName}.{obj.Name}"); } else { return($"{obj.Package.PackageName}.{obj.Outer.Name}.{obj.Name}"); } } } } } catch (Exception e) { Debug.WriteLine(e.Message + Environment.NewLine + e.ToString()); } return(null); }
private static void ProcessPackage(string pathToPackages, string file, Options options) { var packagePath = Path.Combine(pathToPackages, file); var package = UnrealLoader.LoadFullPackage(packagePath, System.IO.FileAccess.Read); var packageName = Path.GetFileNameWithoutExtension(packagePath); var outputMainFolder = Path.Combine("Extracted", packageName); //Init the asset extractor Log.DeserializationErrors = 0; assetExtractor = new AssetExtractor(package); Console.WriteLine($"Processing: {file}"); if (options.ExtractClasses) { assetExtractor.ExportClasses(outputMainFolder); } if (options.ExtractData) { assetExtractor.ExportData(outputMainFolder); } if (options.ExtractMeshInfo) { assetExtractor.ExportMeshObjects(outputMainFolder); } assetExtractor.ExportDummyAssets(outputMainFolder); string deserializationErrors = $"Total deserialization errors: {Log.DeserializationErrors}"; Log.Debug(deserializationErrors); Console.WriteLine(deserializationErrors); }
public void LoadMapPackage_DecompileObjects_ShouldBeValidJson(string mapPath, string objectTypeName) { var package = UnrealLoader.LoadFullPackage(mapPath); for (var i = 0; i < package.Objects.Count; i++) { var obj = package.Objects[i]; // obj.Name.Length > objectTypeName.Length is to include only instances, not bare class types if (!obj.Name.StartsWith(objectTypeName) && obj.Name.Length > objectTypeName.Length) { continue; } try { var json = obj.Decompile(); TestContext.Out.Write(json); Assert.False(string.IsNullOrEmpty(json)); Assert.IsTrue(JsonConvert.DeserializeObject(json) != null); } catch (Exception e) { // catch for a breakpoint Console.WriteLine(e); } } }
private void BgWorkerPackageGen_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { btnGenerate.Text = "Generating ..."; splitContainer1.Panel1.Enabled = false; if (!File.Exists(filePath)) { return; } var fileName = Path.GetFileNameWithoutExtension(filePath); if (fileName == null) { return; } Console.Write("Loading package ... "); var package = UnrealLoader.LoadFullPackage(filePath, FileAccess.Read); Console.WriteLine("Done."); var finalString = "Begin Map\r\n" + "\tBegin Level\r\n"; foreach (var obj in package.Objects) { if (obj.ExportTable == null || obj.Name == "None") { continue; } if (lstBoxTypesToGenerate.SelectedItems.Count == 0 || lstBoxTypesToGenerate.SelectedItems.Contains(obj.NameTable.Name)) { //if (obj.NameTable.Name == "StaticMeshActor_SMC") // Only use one NameTable during my tests until they're all implemented //if (obj.Name == "StaticMeshActor_SMC_39") //{ var nameTable = NameTableFactory.GetNameTable(obj, fileName, chckBoxInvisitek.Checked, chckBoxLayers.Checked); if (nameTable != null) { finalString += nameTable.ProcessString(); } //} } continue; } finalString += "\tEnd Level\r\n" + "\tBegin Surface\r\n" + "\tEnd Surface\r\n" + "End Map"; generatedText = finalString; }
private void AnalyzePotraits(string path) { var package = UnrealLoader.LoadFullPackage(path); foreach (var content in package.Objects) { Console.WriteLine("Name: {0}, Class: {1}, Outer: {2}", content.Name, content.Class.Name, content.Outer == null ? "null" : content.Outer.Name); } }
private void mButton1_Click(object sender, EventArgs e) { // SoundCue'HatinTime_Voice_SubconNoose.SoundCues.01_why_hello_there' var pattern = new Regex(@"([A-Za-z0-9]{1,255})\'([A-Za-z_0-9\.]{1,255})\'$"); var match = pattern.Matches(mTextBox1.Text); if (match.Count != 1 || match[0].Groups.Count != 3) { GUI.MessageBox.Show(this, "Invalid input!"); } try { var type = match[0].Groups[1].Value; var objName = match[0].Groups[2].Value; var spl = objName.Split('.'); var package = spl[0]; var parserType = (UModelFacade.ExportType)Enum.Parse(typeof(UModelFacade.ExportType), type); var pkg = Utils.FindPackage(package); var loader = UnrealLoader.LoadFullPackage(pkg, System.IO.FileAccess.Read); if (loader != null) { foreach (var o in loader.Objects) { if (o.Name.Equals(spl.Last(), StringComparison.InvariantCultureIgnoreCase) && o.Class.Name.Equals(type, StringComparison.InvariantCultureIgnoreCase)) { if (spl.Count() == 3) { if (!o.Outer.Name.Equals(spl[1], StringComparison.InvariantCultureIgnoreCase)) { Debug.WriteLine(o.Outer.Name + " >> Outer invalid"); continue; } } SaveFileDialog dlg = new SaveFileDialog(); var ext = UModelFacade.GetExtensionForType(parserType); if (ext == null) { GUI.MessageBox.Show(this, "Unsupported type: " + parserType); return; } dlg.DefaultExt = ext.TrimStart('.'); dlg.FileName = objName; dlg.Filter = $"{parserType} (*{ext})|*{ext}"; if (dlg.ShowDialog() == DialogResult.OK) { var facade = new UModelFacade(); var result = facade.Export(package, spl.Last(), parserType, dlg.FileName); GUI.MessageBox.Show(this, result ? "File exported sucessfully!" : "Export failed!"); } return; } } } GUI.MessageBox.Show(this, "Asset not found!"); } catch (Exception ex) { GUI.MessageBox.Show(ex.Message + "\n\n" + ex); } }
public void LoadDecryptedPackage() { //Just testing for no unhandled exceptions string testPackage = "TestData\\AkAudio_decrypted.upk"; var package = UnrealLoader.LoadFullPackage(testPackage, System.IO.FileAccess.Read); }