Skip to content

Commit b9dc225

Browse files
iostreamiostream
authored andcommitted
Fix facebook friend, ads in newer spotify/alpha
1 parent c4bccb3 commit b9dc225

File tree

6 files changed

+60
-42
lines changed

6 files changed

+60
-42
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<h4 align="center">A multi-purpose adblocker and skip-bypass for the <strong>Windows</strong> Spotify desktop application.</h4>
1212
<h5 align="center">Please support Spotify by purchasing premium</h5>
1313
<p align="center">
14-
<strong>Last updated:</strong> 24 March 2020<br>
15-
<strong>Last tested version:</strong> 1.1.56.595.g2d2da0de
14+
<strong>Last updated:</strong> 21 April 2021<br>
15+
<strong>Last tested version:</strong> 1.1.57.443.ga029a6c4(-a)
1616
</p>
1717
</center>
1818

src/Logger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Logger {
2828

2929
void Log (std::string_view log) {
3030
if (m_active)
31-
m_log << log << std::endl;
31+
m_log << log << '\n';
3232
}
3333

3434
private:

src/Modify.cpp

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "Modify.h"
22
#include "Logger.h"
33

4-
extern Logger g_Logger;
4+
extern Logger *g_Logger;
55

66
// https://www.unknowncheats.me/forum/1064672-post23.html
77
bool DataCompare (BYTE* pData, BYTE* bSig, char* szMask)
@@ -31,17 +31,15 @@ BYTE* FindPattern (BYTE* dwAddress, DWORD dwSize, BYTE* pbSig, char* szMask)
3131
return 0;
3232
}
3333

34-
DWORD WINAPI KillBanner (LPVOID conf)
34+
DWORD WINAPI KillBanner (LPVOID)
3535
{
36-
auto config = static_cast<Config*>(conf);
37-
auto* logger = new Logger (config);
3836
HMODULE hModule = GetModuleHandle (NULL);
3937
MODULEINFO mInfo = { 0 };
4038
if (GetModuleInformation (GetCurrentProcess (), hModule, &mInfo, sizeof (MODULEINFO))) {
41-
logger->Log ("GetModuleInformation OK!");
39+
g_Logger->Log ("GetModuleInformation OK!");
4240
LPVOID skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage, (BYTE*)"\x83\xC4\x08\x84\xC0\x0F\x84\x00\x04\x00\x00", "xxxxxxxxxxx");
4341

44-
if (skipPod)
42+
if (skipPod) // spotify
4543
{
4644
DWORD oldProtect;
4745
VirtualProtect ((char*)skipPod + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
@@ -51,15 +49,47 @@ DWORD WINAPI KillBanner (LPVOID conf)
5149
VirtualProtect ((char*)skipPod + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
5250
memset ((char*)skipPod + 6, 0xE9, 1);
5351
VirtualProtect ((char*)skipPod + 6, 1, oldProtect, &oldProtect);
54-
logger->Log ("main process - patch success!");
52+
g_Logger->Log ("main process#1 - patch success!");
5553
}
5654
else {
57-
logger->Log ("main process - patch failed!");
55+
g_Logger->Log ("main process#1 - patch failed!");
5856
}
57+
58+
skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage, (BYTE*)"\x83\xC4\x08\x84\xC0\x0F\x84\xE5\x03\x00\x00", "xxxxxxxxxxx");
59+
60+
if (skipPod) // spotify alpha
61+
{
62+
DWORD oldProtect;
63+
VirtualProtect ((char*)skipPod + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
64+
memset ((char*)skipPod + 5, 0x90, 1);
65+
VirtualProtect ((char*)skipPod + 5, 1, oldProtect, &oldProtect);
66+
67+
VirtualProtect ((char*)skipPod + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
68+
memset ((char*)skipPod + 6, 0xE9, 1);
69+
VirtualProtect ((char*)skipPod + 6, 1, oldProtect, &oldProtect);
70+
g_Logger->Log ("main process#2 - patch success!");
71+
}
72+
else {
73+
g_Logger->Log ("main process#2 - patch failed!");
74+
}
75+
76+
//skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage, (BYTE*)"\x48\x83\xF8\x03\x77", "xxxxx");
77+
78+
//if (skipPod)
79+
//{
80+
// DWORD oldProtect;
81+
// VirtualProtect ((char*)skipPod + 4, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
82+
// memset ((char*)skipPod + 4, 0xEB, 1);
83+
// VirtualProtect ((char*)skipPod + 4, 1, oldProtect, &oldProtect);
84+
// g_Logger->Log ("main process#3 - patch success!");
85+
//}
86+
//else {
87+
// g_Logger->Log ("main process#3 - patch failed!");
88+
//}
5989
}
6090
else {
61-
logger->Log ("GetModuleInformation failed!");
91+
g_Logger->Log ("GetModuleInformation failed!");
6292
}
63-
93+
g_Logger->~Logger ();
6494
return 0;
6595
}

src/Modify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#include "stdafx.h"
33

44

5-
DWORD WINAPI KillBanner (LPVOID config);
5+
DWORD WINAPI KillBanner (LPVOID);

src/dllmain.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
extern _getaddrinfo getaddrinfo_orig;
99

10+
11+
Config g_Config;
12+
Logger *g_Logger = new Logger (&g_Config);
13+
1014
BOOL APIENTRY DllMain (HMODULE hModule,
1115
DWORD ul_reason_for_call, LPVOID lpReserved)
1216
{
@@ -17,25 +21,23 @@ BOOL APIENTRY DllMain (HMODULE hModule,
1721
switch (ul_reason_for_call)
1822
{
1923
case DLL_PROCESS_ATTACH:
20-
auto *config = new Config();
21-
if (std::string_view::npos == procname.find ("--type=") && false == config->getConfig("Block_BannerOnly")) {
24+
if (std::string_view::npos == procname.find ("--type=") && false == g_Config.getConfig("Block_BannerOnly")) {
2225
// block ads request - main process
23-
CreateThread (NULL, NULL, KillBanner, config, 0, NULL);
26+
CreateThread (NULL, NULL, KillBanner, NULL, 0, NULL);
2427
//g_Logger.setLogfile ("main_log.txt");
2528
}
2629
else if (std::string_view::npos != procname.find ("--type=utility")) {
2730
// block ads banner by hostname - utility process
2831
//g_Logger.setLogfile ("utility_log.txt");
29-
auto *log = new Logger (config);
3032
getaddrinfo_orig = getaddrinfo;
3133
if (getaddrinfo_orig) {
3234
Mhook_SetHook ((PVOID*)&getaddrinfo_orig, getaddrinfo_hook);
33-
log->Log ("Mhook_SetHook - getaddrinfo success!");
35+
g_Logger->Log ("Mhook_SetHook - getaddrinfo success!");
3436
}
3537
else {
36-
log->Log ("Mhook_SetHook - getaddrinfo failed!");
38+
g_Logger->Log ("Mhook_SetHook - getaddrinfo failed!");
3739
}
38-
log->~Logger ();
40+
g_Logger->~Logger ();
3941
}
4042
break;
4143
}

src/hosts.cpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,16 @@
44
#include "Config.h"
55
#include "Logger.h"
66

7-
//extern Logger g_Logger;
8-
//extern Config g_Config;
7+
extern Logger *g_Logger;
8+
extern Config g_Config;
99

1010
_getaddrinfo getaddrinfo_orig;
1111

12-
auto *config = new Config ();
13-
auto *logger = new Logger (config);
14-
static constexpr std::array<std::string_view, 2> dnscheck = { "dns.google", "cloudflare" };
15-
static constexpr std::array<std::string_view, 4> blockList = { "google", "doubleclick", "qualaroo.com", "fbsbx.com" };
16-
static const bool wpad = config->getConfig ("Skip_wpad");
12+
static constexpr std::array<std::string_view, 5> blockList = { "googletag", "doubleclick", "qualaroo.com",/* "fbsbx.com", */ "dns.google", "cloudflare" };
13+
static const bool wpad = g_Config.getConfig ("Skip_wpad");
1714

1815
// check if ads hostname
1916
bool is_blockhost (std::string_view nodename) {
20-
//static bool wpad = config->getConfig ("Skip_wpad");
21-
22-
2317
if (0 == nodename.compare ("wpad"))
2418
return wpad ? true : false;
2519
for (auto &hostname : blockList) {
@@ -49,21 +43,13 @@ int WSAAPI getaddrinfo_hook (
4943
auto ipv4 = reinterpret_cast<sockaddr_in*>(ptr->ai_addr);
5044
ipv4->sin_addr.S_un.S_addr = INADDR_ANY;
5145
}
52-
logger->Log ("blocked - " + nnodename);
46+
g_Logger->Log ("blocked - " + nnodename);
5347
}
5448
else {
55-
logger->Log ("allowed - " + nnodename);
56-
}
57-
}
58-
if (true == logger->is_active() &&
59-
true == wpad)
60-
{
61-
for (auto &hostname : dnscheck) {
62-
if (std::string_view::npos != nnodename.find (hostname))
63-
logger->Log ("custom dns currently in use - " + nnodename +
64-
" turn on Skip_wpad in config.ini or switch to adguard dns");
49+
g_Logger->Log ("allowed - " + nnodename);
6550
}
6651
}
52+
6753
return result;
6854
}
6955

0 commit comments

Comments
 (0)