Advertisement
sewer56lol

Untitled

Sep 5th, 2019
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 29.80 KB | None | 0 0
  1. using System.Runtime.InteropServices;
  2. using Heroes.SDK.Structures.OneFile;
  3. using Heroes.SDK.Utilities.OneParser;
  4. using Heroes.SDK.Utility;
  5. using Reloaded.Hooks;
  6. using Reloaded.Hooks.Definitions;
  7. using Reloaded.Hooks.Definitions.X86;
  8. using static Reloaded.Hooks.Definitions.X86.FunctionAttribute;
  9.  
  10. namespace Heroes.SDK.NativeClasses
  11. {
  12.     [StructLayout(LayoutKind.Explicit, Size = 0x5C)]
  13.     public unsafe struct OneFile
  14.     {
  15.         /// <summary>
  16.         /// Contains the name of the ONE file.
  17.         /// If it was temporarily loaded with ONEFILE::SetOneFileOneTime, the name
  18.         /// is assumed as "memoryOneFileNoRel.xxx".
  19.         /// </summary>
  20.         [FieldOffset(0)]
  21.         private fixed byte _FileName[0x40];
  22.  
  23.         /// <summary>
  24.         /// Contains an address/pointer to which a file from the current archive may be decompressed to.
  25.         /// </summary>
  26.         [FieldOffset(0x40)]
  27.         public void* AddressToDecompressFileTo;
  28.  
  29.         /// <summary>
  30.         /// Contains the pointer to the file name section of the file.
  31.         /// ONE Archive File Offset: 0x18
  32.         /// </summary>
  33.         [FieldOffset(0x44)]
  34.         public OneFileName* NameSectionPointer;
  35.  
  36.         /// <summary>
  37.         /// Contains a pointer to the ONE file data.
  38.         /// Note: This field isn't always initialized. If not initialized it has the value -1 (0xFFFFFFFF).
  39.         /// </summary>
  40.         [FieldOffset(0x48)]
  41.         public OneArchiveHeader* StartOfFilePointer;
  42.  
  43.         /// <summary>
  44.         /// Contains a pointer to the ONE file data.
  45.         /// Note: This field isn't always initialized. If not initialized it has the value 0.
  46.         /// </summary>
  47.         [FieldOffset(0x4C)]
  48.         public OneArchiveHeader* Unknown;
  49.  
  50.         /// <summary>
  51.         /// Set to 1 if a file is currently loaded into the ONEFile instance, else 0.
  52.         /// This one is set in the constructor - it may or may not be re-used much after.
  53.         /// </summary>
  54.         [FieldOffset(0x50)]
  55.         public int Initialized;
  56.  
  57.         /// <summary>
  58.         /// Contains a pointer to the ONE file data after the 0xC header.
  59.         /// ONE Archive File Offset: 0xC
  60.         /// </summary>
  61.         [FieldOffset(0x54)]
  62.         public OneNameSectionHeader* NameSectionHeaderPointer;
  63.  
  64.         /// <summary>
  65.         /// Contains the size of the .ONE file.
  66.         /// </summary>
  67.         [FieldOffset(0x58)]
  68.         public int FileLength;
  69.  
  70.         /* Function Listing */
  71.  
  72.         public static IFunction<Native_CheckFileID> Fun_CheckFileId { get; } = new Function<Native_CheckFileID>(0x0042F280, ReloadedHooks.Instance);
  73.         public static IFunction<Native_LoadHAnimationEx> Fun_LoadHAnimationEx { get; } = new Function<Native_LoadHAnimationEx>(0x0042F7C0, ReloadedHooks.Instance);
  74.         public static IFunction<Native_LoadOneFile> Fun_LoadOneFile { get; } = new Function<Native_LoadOneFile>(0x0042F100, ReloadedHooks.Instance);
  75.         public static IFunction<Native_OnefileConstructor> Fun_Constructor { get; } = new Function<Native_OnefileConstructor>(0x0042F0D0, ReloadedHooks.Instance);
  76.         public static IFunction<Native_OneFileLoadCameraTmb> Fun_LoadCameraTmb { get; } = new Function<Native_OneFileLoadCameraTmb>(0x0042F770, ReloadedHooks.Instance);
  77.         public static IFunction<Native_OneFileLoadClump> Fun_LoadClump { get; } = new Function<Native_OneFileLoadClump>(0x0042F440, ReloadedHooks.Instance);
  78.         public static IFunction<Native_OneFileLoadDeltaMorph> Fun_LoadDeltaMorph { get; } = new Function<Native_OneFileLoadDeltaMorph>(0x0042F520, ReloadedHooks.Instance);
  79.         public static IFunction<Native_OneFileLoadHAnimation> Fun_LoadHAnimation { get; } = new Function<Native_OneFileLoadHAnimation>(0x0042F600, ReloadedHooks.Instance);
  80.         public static IFunction<Native_OneFileLoadMaestro> Fun_LoadMaestro { get; } = new Function<Native_OneFileLoadMaestro>(0x0042F6F0, ReloadedHooks.Instance);
  81.         public static IFunction<Native_OneFileLoadSpline> Fun_LoadSpline { get; } = new Function<Native_OneFileLoadSpline>(0x0042F4B0, ReloadedHooks.Instance);
  82.         public static IFunction<Native_OneFileLoadTextureDictionary> Fun_LoadTextureDictionary { get; } = new Function<Native_OneFileLoadTextureDictionary>(0x0042F3C0, ReloadedHooks.Instance);
  83.         public static IFunction<Native_OneFileLoadUVAnim> Fun_LoadUVAnim { get; } = new Function<Native_OneFileLoadUVAnim>(0x0042F670, ReloadedHooks.Instance);
  84.         public static IFunction<Native_OneFileLoadWorld> Fun_LoadWorld { get; } = new Function<Native_OneFileLoadWorld>(0x0042F590, ReloadedHooks.Instance);
  85.         public static IFunction<Native_OpenData> Fun_OpenData { get; } = new Function<Native_OpenData>(0x0042F340, ReloadedHooks.Instance);
  86.         public static IFunction<Native_ReleaseOneFile> Fun_ReleaseOneFile { get; } = new Function<Native_ReleaseOneFile>(0x0042F210, ReloadedHooks.Instance);
  87.         public static IFunction<Native_SetOneFileOneTime> Fun_SetOneFileOneTime { get; } = new Function<Native_SetOneFileOneTime>(0x0042F7F0, ReloadedHooks.Instance);
  88.  
  89.         /*
  90.             Original Function Calls
  91.         */
  92.  
  93.         /// <summary>
  94.         /// Initializes a .ONE file into a pre-allocated memory location.
  95.         /// </summary>
  96.         /// <param name="fileName">The name of the ONE File to load from.</param>
  97.         /// <param name="allocatedMemoryPtr">Malloc'd Memory Struct to write ONE file to.</param>
  98.         /// <param name="boolLoadOneFile">Informs the ONEFile class instance whether the .ONE file should be loaded on instantiation. Set 1 to true, 0 to false.</param>
  99.         /// <returns>The "This" pointer with ONEFILE class written to it.</returns>
  100.         public void* Constructor(string fileName, void* allocatedMemoryPtr, int boolLoadOneFile) => Fun_Constructor.GetWrapper()(fileName, allocatedMemoryPtr, ref this, boolLoadOneFile);
  101.  
  102.         /// <summary>
  103.         /// Gets the index of the file with a specified passed in name.
  104.         /// </summary>
  105.         /// <param name="fileNamePtr">The name of the ONE file to load. Up to 64 characters.</param>
  106.         /// <returns>he index of the file with specified file name (or -1). Up to 255</returns>
  107.         public int CheckFileId(string fileNamePtr) => Fun_CheckFileId.GetWrapper()(ref this, fileNamePtr);
  108.  
  109.         /// <summary>
  110.         /// Opens a .ONE file, reads and returns the address of a specified decompressed .anm HAnim file.
  111.         /// </summary>
  112.         /// <param name="fileNamePtr">Pointer to the file name to load the HAnimation (ANM) from.</param>
  113.         /// <param name="allocatedMemoryPtr">Malloc'd Memory Struct To Write ONE File to.</param>
  114.         /// <param name="animationFileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  115.         /// <returns>The address containing the read in ANM (H Anim - Character Animation) stream.</returns>
  116.         public void* LoadHAnimationEx(string fileNamePtr, void* allocatedMemoryPtr, int animationFileIndex) => Fun_LoadHAnimationEx.GetWrapper()(fileNamePtr, allocatedMemoryPtr, ref this, animationFileIndex);
  117.  
  118.         /// <summary>
  119.         /// Loads a .ONE file from the hard drive into memory;
  120.         /// </summary>
  121.         /// <param name="allocatedMemoryPtr">Malloc'd Memory Struct To Write ONE File to.</param>
  122.         /// <param name="fileNamePtr">The name of the ONE file to load.</param>
  123.         /// <returns>1 if the operation succeeded, else 0.</returns>
  124.         public void* LoadOneFile(void* allocatedMemoryPtr, string fileNamePtr) => Fun_LoadOneFile.GetWrapper()(ref this, allocatedMemoryPtr, fileNamePtr);
  125.        
  126.         /// <summary>
  127.         /// Reads a Camera TMB (NJS_MOTION) from a specified file index in the archive.
  128.         /// </summary>
  129.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  130.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  131.         /// <returns>The address containing the read in Camera TMB (NJS_MOTION *) stream.</returns>
  132.         public void* LoadCameraTmb(int fileIndex, void* addressToDecompressTo) => Fun_LoadCameraTmb.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  133.  
  134.         /// <summary>
  135.         /// Reads a DFF/Clump stream from a .ONE archive. Returns address of a decompressed DFF file.
  136.         /// </summary>
  137.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  138.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  139.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  140.         /// <returns>The address containing the read in DFF (Clump) stream.</returns>
  141.         public void* LoadClump(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer) => Fun_LoadClump.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  142.  
  143.         /// <summary>
  144.         /// Reads a DMA/Delta Morph stream from a .ONE archive. Returns address of a decompressed DMA file.
  145.         /// </summary>
  146.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  147.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  148.         /// <returns>The address containing the read in DMA (Delta Morph) stream.</returns>
  149.         public void* LoadDeltaMorph(int fileIndex, void* addressToDecompressTo) => Fun_LoadDeltaMorph.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  150.  
  151.         /// <summary>
  152.         /// Reads a ANM/HAnim stream from a .ONE archive. Returns address of a decompressed ANM file.
  153.         /// </summary>
  154.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  155.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  156.         /// <returns>The address containing the read in ANM (H Anim - Character Animation) stream.</returns>
  157.         public void* LoadHAnimation(int fileIndex, void* addressToDecompressTo) => Fun_LoadHAnimation.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  158.  
  159.         /// <summary>
  160.         /// Reads a ANM/Maestro stream from a .ONE archive. Returns address of a decompressed ANM file.
  161.         /// </summary>
  162.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  163.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  164.         /// <returns>The address containing the read in ANM (RW Maestro) stream.</returns>
  165.         public void* LoadMaestro(void* addressToDecompressTo, int fileIndex) => Fun_LoadMaestro.GetWrapper()(addressToDecompressTo, ref this, fileIndex);
  166.  
  167.         /// <summary>
  168.         /// Reads a SPL/RW Spline stream from a .ONE archive. Returns address of a decompressed SPL file.
  169.         /// </summary>
  170.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  171.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  172.         /// <returns>The address containing the read in SPL (Spline) stream.</returns>
  173.         public void* LoadSpline(int fileIndex, void* addressToDecompressTo) => Fun_LoadSpline.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  174.  
  175.         /// <summary>
  176.         /// Reads a TXD/RW Texture Dictionary stream from a .ONE archive. Returns address of a decompressed TXD file.
  177.         /// </summary>
  178.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  179.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  180.         /// <returns>The address containing the read in TXD (Texture Dictionary) stream.</returns>
  181.         public void* LoadTextureDictionary(int fileIndex, void* addressToDecompressTo) => Fun_LoadTextureDictionary.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  182.  
  183.         /// <summary>
  184.         /// Reads a UVA/RW UV Animation stream from a .ONE archive. Returns address of a decompressed UVA file.
  185.         /// </summary>
  186.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  187.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  188.         /// <returns>The address containing the read in UVA (UV Anim) stream.</returns>
  189.         public void* LoadUVAnim(int fileIndex, void* addressToDecompressTo) => Fun_LoadUVAnim.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  190.  
  191.         /// <summary>
  192.         /// Reads a UVA/RW UV Animation stream from a .ONE archive. Returns address of a decompressed UVA file.
  193.         /// </summary>
  194.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  195.         /// <param name="addressToDecompressTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  196.         /// <returns>The address containing the read in BSP (World) stream.</returns>
  197.         public void* LoadWorld(int fileIndex, void* addressToDecompressTo) => Fun_LoadWorld.GetWrapper()(fileIndex, addressToDecompressTo, ref this);
  198.  
  199.         /// <summary>
  200.         /// Decompresses a file from the ONE archive with a specified index, into a set pointer.
  201.         /// </summary>
  202.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2).</param>
  203.         /// <param name="pointerToWriteTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  204.         /// <returns>The amount of decompressed bytes (the data is at the supplied pointer to write to address).</returns>
  205.         public int OpenData(int fileIndex, void* pointerToWriteTo) => Fun_OpenData.GetWrapper()(ref this, fileIndex, pointerToWriteTo);
  206.  
  207.         /// <summary>
  208.         /// Unloads a ONE file from a specific ONEFILE instance.
  209.         /// </summary>
  210.         /// <returns>1 if the operation succeeded, else 0.</returns>
  211.         public int ReleaseOneFile() => Fun_ReleaseOneFile.GetWrapper()(ref this);
  212.  
  213.         /// <summary>
  214.         /// Presumably an alternate "constructor" of sorts, for creating ONE Files for single time use.
  215.         /// Presumed to be released by calling ReleaseOneFile explicitly rather constructor.
  216.         /// A file loaded by this method assumes the name of memoryOneFileNoRel.xxx.
  217.         /// </summary>
  218.         /// <param name="addressContainingONEFile">The Memory address containing an already loaded .ONE file in memory.</param>
  219.         /// <param name="oneFileSize">The size of the .ONE file to load.</param>
  220.         /// <returns>1 if the operation is successful, else 0.</returns>
  221.         public int SetOneFileOneTime(void* addressContainingONEFile, int oneFileSize) => Fun_SetOneFileOneTime.GetWrapper()(addressContainingONEFile, ref this, oneFileSize);
  222.  
  223.         /*
  224.             Helper Methods
  225.         */
  226.  
  227.         /// <summary>
  228.         /// Obtains the archive parser given the instance of the current native class.
  229.         /// </summary>
  230.         public OneArchive GetArchive()
  231.         {
  232.             var startOfFile = ((byte*)NameSectionHeaderPointer) - sizeof(OneArchiveHeader);
  233.             return new OneArchive(startOfFile);
  234.         }
  235.  
  236.         /*
  237.             Overrides
  238.         */
  239.  
  240.         /// <summary>
  241.         /// Returns the current file name as a string.
  242.         /// </summary>
  243.         /// <returns></returns>
  244.         public override string ToString()
  245.         {
  246.             fixed (byte* fileNamePtr = _FileName)
  247.                 return Strings.Windows1252Encoder.FromCharPtr(fileNamePtr);
  248.         }
  249.  
  250.         /*
  251.             The delegates are sorted in alphabetical order as found in IDA
  252.             Not all of them have been tested.
  253.         */
  254.  
  255.         /// <summary>
  256.         /// Gets the index of the file with a specified passed in name.
  257.         /// </summary>
  258.         /// <param name="thisPointer">[EAX] Pointer To 'This' Variable</param>
  259.         /// <param name="fileNamePtr">[ECX] The name of the ONE file to load. Up to 64 characters.</param>
  260.         /// <returns>he index of the file with specified file name (or -1). Up to 255</returns>
  261.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  262.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Caller, 0x40)]
  263.         public delegate int Native_CheckFileID(ref OneFile thisPointer, string fileNamePtr);
  264.  
  265.         /// <summary>
  266.         /// Opens a .ONE file, reads and returns the address of a specified decompressed .anm HAnim file.
  267.         /// </summary>
  268.         /// <param name="fileNamePtr">[EAX] Pointer to the file name to load the HAnimation (ANM) from.</param>
  269.         /// <param name="allocatedMemoryPtr">[EDI] Malloc'd Memory Struct To Write ONE File to.</param>
  270.         /// <param name="thisPointer">[ESI] "This" pointer for the ONEFILE class instance.</param>
  271.         /// <param name="animationFileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  272.         /// <returns>The address containing the read in ANM (H Anim - Character Animation) stream.</returns>
  273.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  274.         [Function(new[] { Register.eax, Register.edi, Register.esi }, Register.eax, StackCleanup.Callee)]
  275.         public delegate void* Native_LoadHAnimationEx(string fileNamePtr, void* allocatedMemoryPtr, ref OneFile thisPointer, int animationFileIndex);
  276.  
  277.         /// <summary>
  278.         /// Loads a .ONE file from the hard drive into memory;
  279.         /// </summary>
  280.         /// <param name="thisPointer">[EAX] "This" pointer for the ONEFILE class instance.</param>
  281.         /// <param name="allocatedMemoryPtr">[EDI] Malloc'd Memory Struct To Write ONE File to.</param>
  282.         /// <param name="fileNamePtr">The name of the ONE file to load.</param>
  283.         /// <returns>1 if the operation succeeded, else 0.</returns>
  284.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  285.         [Function(new[] { Register.eax, Register.edi }, Register.eax, StackCleanup.Callee)]
  286.         public delegate void* Native_LoadOneFile(ref OneFile thisPointer, void* allocatedMemoryPtr, string fileNamePtr);
  287.  
  288.         /// <summary>
  289.         /// Initializes a .ONE file into a pre-allocated memory location.
  290.         /// </summary>
  291.         /// <param name="fileName">[EAX] The name of the ONE File to load from.</param>
  292.         /// <param name="allocatedMemoryPtr">[EDI] Malloc'd Memory Struct to write ONE file to.</param>
  293.         /// <param name="thisPointer">[ESI] "This" pointer to write ONEFILE class to.</param>
  294.         /// <param name="boolLoadOneFile">Informs the ONEFile class instance whether the .ONE file should be loaded on instantiation. Set 1 to true, 0 to false.</param>
  295.         /// <returns>The "This" pointer with ONEFILE class written to it.</returns>
  296.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  297.         [Function(new[] { Register.eax, Register.edi, Register.esi }, Register.eax, StackCleanup.Callee)]
  298.         public delegate void* Native_OnefileConstructor(string fileName, void* allocatedMemoryPtr, ref OneFile thisPointer, int boolLoadOneFile);
  299.  
  300.         /// <summary>
  301.         /// Reads a Camera TMB (NJS_MOTION) from a specified file index in the archive.
  302.         /// </summary>
  303.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  304.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  305.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  306.         /// <returns>The address containing the read in Camera TMB (NJS_MOTION *) stream.</returns>
  307.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  308.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  309.         public delegate void* Native_OneFileLoadCameraTmb(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  310.  
  311.         /// <summary>
  312.         /// Reads a DFF/Clump stream from a .ONE archive. Returns address of a decompressed DFF file.
  313.         /// </summary>
  314.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  315.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  316.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  317.         /// <returns>The address containing the read in DFF (Clump) stream.</returns>
  318.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  319.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  320.         public delegate void* Native_OneFileLoadClump(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  321.  
  322.         /// <summary>
  323.         /// Reads a DMA/Delta Morph stream from a .ONE archive. Returns address of a decompressed DMA file.
  324.         /// </summary>
  325.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  326.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  327.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  328.         /// <returns>The address containing the read in DMA (Delta Morph) stream.</returns>
  329.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  330.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  331.         public delegate void* Native_OneFileLoadDeltaMorph(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  332.  
  333.         /// <summary>
  334.         /// Reads a ANM/HAnim stream from a .ONE archive. Returns address of a decompressed ANM file.
  335.         /// </summary>
  336.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  337.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  338.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  339.         /// <returns>The address containing the read in ANM (H Anim - Character Animation) stream.</returns>
  340.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  341.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  342.         public delegate void* Native_OneFileLoadHAnimation(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  343.  
  344.         /// <summary>
  345.         /// Reads a ANM/Maestro stream from a .ONE archive. Returns address of a decompressed ANM file.
  346.         /// </summary>
  347.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2)</param>
  348.         /// <param name="addressToDecompressTo">[EAX] The address to which the file inside the ONE archive will be decompressed to.</param>
  349.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  350.         /// <returns>The address containing the read in ANM (RW Maestro) stream.</returns>
  351.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  352.         [Function(new[] { Register.eax }, Register.eax, StackCleanup.Callee)]
  353.         public delegate void* Native_OneFileLoadMaestro(void* addressToDecompressTo, ref OneFile thisPointer, int fileIndex);
  354.  
  355.         /// <summary>
  356.         /// Reads a SPL/RW Spline stream from a .ONE archive. Returns address of a decompressed SPL file.
  357.         /// </summary>
  358.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  359.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  360.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  361.         /// <returns>The address containing the read in SPL (Spline) stream.</returns>
  362.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  363.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  364.         public delegate void* Native_OneFileLoadSpline(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  365.  
  366.         /// <summary>
  367.         /// Reads a TXD/RW Texture Dictionary stream from a .ONE archive. Returns address of a decompressed TXD file.
  368.         /// </summary>
  369.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  370.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  371.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  372.         /// <returns>The address containing the read in TXD (Texture Dictionary) stream.</returns>
  373.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  374.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  375.         public delegate void* Native_OneFileLoadTextureDictionary(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  376.  
  377.         /// <summary>
  378.         /// Reads a UVA/RW UV Animation stream from a .ONE archive. Returns address of a decompressed UVA file.
  379.         /// </summary>
  380.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  381.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  382.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  383.         /// <returns>The address containing the read in UVA (UV Anim) stream.</returns>
  384.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  385.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  386.         public delegate void* Native_OneFileLoadUVAnim(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  387.  
  388.         /// <summary>
  389.         /// Reads a UVA/RW UV Animation stream from a .ONE archive. Returns address of a decompressed UVA file.
  390.         /// </summary>
  391.         /// <param name="fileIndex">[EAX] The index of the file inside the .ONE archive (starting with 2)</param>
  392.         /// <param name="addressToDecompressTo">[ECX] The address to which the file inside the ONE archive will be decompressed to.</param>
  393.         /// <param name="thisPointer">"This" pointer for the ONEFILE class instance.</param>
  394.         /// <returns>The address containing the read in BSP (World) stream.</returns>
  395.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  396.         [Function(new[] { Register.eax, Register.ecx }, Register.eax, StackCleanup.Callee)]
  397.         public delegate void* Native_OneFileLoadWorld(int fileIndex, void* addressToDecompressTo, ref OneFile thisPointer);
  398.  
  399.         /// <summary>
  400.         /// Decompresses a file from the ONE archive with a specified index, into a set pointer.
  401.         /// </summary>
  402.         /// <param name="thisPointer">[EAX] "This" pointer for the ONEFILE class instance.</param>
  403.         /// <param name="fileIndex">The index of the file inside the .ONE archive (starting with 2).</param>
  404.         /// <param name="pointerToWriteTo">The address to which the file inside the ONE archive will be decompressed to.</param>
  405.         /// <returns>The amount of decompressed bytes (the data is at the supplied pointer to write to address).</returns>
  406.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  407.         [Function(new[] { Register.eax }, Register.eax, StackCleanup.Callee, 0x68)] // Reserved stack space needed probably 54h but I added extra for safety.
  408.         public delegate int Native_OpenData(ref OneFile thisPointer, int fileIndex, void* pointerToWriteTo);
  409.  
  410.         /// <summary>
  411.         /// Unloads a ONE file from a specific ONEFILE instance.
  412.         /// </summary>
  413.         /// <param name="thisPointer">[EBX] "This" pointer for the ONEFILE class instance.</param>
  414.         /// <returns>1 if the operation succeeded, else 0.</returns>
  415.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  416.         [Function(new[] { Register.ebx }, Register.eax, StackCleanup.Caller)]
  417.         public delegate int Native_ReleaseOneFile(ref OneFile thisPointer);
  418.  
  419.         /// <summary>
  420.         /// Presumably an alternate "constructor" of sorts, for creating ONE Files for single time use.
  421.         /// Presumed to be released by calling ReleaseOneFile explicitly rather constructor.
  422.         /// A file loaded by this method assumes the name of memoryOneFileNoRel.xxx.
  423.         /// </summary>
  424.         /// <param name="addressContainingONEFile">[EAX] The Memory address containing an already loaded .ONE file in memory.</param>
  425.         /// <param name="thisPointer">[EDX] This pointer to a ONEFile class.</param>
  426.         /// <param name="oneFileSize">[ECX] The size of the .ONE file to load.</param>
  427.         /// <returns>1 if the operation is successful, else 0.</returns>
  428.         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  429.         [Function(new[] { Register.eax, Register.edx, Register.ecx }, Register.eax, StackCleanup.Caller, 0x100)]
  430.         public delegate int Native_SetOneFileOneTime(void* addressContainingONEFile, ref OneFile thisPointer, int oneFileSize);
  431.     }
  432. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement