protected override string ReplaceOperation(List <string> args, int replaceAtOffset, out bool useStandardBackup) { useStandardBackup = true; Int32?package = GetNameIndex(Program.runData.uasset, args); Int32?_class = GetNameIndex(Program.runData.uasset, args); Int32?outerIndex = GetImportIndex(Program.runData.uasset, args); Int32?name = GetNameIndex(Program.runData.uasset, args); Int32 replacementIndex = (replaceAtOffset - BitConverter.ToInt32(Program.runData.uasset, OffsetConstants.importOffsetOffset)) / OffsetConstants.importDefSize; if (package != null) { DOLib.WriteInt32IntoOffset(Program.runData.uasset, package.Value, replaceAtOffset + OffsetConstants.importPackageOffset); Program.runData.importMap[replacementIndex].packageName = package.Value; } if (_class != null) { DOLib.WriteInt32IntoOffset(Program.runData.uasset, _class.Value, replaceAtOffset + OffsetConstants.importClassOffset); Program.runData.importMap[replacementIndex].className = _class.Value; } if (outerIndex != null) { DOLib.WriteInt32IntoOffset(Program.runData.uasset, outerIndex.Value, replaceAtOffset + OffsetConstants.importOuterIndexOffset); Program.runData.importMap[replacementIndex].outerIndex = outerIndex.Value; } if (name != null) { Program.runData.importMap[replacementIndex].importName = name.Value; DOLib.WriteInt32IntoOffset(Program.runData.uasset, name.Value, replaceAtOffset + OffsetConstants.importNameOffset); } return(""); }
protected override string AddOperation(List <string> args, int addAtOffset, out bool useStandardBackup) { useStandardBackup = false; Int32 _class = GetImportExportIndex(Program.runData.uasset, args).Value; Int32 super = Int32.Parse(args.TakeArg()); Int32 template = GetImportExportIndex(Program.runData.uasset, args).Value; Int32 outer = GetImportExportIndex(Program.runData.uasset, args).Value; Int32 name = GetNameIndex(Program.runData.uasset, args).Value; Int32 nameAug = Int32.Parse(args.TakeArg()); Int32 flags = Int32.Parse(args.TakeArg()); Int32 serialOffset = BitConverter.ToInt32(Program.runData.uasset, addAtOffset - OffsetConstants.exportDefSize + relativeSerialOffsetOffset) + BitConverter.ToInt32(Program.runData.uasset, addAtOffset - OffsetConstants.exportDefSize + relativeSerialSizeOffset); List <Int32> other = new List <int>(); for (int i = 0; i < otherDataInt32Count; i++) { other.Add(Int32.Parse(args.TakeArg())); } Program.runData.uasset = Insert(Program.runData.uasset, MakeExportDef(_class, super, template, outer, name, nameAug, flags, 0, serialOffset, other), addAtOffset); if (File.Exists(Program.runData.uassetFileName + ".AddExportDefBackup")) { File.Delete(Program.runData.uassetFileName + ".AddExportDefBackup"); } Directory.Move(Program.runData.uassetFileName, Program.runData.uassetFileName + ".AddExportDefBackup"); File.WriteAllBytes(Program.runData.uassetFileName, Program.runData.uasset); Program.CallOffSetterWithArgs(" -edef 104 1 -r -m"); Program.runData.uasset = File.ReadAllBytes(Program.runData.uassetFileName); byte[] uexp = File.ReadAllBytes(Program.runData.uexpFileName); Int32 newExportSerialOffset = BitConverter.ToInt32(Program.runData.uasset, addAtOffset + relativeSerialOffsetOffset); Int32 newExportFileOffset = newExportSerialOffset - BitConverter.ToInt32(Program.runData.uasset, headerSizeOffset); byte[] stubExport = new byte[12]; DOLib.WriteInt32IntoOffset(stubExport, FindNameIndex(Program.runData.uasset, "None").Value, 0); uexp = Insert(uexp, stubExport, newExportFileOffset); if (File.Exists(Program.runData.uexpFileName + ".AddStubExportBackup")) { File.Delete(Program.runData.uexpFileName + ".AddStubExportBackup"); } File.Move(Program.runData.uexpFileName, Program.runData.uexpFileName + ".AddStubExportBackup"); File.WriteAllBytes(Program.runData.uexpFileName, uexp); Program.CallOffSetterWithArgs($" -e 12 {newExportSerialOffset} -r -m"); Program.runData.uasset = File.ReadAllBytes(Program.runData.uassetFileName); return(""); }
private static byte[] MakeNameDef(string name) { byte[] result = new byte[OffsetConstants.nameHashesSize + OffsetConstants.stringSizeDesignationSize + 1]; result = Insert(result, StringToBytes(name), 4); DOLib.WriteInt32IntoOffset(result, name.Length + 1, 0); return(result); }
private static byte[] MakeImportDef(Int32 package, Int32 _class, Int32 outerIndex, Int32 name) { byte[] result = new byte[OffsetConstants.importDefSize]; DOLib.WriteInt32IntoOffset(result, package, OffsetConstants.importPackageOffset); DOLib.WriteInt32IntoOffset(result, _class, OffsetConstants.importClassOffset); DOLib.WriteInt32IntoOffset(result, outerIndex, OffsetConstants.importOuterIndexOffset); DOLib.WriteInt32IntoOffset(result, name, OffsetConstants.importNameOffset); return(result); }
/// <summary> /// /// </summary> /// <param name="_class"></param> /// <param name="super"></param> /// <param name="template"></param> /// <param name="outer"></param> /// <param name="name"></param> /// <param name="nameAug">Name Augmentation. Seems to be a number sometimes used to distinguish objects sharing same "base" name</param> /// <param name="flags"></param> /// <param name="size">aka SerialSize, usually set to 0 in DAUM, actual value set after by OffSetter</param> /// <param name="serialOffset"></param> /// <param name="other">other is assumed to be 15 elements, less elements will cause exception!</param> /// <returns>byte[] with ExportDefinition </returns> private static byte[] MakeExportDef(Int32 _class, Int32 super, Int32 template, Int32 outer, Int32 name, Int32 nameAug, Int32 flags, Int32 size, Int32 serialOffset, List <Int32> other) { byte[] result = new byte[exportDefinitionSize]; DOLib.WriteInt32IntoOffset(result, _class, relativeClassOffset); DOLib.WriteInt32IntoOffset(result, super, relativeSuperOffset); DOLib.WriteInt32IntoOffset(result, template, relativeTemlateOffset); DOLib.WriteInt32IntoOffset(result, outer, relativeOuterOffset); DOLib.WriteInt32IntoOffset(result, name, relativeObjectNameOffset); DOLib.WriteInt32IntoOffset(result, nameAug, relativeObjectNameOffset + 4); DOLib.WriteInt32IntoOffset(result, flags, relativeObjectFlagsOffset); DOLib.WriteInt32IntoOffset(result, size, relativeSerialSizeOffset); DOLib.WriteInt32IntoOffset(result, serialOffset, relativeSerialOffsetOffset); Int32 currentOtherOffset = relativeOtherDataOffset; for (int i = 0; i < otherDataInt32Count; i++) { DOLib.WriteInt32IntoOffset(result, other[i], currentOtherOffset); currentOtherOffset += 4; } return(result); }