From 6efc131765197ca2f8714f5a2a8cf9356dc45e25 Mon Sep 17 00:00:00 2001 From: Yolilad <152070897+Yolilad@users.noreply.github.com> Date: Thu, 20 Jun 2024 01:08:00 +0300 Subject: [PATCH] fix (#547) * debug issue fixed * fixed runtime libraries issue --- install.ps1 | 38 +++++++++++++++++++------------------- src/BlockTheSpot.cpp | 4 ++-- src/BlockTheSpot.vcxproj | 1 + src/Debug.cpp | 10 ++++------ 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/install.ps1 b/install.ps1 index 2fbbba1..a21a313 100644 --- a/install.ps1 +++ b/install.ps1 @@ -264,25 +264,25 @@ Write-Host 'Patching Spotify...' $patchFiles = (Join-Path -Path $PWD -ChildPath 'dpapi.dll'), (Join-Path -Path $PWD -ChildPath 'config.ini') Copy-Item -LiteralPath $patchFiles -Destination "$spotifyDirectory" -Remove-Item -LiteralPath (Join-Path -Path $spotifyDirectory -ChildPath 'blockthespot_settings.json') -Force -ErrorAction SilentlyContinue # temporary - -function Install-VcRedist { - $architecture = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" } - # https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 - $vcRedistUrl = "https://aka.ms/vs/17/release/vc_redist.$($architecture).exe" - $registryPath = "HKLM:\Software\Microsoft\VisualStudio\14.0\VC\Runtimes\$architecture" - $installedVersion = [version]((Get-ItemProperty $registryPath -ErrorAction SilentlyContinue).Version).Substring(1) - $latestVersion = [version]"14.40.33810.0" - - if ($installedVersion -lt $latestVersion) { - $vcRedistFile = Join-Path -Path $PWD -ChildPath "vc_redist.$architecture.exe" - Write-Host "Downloading and installing vc_redist.$architecture.exe..." - Invoke-WebRequest -Uri $vcRedistUrl -OutFile $vcRedistFile - Start-Process -FilePath $vcRedistFile -ArgumentList "/install /quiet /norestart" -Wait - } -} - -Install-VcRedist +Remove-Item -LiteralPath (Join-Path -Path $spotifyDirectory -ChildPath 'blockthespot_settings.json') -Force -ErrorAction SilentlyContinue + +# function Install-VcRedist { +# $architecture = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" } +# # https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 +# $vcRedistUrl = "https://aka.ms/vs/17/release/vc_redist.$($architecture).exe" +# $registryPath = "HKLM:\Software\Microsoft\VisualStudio\14.0\VC\Runtimes\$architecture" +# $installedVersion = [version]((Get-ItemProperty $registryPath -ErrorAction SilentlyContinue).Version).Substring(1) +# $latestVersion = [version]"14.40.33810.0" +# +# if ($installedVersion -lt $latestVersion) { +# $vcRedistFile = Join-Path -Path $PWD -ChildPath "vc_redist.$architecture.exe" +# Write-Host "Downloading and installing vc_redist.$architecture.exe..." +# Get-File -Uri $vcRedistUrl -TargetFile $vcRedistFile +# Start-Process -FilePath $vcRedistFile -ArgumentList "/install /quiet /norestart" -Wait +# } +# } +# +# Install-VcRedist $tempDirectory = $PWD Pop-Location diff --git a/src/BlockTheSpot.cpp b/src/BlockTheSpot.cpp index f278415..6804316 100644 --- a/src/BlockTheSpot.cpp +++ b/src/BlockTheSpot.cpp @@ -12,7 +12,7 @@ LPVOID __stdcall LoadAPI(const char* api_name) if (!hModule) { hModule = LoadLibraryW(path.c_str()); if (!hModule) { - PrintError(L"Failed to load library: {}", path); + LogError(L"Failed to load library: {}", path); return nullptr; } } @@ -20,7 +20,7 @@ LPVOID __stdcall LoadAPI(const char* api_name) if (function_map.find(api_name) == function_map.end()) { FARPROC proc = GetProcAddress(hModule, api_name); if (!proc) { - PrintError(L"Failed to get address of function: {}", api_name); + LogError(L"Failed to get address of function: {}", Utils::ToString(api_name)); return nullptr; } function_map[api_name] = proc; diff --git a/src/BlockTheSpot.vcxproj b/src/BlockTheSpot.vcxproj index 3501863..04d6f7f 100644 --- a/src/BlockTheSpot.vcxproj +++ b/src/BlockTheSpot.vcxproj @@ -70,6 +70,7 @@ true NDEBUG;%(PreprocessorDefinitions) stdcpp20 + MultiThreaded Console diff --git a/src/Debug.cpp b/src/Debug.cpp index d753e76..1a92a4a 100644 --- a/src/Debug.cpp +++ b/src/Debug.cpp @@ -10,17 +10,15 @@ DWORD WINAPI Debug(LPVOID lpParam) const auto cef_zip_reader_t_read_file = offsetof(cef_zip_reader_t, read_file); if (cef_request_t_get_url != SettingsManager::m_cef_request_t_get_url_offset) { - PrintError(L"The offset of cef_request_t::get_url has changed: {}", cef_request_t_get_url); + LogError(L"The offset of cef_request_t::get_url has changed: {}", cef_request_t_get_url); } if (cef_zip_reader_t_get_file_name != SettingsManager::m_cef_zip_reader_t_get_file_name_offset) { - PrintError(L"The offset of cef_zip_reader_t::get_file_name has changed: {}", cef_zip_reader_t_get_file_name); + LogError(L"The offset of cef_zip_reader_t::get_file_name has changed: {}", cef_zip_reader_t_get_file_name); } if (cef_zip_reader_t_read_file != SettingsManager::m_cef_zip_reader_t_read_file_offset) { - PrintError(L"The offset of cef_zip_reader_t::read_file has changed: {}", cef_zip_reader_t_read_file); + LogError(L"The offset of cef_zip_reader_t::read_file has changed: {}", cef_zip_reader_t_read_file); } - // Utils::PrintSymbols(L"chrome_elf.dll"); - Utils::MeasureExecutionTime([&]() { //for (const auto& pattern : MemoryScanner::ParseBytePattern((L"4? ?D 1?"))) { @@ -41,7 +39,7 @@ DWORD WINAPI Debug(LPVOID lpParam) }); } catch (const std::exception& e) { - PrintError(L"{}", e.what()); + LogError(Utils::ToString(e.what())); } return 0; }