Skip to content

Commit

Permalink
ALTV-469 - add new hwid
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Oct 31, 2024
1 parent 175b268 commit a31fce3
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 10 deletions.
14 changes: 14 additions & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ public ulong HardwareIdExHash
}
}
}

public string HardwareId3
{
get
{
lock (ConnectionInfo)
{
if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default;
return ConnectionInfo.HardwareId3;
}
}
}

public string AuthToken
{
get
Expand All @@ -74,6 +87,7 @@ public string AuthToken
}
}
}

public bool IsDebug
{
get
Expand Down
12 changes: 12 additions & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ public ulong HardwareIdExHash
}
}

public string HardwareId3
{
get
{
lock (Player)
{
if (!AsyncContext.CheckIfExistsOrCachedNullable(Player)) return default;
return Player.HardwareId3;
}
}
}

public string AuthToken
{
get
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net.CApi/Libraries/ClientLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ public unsafe interface IClientLibrary

public unsafe class ClientLibrary : IClientLibrary
{
public readonly uint Methods = 1779;
public readonly uint Methods = 1781;
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
Expand Down Expand Up @@ -3597,7 +3597,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
{
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11629663074568386340UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 17036908327259488488UL) Outdated = true;
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);
Expand Down
14 changes: 12 additions & 2 deletions api/AltV.Net.CApi/Libraries/ServerLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public unsafe interface IServerLibrary
public delegate* unmanaged[Cdecl]<IntPtr, byte> ConnectionInfo_GetCloudAuthResult { get; }
public delegate* unmanaged[Cdecl]<IntPtr, int*, nint> ConnectionInfo_GetCloudID { get; }
public delegate* unmanaged[Cdecl]<IntPtr, long> ConnectionInfo_GetDiscordUserID { get; }
public delegate* unmanaged[Cdecl]<IntPtr, int*, nint> ConnectionInfo_GetHwId3 { get; }
public delegate* unmanaged[Cdecl]<IntPtr, ulong> ConnectionInfo_GetHwIdExHash { get; }
public delegate* unmanaged[Cdecl]<IntPtr, ulong> ConnectionInfo_GetHwIdHash { get; }
public delegate* unmanaged[Cdecl]<IntPtr, uint> ConnectionInfo_GetID { get; }
Expand Down Expand Up @@ -194,6 +195,7 @@ public unsafe interface IServerLibrary
public delegate* unmanaged[Cdecl]<nint, HeadBlendData*, void> Player_GetHeadBlendData { get; }
public delegate* unmanaged[Cdecl]<nint, byte, Rgba*, void> Player_GetHeadBlendPaletteColor { get; }
public delegate* unmanaged[Cdecl]<nint, byte, HeadOverlay*, void> Player_GetHeadOverlay { get; }
public delegate* unmanaged[Cdecl]<nint, int*, nint> Player_GetHwId3 { get; }
public delegate* unmanaged[Cdecl]<nint, ulong> Player_GetHwidExHash { get; }
public delegate* unmanaged[Cdecl]<nint, ulong> Player_GetHwidHash { get; }
public delegate* unmanaged[Cdecl]<nint, uint> Player_GetInteriorLocation { get; }
Expand Down Expand Up @@ -488,7 +490,7 @@ public unsafe interface IServerLibrary

public unsafe class ServerLibrary : IServerLibrary
{
public readonly uint Methods = 1779;
public readonly uint Methods = 1781;
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
Expand All @@ -513,6 +515,7 @@ public unsafe class ServerLibrary : IServerLibrary
public delegate* unmanaged[Cdecl]<IntPtr, byte> ConnectionInfo_GetCloudAuthResult { get; }
public delegate* unmanaged[Cdecl]<IntPtr, int*, nint> ConnectionInfo_GetCloudID { get; }
public delegate* unmanaged[Cdecl]<IntPtr, long> ConnectionInfo_GetDiscordUserID { get; }
public delegate* unmanaged[Cdecl]<IntPtr, int*, nint> ConnectionInfo_GetHwId3 { get; }
public delegate* unmanaged[Cdecl]<IntPtr, ulong> ConnectionInfo_GetHwIdExHash { get; }
public delegate* unmanaged[Cdecl]<IntPtr, ulong> ConnectionInfo_GetHwIdHash { get; }
public delegate* unmanaged[Cdecl]<IntPtr, uint> ConnectionInfo_GetID { get; }
Expand Down Expand Up @@ -672,6 +675,7 @@ public unsafe class ServerLibrary : IServerLibrary
public delegate* unmanaged[Cdecl]<nint, HeadBlendData*, void> Player_GetHeadBlendData { get; }
public delegate* unmanaged[Cdecl]<nint, byte, Rgba*, void> Player_GetHeadBlendPaletteColor { get; }
public delegate* unmanaged[Cdecl]<nint, byte, HeadOverlay*, void> Player_GetHeadOverlay { get; }
public delegate* unmanaged[Cdecl]<nint, int*, nint> Player_GetHwId3 { get; }
public delegate* unmanaged[Cdecl]<nint, ulong> Player_GetHwidExHash { get; }
public delegate* unmanaged[Cdecl]<nint, ulong> Player_GetHwidHash { get; }
public delegate* unmanaged[Cdecl]<nint, uint> Player_GetInteriorLocation { get; }
Expand Down Expand Up @@ -1010,6 +1014,8 @@ public unsafe class ServerLibrary : IServerLibrary
private static nint ConnectionInfo_GetCloudIDFallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetCloudID", "ConnectionInfo_GetCloudID SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate long ConnectionInfo_GetDiscordUserIDDelegate(IntPtr _connectionInfo);
private static long ConnectionInfo_GetDiscordUserIDFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetDiscordUserID", "ConnectionInfo_GetDiscordUserID SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint ConnectionInfo_GetHwId3Delegate(IntPtr _connectionInfo, int* _size);
private static nint ConnectionInfo_GetHwId3Fallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetHwId3", "ConnectionInfo_GetHwId3 SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong ConnectionInfo_GetHwIdExHashDelegate(IntPtr _connectionInfo);
private static ulong ConnectionInfo_GetHwIdExHashFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetHwIdExHash", "ConnectionInfo_GetHwIdExHash SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong ConnectionInfo_GetHwIdHashDelegate(IntPtr _connectionInfo);
Expand Down Expand Up @@ -1328,6 +1334,8 @@ public unsafe class ServerLibrary : IServerLibrary
private static void Player_GetHeadBlendPaletteColorFallback(nint _player, byte _id, Rgba* _headBlendPaletteColor) => throw new Exceptions.OutdatedSdkException("Player_GetHeadBlendPaletteColor", "Player_GetHeadBlendPaletteColor SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_GetHeadOverlayDelegate(nint _player, byte _overlayID, HeadOverlay* _headOverlay);
private static void Player_GetHeadOverlayFallback(nint _player, byte _overlayID, HeadOverlay* _headOverlay) => throw new Exceptions.OutdatedSdkException("Player_GetHeadOverlay", "Player_GetHeadOverlay SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Player_GetHwId3Delegate(nint _player, int* _size);
private static nint Player_GetHwId3Fallback(nint _player, int* _size) => throw new Exceptions.OutdatedSdkException("Player_GetHwId3", "Player_GetHwId3 SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Player_GetHwidExHashDelegate(nint _player);
private static ulong Player_GetHwidExHashFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_GetHwidExHash", "Player_GetHwidExHash SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Player_GetHwidHashDelegate(nint _player);
Expand Down Expand Up @@ -1917,7 +1925,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
{
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11629663074568386340UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 17036908327259488488UL) Outdated = true;
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void>) GetUnmanagedPtr<BaseObject_SetMultipleSyncedMetaDataDelegate>(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback);
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);
Expand All @@ -1942,6 +1950,7 @@ public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
ConnectionInfo_GetCloudAuthResult = (delegate* unmanaged[Cdecl]<IntPtr, byte>) GetUnmanagedPtr<ConnectionInfo_GetCloudAuthResultDelegate>(funcTable, 7415605567391116903UL, ConnectionInfo_GetCloudAuthResultFallback);
ConnectionInfo_GetCloudID = (delegate* unmanaged[Cdecl]<IntPtr, int*, nint>) GetUnmanagedPtr<ConnectionInfo_GetCloudIDDelegate>(funcTable, 7998061229071288348UL, ConnectionInfo_GetCloudIDFallback);
ConnectionInfo_GetDiscordUserID = (delegate* unmanaged[Cdecl]<IntPtr, long>) GetUnmanagedPtr<ConnectionInfo_GetDiscordUserIDDelegate>(funcTable, 4175744399917476392UL, ConnectionInfo_GetDiscordUserIDFallback);
ConnectionInfo_GetHwId3 = (delegate* unmanaged[Cdecl]<IntPtr, int*, nint>) GetUnmanagedPtr<ConnectionInfo_GetHwId3Delegate>(funcTable, 11277934694982627403UL, ConnectionInfo_GetHwId3Fallback);
ConnectionInfo_GetHwIdExHash = (delegate* unmanaged[Cdecl]<IntPtr, ulong>) GetUnmanagedPtr<ConnectionInfo_GetHwIdExHashDelegate>(funcTable, 3151831504154255688UL, ConnectionInfo_GetHwIdExHashFallback);
ConnectionInfo_GetHwIdHash = (delegate* unmanaged[Cdecl]<IntPtr, ulong>) GetUnmanagedPtr<ConnectionInfo_GetHwIdHashDelegate>(funcTable, 11409383581668438027UL, ConnectionInfo_GetHwIdHashFallback);
ConnectionInfo_GetID = (delegate* unmanaged[Cdecl]<IntPtr, uint>) GetUnmanagedPtr<ConnectionInfo_GetIDDelegate>(funcTable, 8080268107975854795UL, ConnectionInfo_GetIDFallback);
Expand Down Expand Up @@ -2101,6 +2110,7 @@ public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
Player_GetHeadBlendData = (delegate* unmanaged[Cdecl]<nint, HeadBlendData*, void>) GetUnmanagedPtr<Player_GetHeadBlendDataDelegate>(funcTable, 12996031514192232278UL, Player_GetHeadBlendDataFallback);
Player_GetHeadBlendPaletteColor = (delegate* unmanaged[Cdecl]<nint, byte, Rgba*, void>) GetUnmanagedPtr<Player_GetHeadBlendPaletteColorDelegate>(funcTable, 6875264309357036667UL, Player_GetHeadBlendPaletteColorFallback);
Player_GetHeadOverlay = (delegate* unmanaged[Cdecl]<nint, byte, HeadOverlay*, void>) GetUnmanagedPtr<Player_GetHeadOverlayDelegate>(funcTable, 18242810182906526031UL, Player_GetHeadOverlayFallback);
Player_GetHwId3 = (delegate* unmanaged[Cdecl]<nint, int*, nint>) GetUnmanagedPtr<Player_GetHwId3Delegate>(funcTable, 12439246743379924111UL, Player_GetHwId3Fallback);
Player_GetHwidExHash = (delegate* unmanaged[Cdecl]<nint, ulong>) GetUnmanagedPtr<Player_GetHwidExHashDelegate>(funcTable, 424368865670330442UL, Player_GetHwidExHashFallback);
Player_GetHwidHash = (delegate* unmanaged[Cdecl]<nint, ulong>) GetUnmanagedPtr<Player_GetHwidHashDelegate>(funcTable, 9546723288515311389UL, Player_GetHwidHashFallback);
Player_GetInteriorLocation = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Player_GetInteriorLocationDelegate>(funcTable, 16961931856292652951UL, Player_GetInteriorLocationFallback);
Expand Down
4 changes: 2 additions & 2 deletions api/AltV.Net.CApi/Libraries/SharedLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public unsafe interface ISharedLibrary

public unsafe class SharedLibrary : ISharedLibrary
{
public readonly uint Methods = 1779;
public readonly uint Methods = 1781;
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
Expand Down Expand Up @@ -1669,7 +1669,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
{
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11629663074568386340UL) Outdated = true;
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 17036908327259488488UL) Outdated = true;
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);
Expand Down
20 changes: 17 additions & 3 deletions api/AltV.Net/Elements/Entities/ConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace AltV.Net.Elements.Entities;

public class ConnectionInfo : BaseObject, IConnectionInfo
{

public IntPtr ConnectionInfoNativePointer { get; }
public override IntPtr NativePointer => ConnectionInfoNativePointer;

Expand All @@ -32,7 +31,8 @@ public static uint GetId(IntPtr pointer)
}


public ConnectionInfo(ICore core, IntPtr nativePointer, uint id) : base(core, GetBaseObjectPointer(core, nativePointer), BaseObjectType.ConnectionInfo, id)
public ConnectionInfo(ICore core, IntPtr nativePointer, uint id) : base(core,
GetBaseObjectPointer(core, nativePointer), BaseObjectType.ConnectionInfo, id)
{
ConnectionInfoNativePointer = nativePointer;
}
Expand Down Expand Up @@ -83,6 +83,19 @@ public ulong HardwareIdExHash
}
}

