Skip to content

Commit e8a8217

Browse files
committed
add BaseObjectTypeSize check
1 parent 9b71a54 commit e8a8217

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

api/AltV.Net.CApi/Libraries/ClientLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ public unsafe interface IClientLibrary
886886

887887
public unsafe class ClientLibrary : IClientLibrary
888888
{
889-
public readonly uint Methods = 1727;
889+
public readonly uint Methods = 1728;
890890
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
891891
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
892892
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -3512,7 +3512,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
35123512
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35133513
{
35143514
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3515-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 1329516003325097705UL) Outdated = true;
3515+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3415677601440942791UL) Outdated = true;
35163516
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
35173517
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
35183518
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);

api/AltV.Net.CApi/Libraries/ServerLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public unsafe interface IServerLibrary
472472

473473
public unsafe class ServerLibrary : IServerLibrary
474474
{
475-
public readonly uint Methods = 1727;
475+
public readonly uint Methods = 1728;
476476
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
477477
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
478478
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
@@ -1856,7 +1856,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
18561856
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
18571857
{
18581858
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1859-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 1329516003325097705UL) Outdated = true;
1859+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3415677601440942791UL) Outdated = true;
18601860
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
18611861
BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void>) GetUnmanagedPtr<BaseObject_SetMultipleSyncedMetaDataDelegate>(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback);
18621862
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);

api/AltV.Net.CApi/Libraries/SharedLibrary.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ public unsafe interface ISharedLibrary
180180
public delegate* unmanaged[Cdecl]<nint, nint, int*, nint> Core_FileRead { get; }
181181
public delegate* unmanaged[Cdecl]<nint, uint*, nint> Core_GetAllResources { get; }
182182
public delegate* unmanaged[Cdecl]<nint, byte, uint, nint> Core_GetBaseObjectByID { get; }
183+
public delegate* unmanaged[Cdecl]<byte> Core_GetBaseObjectTypeSize { get; }
183184
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetBlips { get; }
184185
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetBranch { get; }
185186
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetCheckpoints { get; }
186187
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetColShapes { get; }
187188
public delegate* unmanaged[Cdecl]<nint> Core_GetCoreInstance { get; }
188-
public delegate* unmanaged[Cdecl]<byte> Core_GetEventEnumSize { get; }
189+
public delegate* unmanaged[Cdecl]<byte> Core_GetEventTypeSize { get; }
189190
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetMarkers { get; }
190191
public delegate* unmanaged[Cdecl]<nint, nint, nint> Core_GetMetaData { get; }
191192
public delegate* unmanaged[Cdecl]<nint, int> Core_GetNetTime { get; }
@@ -409,7 +410,7 @@ public unsafe interface ISharedLibrary
409410

410411
public unsafe class SharedLibrary : ISharedLibrary
411412
{
412-
public readonly uint Methods = 1727;
413+
public readonly uint Methods = 1728;
413414
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
414415
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
415416
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
@@ -580,12 +581,13 @@ public unsafe class SharedLibrary : ISharedLibrary
580581
public delegate* unmanaged[Cdecl]<nint, nint, int*, nint> Core_FileRead { get; }
581582
public delegate* unmanaged[Cdecl]<nint, uint*, nint> Core_GetAllResources { get; }
582583
public delegate* unmanaged[Cdecl]<nint, byte, uint, nint> Core_GetBaseObjectByID { get; }
584+
public delegate* unmanaged[Cdecl]<byte> Core_GetBaseObjectTypeSize { get; }
583585
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetBlips { get; }
584586
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetBranch { get; }
585587
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetCheckpoints { get; }
586588
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetColShapes { get; }
587589
public delegate* unmanaged[Cdecl]<nint> Core_GetCoreInstance { get; }
588-
public delegate* unmanaged[Cdecl]<byte> Core_GetEventEnumSize { get; }
590+
public delegate* unmanaged[Cdecl]<byte> Core_GetEventTypeSize { get; }
589591
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetMarkers { get; }
590592
public delegate* unmanaged[Cdecl]<nint, nint, nint> Core_GetMetaData { get; }
591593
public delegate* unmanaged[Cdecl]<nint, int> Core_GetNetTime { get; }
@@ -1145,6 +1147,8 @@ public unsafe class SharedLibrary : ISharedLibrary
11451147
private static nint Core_GetAllResourcesFallback(nint _core, uint* _size) => throw new Exceptions.OutdatedSdkException("Core_GetAllResources", "Core_GetAllResources SDK method is outdated. Please update your module nuget");
11461148
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetBaseObjectByIDDelegate(nint _core, byte _type, uint _id);
11471149
private static nint Core_GetBaseObjectByIDFallback(nint _core, byte _type, uint _id) => throw new Exceptions.OutdatedSdkException("Core_GetBaseObjectByID", "Core_GetBaseObjectByID SDK method is outdated. Please update your module nuget");
1150+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_GetBaseObjectTypeSizeDelegate();
1151+
private static byte Core_GetBaseObjectTypeSizeFallback() => throw new Exceptions.OutdatedSdkException("Core_GetBaseObjectTypeSize", "Core_GetBaseObjectTypeSize SDK method is outdated. Please update your module nuget");
11481152
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetBlipsDelegate(nint _core, ulong* _size);
11491153
private static nint Core_GetBlipsFallback(nint _core, ulong* _size) => throw new Exceptions.OutdatedSdkException("Core_GetBlips", "Core_GetBlips SDK method is outdated. Please update your module nuget");
11501154
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetBranchDelegate(nint _core, int* _size);
@@ -1155,8 +1159,8 @@ public unsafe class SharedLibrary : ISharedLibrary
11551159
private static nint Core_GetColShapesFallback(nint _core, ulong* _size) => throw new Exceptions.OutdatedSdkException("Core_GetColShapes", "Core_GetColShapes SDK method is outdated. Please update your module nuget");
11561160
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetCoreInstanceDelegate();
11571161
private static nint Core_GetCoreInstanceFallback() => throw new Exceptions.OutdatedSdkException("Core_GetCoreInstance", "Core_GetCoreInstance SDK method is outdated. Please update your module nuget");
1158-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_GetEventEnumSizeDelegate();
1159-
private static byte Core_GetEventEnumSizeFallback() => throw new Exceptions.OutdatedSdkException("Core_GetEventEnumSize", "Core_GetEventEnumSize SDK method is outdated. Please update your module nuget");
1162+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_GetEventTypeSizeDelegate();
1163+
private static byte Core_GetEventTypeSizeFallback() => throw new Exceptions.OutdatedSdkException("Core_GetEventTypeSize", "Core_GetEventTypeSize SDK method is outdated. Please update your module nuget");
11601164
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetMarkersDelegate(nint _core, ulong* _size);
11611165
private static nint Core_GetMarkersFallback(nint _core, ulong* _size) => throw new Exceptions.OutdatedSdkException("Core_GetMarkers", "Core_GetMarkers SDK method is outdated. Please update your module nuget");
11621166
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetMetaDataDelegate(nint _core, nint _key);
@@ -1604,7 +1608,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
16041608
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
16051609
{
16061610
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1607-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 1329516003325097705UL) Outdated = true;
1611+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3415677601440942791UL) Outdated = true;
16081612
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
16091613
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
16101614
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);
@@ -1775,12 +1779,13 @@ public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
17751779
Core_FileRead = (delegate* unmanaged[Cdecl]<nint, nint, int*, nint>) GetUnmanagedPtr<Core_FileReadDelegate>(funcTable, 13630176403103570557UL, Core_FileReadFallback);
17761780
Core_GetAllResources = (delegate* unmanaged[Cdecl]<nint, uint*, nint>) GetUnmanagedPtr<Core_GetAllResourcesDelegate>(funcTable, 3926770362965932159UL, Core_GetAllResourcesFallback);
17771781
Core_GetBaseObjectByID = (delegate* unmanaged[Cdecl]<nint, byte, uint, nint>) GetUnmanagedPtr<Core_GetBaseObjectByIDDelegate>(funcTable, 7276494048261315747UL, Core_GetBaseObjectByIDFallback);
1782+
Core_GetBaseObjectTypeSize = (delegate* unmanaged[Cdecl]<byte>) GetUnmanagedPtr<Core_GetBaseObjectTypeSizeDelegate>(funcTable, 12468229273898885542UL, Core_GetBaseObjectTypeSizeFallback);
17781783
Core_GetBlips = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetBlipsDelegate>(funcTable, 11611786081777275389UL, Core_GetBlipsFallback);
17791784
Core_GetBranch = (delegate* unmanaged[Cdecl]<nint, int*, nint>) GetUnmanagedPtr<Core_GetBranchDelegate>(funcTable, 12434012012299018294UL, Core_GetBranchFallback);
17801785
Core_GetCheckpoints = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetCheckpointsDelegate>(funcTable, 14291068473487208197UL, Core_GetCheckpointsFallback);
17811786
Core_GetColShapes = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetColShapesDelegate>(funcTable, 9480713887250028309UL, Core_GetColShapesFallback);
17821787
Core_GetCoreInstance = (delegate* unmanaged[Cdecl]<nint>) GetUnmanagedPtr<Core_GetCoreInstanceDelegate>(funcTable, 16862996593036574459UL, Core_GetCoreInstanceFallback);
1783-
Core_GetEventEnumSize = (delegate* unmanaged[Cdecl]<byte>) GetUnmanagedPtr<Core_GetEventEnumSizeDelegate>(funcTable, 6921054663232355759UL, Core_GetEventEnumSizeFallback);
1788+
Core_GetEventTypeSize = (delegate* unmanaged[Cdecl]<byte>) GetUnmanagedPtr<Core_GetEventTypeSizeDelegate>(funcTable, 13737530370025977174UL, Core_GetEventTypeSizeFallback);
17841789
Core_GetMarkers = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetMarkersDelegate>(funcTable, 7482854450085275693UL, Core_GetMarkersFallback);
17851790
Core_GetMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint>) GetUnmanagedPtr<Core_GetMetaDataDelegate>(funcTable, 2139798095052897524UL, Core_GetMetaDataFallback);
17861791
Core_GetNetTime = (delegate* unmanaged[Cdecl]<nint, int>) GetUnmanagedPtr<Core_GetNetTimeDelegate>(funcTable, 15652019729912249391UL, Core_GetNetTimeFallback);

