Skip to content

Commit aac0f1b

Browse files
Fix crash caused by new update to Spotify
1 parent c005e3c commit aac0f1b

File tree

5 files changed

+62
-80
lines changed

5 files changed

+62
-80
lines changed

SpotifyInternal/SpotifyInternal.vcxproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
<EnableCOMDATFolding>true</EnableCOMDATFolding>
8787
<OptimizeReferences>true</OptimizeReferences>
8888
<GenerateDebugInformation>false</GenerateDebugInformation>
89-
<ModuleDefinitionFile>chrome_elf.def</ModuleDefinitionFile>
89+
<ModuleDefinitionFile>
90+
</ModuleDefinitionFile>
9091
<IgnoreAllDefaultLibraries>
9192
</IgnoreAllDefaultLibraries>
9293
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
@@ -97,17 +98,13 @@
9798
</ItemDefinitionGroup>
9899
<ItemGroup>
99100
<ClCompile Include="dllmain.cpp" />
100-
<ClCompile Include="exports.cpp" />
101101
</ItemGroup>
102102
<ItemGroup>
103103
<ClInclude Include="resource.h" />
104104
</ItemGroup>
105105
<ItemGroup>
106106
<ResourceCompile Include="SpotifyInternal.rc" />
107107
</ItemGroup>
108-
<ItemGroup>
109-
<None Include="chrome_elf.def" />
110-
</ItemGroup>
111108
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
112109
<ImportGroup Label="ExtensionTargets">
113110
</ImportGroup>

SpotifyInternal/SpotifyInternal.vcxproj.filters

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@
1010
<ClCompile Include="dllmain.cpp">
1111
<Filter>Source Files</Filter>
1212
</ClCompile>
13-
<ClCompile Include="exports.cpp">
14-
<Filter>Source Files</Filter>
15-
</ClCompile>
1613
</ItemGroup>
1714
<ItemGroup>
1815
<ClInclude Include="resource.h" />
1916
</ItemGroup>
2017
<ItemGroup>
2118
<ResourceCompile Include="SpotifyInternal.rc" />
2219
</ItemGroup>
23-
<ItemGroup>
24-
<None Include="chrome_elf.def">
25-
<Filter>Source Files</Filter>
26-
</None>
27-
</ItemGroup>
2820
</Project>

SpotifyInternal/chrome_elf.def

Lines changed: 0 additions & 30 deletions
This file was deleted.

SpotifyInternal/dllmain.cpp

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
11
#include <Windows.h>
22
#include <Psapi.h>
33

4+
void WINAPI load_api(LPVOID* destination, LPCSTR api_name) noexcept
5+
{
6+
if (*destination)
7+
return;
8+
9+
const auto h_mod{ ::LoadLibraryA("_chrome_elf.dll") };
10+
11+
if (!h_mod)
12+
return;
13+
14+
*destination = ::GetProcAddress(h_mod, api_name);
15+
}
16+
17+
#define API_EXPORT_ORIG(N) \
18+
static LPVOID _##N = NULL; \
19+
char S_##N[] = "" # N; \
20+
extern "C" __declspec(dllexport) __declspec(naked) void N ## () \
21+
{ \
22+
__asm pushad \
23+
__asm push offset S_##N \
24+
__asm push offset _##N \
25+
__asm call load_api \
26+
__asm popad \
27+
__asm jmp [_##N] \
28+
} \
29+
30+
API_EXPORT_ORIG(ClearReportsBetween_ExportThunk)
31+
API_EXPORT_ORIG(CrashForException_ExportThunk)
32+
API_EXPORT_ORIG(DisableHook)
33+
API_EXPORT_ORIG(DrainLog)
34+
API_EXPORT_ORIG(DumpHungProcessWithPtype_ExportThunk)
35+
API_EXPORT_ORIG(DumpProcessWithoutCrash)
36+
API_EXPORT_ORIG(GetApplyHookResult)
37+
API_EXPORT_ORIG(GetBlockedModulesCount)
38+
API_EXPORT_ORIG(GetCrashReports_ExportThunk)
39+
API_EXPORT_ORIG(GetCrashpadDatabasePath_ExportThunk)
40+
API_EXPORT_ORIG(GetHandleVerifier)
41+
API_EXPORT_ORIG(GetInstallDetailsPayload)
42+
API_EXPORT_ORIG(GetUniqueBlockedModulesCount)
43+
API_EXPORT_ORIG(GetUserDataDirectoryThunk)
44+
API_EXPORT_ORIG(InjectDumpForHungInput_ExportThunk)
45+
API_EXPORT_ORIG(IsBrowserProcess)
46+
API_EXPORT_ORIG(IsCrashReportingEnabledImpl)
47+
API_EXPORT_ORIG(IsThirdPartyInitialized)
48+
API_EXPORT_ORIG(RegisterLogNotification)
49+
API_EXPORT_ORIG(RequestSingleCrashUpload_ExportThunk)
50+
API_EXPORT_ORIG(SetCrashKeyValueImpl)
51+
API_EXPORT_ORIG(SetMetricsClientId)
52+
API_EXPORT_ORIG(SetUploadConsent_ExportThunk)
53+
API_EXPORT_ORIG(SignalChromeElf)
54+
API_EXPORT_ORIG(SignalInitializeCrashReporting)
55+
456
bool DataCompare(char* pData, const char* bSig, const char* szMask) noexcept
557
{
658
for (; *szMask; ++szMask, ++pData, ++bSig) {
@@ -12,7 +64,7 @@ bool DataCompare(char* pData, const char* bSig, const char* szMask) noexcept
1264

1365
char* FindPattern(char* dwAddress, DWORD dwSize, const char* pbSig, const char* szMask) noexcept
1466
{
15-
DWORD length{ strlen(szMask) };
67+
DWORD length{ ::strlen(szMask) };
1668

1769
for (DWORD i{ 0 }; i < dwSize - length; ++i) {
1870
__try {
@@ -28,21 +80,21 @@ char* FindPattern(char* dwAddress, DWORD dwSize, const char* pbSig, const char*
2880

2981
char* scan(const char* pattern, const char* mask, MODULEINFO m) noexcept
3082
{
31-
const auto hModule{ GetModuleHandleA(nullptr) };
83+
const auto hModule{ ::GetModuleHandleA(nullptr) };
3284
return FindPattern((char*)hModule, m.SizeOfImage, pattern, mask);
3385
}
3486

3587
void removeAds(char* fn) noexcept
3688
{
3789
DWORD oldProtect;
3890

39-
VirtualProtect(fn + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
40-
memset(fn + 5, 0x90, 1);
41-
VirtualProtect(fn + 5, 1, oldProtect, &oldProtect);
91+
::VirtualProtect(fn + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
92+
::memset(fn + 5, 0x90, 1);
93+
::VirtualProtect(fn + 5, 1, oldProtect, &oldProtect);
4294

43-
VirtualProtect(fn + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
44-
memset(fn + 6, 0xE9, 1);
45-
VirtualProtect(fn + 6, 1, oldProtect, &oldProtect);
95+
::VirtualProtect(fn + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
96+
::memset(fn + 6, 0xE9, 1);
97+
::VirtualProtect(fn + 6, 1, oldProtect, &oldProtect);
4698
}
4799

48100
void APIENTRY main() noexcept

SpotifyInternal/exports.cpp

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)