-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRTSSInterface.cpp
More file actions
169 lines (154 loc) · 5.41 KB
/
RTSSInterface.cpp
File metadata and controls
169 lines (154 loc) · 5.41 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// RTSSProfileInterface.cpp : implementation file
//
// created by Unwinder
/////////////////////////////////////////////////////////////////////////////
//#include "stdafx.h"
#include "RTSSInterface.h"
#include "WinUser.h"
#include <shlwapi.h>
/////////////////////////////////////////////////////////////////////////////
CRTSSInterface::CRTSSInterface()
{
m_hRTSSHooksDLL = NULL;
m_pFnEnumProfiles = NULL;
m_pFnLoadProfile = NULL;
m_pFnSaveProfile = NULL;
m_pFnGetProfileProperty = NULL;
m_pFnSetProfileProperty = NULL;
m_pFnDeleteProfile = NULL;
m_pFnResetProfile = NULL;
m_pFnUpdateProfiles = NULL;
}
/////////////////////////////////////////////////////////////////////////////
CRTSSInterface::~CRTSSInterface()
{
Uninit();
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::Uninit()
{
if (m_hRTSSHooksDLL)
FreeLibrary(m_hRTSSHooksDLL);
m_hRTSSHooksDLL = NULL;
m_pFnEnumProfiles = NULL;
m_pFnLoadProfile = NULL;
m_pFnSaveProfile = NULL;
m_pFnGetProfileProperty = NULL;
m_pFnSetProfileProperty = NULL;
m_pFnDeleteProfile = NULL;
m_pFnResetProfile = NULL;
m_pFnUpdateProfiles = NULL;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CRTSSInterface::Init(LPCSTR lpInstallPath)
{
Uninit();
char szLibraryPath[MAX_PATH];
strcpy_s(szLibraryPath, sizeof(szLibraryPath), lpInstallPath);
//PathRemoveFileSpec(szLibraryPath);
strcat_s(szLibraryPath, sizeof(szLibraryPath), "\\RTSSHooks64.dll");
m_hRTSSHooksDLL = LoadLibrary(szLibraryPath);
if (m_hRTSSHooksDLL)
{
m_pFnEnumProfiles = (PFNENUMPROFILES )GetProcAddress(m_hRTSSHooksDLL, "EnumProfiles" );
m_pFnLoadProfile = (PFNLOADPROFILE )GetProcAddress(m_hRTSSHooksDLL, "LoadProfile" );
m_pFnSaveProfile = (PFNSAVEPROFILE )GetProcAddress(m_hRTSSHooksDLL, "SaveProfile" );
m_pFnGetProfileProperty = (PFNGETPROFILEPROPERTY)GetProcAddress(m_hRTSSHooksDLL, "GetProfileProperty" );
m_pFnSetProfileProperty = (PFNSETPROFILEPROPERTY)GetProcAddress(m_hRTSSHooksDLL, "SetProfileProperty" );
m_pFnDeleteProfile = (PFNDELETEPROFILE )GetProcAddress(m_hRTSSHooksDLL, "DeleteProfile" );
m_pFnResetProfile = (PFNRESETPROFILE )GetProcAddress(m_hRTSSHooksDLL, "ResetProfile" );
m_pFnUpdateProfiles = (PFNUPDATEPROFILES )GetProcAddress(m_hRTSSHooksDLL, "UpdateProfiles" );
m_pFnSetFlags = (SETFLAGS )GetProcAddress(m_hRTSSHooksDLL, "SetFlags" );
m_pFnGetFlags = (GETFLAGS )GetProcAddress(m_hRTSSHooksDLL, "GetFlags" );
if (m_pFnEnumProfiles &&
m_pFnLoadProfile &&
m_pFnSaveProfile &&
m_pFnGetProfileProperty &&
m_pFnSetProfileProperty &&
m_pFnDeleteProfile &&
m_pFnResetProfile &&
m_pFnUpdateProfiles)
return TRUE;
Uninit();
}
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CRTSSInterface::IsInitialized()
{
return (m_hRTSSHooksDLL != NULL);
}
/////////////////////////////////////////////////////////////////////////////
DWORD CRTSSInterface::EnumProfiles(LPSTR lpProfilesList, DWORD dwProfilesListSize)
{
if (m_pFnEnumProfiles)
return m_pFnEnumProfiles(lpProfilesList, dwProfilesListSize);
return 0;
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::LoadProfile(LPCSTR lpProfile)
{
if (m_pFnLoadProfile)
m_pFnLoadProfile(lpProfile);
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::SaveProfile(LPCSTR lpProfile)
{
if (m_pFnSaveProfile)
m_pFnSaveProfile(lpProfile);
}
/////////////////////////////////////////////////////////////////////////////
BOOL CRTSSInterface::GetProfileProperty(LPCSTR lpPropertyName, LPBYTE lpPropertyData, DWORD dwPropertySize)
{
if (m_pFnGetProfileProperty)
return m_pFnGetProfileProperty(lpPropertyName, lpPropertyData, dwPropertySize);
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
BOOL CRTSSInterface::SetProfileProperty(LPCSTR lpPropertyName, LPBYTE lpPropertyData, DWORD dwPropertySize)
{
if (m_pFnSetProfileProperty)
return m_pFnSetProfileProperty(lpPropertyName, lpPropertyData, dwPropertySize);
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::DeleteProfile(LPCSTR lpProfile)
{
if (m_pFnDeleteProfile)
m_pFnDeleteProfile(lpProfile);
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::ResetProfile(LPCSTR lpProfile)
{
if (m_pFnResetProfile)
m_pFnResetProfile(lpProfile);
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::UpdateProfiles()
{
if (m_pFnUpdateProfiles)
m_pFnUpdateProfiles();
}
/////////////////////////////////////////////////////////////////////////////
DWORD CRTSSInterface::SetFlags(DWORD dwAND, DWORD dwXOR)
{
if(m_pFnSetFlags)
return m_pFnSetFlags(dwAND, dwXOR);
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
DWORD CRTSSInterface::GetFlags()
{
if(m_pFnGetFlags)
return m_pFnGetFlags();
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
void CRTSSInterface::PostMessage(UINT Msg, WPARAM wParam, LPARAM lParam)
{
HWND hWnd = hWnd = ::FindWindow(NULL, "RTSS");
if (!hWnd)
hWnd = ::FindWindow(NULL, "RivaTuner Statistics Server");
if (hWnd)
::PostMessage(hWnd, Msg, wParam, lParam);
}