api/AltV.Net.Client/ModuleWrapper.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Reflection;
33
using System.Runtime.InteropServices;
44
using AltV.Net.CApi;
5+
using AltV.Net.CApi.Exceptions;
56
using AltV.Net.Client.Elements.Data;
67
using AltV.Net.Client.Elements.Factories;
78
using AltV.Net.Client.Elements.Pools;
@@ -35,9 +36,13 @@ public static void MainWithAssembly(Assembly resourceAssembly, IntPtr resourcePo
3536

3637
unsafe
3738
{
38-
if (library.Shared.Core_GetEventEnumSize() != (byte) EventType.SIZE)
39+
if (library.Shared.Core_GetEventTypeSize() != (byte) EventType.SIZE)
3940
{
40-
throw new Exception("Event type enum size doesn't match. Please, update the nuget");
41+
throw new OutdatedSdkException("EventType", "Event type enum size doesn't match. Please, update the nuget");
42+
}
43+
if (library.Shared.Core_GetBaseObjectTypeSize() != (byte) BaseObjectType.Size)
44+
{
45+
throw new OutdatedSdkException("BaseObjectType", "BaseObject type enum size doesn't match. Please, update the nuget");
4146
}
4247
}
4348

api/AltV.Net/ModuleWrapper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ public static void MainWithAssembly(IntPtr serverPointer, IntPtr resourcePointer
8181

8282
unsafe
8383
{
84-
if (library.Shared.Core_GetEventEnumSize() != (byte) EventType.SIZE)
84+
if (library.Shared.Core_GetEventTypeSize() != (byte) EventType.SIZE)
8585
{
8686
throw new OutdatedSdkException("EventType", "Event type enum size doesn't match. Please, update the nuget");
8787
}
88+
if (library.Shared.Core_GetBaseObjectTypeSize() != (byte) BaseObjectType.Size)
89+
{
90+
throw new OutdatedSdkException("BaseObjectType", "BaseObject type enum size doesn't match. Please, update the nuget");
91+
}
8892
}
8993

9094
var playerFactory = _resource.GetPlayerFactory() ?? new PlayerFactory();

runtime

0 commit comments

Comments
 (0)