Skip to content

Commit e36d71f

Browse files
author
mrpond
committed
add developer mode into blockthespot
1 parent 961123d commit e36d71f

File tree

7 files changed

+104
-14
lines changed

7 files changed

+104
-14
lines changed

config.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[Config]
22
;Log system
3-
Log = 0
3+
Log = 0
4+
Developer = 1

src/BlockTheSpot.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
4949
<TargetName>dpapi</TargetName>
5050
<OutDir>$(ProjectDir)..\</OutDir>
51+
<LinkIncremental>false</LinkIncremental>
5152
</PropertyGroup>
5253
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5354
<ClCompile>
@@ -56,6 +57,8 @@
5657
<LanguageStandard>stdcpp20</LanguageStandard>
5758
<AdditionalIncludeDirectories>./cef_binary_109.1.13+g18f6895+chromium-109.0.5414.87_windows32_minimal</AdditionalIncludeDirectories>
5859
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
60+
<ExceptionHandling>Sync</ExceptionHandling>
61+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
5962
</ClCompile>
6063
<Link>
6164
<ModuleDefinitionFile>dpapi.def</ModuleDefinitionFile>
@@ -76,6 +79,7 @@
7679
<LanguageStandard>stdcpp20</LanguageStandard>
7780
<AdditionalIncludeDirectories>
7881
</AdditionalIncludeDirectories>
82+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
7983
</ClCompile>
8084
<Link>
8185
<EnableCOMDATFolding>true</EnableCOMDATFolding>

src/Logger.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,32 @@ class Logger {
1313
}
1414

