mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-02 13:53:42 +01:00
Add Byte String stuff, remove Services, cleanup and refactor interop stuff, disable path resolver for the moment
This commit is contained in:
parent
0e8f839471
commit
c3454f1d16
65 changed files with 4707 additions and 3371 deletions
87
Penumbra/Interop/Structs/CharacterUtility.cs
Normal file
87
Penumbra/Interop/Structs/CharacterUtility.cs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct CharacterUtility
|
||||
{
|
||||
public const int NumResources = 85;
|
||||
public const int EqpIdx = 0;
|
||||
public const int GmpIdx = 1;
|
||||
public const int HumanCmpIdx = 63;
|
||||
public const int FaceEstIdx = 64;
|
||||
public const int HairEstIdx = 65;
|
||||
public const int BodyEstIdx = 66;
|
||||
public const int HeadEstIdx = 67;
|
||||
|
||||
public static int EqdpIdx( ushort raceCode, bool accessory )
|
||||
=> ( accessory ? 28 : 0 )
|
||||
+ raceCode switch
|
||||
{
|
||||
0101 => 2,
|
||||
0201 => 3,
|
||||
0301 => 4,
|
||||
0401 => 5,
|
||||
0501 => 6,
|
||||
0601 => 7,
|
||||
0701 => 8,
|
||||
0801 => 9,
|
||||
0901 => 10,
|
||||
1001 => 11,
|
||||
1101 => 12,
|
||||
1201 => 13,
|
||||
1301 => 14,
|
||||
1401 => 15,
|
||||
1501 => 16,
|
||||
1601 => 17, // Does not exist yet
|
||||
1701 => 18,
|
||||
1801 => 19,
|
||||
0104 => 20,
|
||||
0204 => 21,
|
||||
0504 => 22,
|
||||
0604 => 23,
|
||||
0704 => 24,
|
||||
0804 => 25,
|
||||
1304 => 26,
|
||||
1404 => 27,
|
||||
9104 => 28,
|
||||
9204 => 29,
|
||||
_ => throw new ArgumentException(),
|
||||
};
|
||||
|
||||
[FieldOffset( 0 )]
|
||||
public void* VTable;
|
||||
|
||||
[FieldOffset( 8 )]
|
||||
public fixed ulong Resources[NumResources];
|
||||
|
||||
[FieldOffset( 8 + EqpIdx * 8 )]
|
||||
public ResourceHandle* EqpResource;
|
||||
|
||||
[FieldOffset( 8 + GmpIdx * 8 )]
|
||||
public ResourceHandle* GmpResource;
|
||||
|
||||
public ResourceHandle* Resource( int idx )
|
||||
=> ( ResourceHandle* )Resources[ idx ];
|
||||
|
||||
public ResourceHandle* EqdpResource( ushort raceCode, bool accessory )
|
||||
=> Resource( EqdpIdx( raceCode, accessory ) );
|
||||
|
||||
[FieldOffset( 8 + HumanCmpIdx * 8 )]
|
||||
public ResourceHandle* HumanCmpResource;
|
||||
|
||||
[FieldOffset( 8 + FaceEstIdx * 8 )]
|
||||
public ResourceHandle* FaceEstResource;
|
||||
|
||||
[FieldOffset( 8 + HairEstIdx * 8 )]
|
||||
public ResourceHandle* HairEstResource;
|
||||
|
||||
[FieldOffset( 8 + BodyEstIdx * 8 )]
|
||||
public ResourceHandle* BodyEstResource;
|
||||
|
||||
[FieldOffset( 8 + HeadEstIdx * 8 )]
|
||||
public ResourceHandle* HeadEstResource;
|
||||
|
||||
// not included resources have no known use case.
|
||||
}
|
||||
11
Penumbra/Interop/Structs/FileMode.cs
Normal file
11
Penumbra/Interop/Structs/FileMode.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
public enum FileMode : uint
|
||||
{
|
||||
LoadUnpackedResource = 0,
|
||||
LoadFileResource = 1, // Shit in My Games uses this
|
||||
|
||||
// some shit here, the game does some jump if its < 0xA for other files for some reason but there's no impl, probs debug?
|
||||
LoadIndexResource = 0xA, // load index/index2
|
||||
LoadSqPackResource = 0xB,
|
||||
}
|
||||
67
Penumbra/Interop/Structs/ResourceHandle.cs
Normal file
67
Penumbra/Interop/Structs/ResourceHandle.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct ResourceHandle
|
||||
{
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public struct DataIndirection
|
||||
{
|
||||
[FieldOffset( 0x10 )]
|
||||
public byte* DataPtr;
|
||||
|
||||
[FieldOffset( 0x28 )]
|
||||
public ulong DataLength;
|
||||
}
|
||||
|
||||
public const int SsoSize = 15;
|
||||
|
||||
public byte* FileName()
|
||||
{
|
||||
if( FileNameLength > SsoSize )
|
||||
{
|
||||
return FileNameData;
|
||||
}
|
||||
|
||||
fixed( byte** name = &FileNameData )
|
||||
{
|
||||
return ( byte* )name;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlySpan< byte > FileNameSpan()
|
||||
=> new(FileName(), FileNameLength);
|
||||
|
||||
[FieldOffset( 0x48 )]
|
||||
public byte* FileNameData;
|
||||
|
||||
[FieldOffset( 0x58 )]
|
||||
public int FileNameLength;
|
||||
|
||||
[FieldOffset( 0xB0 )]
|
||||
public DataIndirection* Data;
|
||||
|
||||
[FieldOffset( 0xB8 )]
|
||||
public uint DataLength;
|
||||
|
||||
|
||||
public (IntPtr Data, int Length) GetData()
|
||||
=> Data != null
|
||||
? ( ( IntPtr )Data->DataPtr, ( int )Data->DataLength )
|
||||
: ( IntPtr.Zero, 0 );
|
||||
|
||||
public bool SetData( IntPtr data, int length )
|
||||
{
|
||||
if( Data == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Data->DataPtr = length != 0 ? ( byte* )data : null;
|
||||
Data->DataLength = ( ulong )length;
|
||||
DataLength = ( uint )length;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
21
Penumbra/Interop/Structs/SeFileDescriptor.cs
Normal file
21
Penumbra/Interop/Structs/SeFileDescriptor.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using Penumbra.Structs;
|
||||
|
||||
namespace Penumbra.Interop.Structs;
|
||||
|
||||
[StructLayout( LayoutKind.Explicit )]
|
||||
public unsafe struct SeFileDescriptor
|
||||
{
|
||||
[FieldOffset( 0x00 )]
|
||||
public FileMode FileMode;
|
||||
|
||||
[FieldOffset( 0x30 )]
|
||||
public void* FileDescriptor; //
|
||||
|
||||
[FieldOffset( 0x50 )]
|
||||
public ResourceHandle* ResourceHandle; //
|
||||
|
||||
|
||||
[FieldOffset( 0x70 )]
|
||||
public char Utf16FileName; //
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue