diff --git a/README.md b/README.md index e48e210..724575d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ## Video, audio & banner adblock/skip for Spotify -**Current Version:** 0.12 +**Current Version:** 0.13 -**Last updated:** 8th January 2019 +**Last updated:** 5th March 2019 -**Last tested version:** 1.1.0.237.g378f6f25 +**Last tested version:** 1.1.1.348.g9064793a This mod is designed to work with any version update. Please create an issue if it breaks. @@ -14,7 +14,7 @@ This mod is designed to work with any version update. Please create an issue if * Windows only * Set and forget * Blocks all banner/video/audio ads within the app -* Retains friend and vertical video functionality +* Retains friend, vertical video and radio functionality * Unlocks the skip function for any track :warning: This mod is for the [**Desktop release**](https://www.spotify.com/download/windows/) of Spotify on Windows and **not the Microsoft Store version**. diff --git a/install.bat b/install.bat index 3796786..0be6804 100644 Binary files a/install.bat and b/install.bat differ diff --git a/netutils.dll b/netutils.dll index 8c6b026..49787ac 100644 Binary files a/netutils.dll and b/netutils.dll differ diff --git a/src/dllmain.cpp b/src/dllmain.cpp index f016385..65e95a4 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -9,6 +9,7 @@ #pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "Psapi.lib") +#pragma comment(lib, "Version.lib") typedef int (WSAAPI* _getaddrinfo)( _In_opt_ PCSTR pNodeName, @@ -452,6 +453,56 @@ void WriteAll(HMODULE hModule, MODULEINFO mInfo) } } +typedef struct +{ + DWORD dwMajor; + DWORD dwMinor; + DWORD dwBuild; + DWORD dwRevision; +} version_t; + +typedef struct { + WORD wLength; + WORD wValueLength; + WORD wType; + WCHAR szKey[16]; + WORD Padding1; + VS_FIXEDFILEINFO Value; + WORD Padding2; + WORD Children; +} VS_VERSIONINFO; + +BOOL GetFileVersionInfo(version_t* v) +{ + BOOL ok = FALSE; + WCHAR moduleFilePath[MAX_PATH]; + DWORD verHandle; + GetModuleFileName(GetModuleHandle(NULL), moduleFilePath, MAX_PATH); + DWORD verSize = GetFileVersionInfoSize(moduleFilePath, &verHandle); + if (verSize) + { + LPVOID verBuffer; + UINT size; + LPVOID verData = new char[verSize]; + if (GetFileVersionInfo(moduleFilePath, verHandle, verSize, verData) && + VerQueryValueA(verData, "\\", &verBuffer, &size) && + size) + { + VS_VERSIONINFO *verInfo = (VS_VERSIONINFO *) verData; + if (verInfo->Value.dwSignature == 0xfeef04bd) + { + v->dwMajor = verInfo->Value.dwFileVersionMS >> 16 & 0xffff; + v->dwMinor = verInfo->Value.dwFileVersionMS & 0xffff; + v->dwBuild = verInfo->Value.dwFileVersionLS >> 16 & 0xffff; + v->dwRevision = verInfo->Value.dwFileVersionLS & 0xffff; + ok = TRUE; + } + } + delete (char*) verData; + } + return ok; +} + DWORD WINAPI MainThread(LPVOID) { // Block known ad hosts via function hooks @@ -474,11 +525,16 @@ DWORD WINAPI MainThread(LPVOID) } // Perform fallback patches (just in-case the main method fails) - __try { - Patch(hModule, mInfo); - } - __except (EXCEPTION_EXECUTE_HANDLER) + // Only allow for version 1.1.0.xx and below + version_t v; + if (GetFileVersionInfo(&v) && v.dwMajor <= 1 && v.dwMinor <= 1 && v.dwBuild <= 0) { + __try { + Patch(hModule, mInfo); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + } } // Perform main ad patch