Skip to content

Commit

Permalink
a few fixes (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yolilad authored Jun 16, 2024
1 parent e736db8 commit 84bfd19
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 134 deletions.
170 changes: 85 additions & 85 deletions blockthespot_settings.json
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
{
"Latest Release Date": "2024-05-24",
"Block List": [
"/ads/",
"/ad-logic/",
"/gabo-receiver-service/"
],
"Zip Reader": {
"home-hpto.css": {
"hptocss": {
"Signature": ".utUDWsORU96S7boXm2Aq{display:-webkit-box;display:-ms-flexbox;display:flex;",
"Value": "none",
"Offset": 70,
"Fill": 0,
"Address": -1
}
},
"xpui.js": {
"adsEnabled": {
"Signature": "adsEnabled:!0",
"Value": "1",
"Offset": 12,
"Fill": 0,
"Address": -1
},
"ishptohidden": {
"Signature": "isHptoHidden:!0",
"Value": "1",
"Offset": 14,
"Fill": 0,
"Address": -1
},
"sponsorship": {
"Signature": ".set(\"allSponsorships\",t.sponsorships)})}(e,t);",
"Value": "\"",
"Offset": 5,
"Fill": 15,
"Address": -1
},
"skipsentry": {
"Signature": "sentry.io",
"Value": "localhost",
"Offset": 0,
"Fill": 0,
"Address": -1
},
"hptoEnabled": {
"Signature": "hptoEnabled:!0",
"Value": "1",
"Offset": 13,
"Fill": 0,
"Address": -1
},
"sp_localhost": {
"Signature": "sp://ads/v1/ads/",
"Value": "sp://localhost//",
"Offset": 0,
"Fill": 0,
"Address": -1
},
"premium_free": {
"Signature": "\"free\"===(null===(t=e.session)",
"Value": "\"\"",
"Offset": 0,
"Fill": 4,
"Address": -1
}
"Latest Release Date": "2024-06-16",
"Block List": [
"/ads/",
"/ad-logic/",
"/gabo-receiver-service/"
],
"Zip Reader": {
"home-hpto.css": {
"hptocss": {
"Signature": ".utUDWsORU96S7boXm2Aq{display:-webkit-box;display:-ms-flexbox;display:flex;",
"Value": "none",
"Offset": 70,
"Fill": 0,
"Address": -1
}
},
"Developer": {
"x64": {
"Signature": "80 E3 01 48 8B 95 ?? ?? ?? ?? 48 83 FA 10",
"Value": "B3 01 90",
"xpui.js": {
"adsEnabled": {
"Signature": "adsEnabled:!0",
"Value": "1",
"Offset": 12,
"Fill": 0,
"Address": -1
},
"ishptohidden": {
"Signature": "isHptoHidden:!0",
"Value": "1",
"Offset": 14,
"Fill": 0,
"Address": -1
},
"sponsorship": {
"Signature": ".set(\"allSponsorships\",t.sponsorships)})}(e,t);",
"Value": "\"",
"Offset": 5,
"Fill": 15,
"Address": -1
},
"skipsentry": {
"Signature": "sentry.io",
"Value": "localhost",
"Offset": 0,
"Fill": 0,
"Address": -1
},
"hptoEnabled": {
"Signature": "hptoEnabled:!0",
"Value": "1",
"Offset": 13,
"Fill": 0,
"Address": -1
},
"sp_localhost": {
"Signature": "sp://ads/v1/ads/",
"Value": "sp://localhost//",
"Offset": 0,
"Fill": 0,
"Address": -1
},
"x32": {
"Signature": "25 01 FF FF FF 89 ?? ?? ?? FF FF",
"Value": "B8 03 00",
"premium_free": {
"Signature": "\"free\"===(null===(t=e.session)",
"Value": "\"",
"Offset": 0,
"Fill": 4,
"Address": -1
}
}
},
"Developer": {
"x64": {
"Signature": "80 E3 01 48 8B 95 ?? ?? ?? ?? 48 83 FA 10",
"Value": "B3 01 90",
"Offset": 0,
"Address": -1
},
"Cef Offsets": {
"x64": {
"cef_request_t_get_url": 48,
"cef_zip_reader_t_get_file_name": 72,
"cef_zip_reader_t_read_file": 112
},
"x32": {
"cef_request_t_get_url": 24,
"cef_zip_reader_t_get_file_name": 36,
"cef_zip_reader_t_read_file": 56
}
"x32": {
"Signature": "25 01 FF FF FF 89 ?? ?? ?? FF FF",
"Value": "B8 03 00",
"Offset": 0,
"Address": -1
}
},
"Cef Offsets": {
"x64": {
"cef_request_t_get_url": 48,
"cef_zip_reader_t_get_file_name": 72,
"cef_zip_reader_t_read_file": 112
},
"x32": {
"cef_request_t_get_url": 24,
"cef_zip_reader_t_get_file_name": 36,
"cef_zip_reader_t_read_file": 56
}
}
}
}
2 changes: 1 addition & 1 deletion src/BasicUtils/Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ Json Json::parse(std::wistream& is)
}
}
catch (const std::exception& e) {
LogError(L"{}", e.what());
LogError(Utils::ToString(e.what()));
return Json();
}
}
Expand Down
20 changes: 0 additions & 20 deletions src/BasicUtils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,25 +303,5 @@ namespace Utils
SetConsoleTitleW(FormatString(L"Execution time: {:f} seconds", diff.count()).c_str());
}
}

void PrintSymbols(std::wstring_view module_name)
{
HMODULE hModule = GetModuleHandleW(module_name.data());
if (!hModule && !(hModule = LoadLibraryW(module_name.data()))) {
PrintError(L"PrintSymbols: Failed to load module.");
return;
}

PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)hModule;
PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)((BYTE*)dosHeader + dosHeader->e_lfanew);
PIMAGE_EXPORT_DIRECTORY exportDirectory = (PIMAGE_EXPORT_DIRECTORY)((BYTE*)dosHeader + ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
PDWORD functions = (PDWORD)((BYTE*)dosHeader + exportDirectory->AddressOfFunctions);
PDWORD names = (PDWORD)((BYTE*)dosHeader + exportDirectory->AddressOfNames);
PWORD ordinals = (PWORD)((BYTE*)dosHeader + exportDirectory->AddressOfNameOrdinals);

for (DWORD i = 0; i < exportDirectory->NumberOfNames; i++) {
Print(L"{}", reinterpret_cast<const char*>((BYTE*)dosHeader + names[i]));
}
}
#endif // NDEBUG
};
27 changes: 3 additions & 24 deletions src/BasicUtils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace Utils
bool Equals(std::string_view str1, std::string_view str2, bool case_sensitive = false);
bool Equals(std::wstring_view str1, std::wstring_view str2, bool case_sensitive = false);