1515
std::wofstream log_wstream;
16-
const bool read (std::wstring_view app, std::wstring_view key,const int def_value = 0) {
17-
if (1 == GetPrivateProfileInt (app.data (), key.data (), def_value, L"./config.ini")) {
16+
17+
public:
18+
19+
const bool read(std::wstring_view app, std::wstring_view key, const int def_value = 0) {
20+
if (1 == GetPrivateProfileInt(app.data(), key.data(), def_value, L"./config.ini")) {
1821
return true;
1922
}
2023
return false;
2124
}
2225

23-
24-
public:
2526
Logger () {
26-
if (read (L"Config", L"Log")) {
27+
if (true == read (L"Config", L"Log")) {
2728
log_wstream.open (L"blockthespot_log.txt", std::ios::out | std::ios::app);
2829
//m_log << "BlockTheSpot - Build date: " << __TIMESTAMP__ << std::endl;
2930
}
3031
}
3132

3233
~Logger () {
33-
if (log_wstream.is_open()) {
34+
if (true == log_wstream.is_open()) {
3435
log_wstream.flush ();
3536
log_wstream.close ();
3637
}
3738
}
3839

3940
void Log (std::wstring_view log) {
40-
if (log_wstream.is_open ()) {
41+
if (true == log_wstream.is_open ()) {
4142
std::wstringstream message;
4243
const auto& time = current_datetime();
4344
message << L"LOG | " << std::put_time(&time, L"%d-%b-%Y %H:%M:%S") << L" - " << log;

src/Modify.cpp

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#ifndef NDEBUG
66
#include <include/capi/cef_urlrequest_capi.h>
77
#endif
8-
98
/*
109
*
1110
* Black banner still show even libcef hooked.
@@ -29,7 +28,7 @@ static _cef_urlrequest_create cef_urlrequest_create_orig;
2928
static _cef_string_userfree_utf16_free cef_string_userfree_utf16_free_orig;
3029

3130
static constexpr auto block_list = { L"/ads/", L"/ad-logic/", L"/gabo-receiver-service/" };
32-
31+
//static constexpr char search_str[] = {0x61,0x70,0x70,0x2D,0x64,0x65,0x76,0x65,0x6C,0x6F,0x70,0x65,0x72,0x09,0x01,0x30,0x78};
3332

3433
DWORD WINAPI get_url(DWORD pRequest)
3534
{
@@ -86,6 +85,52 @@ void* cef_urlrequest_create_hook(void* request, void* client, void* request_cont
8685
return cef_urlrequest_create_orig (request, client, request_context);
8786
}
8887

88+
89+
// https://www.unknowncheats.me/forum/1064672-post23.html
90+
bool DataCompare(BYTE* pData, BYTE* bSig, const char* szMask)
91+
{
92+
for (; *szMask; ++szMask, ++pData, ++bSig)
93+
{
94+
if (*szMask == 'x' && *pData != *bSig)
95+
return false;
96+
}
97+
return (*szMask) == NULL;
98+
}
99+
100+
BYTE* FindPattern(BYTE* dwAddress, const DWORD dwSize, BYTE* pbSig, const char* szMask)
101+
{
102+
DWORD length = strlen(szMask);
103+
for (DWORD i = NULL; i < dwSize - length; i++)
104+
{
105+
__try
106+
{
107+
if (DataCompare(dwAddress + i, pbSig, szMask))
108+
return dwAddress + i;
109+
}
110+
__except (EXCEPTION_EXECUTE_HANDLER) {
111+
return nullptr;
112+
}
113+
}
114+
return 0;
115+
}
116+
117+
int FindPattern2(BYTE* dwAddress, const DWORD dwSize, BYTE* pbSig, const char* szMask)
118+
{
119+
DWORD length = strlen(szMask);
120+
for (DWORD i = NULL; i < dwSize - length; i++)
121+
{
122+
__try
123+
{
124+
if (DataCompare(dwAddress + i, pbSig, szMask))
125+
return i;
126+
}
127+
__except (EXCEPTION_EXECUTE_HANDLER) {
128+
return 0;
129+
}
130+
}
131+
return 0;
132+
}
133+
89134
DWORD WINAPI KillBanner (LPVOID)
90135
{
91136
constexpr auto libcef_str{ L"libcef.dll" };
@@ -104,6 +149,42 @@ DWORD WINAPI KillBanner (LPVOID)
104149
result ? g_Logger.Log(L"main process - patch success!") : g_Logger.Log(L"main process - patch failed!");
105150
}
106151
}
107-
108152
return 0;
109153
}
154+
155+
DWORD WINAPI Developer(LPVOID)
156+
{
157+
if (true == g_Logger.read(L"Config", L"Developer")) {
158+
auto appdata = std::getenv("APPDATA");
159+
std::filesystem::path file{ appdata };
160+
file = file.parent_path();
161+
file /= "Local\\Spotify\\offline.bnk";
162+
std::fstream offline_bnk;
163+
offline_bnk.open(file, std::ios::in | std::ios::out | std::ios::binary);
164+
if (true == offline_bnk.is_open()) {
165+
const auto length = std::filesystem::file_size(file);
166+
if (length > 0)
167+
{
168+
char* temp_buffer = new char[length];
169+
offline_bnk.rdbuf()->sgetn(temp_buffer, length);
170+
auto developer = FindPattern2((uint8_t*)temp_buffer, length,
171+
(BYTE*)"\x61\x70\x70\x2D\x64\x65\x76\x65\x6C\x6F\x70\x65\x72\x09\x01\x30\x78",
172+
"xxxxxxxxxxxxxxxxx");
173+
//app-developer \x09 \x01 \x30 \x78 -> app-developer(\t\x01)00x
174+
if (developer) {
175+
offline_bnk.seekp(developer + 15);
176+
offline_bnk << char(0x32);//00x -> 02x
177+
g_Logger.Log(L"offline.bnk modified!");
178+
}
179+
else {
180+
g_Logger.Log(L"offline.bnk not modified!");
181+
}
182+
delete[] temp_buffer;
183+
}
184+
}
185+
else {
186+
g_Logger.Log(L"offline.bnk not exists/access denied!");
187+
}
188+
}
189+
return 0;
190+
}

src/Modify.h

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

4-
DWORD WINAPI KillBanner (LPVOID);
4+
DWORD WINAPI KillBanner (LPVOID);
5+
DWORD WINAPI Developer (LPVOID);

src/dllmain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ BOOL APIENTRY DllMain (HMODULE hModule,
1313
{
1414
case DLL_PROCESS_ATTACH:
1515
if (std::wstring_view::npos == procname.find (L"--type=")) {
16+
// Modify offline.bnk
17+
CreateThread (NULL, NULL, Developer, NULL, 0, NULL);
1618
// block ads request - main process
1719
CreateThread (NULL, NULL, KillBanner, NULL, 0, NULL);
1820
}

src/stdafx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
1010
// Windows Header Files:
1111
#include <windows.h>
12+
#include <shlobj.h>
1213
#include <Psapi.h>
13-
14+
#include <filesystem>
1415

1516
// TODO: reference additional headers your program requires here
1617
#include <fstream>
17-
#include <iomanip>
1818
#include <sstream>
1919
#include <string>
2020
#include "mhook-lib/mhook.h"

0 commit comments

Comments
 (0)