public string HardwareId3
{
get
{
unsafe
{
var size = 0;
return Core.PtrToStringUtf8AndFree(
Core.Library.Server.ConnectionInfo_GetHwId3(ConnectionInfoNativePointer, &size), size);
}
}
}

public string AuthToken
{
get
Expand Down Expand Up @@ -274,7 +287,8 @@ public CloudAuthResult CloudAuthResult
{
unsafe
{
return (CloudAuthResult)Core.Library.Server.ConnectionInfo_GetCloudAuthResult(ConnectionInfoNativePointer);
return (CloudAuthResult)Core.Library.Server.ConnectionInfo_GetCloudAuthResult(
ConnectionInfoNativePointer);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions api/AltV.Net/Elements/Entities/IConnectionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IConnectionInfo : IBaseObject
ulong SocialId { get; }
ulong HardwareIdHash { get; }
ulong HardwareIdExHash { get; }
string HardwareId3 { get; }
string AuthToken { get; }
bool IsDebug { get; }
string Branch { get; }
Expand Down
2 changes: 2 additions & 0 deletions api/AltV.Net/Elements/Entities/IPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public interface IPlayer : ISharedPlayer, IEntity

ulong HardwareIdExHash { get; }

string HardwareId3 { get; }

string AuthToken { get; }

long DiscordId { get; }
Expand Down
14 changes: 14 additions & 0 deletions api/AltV.Net/Elements/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,20 @@ public ulong HardwareIdExHash
}
}

public string HardwareId3
{
get
{
unsafe
{
CheckIfEntityExistsOrCached();
var size = 0;
return Core.PtrToStringUtf8AndFree(
Core.Library.Server.Player_GetHwId3(PlayerNativePointer, &size), size);
}
}
}

public string AuthToken
{
get
Expand Down

0 comments on commit a31fce3

Please sign in to comment.