void WriteIniFile(std::wstring_view ini_path, std::wstring_view section, std::wstring_view key, std::wstring_view value);
std::wstring ReadIniFile(std::wstring_view ini_path, std::wstring_view section, std::wstring_view key);
void WriteIniFile(std::wstring_view ini_path, std::wstring_view section, std::wstring_view key, std::wstring_view value);
std::wstring ReadIniFile(std::wstring_view ini_path, std::wstring_view section, std::wstring_view key);

bool ReadFile(const std::wstring_view filename, std::wstring& out);
bool WriteFile(const std::wstring_view filename, const std::wstring_view content);
Expand All @@ -43,37 +43,16 @@ namespace Utils

#ifndef NDEBUG
void MeasureExecutionTime(std::function<void()> func, bool total_duration = true);
void PrintSymbols(std::wstring_view module_name);
#endif

template<typename T>
const auto& TypeConvert(const T& arg)
{
if constexpr (std::is_same_v<T, const wchar_t*>) {
return std::wstring_view(arg);
}
else if constexpr (std::is_same_v<T, const char*>) {
return ToString(arg);
}
else if constexpr (std::is_same_v < T, void*>) {
return reinterpret_cast<uintptr_t>(arg);
}
else if constexpr (std::is_pointer_v<T>) {
return *arg;
}
else {
return arg;
}
}

std::string FormatString(std::string_view fmt, const auto&... args)
{
return std::vformat(fmt, std::make_format_args(args...));
}

std::wstring FormatString(std::wstring_view fmt, const auto&... args)
{
return std::vformat(fmt, std::make_wformat_args(TypeConvert(args)...));
return std::vformat(fmt, std::make_wformat_args(args...));
}

enum class Color : WORD
Expand Down
8 changes: 4 additions & 4 deletions src/SettingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void SettingsManager::Init()

bool SettingsManager::Save()
{
m_latest_release_date = L"2024-05-24"; // Update only when significant changes occur.
m_latest_release_date = L"2024-06-16"; // Update only when significant changes occur.

m_block_list = {
L"/ads/",
Expand Down Expand Up @@ -86,7 +86,7 @@ bool SettingsManager::Save()
}},
{L"premium_free", {
{L"Signature", L"\"free\"===(null===(t=e.session)"},
{L"Value", L"\"\""},
{L"Value", L"\""},
{L"Offset", 0},
{L"Fill", 4},
{L"Address", -1}
Expand Down Expand Up @@ -224,8 +224,8 @@ bool SettingsManager::UpdateSettingsFromServer()

if (!CompareSettings(server_settings)) {
const auto forced_update = m_latest_release_date != server_settings.at(L"Latest Release Date");

if (!Load(server_settings) && !Utils::WriteFile(m_app_settings_file, server_settings.dump(2))) {
if (!Load(server_settings) || !Utils::WriteFile(m_app_settings_file, server_settings.dump(2))) {
LogError(L"Failed to load server settings or write to the settings file: {}", m_app_settings_file);
return false;
}
Expand Down

0 comments on commit 84bfd19

Please sign in to comment.