Skip to content

Commit

Permalink
fix (#547)
Browse files Browse the repository at this point in the history
* debug issue fixed

* fixed runtime libraries issue
  • Loading branch information
Yolilad authored Jun 19, 2024
1 parent 84bfd19 commit 6efc131
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
38 changes: 19 additions & 19 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/BlockTheSpot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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;
}
}

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;
Expand Down
1 change: 1 addition & 0 deletions src/BlockTheSpot.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
10 changes: 4 additions & 6 deletions src/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?"))) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 6efc131

Please sign in to comment.