-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpotifyFunctions.cs
85 lines (66 loc) · 3.52 KB
/
SpotifyFunctions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Runtime.InteropServices;
namespace SpotifySharper.Injector.Tools
{
/*
*
* SpotifyFunctions.h: https://github.com/meik1710/Spotify1710/blob/master/HookingBase/SpotifyFunctions.h
typedef void(__cdecl * CmdAddTextGAIA_t)(int a1, int a2, const char* msg, int dummy, int dummy1, int dummy2, int dummy3);
extern CmdAddTextGAIA_t CmdAddTextGAIA;
CmdAddTextGAIA_t CmdAddTextGAIA = (CmdAddTextGAIA_t)0x116B010;
typedef void(__thiscall * CreateTrackPlayer_t)(void *a1, int a2 , int a3, double speed, int a5, int a6, int flag, int a8, int a9);
extern CreateTrackPlayer_t CreateTrackPlayer;
CreateTrackPlayer_t CreateTrackPlayer = (CreateTrackPlayer_t)0xD88A50;
typedef void(__thiscall * OpenTrack_t)(void *_this, int a2, int a3, __int64 position, int a5, int a6);
extern OpenTrack_t OpenTrack;
OpenTrack_t OpenTrack = (OpenTrack_t)0xD8B4F0;
typedef void(__thiscall * CloseTrack_t)(void *_this, int a2, int a3, int a4);
extern CloseTrack_t CloseTrack;
CloseTrack_t CloseTrack = (CloseTrack_t)0xD88390;
* Equivalent: https://stackoverflow.com/questions/51991689/c-sharp-call-a-method-by-memory-address
* =================================================================
public delegate void _do(int i); // the delegate type
var ptr = new IntPtr(0xAAAABEEF);
var doActor = Marshal.GetDelegateForFunctionPointer<_do>(ptr);
doActor(1);
* ==================================================================
*
*/
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CmdAddTextGAIA_t(int a1, int a2, [MarshalAs(UnmanagedType.LPStr)] string msg, [MarshalAs(UnmanagedType.LPStr)] string dummy, int dummy1, int dummy2, int dummy3);
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
public delegate void CreateTrackPlayer_t(IntPtr a1, int a2, int a3, double speed, int a5, int a6, int flag, int a8, int a9);
[UnmanagedFunctionPointer(CallingConvention.ThisCall | CallingConvention.FastCall)]
public delegate void OpenTrack_t(IntPtr _this, uint edx, int a2, int a3, long position, int a5, int a6);
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
public delegate void CloseTrack_t(IntPtr _this, int a2, int a3, int a4);
public static class SpotifyFunctions
{
public static void Init()
{
Main.SendMessage("Setting pointers!");
CmdAddTextGAIA = new IntPtr(0x116B010);
OpenTrack = new IntPtr(0xD8B4F0);
}
public static IntPtr CmdAddTextGAIA;
public static IntPtr OpenTrack;
//public static IntPtr CmdAddTextGAIA_Ptr
// => _CmdAddTextGAIA = _CmdAddTextGAIA == default ? new IntPtr(0x116B010) : _CmdAddTextGAIA;
public static CmdAddTextGAIA_t CmdAddTextGAIA_Stub
=> GetFunc<CmdAddTextGAIA_t>(CmdAddTextGAIA);
public static CreateTrackPlayer_t CreateTrackPlayer_Stub
=> GetFunc<CreateTrackPlayer_t>(0xD88A50);
public static OpenTrack_t OpenTrack_Stub
=> GetFunc<OpenTrack_t>(0xD8B4F0);
public static CloseTrack_t CloseTrack_Stub
=> GetFunc<CloseTrack_t>(0xD88390);
public static T GetFunc<T>(long address)
where T : Delegate // C# 7.3 :D
=> GetFunc<T>(new IntPtr(address));
public static T GetFunc<T>(IntPtr ptr)
where T : Delegate // C# 7.3 :D
{
return Marshal.GetDelegateForFunctionPointer<T>(ptr);
}
}
}