sewer56lol

Untitled

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