Skip to content

Commit

Permalink
performance improve, you'll notice it!
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpond committed Sep 16, 2019
1 parent 0874769 commit 7d9f3fe
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Please do support Spotify by using premium!!!!

## Video, audio & banner adblock/skip for Spotify

**Current Version:** 0.22
**Current Version:** 0.23

**Last updated:** 14 September 2019
**Last updated:** 16 September 2019

**Last tested version:** 1.1.15.448.g00fba0e3

Expand Down
Binary file modified chrome_elf.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions src/BlockTheSpot.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>chrome_elf</TargetName>
<OutDir>$(ProjectDir)..\</OutDir>
<IncludePath>$(ACE_ROOT);$(IncludePath)</IncludePath>
<LibraryPath>$(ACE_ROOT)\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
19 changes: 15 additions & 4 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ BOOL APIENTRY DllMain (HMODULE hModule,
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls (hModule);
// block the ads banner by hostname
InstallHookApi ("ws2_32.dll", "getaddrinfo", getaddrinfohook);
// real ads block
InstallHookApi ("Winhttp.dll", "WinHttpOpenRequest", winhttpopenrequesthook);
// block the ads banner by hostname.
// but I like new song ad.
//InstallHookApi ("ws2_32.dll", "getaddrinfo", getaddrinfohook);

// real ads block, no data out
InstallHookApi ("Winhttp.dll", "WinHttpSendRequest", winhttpsendrequesthook);
InstallHookApi ("Winhttp.dll", "WinHttpSetStatusCallback", winhttpsetstatuscallbackhook);
// we don't need it, for future only.
//InstallHookApi ("Winhttp.dll", "WinHttpWriteData", winhttpwritedatahook);
//InstallHookApi ("Winhttp.dll", "WinHttpReceiveResponse", winhttpreceiveresponsehook);
//InstallHookApi ("Winhttp.dll", "WinHttpQueryDataAvailable", winhttpquerydataavailablehook);

// archive
// sent only clicked playlist data back to Spotify.
//InstallHookApi ("Winhttp.dll", "WinHttpOpenRequest", winhttpopenrequesthook);
break;
}
return TRUE;
Expand Down
68 changes: 63 additions & 5 deletions src/hosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ int WINAPI winhttpopenrequesthook (DWORD RetAddr,
//"spclient.wg.spotify.com"
//POST
//L"/ad-logic/state/config"
//L"/playlist-publish/v1/subscription/playlist/xxxxx"
//GET
//L"/ad-logic/flashpoint" /* this is ad between song/popup */
//L"/playlist-publish/v1/subscription/playlist/xxxxx" /* sent when change playlist */
//GET /* payload are base64 */
//L"/ads/v2/config?payload=xxxxx"
//L"/ads/v1/ads/hpto?payload=xxxxx"
//L"/ads/v1/ads/leaderboard?payload=xxxxx
//HEADER
//L"/pagead/conversion/?ai=xxxxx"
//L"/monitoring?pload=xxxxx"
//L"/pcs/view?xai=xxxxx"
//HEADER /* add into every request */
//L"User-Agent: Spotify/111500448 Win32/0 (PC laptop)"
//L"Authorization: Bearer xxxxx"

Expand All @@ -31,10 +36,12 @@ int WINAPI winhttpopenrequesthook (DWORD RetAddr,
ppwszAcceptTypes,
dwFlags);
}
return NULL;
else {
// the failed will retry.. not good.
return 0;
}
}


int WINAPI getaddrinfohook (DWORD RetAddr,
pfngetaddrinfo fngetaddrinfo,
const char* nodename,
Expand All @@ -49,3 +56,54 @@ int WINAPI getaddrinfohook (DWORD RetAddr,
}
return fngetaddrinfo (nodename, servname, hints, res);
}

int WINAPI winhttpsendrequesthook (DWORD RetAddr,
pfnwinhttpsendrequest fnwinhttpsendrequest,
HINTERNET hRequest,
LPCWSTR pwszHeaders,
DWORD dwHeadersLength,
LPVOID lpOptional,
DWORD dwOptionalLength,
DWORD dwTotalLength,
DWORD_PTR dwContext)
{
return 1; // return success but nothing sent
}

int WINAPI winhttpwritedatahook (DWORD RetAddr,
pfnwinhttpwritedata fnwinhttpwritedata,
HINTERNET hRequest,
LPCVOID lpBuffer,
DWORD dwNumberOfBytesToWrite,
LPDWORD lpdwNumberOfBytesWritten)
{
return 1; // return success but nothing write
}

int WINAPI winhttpreceiveresponsehook (DWORD RetAddr,
pfnwinhttpreceiveresponse fnwinhttpreceiveresponse,
HINTERNET hRequest,
LPVOID lpReserved)
{
return 1; // return success but nothing receive
}

