From 8495983c3639bc428434695ed12a7cd5746b780d Mon Sep 17 00:00:00 2001 From: R3nzTheCodeGOD Date: Sat, 7 Aug 2021 03:15:16 +0300 Subject: [PATCH] update and fix the crash --- .gitattributes | 3 +- Builds/chrome_elf.dll | Bin 36864 -> 0 bytes SpotifyInternal/Spotify.cpp | 49 - SpotifyInternal/Spotify.hpp | 20 - SpotifyInternal/SpotifyInternal.vcxproj | 112 +- .../SpotifyInternal.vcxproj.filters | 34 +- SpotifyInternal/chrome_elf.def | 30 + SpotifyInternal/detours/include/detours.h | 1075 ----------------- SpotifyInternal/detours/include/detver.h | 27 - SpotifyInternal/detours/include/syelog.h | 89 -- SpotifyInternal/detours/include/uniHook.hpp | 57 - SpotifyInternal/dllmain.cpp | 160 +-- SpotifyInternal/exports.cpp | 29 + SpotifyInternal/utils.cpp | 39 - SpotifyInternal/utils.hpp | 18 - {Builds => scripts}/installer.bat | 0 noAdsScript.py => scripts/noAdsScript.py | 0 {Builds => scripts}/uinstaller.bat | 0 18 files changed, 123 insertions(+), 1619 deletions(-) delete mode 100644 Builds/chrome_elf.dll delete mode 100644 SpotifyInternal/Spotify.cpp delete mode 100644 SpotifyInternal/Spotify.hpp create mode 100644 SpotifyInternal/chrome_elf.def delete mode 100644 SpotifyInternal/detours/include/detours.h delete mode 100644 SpotifyInternal/detours/include/detver.h delete mode 100644 SpotifyInternal/detours/include/syelog.h delete mode 100644 SpotifyInternal/detours/include/uniHook.hpp create mode 100644 SpotifyInternal/exports.cpp delete mode 100644 SpotifyInternal/utils.cpp delete mode 100644 SpotifyInternal/utils.hpp rename {Builds => scripts}/installer.bat (100%) rename noAdsScript.py => scripts/noAdsScript.py (100%) rename {Builds => scripts}/uinstaller.bat (100%) diff --git a/.gitattributes b/.gitattributes index 2f59e37..3b28ec0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,8 +2,7 @@ # Set default behavior to automatically normalize line endings. ############################################################################### * text=auto -*.h linguist-language=C++ -*.hpp linguist-language=C++ +*.def linguist-language=Assembly ############################################################################### # Set default behavior for command prompt diff. diff --git a/Builds/chrome_elf.dll b/Builds/chrome_elf.dll deleted file mode 100644 index dcbb1348a1cddd3af7b3bdec724f779fd34d5721..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36864 zcmeHw4}4U`wf{}BffW{Z(WIhASRp8uKi$9C-RveCLKcH0y7>zz7y{X_3HjH}T>%T4 zxQS(1($b2p?W4aZLR;;lEqzjo7HtC5fQ=e0RciBUq^LJ;s;QG>Y2w9<9&cpsi`p=G|GMt#7RIES@%P zN;)UK#}oW*uj1X7X!!j$vE?k%S2dk$J;C6gTHj#seCw-#IrZmSf6LPEw4MPx+4xTD z>wvwAcUsy3r!>9K@~1St+xiMi&uk&st7u|yO4Hj6UtF`nOKnDb=ynN0LBeFA?v}r; zi{ko)#G9rjOivST2PR*}e*X?Y4Z=E>*06Y@AWUM(F(~u{K|;lqDC9s=s6_Q*P)@q* z1>p${z(|uIoTBVbL730$Q8IS*3WD`2LFlUz1QeZcf=H9{Ri+?B)Vv2s-^!XH9_tcCk2F?Qt;JzukL15iwMorutY zv>?P?IYiIrscS?*lBLj#Fa_Zugt#k55OU*^|E;6zym=1_8t>p&1&ySE9#%%?QM@O5 zt@9pjMgA$uAA;FfrTktwpW<=(X;eRj+CL=cQ#>wz8`U4B`n%N9NE$34_E`JT>_fvhHoKNw%{3?>Kmg;Nde2T~A&!l{T@`o@J(0_`@uIz3<%WHMFpXV{@w`SJM(2!iKd}XbGni6V4e0O%R zf}lt>-QKfRB<$2dIaeQemXQ(Xx86VhS;YsR`Dd$tvCN?U#r?YSV0%AmNc%uN#G;U7 z_)8&1C-f{)ix#iP$6-Qy@l-NY80OBuj%XM_zYJ zyXQeQ*FlLomMPrQoEuQ!QxpJoEKK7WvQK2_o5^DgNgmWAl37IZ5F@E{OE1G|k$xnT zB)?=_A0^|2K04z`Ud>6qmkyF{kSv!TAbNMn^iXu1hJR-~xu}K@qFq_T%>ugJ(LqC5 zR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h9p|W$nq@n{^=TVAkQRV_7G&da}-B^<|yU8q6Bb8qHE$1h{ZP{(vyR!FW@6A4teK7lQ_Oa}f**)23viq{nXAfo%XOCtpoGNFE zGtHR}`)qPLoO!U%rOq|ZDrX(6^EPLjbC+|EbFcG&^Puyv^O*Cbv&VVH+2=g(9CQxT X3W^7A_-+qCp-cIkS&TyeO|Jh95fVnl diff --git a/SpotifyInternal/Spotify.cpp b/SpotifyInternal/Spotify.cpp deleted file mode 100644 index 8950192..0000000 --- a/SpotifyInternal/Spotify.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "Spotify.hpp" -#include "memory.hpp" -#include "utils.hpp" - -Spotify* l = nullptr; - -Spotify::Spotify() noexcept -{ - auto main = GetModuleHandle(nullptr); - auto get_function_start = [=](uint8_t* ptr) -> uint8_t* { - for (size_t i = 0; i < 0x1000; ++i) { - if (*reinterpret_cast(ptr - i) == 0x6AEC8B55) return ptr - i; - } - return nullptr; - }; - m_jne_ad_missing_id = memory::pattern_scan(main, 0, "0F 85 ?? ?? ?? ?? A1 ?? ?? ?? ?? F3 0F 7E 05 ?? ?? ?? ?? 89 45 E0 A0"); - m_mov_skip_stuck_seconds = memory::pattern_scan(main, 0, "B9 E8 03 00 00 F7 E9 83"); - m_fn_is_skippable = memory::pattern_scan(main, 0, "83 C4 10 BB ? ? ? ? 83 78 14 10"); - m_fn_now_playing = memory::pattern_scan(main, 0, "8B C1 89 85 ? ? ? ? 8B 55 08 C7 85"); - m_fn_require_focus = memory::pattern_scan(main, 0, "72 65 71 75 69 72 65 5F 66 6F 63 75 73 00 00 00 0D"); - if (m_fn_is_skippable) - m_fn_is_skippable = get_function_start(m_fn_is_skippable); - if (m_fn_now_playing) - m_fn_now_playing = get_function_start(m_fn_now_playing); - if (m_mov_skip_stuck_seconds) - m_mov_skip_stuck_seconds += 1; - if (m_fn_require_focus) { - auto pattern = new uint8_t[5]; - pattern[0] = 0x68; - *reinterpret_cast(&pattern[1]) = m_fn_require_focus; - m_fn_require_focus = memory::find_pattern(main, memory::get_mod_size(main), pattern, 5); - } - if (m_fn_require_focus) - m_fn_require_focus = get_function_start(m_fn_require_focus); -} - -bool Spotify::valid_ptrs() noexcept -{ - return (m_jne_ad_missing_id && m_mov_skip_stuck_seconds && m_fn_is_skippable && m_fn_now_playing && m_fn_require_focus); -} - -Spotify::~Spotify() = default; - -Spotify* Spotify::instance() noexcept -{ - if (l == nullptr) - l = new Spotify(); - return l; -} \ No newline at end of file diff --git a/SpotifyInternal/Spotify.hpp b/SpotifyInternal/Spotify.hpp deleted file mode 100644 index 490fd25..0000000 --- a/SpotifyInternal/Spotify.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -class Spotify -{ -public: - Spotify() noexcept; - ~Spotify(); - static Spotify* instance() noexcept; - uint8_t* m_fn_is_skippable = nullptr; - uint8_t* m_fn_require_focus = nullptr; - uint8_t* m_fn_now_playing = nullptr; - uint8_t* m_jne_ad_missing_id = nullptr; - uint8_t* m_mov_skip_stuck_seconds = nullptr; - - bool valid_ptrs() noexcept; -private: - -}; diff --git a/SpotifyInternal/SpotifyInternal.vcxproj b/SpotifyInternal/SpotifyInternal.vcxproj index c0eb1d1..d998913 100644 --- a/SpotifyInternal/SpotifyInternal.vcxproj +++ b/SpotifyInternal/SpotifyInternal.vcxproj @@ -9,14 +9,6 @@ Release Win32 - - Debug - x64 - - - Release - x64 - 16.0 @@ -39,19 +31,6 @@ true Unicode - - DynamicLibrary - true - v142 - Unicode - - - DynamicLibrary - false - v142 - true - Unicode - @@ -63,12 +42,6 @@ - - - - - - true @@ -76,14 +49,6 @@ false chrome_elf - detours\include;$(IncludePath) - detours\libs\x86;$(LibraryPath) - - - true - - - false @@ -91,88 +56,57 @@ true WIN32;_DEBUG;SPOTIFYINTERNAL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use - pch.h + NotUsing Windows true false + chrome_elf.def - + Level3 + NotUsing + MaxSpeed true - true - true WIN32;NDEBUG;SPOTIFYINTERNAL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - Default - NotUsing - pch.h + MultiThreaded + None + Speed + AnySuitable + Sync + true stdcpplatest - StreamingSIMDExtensions2 Windows true true - true - false - - - - - Level3 - true - _DEBUG;SPOTIFYINTERNAL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - NDEBUG;SPOTIFYINTERNAL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - true - true - false + false + chrome_elf.def + + + UseLinkTimeCodeGeneration + true + false + %(AdditionalDependencies) - - + - - - - - - - + + + diff --git a/SpotifyInternal/SpotifyInternal.vcxproj.filters b/SpotifyInternal/SpotifyInternal.vcxproj.filters index 5032e3b..561a416 100644 --- a/SpotifyInternal/SpotifyInternal.vcxproj.filters +++ b/SpotifyInternal/SpotifyInternal.vcxproj.filters @@ -1,9 +1,6 @@  - - {db4ac997-c267-4462-9553-a1cf3265585c} - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx @@ -13,38 +10,19 @@ Source Files - - Source Files - - + Source Files - - Detours - - - Detours - - - Detours - - - Detours - - - Source Files - - - Source Files - - - Source Files - + + + Source Files + + \ No newline at end of file diff --git a/SpotifyInternal/chrome_elf.def b/SpotifyInternal/chrome_elf.def new file mode 100644 index 0000000..9f4d7a4 --- /dev/null +++ b/SpotifyInternal/chrome_elf.def @@ -0,0 +1,30 @@ +LIBRARY "chrome_elf" + +EXPORTS +AddDllToBlacklist +ClearReportsBetween_ExportThunk +CrashForException_ExportThunk +DisableHook +DrainLog +DumpHungProcessWithPtype_ExportThunk +DumpProcessWithoutCrash +GetApplyHookResult +GetBlockedModulesCount +GetCrashReports_ExportThunk +GetCrashpadDatabasePath_ExportThunk +GetHandleVerifier +GetInstallDetailsPayload +GetUniqueBlockedModulesCount +GetUserDataDirectoryThunk +InjectDumpForHungInput_ExportThunk +IsBlacklistInitialized +IsCrashReportingEnabledImpl +IsThirdPartyInitialized +RegisterLogNotification +RequestSingleCrashUpload_ExportThunk +SetCrashKeyValueImpl +SetMetricsClientId +SetUploadConsent_ExportThunk +SignalChromeElf +SignalInitializeCrashReporting +SuccessfullyBlocked \ No newline at end of file diff --git a/SpotifyInternal/detours/include/detours.h b/SpotifyInternal/detours/include/detours.h deleted file mode 100644 index faff4fe..0000000 --- a/SpotifyInternal/detours/include/detours.h +++ /dev/null @@ -1,1075 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// Core Detours Functionality (detours.h of detours.lib) -// -// Microsoft Research Detours Package, Version 4.0.1 -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// - -#pragma once -#ifndef _DETOURS_H_ -#define _DETOURS_H_ - -#define DETOURS_VERSION 0x4c0c1 // 0xMAJORcMINORcPATCH - -////////////////////////////////////////////////////////////////////////////// -// - -#undef DETOURS_X64 -#undef DETOURS_X86 -#undef DETOURS_IA64 -#undef DETOURS_ARM -#undef DETOURS_ARM64 -#undef DETOURS_BITS -#undef DETOURS_32BIT -#undef DETOURS_64BIT - -#if defined(_X86_) -#define DETOURS_X86 -#define DETOURS_OPTION_BITS 64 - -#elif defined(_AMD64_) -#define DETOURS_X64 -#define DETOURS_OPTION_BITS 32 - -#elif defined(_IA64_) -#define DETOURS_IA64 -#define DETOURS_OPTION_BITS 32 - -#elif defined(_ARM_) -#define DETOURS_ARM - -#elif defined(_ARM64_) -#define DETOURS_ARM64 - -#else -#error Unknown architecture (x86, amd64, ia64, arm, arm64) -#endif - -#ifdef _WIN64 -#undef DETOURS_32BIT -#define DETOURS_64BIT 1 -#define DETOURS_BITS 64 -// If all 64bit kernels can run one and only one 32bit architecture. -//#define DETOURS_OPTION_BITS 32 -#else -#define DETOURS_32BIT 1 -#undef DETOURS_64BIT -#define DETOURS_BITS 32 -// If all 64bit kernels can run one and only one 32bit architecture. -//#define DETOURS_OPTION_BITS 32 -#endif - -#define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS) - -////////////////////////////////////////////////////////////////////////////// -// - -#if (_MSC_VER < 1299) -typedef LONG LONG_PTR; -typedef ULONG ULONG_PTR; -#endif - -///////////////////////////////////////////////// SAL 2.0 Annotations w/o SAL. -// -// These definitions are include so that Detours will build even if the -// compiler doesn't have full SAL 2.0 support. -// -#ifndef DETOURS_DONT_REMOVE_SAL_20 - -#ifdef DETOURS_TEST_REMOVE_SAL_20 -#undef _Analysis_assume_ -#undef _Benign_race_begin_ -#undef _Benign_race_end_ -#undef _Field_range_ -#undef _Field_size_ -#undef _In_ -#undef _In_bytecount_ -#undef _In_count_ -#undef _In_opt_ -#undef _In_opt_bytecount_ -#undef _In_opt_count_ -#undef _In_opt_z_ -#undef _In_range_ -#undef _In_reads_ -#undef _In_reads_bytes_ -#undef _In_reads_opt_ -#undef _In_reads_opt_bytes_ -#undef _In_reads_or_z_ -#undef _In_z_ -#undef _Inout_ -#undef _Inout_opt_ -#undef _Inout_z_count_ -#undef _Out_ -#undef _Out_opt_ -#undef _Out_writes_ -#undef _Outptr_result_maybenull_ -#undef _Readable_bytes_ -#undef _Success_ -#undef _Writable_bytes_ -#undef _Pre_notnull_ -#endif - -#if defined(_Deref_out_opt_z_) && !defined(_Outptr_result_maybenull_) -#define _Outptr_result_maybenull_ _Deref_out_opt_z_ -#endif - -#if defined(_In_count_) && !defined(_In_reads_) -#define _In_reads_(x) _In_count_(x) -#endif - -#if defined(_In_opt_count_) && !defined(_In_reads_opt_) -#define _In_reads_opt_(x) _In_opt_count_(x) -#endif - -#if defined(_In_opt_bytecount_) && !defined(_In_reads_opt_bytes_) -#define _In_reads_opt_bytes_(x) _In_opt_bytecount_(x) -#endif - -#if defined(_In_bytecount_) && !defined(_In_reads_bytes_) -#define _In_reads_bytes_(x) _In_bytecount_(x) -#endif - -#ifndef _In_ -#define _In_ -#endif - -#ifndef _In_bytecount_ -#define _In_bytecount_(x) -#endif - -#ifndef _In_count_ -#define _In_count_(x) -#endif - -#ifndef _In_opt_ -#define _In_opt_ -#endif - -#ifndef _In_opt_bytecount_ -#define _In_opt_bytecount_(x) -#endif - -#ifndef _In_opt_count_ -#define _In_opt_count_(x) -#endif - -#ifndef _In_opt_z_ -#define _In_opt_z_ -#endif - -#ifndef _In_range_ -#define _In_range_(x,y) -#endif - -#ifndef _In_reads_ -#define _In_reads_(x) -#endif - -#ifndef _In_reads_bytes_ -#define _In_reads_bytes_(x) -#endif - -#ifndef _In_reads_opt_ -#define _In_reads_opt_(x) -#endif - -#ifndef _In_reads_opt_bytes_ -#define _In_reads_opt_bytes_(x) -#endif - -#ifndef _In_reads_or_z_ -#define _In_reads_or_z_ -#endif - -#ifndef _In_z_ -#define _In_z_ -#endif - -#ifndef _Inout_ -#define _Inout_ -#endif - -#ifndef _Inout_opt_ -#define _Inout_opt_ -#endif - -#ifndef _Inout_z_count_ -#define _Inout_z_count_(x) -#endif - -#ifndef _Out_ -#define _Out_ -#endif - -#ifndef _Out_opt_ -#define _Out_opt_ -#endif - -#ifndef _Out_writes_ -#define _Out_writes_(x) -#endif - -#ifndef _Outptr_result_maybenull_ -#define _Outptr_result_maybenull_ -#endif - -#ifndef _Writable_bytes_ -#define _Writable_bytes_(x) -#endif - -#ifndef _Readable_bytes_ -#define _Readable_bytes_(x) -#endif - -#ifndef _Success_ -#define _Success_(x) -#endif - -#ifndef _Pre_notnull_ -#define _Pre_notnull_ -#endif - -#ifdef DETOURS_INTERNAL - -#pragma warning(disable:4615) // unknown warning type (suppress with older compilers) - -#ifndef _Benign_race_begin_ -#define _Benign_race_begin_ -#endif - -#ifndef _Benign_race_end_ -#define _Benign_race_end_ -#endif - -#ifndef _Field_size_ -#define _Field_size_(x) -#endif - -#ifndef _Field_range_ -#define _Field_range_(x,y) -#endif - -#ifndef _Analysis_assume_ -#define _Analysis_assume_(x) -#endif - -#endif // DETOURS_INTERNAL -#endif // DETOURS_DONT_REMOVE_SAL_20 - -////////////////////////////////////////////////////////////////////////////// -// -#ifndef GUID_DEFINED -#define GUID_DEFINED -typedef struct _GUID -{ - DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[ 8 ]; -} GUID; - -#ifdef INITGUID -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID name \ - = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -#else -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - const GUID name -#endif // INITGUID -#endif // !GUID_DEFINED - -#if defined(__cplusplus) -#ifndef _REFGUID_DEFINED -#define _REFGUID_DEFINED -#define REFGUID const GUID & -#endif // !_REFGUID_DEFINED -#else // !__cplusplus -#ifndef _REFGUID_DEFINED -#define _REFGUID_DEFINED -#define REFGUID const GUID * const -#endif // !_REFGUID_DEFINED -#endif // !__cplusplus - -#ifndef ARRAYSIZE -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) -#endif - -// -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/////////////////////////////////////////////////// Instruction Target Macros. -// -#define DETOUR_INSTRUCTION_TARGET_NONE ((PVOID)0) -#define DETOUR_INSTRUCTION_TARGET_DYNAMIC ((PVOID)(LONG_PTR)-1) -#define DETOUR_SECTION_HEADER_SIGNATURE 0x00727444 // "Dtr\0" - -extern const GUID DETOUR_EXE_RESTORE_GUID; -extern const GUID DETOUR_EXE_HELPER_GUID; - -#define DETOUR_TRAMPOLINE_SIGNATURE 0x21727444 // Dtr! -typedef struct _DETOUR_TRAMPOLINE DETOUR_TRAMPOLINE, *PDETOUR_TRAMPOLINE; - -/////////////////////////////////////////////////////////// Binary Structures. -// -#pragma pack(push, 8) -typedef struct _DETOUR_SECTION_HEADER -{ - DWORD cbHeaderSize; - DWORD nSignature; - DWORD nDataOffset; - DWORD cbDataSize; - - DWORD nOriginalImportVirtualAddress; - DWORD nOriginalImportSize; - DWORD nOriginalBoundImportVirtualAddress; - DWORD nOriginalBoundImportSize; - - DWORD nOriginalIatVirtualAddress; - DWORD nOriginalIatSize; - DWORD nOriginalSizeOfImage; - DWORD cbPrePE; - - DWORD nOriginalClrFlags; - DWORD reserved1; - DWORD reserved2; - DWORD reserved3; - - // Followed by cbPrePE bytes of data. -} DETOUR_SECTION_HEADER, *PDETOUR_SECTION_HEADER; - -typedef struct _DETOUR_SECTION_RECORD -{ - DWORD cbBytes; - DWORD nReserved; - GUID guid; -} DETOUR_SECTION_RECORD, *PDETOUR_SECTION_RECORD; - -typedef struct _DETOUR_CLR_HEADER -{ - // Header versioning - ULONG cb; - USHORT MajorRuntimeVersion; - USHORT MinorRuntimeVersion; - - // Symbol table and startup information - IMAGE_DATA_DIRECTORY MetaData; - ULONG Flags; - - // Followed by the rest of the IMAGE_COR20_HEADER -} DETOUR_CLR_HEADER, *PDETOUR_CLR_HEADER; - -typedef struct _DETOUR_EXE_RESTORE -{ - DWORD cb; - DWORD cbidh; - DWORD cbinh; - DWORD cbclr; - - PBYTE pidh; - PBYTE pinh; - PBYTE pclr; - - IMAGE_DOS_HEADER idh; - union { - IMAGE_NT_HEADERS inh; // all environments have this -#ifdef IMAGE_NT_OPTIONAL_HDR32_MAGIC // some environments do not have this - IMAGE_NT_HEADERS32 inh32; -#endif -#ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC // some environments do not have this - IMAGE_NT_HEADERS64 inh64; -#endif -#ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC // some environments do not have this - BYTE raw[sizeof(IMAGE_NT_HEADERS64) + - sizeof(IMAGE_SECTION_HEADER) * 32]; - C_ASSERT(sizeof(IMAGE_NT_HEADERS64) == 0x108); -#else - BYTE raw[0x108 + sizeof(IMAGE_SECTION_HEADER) * 32]; -#endif - }; - DETOUR_CLR_HEADER clr; - -} DETOUR_EXE_RESTORE, *PDETOUR_EXE_RESTORE; - -// The size can change, but assert for clarity due to the muddying #ifdefs. -#ifdef _WIN64 -C_ASSERT(sizeof(DETOUR_EXE_RESTORE) == 0x688); -#else -C_ASSERT(sizeof(DETOUR_EXE_RESTORE) == 0x678); -#endif - -typedef struct _DETOUR_EXE_HELPER -{ - DWORD cb; - DWORD pid; - DWORD nDlls; - CHAR rDlls[4]; -} DETOUR_EXE_HELPER, *PDETOUR_EXE_HELPER; - -#pragma pack(pop) - -#define DETOUR_SECTION_HEADER_DECLARE(cbSectionSize) \ -{ \ - sizeof(DETOUR_SECTION_HEADER),\ - DETOUR_SECTION_HEADER_SIGNATURE,\ - sizeof(DETOUR_SECTION_HEADER),\ - (cbSectionSize),\ - \ - 0,\ - 0,\ - 0,\ - 0,\ - \ - 0,\ - 0,\ - 0,\ - 0,\ -} - -/////////////////////////////////////////////////////////////// Helper Macros. -// -#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) -#define DETOURS_STRINGIFY_(x) #x - -///////////////////////////////////////////////////////////// Binary Typedefs. -// -typedef BOOL (CALLBACK *PF_DETOUR_BINARY_BYWAY_CALLBACK)( - _In_opt_ PVOID pContext, - _In_opt_ LPCSTR pszFile, - _Outptr_result_maybenull_ LPCSTR *ppszOutFile); - -typedef BOOL (CALLBACK *PF_DETOUR_BINARY_FILE_CALLBACK)( - _In_opt_ PVOID pContext, - _In_ LPCSTR pszOrigFile, - _In_ LPCSTR pszFile, - _Outptr_result_maybenull_ LPCSTR *ppszOutFile); - -typedef BOOL (CALLBACK *PF_DETOUR_BINARY_SYMBOL_CALLBACK)( - _In_opt_ PVOID pContext, - _In_ ULONG nOrigOrdinal, - _In_ ULONG nOrdinal, - _Out_ ULONG *pnOutOrdinal, - _In_opt_ LPCSTR pszOrigSymbol, - _In_opt_ LPCSTR pszSymbol, - _Outptr_result_maybenull_ LPCSTR *ppszOutSymbol); - -typedef BOOL (CALLBACK *PF_DETOUR_BINARY_COMMIT_CALLBACK)( - _In_opt_ PVOID pContext); - -typedef BOOL (CALLBACK *PF_DETOUR_ENUMERATE_EXPORT_CALLBACK)(_In_opt_ PVOID pContext, - _In_ ULONG nOrdinal, - _In_opt_ LPCSTR pszName, - _In_opt_ PVOID pCode); - -typedef BOOL (CALLBACK *PF_DETOUR_IMPORT_FILE_CALLBACK)(_In_opt_ PVOID pContext, - _In_opt_ HMODULE hModule, - _In_opt_ LPCSTR pszFile); - -typedef BOOL (CALLBACK *PF_DETOUR_IMPORT_FUNC_CALLBACK)(_In_opt_ PVOID pContext, - _In_ DWORD nOrdinal, - _In_opt_ LPCSTR pszFunc, - _In_opt_ PVOID pvFunc); - -// Same as PF_DETOUR_IMPORT_FUNC_CALLBACK but extra indirection on last parameter. -typedef BOOL (CALLBACK *PF_DETOUR_IMPORT_FUNC_CALLBACK_EX)(_In_opt_ PVOID pContext, - _In_ DWORD nOrdinal, - _In_opt_ LPCSTR pszFunc, - _In_opt_ PVOID* ppvFunc); - -typedef VOID * PDETOUR_BINARY; -typedef VOID * PDETOUR_LOADED_BINARY; - -//////////////////////////////////////////////////////////// Transaction APIs. -// -LONG WINAPI DetourTransactionBegin(VOID); -LONG WINAPI DetourTransactionAbort(VOID); -LONG WINAPI DetourTransactionCommit(VOID); -LONG WINAPI DetourTransactionCommitEx(_Out_opt_ PVOID **pppFailedPointer); - -LONG WINAPI DetourUpdateThread(_In_ HANDLE hThread); - -LONG WINAPI DetourAttach(_Inout_ PVOID *ppPointer, - _In_ PVOID pDetour); - -LONG WINAPI DetourAttachEx(_Inout_ PVOID *ppPointer, - _In_ PVOID pDetour, - _Out_opt_ PDETOUR_TRAMPOLINE *ppRealTrampoline, - _Out_opt_ PVOID *ppRealTarget, - _Out_opt_ PVOID *ppRealDetour); - -LONG WINAPI DetourDetach(_Inout_ PVOID *ppPointer, - _In_ PVOID pDetour); - -BOOL WINAPI DetourSetIgnoreTooSmall(_In_ BOOL fIgnore); -BOOL WINAPI DetourSetRetainRegions(_In_ BOOL fRetain); -PVOID WINAPI DetourSetSystemRegionLowerBound(_In_ PVOID pSystemRegionLowerBound); -PVOID WINAPI DetourSetSystemRegionUpperBound(_In_ PVOID pSystemRegionUpperBound); - -////////////////////////////////////////////////////////////// Code Functions. -// -PVOID WINAPI DetourFindFunction(_In_ LPCSTR pszModule, - _In_ LPCSTR pszFunction); -PVOID WINAPI DetourCodeFromPointer(_In_ PVOID pPointer, - _Out_opt_ PVOID *ppGlobals); -PVOID WINAPI DetourCopyInstruction(_In_opt_ PVOID pDst, - _Inout_opt_ PVOID *ppDstPool, - _In_ PVOID pSrc, - _Out_opt_ PVOID *ppTarget, - _Out_opt_ LONG *plExtra); -BOOL WINAPI DetourSetCodeModule(_In_ HMODULE hModule, - _In_ BOOL fLimitReferencesToModule); - -///////////////////////////////////////////////////// Loaded Binary Functions. -// -HMODULE WINAPI DetourGetContainingModule(_In_ PVOID pvAddr); -HMODULE WINAPI DetourEnumerateModules(_In_opt_ HMODULE hModuleLast); -PVOID WINAPI DetourGetEntryPoint(_In_opt_ HMODULE hModule); -ULONG WINAPI DetourGetModuleSize(_In_opt_ HMODULE hModule); -BOOL WINAPI DetourEnumerateExports(_In_ HMODULE hModule, - _In_opt_ PVOID pContext, - _In_ PF_DETOUR_ENUMERATE_EXPORT_CALLBACK pfExport); -BOOL WINAPI DetourEnumerateImports(_In_opt_ HMODULE hModule, - _In_opt_ PVOID pContext, - _In_opt_ PF_DETOUR_IMPORT_FILE_CALLBACK pfImportFile, - _In_opt_ PF_DETOUR_IMPORT_FUNC_CALLBACK pfImportFunc); - -BOOL WINAPI DetourEnumerateImportsEx(_In_opt_ HMODULE hModule, - _In_opt_ PVOID pContext, - _In_opt_ PF_DETOUR_IMPORT_FILE_CALLBACK pfImportFile, - _In_opt_ PF_DETOUR_IMPORT_FUNC_CALLBACK_EX pfImportFuncEx); - -_Writable_bytes_(*pcbData) -_Readable_bytes_(*pcbData) -_Success_(return != NULL) -PVOID WINAPI DetourFindPayload(_In_opt_ HMODULE hModule, - _In_ REFGUID rguid, - _Out_ DWORD *pcbData); - -_Writable_bytes_(*pcbData) -_Readable_bytes_(*pcbData) -_Success_(return != NULL) -PVOID WINAPI DetourFindPayloadEx(_In_ REFGUID rguid, - _Out_ DWORD * pcbData); - -DWORD WINAPI DetourGetSizeOfPayloads(_In_opt_ HMODULE hModule); - -///////////////////////////////////////////////// Persistent Binary Functions. -// - -PDETOUR_BINARY WINAPI DetourBinaryOpen(_In_ HANDLE hFile); - -_Writable_bytes_(*pcbData) -_Readable_bytes_(*pcbData) -_Success_(return != NULL) -PVOID WINAPI DetourBinaryEnumeratePayloads(_In_ PDETOUR_BINARY pBinary, - _Out_opt_ GUID *pGuid, - _Out_ DWORD *pcbData, - _Inout_ DWORD *pnIterator); - -_Writable_bytes_(*pcbData) -_Readable_bytes_(*pcbData) -_Success_(return != NULL) -PVOID WINAPI DetourBinaryFindPayload(_In_ PDETOUR_BINARY pBinary, - _In_ REFGUID rguid, - _Out_ DWORD *pcbData); - -PVOID WINAPI DetourBinarySetPayload(_In_ PDETOUR_BINARY pBinary, - _In_ REFGUID rguid, - _In_reads_opt_(cbData) PVOID pData, - _In_ DWORD cbData); -BOOL WINAPI DetourBinaryDeletePayload(_In_ PDETOUR_BINARY pBinary, _In_ REFGUID rguid); -BOOL WINAPI DetourBinaryPurgePayloads(_In_ PDETOUR_BINARY pBinary); -BOOL WINAPI DetourBinaryResetImports(_In_ PDETOUR_BINARY pBinary); -BOOL WINAPI DetourBinaryEditImports(_In_ PDETOUR_BINARY pBinary, - _In_opt_ PVOID pContext, - _In_opt_ PF_DETOUR_BINARY_BYWAY_CALLBACK pfByway, - _In_opt_ PF_DETOUR_BINARY_FILE_CALLBACK pfFile, - _In_opt_ PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbol, - _In_opt_ PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommit); -BOOL WINAPI DetourBinaryWrite(_In_ PDETOUR_BINARY pBinary, _In_ HANDLE hFile); -BOOL WINAPI DetourBinaryClose(_In_ PDETOUR_BINARY pBinary); - -/////////////////////////////////////////////////// Create Process & Load Dll. -// -typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEA)( - _In_opt_ LPCSTR lpApplicationName, - _Inout_opt_ LPSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOA lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation); - -typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEW)( - _In_opt_ LPCWSTR lpApplicationName, - _Inout_opt_ LPWSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCWSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOW lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation); - -BOOL WINAPI DetourCreateProcessWithDllA(_In_opt_ LPCSTR lpApplicationName, - _Inout_opt_ LPSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOA lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation, - _In_ LPCSTR lpDllName, - _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA); - -BOOL WINAPI DetourCreateProcessWithDllW(_In_opt_ LPCWSTR lpApplicationName, - _Inout_opt_ LPWSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCWSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOW lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation, - _In_ LPCSTR lpDllName, - _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); - -#ifdef UNICODE -#define DetourCreateProcessWithDll DetourCreateProcessWithDllW -#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEW -#else -#define DetourCreateProcessWithDll DetourCreateProcessWithDllA -#define PDETOUR_CREATE_PROCESS_ROUTINE PDETOUR_CREATE_PROCESS_ROUTINEA -#endif // !UNICODE - -BOOL WINAPI DetourCreateProcessWithDllExA(_In_opt_ LPCSTR lpApplicationName, - _Inout_opt_ LPSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOA lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation, - _In_ LPCSTR lpDllName, - _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA); - -BOOL WINAPI DetourCreateProcessWithDllExW(_In_opt_ LPCWSTR lpApplicationName, - _Inout_opt_ LPWSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCWSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOW lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation, - _In_ LPCSTR lpDllName, - _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); - -#ifdef UNICODE -#define DetourCreateProcessWithDllEx DetourCreateProcessWithDllExW -#else -#define DetourCreateProcessWithDllEx DetourCreateProcessWithDllExA -#endif // !UNICODE - -BOOL WINAPI DetourCreateProcessWithDllsA(_In_opt_ LPCSTR lpApplicationName, - _Inout_opt_ LPSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOA lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation, - _In_ DWORD nDlls, - _In_reads_(nDlls) LPCSTR *rlpDlls, - _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA); - -BOOL WINAPI DetourCreateProcessWithDllsW(_In_opt_ LPCWSTR lpApplicationName, - _Inout_opt_ LPWSTR lpCommandLine, - _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, - _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, - _In_ BOOL bInheritHandles, - _In_ DWORD dwCreationFlags, - _In_opt_ LPVOID lpEnvironment, - _In_opt_ LPCWSTR lpCurrentDirectory, - _In_ LPSTARTUPINFOW lpStartupInfo, - _Out_ LPPROCESS_INFORMATION lpProcessInformation, - _In_ DWORD nDlls, - _In_reads_(nDlls) LPCSTR *rlpDlls, - _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); - -#ifdef UNICODE -#define DetourCreateProcessWithDlls DetourCreateProcessWithDllsW -#else -#define DetourCreateProcessWithDlls DetourCreateProcessWithDllsA -#endif // !UNICODE - -BOOL WINAPI DetourProcessViaHelperA(_In_ DWORD dwTargetPid, - _In_ LPCSTR lpDllName, - _In_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA); - -BOOL WINAPI DetourProcessViaHelperW(_In_ DWORD dwTargetPid, - _In_ LPCSTR lpDllName, - _In_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); - -#ifdef UNICODE -#define DetourProcessViaHelper DetourProcessViaHelperW -#else -#define DetourProcessViaHelper DetourProcessViaHelperA -#endif // !UNICODE - -BOOL WINAPI DetourProcessViaHelperDllsA(_In_ DWORD dwTargetPid, - _In_ DWORD nDlls, - _In_reads_(nDlls) LPCSTR *rlpDlls, - _In_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA); - -BOOL WINAPI DetourProcessViaHelperDllsW(_In_ DWORD dwTargetPid, - _In_ DWORD nDlls, - _In_reads_(nDlls) LPCSTR *rlpDlls, - _In_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); - -#ifdef UNICODE -#define DetourProcessViaHelperDlls DetourProcessViaHelperDllsW -#else -#define DetourProcessViaHelperDlls DetourProcessViaHelperDllsA -#endif // !UNICODE - -BOOL WINAPI DetourUpdateProcessWithDll(_In_ HANDLE hProcess, - _In_reads_(nDlls) LPCSTR *rlpDlls, - _In_ DWORD nDlls); - -BOOL WINAPI DetourUpdateProcessWithDllEx(_In_ HANDLE hProcess, - _In_ HMODULE hImage, - _In_ BOOL bIs32Bit, - _In_reads_(nDlls) LPCSTR *rlpDlls, - _In_ DWORD nDlls); - -BOOL WINAPI DetourCopyPayloadToProcess(_In_ HANDLE hProcess, - _In_ REFGUID rguid, - _In_reads_bytes_(cbData) PVOID pvData, - _In_ DWORD cbData); -BOOL WINAPI DetourRestoreAfterWith(VOID); -BOOL WINAPI DetourRestoreAfterWithEx(_In_reads_bytes_(cbData) PVOID pvData, - _In_ DWORD cbData); -BOOL WINAPI DetourIsHelperProcess(VOID); -VOID CALLBACK DetourFinishHelperProcess(_In_ HWND, - _In_ HINSTANCE, - _In_ LPSTR, - _In_ INT); - -// -////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -} -#endif // __cplusplus - -//////////////////////////////////////////////// Detours Internal Definitions. -// -#ifdef __cplusplus -#ifdef DETOURS_INTERNAL - -#define NOTHROW -// #define NOTHROW (nothrow) - -////////////////////////////////////////////////////////////////////////////// -// -#if (_MSC_VER < 1299) -#include -typedef IMAGEHLP_MODULE IMAGEHLP_MODULE64; -typedef PIMAGEHLP_MODULE PIMAGEHLP_MODULE64; -typedef IMAGEHLP_SYMBOL SYMBOL_INFO; -typedef PIMAGEHLP_SYMBOL PSYMBOL_INFO; - -static inline -LONG InterlockedCompareExchange(_Inout_ LONG *ptr, _In_ LONG nval, _In_ LONG oval) -{ - return (LONG)::InterlockedCompareExchange((PVOID*)ptr, (PVOID)nval, (PVOID)oval); -} -#else -#pragma warning(push) -#pragma warning(disable:4091) // empty typedef -#include -#pragma warning(pop) -#endif - -#ifdef IMAGEAPI // defined by DBGHELP.H -typedef LPAPI_VERSION (NTAPI *PF_ImagehlpApiVersionEx)(_In_ LPAPI_VERSION AppVersion); - -typedef BOOL (NTAPI *PF_SymInitialize)(_In_ HANDLE hProcess, - _In_opt_ LPCSTR UserSearchPath, - _In_ BOOL fInvadeProcess); -typedef DWORD (NTAPI *PF_SymSetOptions)(_In_ DWORD SymOptions); -typedef DWORD (NTAPI *PF_SymGetOptions)(VOID); -typedef DWORD64 (NTAPI *PF_SymLoadModule64)(_In_ HANDLE hProcess, - _In_opt_ HANDLE hFile, - _In_ LPSTR ImageName, - _In_opt_ LPSTR ModuleName, - _In_ DWORD64 BaseOfDll, - _In_opt_ DWORD SizeOfDll); -typedef BOOL (NTAPI *PF_SymGetModuleInfo64)(_In_ HANDLE hProcess, - _In_ DWORD64 qwAddr, - _Out_ PIMAGEHLP_MODULE64 ModuleInfo); -typedef BOOL (NTAPI *PF_SymFromName)(_In_ HANDLE hProcess, - _In_ LPSTR Name, - _Out_ PSYMBOL_INFO Symbol); - -typedef struct _DETOUR_SYM_INFO -{ - HANDLE hProcess; - HMODULE hDbgHelp; - PF_ImagehlpApiVersionEx pfImagehlpApiVersionEx; - PF_SymInitialize pfSymInitialize; - PF_SymSetOptions pfSymSetOptions; - PF_SymGetOptions pfSymGetOptions; - PF_SymLoadModule64 pfSymLoadModule64; - PF_SymGetModuleInfo64 pfSymGetModuleInfo64; - PF_SymFromName pfSymFromName; -} DETOUR_SYM_INFO, *PDETOUR_SYM_INFO; - -PDETOUR_SYM_INFO DetourLoadImageHlp(VOID); - -#endif // IMAGEAPI - -#if defined(_INC_STDIO) && !defined(_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS) -#error detours.h must be included before stdio.h (or at least define _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS earlier) -#endif -#define _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS 1 - -#ifndef DETOUR_TRACE -#if DETOUR_DEBUG -#define DETOUR_TRACE(x) printf x -#define DETOUR_BREAK() __debugbreak() -#include -#include -#else -#define DETOUR_TRACE(x) -#define DETOUR_BREAK() -#endif -#endif - -#if 1 || defined(DETOURS_IA64) - -// -// IA64 instructions are 41 bits, 3 per bundle, plus 5 bit bundle template => 128 bits per bundle. -// - -#define DETOUR_IA64_INSTRUCTIONS_PER_BUNDLE (3) - -#define DETOUR_IA64_TEMPLATE_OFFSET (0) -#define DETOUR_IA64_TEMPLATE_SIZE (5) - -#define DETOUR_IA64_INSTRUCTION_SIZE (41) -#define DETOUR_IA64_INSTRUCTION0_OFFSET (DETOUR_IA64_TEMPLATE_SIZE) -#define DETOUR_IA64_INSTRUCTION1_OFFSET (DETOUR_IA64_TEMPLATE_SIZE + DETOUR_IA64_INSTRUCTION_SIZE) -#define DETOUR_IA64_INSTRUCTION2_OFFSET (DETOUR_IA64_TEMPLATE_SIZE + DETOUR_IA64_INSTRUCTION_SIZE + DETOUR_IA64_INSTRUCTION_SIZE) - -C_ASSERT(DETOUR_IA64_TEMPLATE_SIZE + DETOUR_IA64_INSTRUCTIONS_PER_BUNDLE * DETOUR_IA64_INSTRUCTION_SIZE == 128); - -__declspec(align(16)) struct DETOUR_IA64_BUNDLE -{ - public: - union - { - BYTE data[16]; - UINT64 wide[2]; - }; - - enum { - A_UNIT = 1u, - I_UNIT = 2u, - M_UNIT = 3u, - B_UNIT = 4u, - F_UNIT = 5u, - L_UNIT = 6u, - X_UNIT = 7u, - }; - struct DETOUR_IA64_METADATA - { - ULONG nTemplate : 8; // Instruction template. - ULONG nUnit0 : 4; // Unit for slot 0 - ULONG nUnit1 : 4; // Unit for slot 1 - ULONG nUnit2 : 4; // Unit for slot 2 - }; - - protected: - static const DETOUR_IA64_METADATA s_rceCopyTable[33]; - - UINT RelocateBundle(_Inout_ DETOUR_IA64_BUNDLE* pDst, _Inout_opt_ DETOUR_IA64_BUNDLE* pBundleExtra) const; - - bool RelocateInstruction(_Inout_ DETOUR_IA64_BUNDLE* pDst, - _In_ BYTE slot, - _Inout_opt_ DETOUR_IA64_BUNDLE* pBundleExtra) const; - - // 120 112 104 96 88 80 72 64 56 48 40 32 24 16 8 0 - // f. e. d. c. b. a. 9. 8. 7. 6. 5. 4. 3. 2. 1. 0. - - // 00 - // f.e. d.c. b.a. 9.8. 7.6. 5.4. 3.2. 1.0. - // 0000 0000 0000 0000 0000 0000 0000 001f : Template [4..0] - // 0000 0000 0000 0000 0000 03ff ffff ffe0 : Zero [ 41.. 5] - // 0000 0000 0000 0000 0000 3c00 0000 0000 : Zero [ 45.. 42] - // 0000 0000 0007 ffff ffff c000 0000 0000 : One [ 82.. 46] - // 0000 0000 0078 0000 0000 0000 0000 0000 : One [ 86.. 83] - // 0fff ffff ff80 0000 0000 0000 0000 0000 : Two [123.. 87] - // f000 0000 0000 0000 0000 0000 0000 0000 : Two [127..124] - BYTE GetTemplate() const; - // Get 4 bit opcodes. - BYTE GetInst0() const; - BYTE GetInst1() const; - BYTE GetInst2() const; - BYTE GetUnit(BYTE slot) const; - BYTE GetUnit0() const; - BYTE GetUnit1() const; - BYTE GetUnit2() const; - // Get 37 bit data. - UINT64 GetData0() const; - UINT64 GetData1() const; - UINT64 GetData2() const; - - // Get/set the full 41 bit instructions. - UINT64 GetInstruction(BYTE slot) const; - UINT64 GetInstruction0() const; - UINT64 GetInstruction1() const; - UINT64 GetInstruction2() const; - void SetInstruction(BYTE slot, UINT64 instruction); - void SetInstruction0(UINT64 instruction); - void SetInstruction1(UINT64 instruction); - void SetInstruction2(UINT64 instruction); - - // Get/set bitfields. - static UINT64 GetBits(UINT64 Value, UINT64 Offset, UINT64 Count); - static UINT64 SetBits(UINT64 Value, UINT64 Offset, UINT64 Count, UINT64 Field); - - // Get specific read-only fields. - static UINT64 GetOpcode(UINT64 instruction); // 4bit opcode - static UINT64 GetX(UINT64 instruction); // 1bit opcode extension - static UINT64 GetX3(UINT64 instruction); // 3bit opcode extension - static UINT64 GetX6(UINT64 instruction); // 6bit opcode extension - - // Get/set specific fields. - static UINT64 GetImm7a(UINT64 instruction); - static UINT64 SetImm7a(UINT64 instruction, UINT64 imm7a); - static UINT64 GetImm13c(UINT64 instruction); - static UINT64 SetImm13c(UINT64 instruction, UINT64 imm13c); - static UINT64 GetSignBit(UINT64 instruction); - static UINT64 SetSignBit(UINT64 instruction, UINT64 signBit); - static UINT64 GetImm20a(UINT64 instruction); - static UINT64 SetImm20a(UINT64 instruction, UINT64 imm20a); - static UINT64 GetImm20b(UINT64 instruction); - static UINT64 SetImm20b(UINT64 instruction, UINT64 imm20b); - - static UINT64 SignExtend(UINT64 Value, UINT64 Offset); - - BOOL IsMovlGp() const; - - VOID SetInst(BYTE Slot, BYTE nInst); - VOID SetInst0(BYTE nInst); - VOID SetInst1(BYTE nInst); - VOID SetInst2(BYTE nInst); - VOID SetData(BYTE Slot, UINT64 nData); - VOID SetData0(UINT64 nData); - VOID SetData1(UINT64 nData); - VOID SetData2(UINT64 nData); - BOOL SetNop(BYTE Slot); - BOOL SetNop0(); - BOOL SetNop1(); - BOOL SetNop2(); - - public: - BOOL IsBrl() const; - VOID SetBrl(); - VOID SetBrl(UINT64 target); - UINT64 GetBrlTarget() const; - VOID SetBrlTarget(UINT64 target); - VOID SetBrlImm(UINT64 imm); - UINT64 GetBrlImm() const; - - UINT64 GetMovlGp() const; - VOID SetMovlGp(UINT64 gp); - - VOID SetStop(); - - UINT Copy(_Out_ DETOUR_IA64_BUNDLE *pDst, _Inout_opt_ DETOUR_IA64_BUNDLE* pBundleExtra = NULL) const; -}; -#endif // DETOURS_IA64 - -#ifdef DETOURS_ARM - -#define DETOURS_PFUNC_TO_PBYTE(p) ((PBYTE)(((ULONG_PTR)(p)) & ~(ULONG_PTR)1)) -#define DETOURS_PBYTE_TO_PFUNC(p) ((PBYTE)(((ULONG_PTR)(p)) | (ULONG_PTR)1)) - -#endif // DETOURS_ARM - -////////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#define DETOUR_OFFLINE_LIBRARY(x) \ -PVOID WINAPI DetourCopyInstruction##x(_In_opt_ PVOID pDst, \ - _Inout_opt_ PVOID *ppDstPool, \ - _In_ PVOID pSrc, \ - _Out_opt_ PVOID *ppTarget, \ - _Out_opt_ LONG *plExtra); \ - \ -BOOL WINAPI DetourSetCodeModule##x(_In_ HMODULE hModule, \ - _In_ BOOL fLimitReferencesToModule); \ - -DETOUR_OFFLINE_LIBRARY(X86) -DETOUR_OFFLINE_LIBRARY(X64) -DETOUR_OFFLINE_LIBRARY(ARM) -DETOUR_OFFLINE_LIBRARY(ARM64) -DETOUR_OFFLINE_LIBRARY(IA64) - -#undef DETOUR_OFFLINE_LIBRARY - -////////////////////////////////////////////////////////////////////////////// -// -// Helpers for manipulating page protection. -// - -_Success_(return != FALSE) -BOOL WINAPI DetourVirtualProtectSameExecuteEx(_In_ HANDLE hProcess, - _In_ PVOID pAddress, - _In_ SIZE_T nSize, - _In_ DWORD dwNewProtect, - _Out_ PDWORD pdwOldProtect); - -_Success_(return != FALSE) -BOOL WINAPI DetourVirtualProtectSameExecute(_In_ PVOID pAddress, - _In_ SIZE_T nSize, - _In_ DWORD dwNewProtect, - _Out_ PDWORD pdwOldProtect); -#ifdef __cplusplus -} -#endif // __cplusplus - -////////////////////////////////////////////////////////////////////////////// - -#define MM_ALLOCATION_GRANULARITY 0x10000 - -////////////////////////////////////////////////////////////////////////////// - -#endif // DETOURS_INTERNAL -#endif // __cplusplus - -#endif // _DETOURS_H_ -// -//////////////////////////////////////////////////////////////// End of File. diff --git a/SpotifyInternal/detours/include/detver.h b/SpotifyInternal/detours/include/detver.h deleted file mode 100644 index f0aae9b..0000000 --- a/SpotifyInternal/detours/include/detver.h +++ /dev/null @@ -1,27 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Common version parameters. -// -// Microsoft Research Detours Package, Version 4.0.1 -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// - -#define _USING_V110_SDK71_ 1 -#include "winver.h" -#if 0 -#include -#include -#else -#ifndef DETOURS_STRINGIFY -#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) -#define DETOURS_STRINGIFY_(x) #x -#endif - -#define VER_FILEFLAGSMASK 0x3fL -#define VER_FILEFLAGS 0x0L -#define VER_FILEOS 0x00040004L -#define VER_FILETYPE 0x00000002L -#define VER_FILESUBTYPE 0x00000000L -#endif -#define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS) diff --git a/SpotifyInternal/detours/include/syelog.h b/SpotifyInternal/detours/include/syelog.h deleted file mode 100644 index 7cfa9f3..0000000 --- a/SpotifyInternal/detours/include/syelog.h +++ /dev/null @@ -1,89 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Detours Test Program (syelog.h of syelog.lib) -// -// Microsoft Research Detours Package -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -#pragma once -#ifndef _SYELOGD_H_ -#define _SYELOGD_H_ -#include - -#pragma pack(push, 1) -#pragma warning(push) -#pragma warning(disable: 4200) - -////////////////////////////////////////////////////////////////////////////// -// -// -#define SYELOG_PIPE_NAMEA "\\\\.\\pipe\\syelog" -#define SYELOG_PIPE_NAMEW L"\\\\.\\pipe\\syelog" -#ifdef UNICODE -#define SYELOG_PIPE_NAME SYELOG_PIPE_NAMEW -#else -#define SYELOG_PIPE_NAME SYELOG_PIPE_NAMEA -#endif - -////////////////////////////////////////////////////////////////////////////// -// -#define SYELOG_MAXIMUM_MESSAGE 4086 // 4096 - sizeof(header stuff) - -typedef struct _SYELOG_MESSAGE -{ - USHORT nBytes; - BYTE nFacility; - BYTE nSeverity; - DWORD nProcessId; - FILETIME ftOccurance; - BOOL fTerminate; - CHAR szMessage[SYELOG_MAXIMUM_MESSAGE]; -} SYELOG_MESSAGE, *PSYELOG_MESSAGE; - - -// Facility Codes. -// -#define SYELOG_FACILITY_KERNEL 0x10 // OS Kernel -#define SYELOG_FACILITY_SECURITY 0x20 // OS Security -#define SYELOG_FACILITY_LOGGING 0x30 // OS Logging-internal -#define SYELOG_FACILITY_SERVICE 0x40 // User-mode system daemon -#define SYELOG_FACILITY_APPLICATION 0x50 // User-mode application -#define SYELOG_FACILITY_USER 0x60 // User self-generated. -#define SYELOG_FACILITY_LOCAL0 0x70 // Locally defined. -#define SYELOG_FACILITY_LOCAL1 0x71 // Locally defined. -#define SYELOG_FACILITY_LOCAL2 0x72 // Locally defined. -#define SYELOG_FACILITY_LOCAL3 0x73 // Locally defined. -#define SYELOG_FACILITY_LOCAL4 0x74 // Locally defined. -#define SYELOG_FACILITY_LOCAL5 0x75 // Locally defined. -#define SYELOG_FACILITY_LOCAL6 0x76 // Locally defined. -#define SYELOG_FACILITY_LOCAL7 0x77 // Locally defined. -#define SYELOG_FACILITY_LOCAL8 0x78 // Locally defined. -#define SYELOG_FACILITY_LOCAL9 0x79 // Locally defined. - -// Severity Codes. -// -#define SYELOG_SEVERITY_FATAL 0x00 // System is dead. -#define SYELOG_SEVERITY_ALERT 0x10 // Take action immediately. -#define SYELOG_SEVERITY_CRITICAL 0x20 // Critical condition. -#define SYELOG_SEVERITY_ERROR 0x30 // Error -#define SYELOG_SEVERITY_WARNING 0x40 // Warning -#define SYELOG_SEVERITY_NOTICE 0x50 // Significant condition. -#define SYELOG_SEVERITY_INFORMATION 0x60 // Informational -#define SYELOG_SEVERITY_AUDIT_FAIL 0x66 // Audit Failed -#define SYELOG_SEVERITY_AUDIT_PASS 0x67 // Audit Succeeeded -#define SYELOG_SEVERITY_DEBUG 0x70 // Debugging - -// Logging Functions. -// -VOID SyelogOpen(PCSTR pszIdentifier, BYTE nFacility); -VOID Syelog(BYTE nSeverity, PCSTR pszMsgf, ...); -VOID SyelogV(BYTE nSeverity, PCSTR pszMsgf, va_list args); -VOID SyelogClose(BOOL fTerminate); - -#pragma warning(pop) -#pragma pack(pop) - -#endif // _SYELOGD_H_ -// -///////////////////////////////////////////////////////////////// End of File. diff --git a/SpotifyInternal/detours/include/uniHook.hpp b/SpotifyInternal/detours/include/uniHook.hpp deleted file mode 100644 index eb94685..0000000 --- a/SpotifyInternal/detours/include/uniHook.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once -#include -#include -#include -#include -#if _WIN64 -#pragma comment(lib, "detours.lib") -#else -#pragma comment(lib, "detours.lib") -#endif -using namespace std; -enum hkType -{ - MS_Detour, - MinHook, - Simple -}; -namespace hk -{ - - template - bool apply_detour(D detour, T & address_o) - { - const auto p_detour = reinterpret_cast(detour); - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourAttach(&reinterpret_cast(address_o), p_detour); - DetourTransactionCommit(); - return true; - } - template - bool rem_detour(D detour, T & address_o) - { - const auto p_detour = reinterpret_cast(detour); - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourDetach(&reinterpret_cast(address_o), p_detour); - DetourTransactionCommit(); - return true; - } - template - bool apply_vtable(T v_table, V v_detour, PVOID * original) - { - auto ret = false; - auto const change_this = reinterpret_cast(v_table); - *original = reinterpret_cast(change_this[0]); - DWORD p = 0; - if (VirtualProtect(change_this, 0x100, PAGE_EXECUTE_READWRITE, &p)) - { - change_this[0] = uintptr_t(v_detour); - ret = true; - VirtualProtect(change_this, 0x100, p, &p); - } - return ret; - } - -}; \ No newline at end of file diff --git a/SpotifyInternal/dllmain.cpp b/SpotifyInternal/dllmain.cpp index 88eb65d..8749f42 100644 --- a/SpotifyInternal/dllmain.cpp +++ b/SpotifyInternal/dllmain.cpp @@ -1,147 +1,54 @@ -#include -#include -#include -#include +#include #include -#include -#include -#include "utils.hpp" -#include "Spotify.hpp" - -void __stdcall load_api(LPVOID* destination, LPCSTR api_name) noexcept; - -#define API_EXPORT_ORIG(N) \ - static LPVOID _##N = NULL; \ - char S_##N[] = "" # N; \ - extern "C" __declspec(dllexport) __declspec(naked) void N ## () \ - { \ - __asm pushad \ - __asm push offset S_##N \ - __asm push offset _##N \ - __asm call load_api \ - __asm popad \ - __asm jmp [_##N] \ - } \ - -API_EXPORT_ORIG(ClearReportsBetween_ExportThunk) -API_EXPORT_ORIG(CrashForException_ExportThunk) -API_EXPORT_ORIG(DisableHook) -API_EXPORT_ORIG(DrainLog) -API_EXPORT_ORIG(DumpHungProcessWithPtype_ExportThunk) -API_EXPORT_ORIG(DumpProcessWithoutCrash) -API_EXPORT_ORIG(GetApplyHookResult) -API_EXPORT_ORIG(GetBlockedModulesCount) -API_EXPORT_ORIG(GetCrashReports_ExportThunk) -API_EXPORT_ORIG(GetCrashpadDatabasePath_ExportThunk) -API_EXPORT_ORIG(GetHandleVerifier) -API_EXPORT_ORIG(GetInstallDetailsPayload) -API_EXPORT_ORIG(GetUniqueBlockedModulesCount) -API_EXPORT_ORIG(GetUserDataDirectoryThunk) -API_EXPORT_ORIG(InjectDumpForHungInput_ExportThunk) -API_EXPORT_ORIG(IsBrowserProcess) -API_EXPORT_ORIG(IsCrashReportingEnabledImpl) -API_EXPORT_ORIG(IsThirdPartyInitialized) -API_EXPORT_ORIG(RegisterLogNotification) -API_EXPORT_ORIG(RequestSingleCrashUpload_ExportThunk) -API_EXPORT_ORIG(SetCrashKeyValueImpl) -API_EXPORT_ORIG(SetMetricsClientId) -API_EXPORT_ORIG(SetUploadConsent_ExportThunk) -API_EXPORT_ORIG(SignalChromeElf) -API_EXPORT_ORIG(SignalInitializeCrashReporting) - -void __stdcall load_api(LPVOID* destination, LPCSTR api_name) noexcept -{ - if (*destination) return; - auto* h_mod = LoadLibrary(L"_chrome_elf.dll"); - if (!h_mod) return; - *destination = GetProcAddress(h_mod, api_name); -} - -char last_playing_uri[200] = { 0 }; -bool g_skip_track = false; - -__declspec(naked) void is_skippable_hook() noexcept -{ - __asm { - mov eax, 1 - ret - } -} - -_declspec(naked) void can_focus_hook() noexcept -{ - __asm { - xor eax, eax - ret - } -} - -void __stdcall skip_track() noexcept +bool DataCompare(BYTE* pData, BYTE* bSig, char* szMask) { - int cnt = 0; - while (g_skip_track && cnt++ < 2) { - Sleep(250); - if (g_skip_track) { - keybd_event(VK_MEDIA_NEXT_TRACK, 0x0, KEYEVENTF_EXTENDEDKEY, 0); - keybd_event(VK_MEDIA_NEXT_TRACK, 0x0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); - break; - } + for (; *szMask; ++szMask, ++pData, ++bSig) { + if (*szMask == 'x' && *pData != *bSig) + return false; } + return (*szMask) == NULL; } -int __fastcall now_playing_hook(char* p_this, void* edx, uintptr_t track) noexcept +BYTE* FindPattern(BYTE* dwAddress, DWORD dwSize, BYTE* pbSig, char* szMask) { - auto current_track_uri = *reinterpret_cast(track + 0x184); - if (current_track_uri && strncmp(current_track_uri, last_playing_uri, 200)) { - strncpy_s(last_playing_uri, current_track_uri, 200); - if (!strncmp(current_track_uri, "spotify:ad:", 11) || !strncmp(current_track_uri, "spotify:interruption:", 21)) { - g_skip_track = true; - CreateThread(nullptr, 0, reinterpret_cast(skip_track), nullptr, 0, nullptr); - } - else { - g_skip_track = false; + DWORD length = strlen(szMask); + + for (DWORD i = NULL; i < dwSize - length; i++) { + __try + { + if (DataCompare(dwAddress + i, pbSig, szMask)) + return dwAddress + i; + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + return nullptr; } } - return reinterpret_cast(Spotify::instance()->m_fn_now_playing)(p_this, edx, track); -} - -void patch_ad_missing_id() noexcept -{ - DWORD p; - VirtualProtect(Spotify::instance()->m_jne_ad_missing_id, 6, PAGE_EXECUTE_READWRITE, &p); - memset(Spotify::instance()->m_jne_ad_missing_id, 0x90, 6); - VirtualProtect(Spotify::instance()->m_jne_ad_missing_id, 6, p, &p); -} -void patch_skip_stuck_seconds() noexcept -{ - DWORD p; - VirtualProtect(Spotify::instance()->m_mov_skip_stuck_seconds, 6, PAGE_EXECUTE_READWRITE, &p); - *reinterpret_cast(Spotify::instance()->m_mov_skip_stuck_seconds) = 0; - VirtualProtect(Spotify::instance()->m_mov_skip_stuck_seconds, 6, p, &p); + return 0; } int __stdcall main() noexcept { - version_t v; - utils::get_version(&v); + const auto hModule = GetModuleHandle(NULL); + MODULEINFO mInfo = { 0 }; + DWORD oldProtect; - if (v.dwMajor < 1 || v.dwMinor < 1) { - MessageBoxA(nullptr, "Need a higher version", "R3nzError", 0); - return 0; - } + if (GetModuleInformation(GetCurrentProcess(), hModule, &mInfo, sizeof(MODULEINFO))) { + const auto skipPod = FindPattern((BYTE*)hModule, mInfo.SizeOfImage, (BYTE*)"\x83\xC4\x08\x84\xC0\x0F\x84\xE5\x03\x00\x00", (char*)"xxxxxxxxxxx"); - if (!Spotify::instance()->valid_ptrs()) { - MessageBoxA(nullptr, "Spotify fail", "R3nzError", 0); - return 0; + if (skipPod) { + VirtualProtect((char*)skipPod + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect); + memset((char*)skipPod + 5, 0x90, 1); + VirtualProtect((char*)skipPod + 5, 1, oldProtect, &oldProtect); + + VirtualProtect((char*)skipPod + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect); + memset((char*)skipPod + 6, 0xE9, 1); + VirtualProtect((char*)skipPod + 6, 1, oldProtect, &oldProtect); + } } - hk::apply_detour(can_focus_hook, Spotify::instance()->m_fn_require_focus); - hk::apply_detour(now_playing_hook, Spotify::instance()->m_fn_now_playing); - hk::apply_detour(is_skippable_hook, Spotify::instance()->m_fn_is_skippable); - patch_skip_stuck_seconds(); - patch_ad_missing_id(); return 0; } @@ -152,5 +59,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv if (!wcsstr(GetCommandLine(), L"--type=")) CreateThread(nullptr, 0, reinterpret_cast(main), nullptr, 0, nullptr); } + return TRUE; } \ No newline at end of file diff --git a/SpotifyInternal/exports.cpp b/SpotifyInternal/exports.cpp new file mode 100644 index 0000000..29ce1e0 --- /dev/null +++ b/SpotifyInternal/exports.cpp @@ -0,0 +1,29 @@ +#include + +bool AddDllToBlacklist(const wchar_t* dll_name) { return true; } +void ClearReportsBetween_ExportThunk(time_t begin, time_t end) {} +int CrashForException_ExportThunk(EXCEPTION_POINTERS* info) { return EXCEPTION_CONTINUE_SEARCH; } +void DisableHook() {} +UINT32 DrainLog(UINT8* buffer, UINT32 buffer_size, UINT32* log_remaining) { return 0; } +bool DumpHungProcessWithPtype_ExportThunk(HANDLE process_handle, const char* ptype) { return false; } +void DumpProcessWithoutCrash(void* task_port) {} +INT32 GetApplyHookResult() { return 0; } +UINT32 GetBlockedModulesCount() { return 0; } +size_t GetCrashReports_ExportThunk(void* reports, size_t reports_size) { return 0; } +const wchar_t* GetCrashpadDatabasePath_ExportThunk() { return nullptr; } +void* GetHandleVerifier() { return nullptr; } +UINT32 GetInstallDetailsPayload() { return 0; } +UINT32 GetUniqueBlockedModulesCount() { return 0; } +bool GetUserDataDirectoryThunk(wchar_t* user_data_dir, size_t user_data_dir_length, wchar_t* invalid_user_data_dir, size_t invalid_user_data_dir_length) { return true; } +HANDLE InjectDumpForHungInput_ExportThunk(HANDLE process) { return nullptr; } +bool IsBlacklistInitialized() { return false; } +bool IsCrashReportingEnabledImpl() { return false; } +bool IsThirdPartyInitialized() { return false; } +bool RegisterLogNotification(HANDLE event_handle) { return false; } +void RequestSingleCrashUpload_ExportThunk(const char* local_id) {} +void SetCrashKeyValueImpl() {} +void SetMetricsClientId(const char* client_id) {} +void SetUploadConsent_ExportThunk(bool consent) {} +void SignalChromeElf() {} +void SignalInitializeCrashReporting() {} +void SuccessfullyBlocked(const wchar_t** blocked_dlls, int* size) {} \ No newline at end of file diff --git a/SpotifyInternal/utils.cpp b/SpotifyInternal/utils.cpp deleted file mode 100644 index d09bac7..0000000 --- a/SpotifyInternal/utils.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "utils.hpp" -#pragma comment(lib, "Version.lib") - -typedef struct { - WORD wLength; - WORD wValueLength; - WORD wType; - WCHAR szKey[16]; - WORD Padding1; - VS_FIXEDFILEINFO Value; - WORD Padding2; - WORD Children; -} VS_VERSIONINFO; - -bool utils::get_version(version_t* v) noexcept -{ - WCHAR module_file_path[MAX_PATH]; - bool ok = false; - DWORD ver_handle = 0; - GetModuleFileName(GetModuleHandle(nullptr), module_file_path, MAX_PATH); - auto ver_size = GetFileVersionInfoSize(module_file_path, &ver_handle); - if (ver_size != 0) { - void* ver_buffer = nullptr; - UINT size = 0; - auto* ver_data = new char[ver_size]; - if (GetFileVersionInfoW(module_file_path, 0, ver_size, ver_data) && VerQueryValueA(ver_data, "\\", &ver_buffer, &size) && size) { - auto* ver_info = reinterpret_cast(ver_data); - if (ver_info->Value.dwSignature == 0xfeef04bd) { - v->dwMajor = ver_info->Value.dwFileVersionMS >> 16 & 0xffff; - v->dwMinor = ver_info->Value.dwFileVersionMS & 0xffff; - v->dwBuild = ver_info->Value.dwFileVersionLS >> 16 & 0xffff; - v->dwRevision = ver_info->Value.dwFileVersionLS & 0xffff; - ok = true; - } - } - delete[] reinterpret_cast(ver_data); - } - return ok; -} \ No newline at end of file diff --git a/SpotifyInternal/utils.hpp b/SpotifyInternal/utils.hpp deleted file mode 100644 index 69b5e07..0000000 --- a/SpotifyInternal/utils.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include - -typedef struct -{ - DWORD dwMajor; - DWORD dwMinor; - DWORD dwBuild; - DWORD dwRevision; -} version_t; - -namespace utils -{ - bool get_version(version_t* v) noexcept; - -} diff --git a/Builds/installer.bat b/scripts/installer.bat similarity index 100% rename from Builds/installer.bat rename to scripts/installer.bat diff --git a/noAdsScript.py b/scripts/noAdsScript.py similarity index 100% rename from noAdsScript.py rename to scripts/noAdsScript.py diff --git a/Builds/uinstaller.bat b/scripts/uinstaller.bat similarity index 100% rename from Builds/uinstaller.bat rename to scripts/uinstaller.bat