int WINAPI winhttpquerydataavailablehook (DWORD RetAddr,
pfnwinhttpquerydataavailable fnwinhttpquerydataavailable,
HINTERNET hRequest,
LPDWORD lpdwNumberOfBytesAvailable)
{
//lpdwNumberOfBytesAvailable = 0;
return 1; // return success with 0 byte to read
}

int WINAPI winhttpsetstatuscallbackhook (DWORD RetAddr,
pfnwinhttpsetstatuscallback fnwinhttpsetstatuscallback,
HINTERNET hInternet,
WINHTTP_STATUS_CALLBACK lpfnInternetCallback,
DWORD dwNotificationFlags,
DWORD_PTR dwReserved)
{
// lpfnInternetCallback - Set this to NULL to remove the existing callback function.
return fnwinhttpsetstatuscallback (hInternet, NULL, dwNotificationFlags, NULL);
}
59 changes: 59 additions & 0 deletions src/hosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ typedef int (__stdcall* pfnwinhttpopenrequest)(HINTERNET hConnect,
LPCWSTR* ppwszAcceptTypes,
DWORD dwFlags);

typedef int (__stdcall* pfnwinhttpquerydataavailable)(HINTERNET hRequest,
LPDWORD lpdwNumberOfBytesAvailable);

typedef int (__stdcall* pfnwinhttpsendrequest)(HINTERNET hRequest,
LPCWSTR pwszHeaders,
DWORD dwHeadersLength,
LPVOID lpOptional,
DWORD dwOptionalLength,
DWORD dwTotalLength,
DWORD_PTR dwContext);

typedef int (__stdcall* pfnwinhttpwritedata) (HINTERNET hRequest,
LPCVOID lpBuffer,
DWORD dwNumberOfBytesToWrite,
LPDWORD lpdwNumberOfBytesWritten);

typedef int (__stdcall* pfnwinhttpreceiveresponse) (HINTERNET hRequest,
LPVOID lpReserved);

typedef int (__stdcall* pfnwinhttpsetstatuscallback) (HINTERNET hInternet,
WINHTTP_STATUS_CALLBACK lpfnInternetCallback,
DWORD dwNotificationFlags,
DWORD_PTR dwReserved);

int WINAPI winhttpopenrequesthook (DWORD RetAddr,
pfnwinhttpopenrequest fnwinhttpopenrequest,
HINTERNET hConnect,
Expand All @@ -32,6 +56,40 @@ int WINAPI getaddrinfohook (DWORD RetAddr,
const struct addrinfo* hints,
struct addrinfo** res);

int WINAPI winhttpquerydataavailablehook (DWORD RetAddr,
pfnwinhttpquerydataavailable fnwinhttpquerydataavailable,
HINTERNET hRequest,
LPDWORD lpdwNumberOfBytesAvailable);

int WINAPI winhttpsendrequesthook (DWORD RetAddr,
pfnwinhttpsendrequest fnwinhttpsendrequest,
HINTERNET hRequest,
LPCWSTR pwszHeaders,
DWORD dwHeadersLength,
LPVOID lpOptional,
DWORD dwOptionalLength,
DWORD dwTotalLength,
DWORD_PTR dwContext);

int WINAPI winhttpwritedatahook (DWORD RetAddr,
pfnwinhttpwritedata fnwinhttpwritedata,
HINTERNET hRequest,
LPCVOID lpBuffer,
DWORD dwNumberOfBytesToWrite,
LPDWORD lpdwNumberOfBytesWritten);

int WINAPI winhttpreceiveresponsehook (DWORD RetAddr,
pfnwinhttpreceiveresponse fnwinhttpreceiveresponse,
HINTERNET hRequest,
LPVOID lpReserved);

int WINAPI winhttpsetstatuscallbackhook (DWORD RetAddr,
pfnwinhttpsetstatuscallback fnwinhttpsetstatuscallback,
HINTERNET hInternet,
WINHTTP_STATUS_CALLBACK lpfnInternetCallback,
DWORD dwNotificationFlags,
DWORD_PTR dwReserved);

static const char* blockhost[] = {
// fork this if you found more... I'll check if had time.
"google.ac",
Expand Down Expand Up @@ -487,6 +545,7 @@ static const char* blockhost[] = {
"beacons5.gvt3.com",
"clients2.google.com",
"crashdump.spotify.com",
"invitemedia.com",
"adeventtracker.spotify.com", /* ad tracker */
"dealer.spotify.com" /* unknown */
//"cache.spotify.com" /* not working */
Expand Down

0 comments on commit 7d9f3fe

Please sign in to comment.