Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

developer pattern update & a few changes #484

Merged
merged 12 commits into from Sep 1, 2023
Prev Previous commit
Next Next commit
"is_found" function has been updated.
  • Loading branch information
Yolilad committed Aug 25, 2023
commit 22d5ff8b504edb9e6ddb28793eef1d12b7f2c0a5
14 changes: 12 additions & 2 deletions src/BasicUtils/PatternScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,19 @@ void Scan::print_address(std::wstring_view name) const
Print({ Color::Yellow , Color::Cyan }, L"{:X} {}", m_address, !name.empty() ? L" : " + std::wstring(name.data()) : L"");
}

bool Scan::is_found() const
bool Scan::is_found(const std::vector<std::uint8_t>& value) const
{
return m_address != NULL;
if (m_address == NULL)
return false;

if (!value.empty()) {
for (std::size_t i = 0; i < value.size(); ++i) {
if (*(reinterpret_cast<std::uint8_t*>(m_address) + i) != value[i])
return false;
}
}

return true;
}

std::uint8_t* Scan::data() const
Expand Down
2 changes: 1 addition & 1 deletion src/BasicUtils/PatternScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Scan {

void print_address(std::wstring_view name = {}) const;

bool is_found() const;
bool is_found(const std::vector<std::uint8_t>& value = {}) const;
std::uint8_t* data() const;
Scan rva() const;
Scan offset(std::size_t value) const;
Expand Down
39 changes: 27 additions & 12 deletions src/Modify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,35 @@ int cef_zip_reader_read_file_hook(void* self, void* buffer, size_t bufferSize)
}
}

if (file_name == L"xpui-routes-profile.js") {
const auto isModalOpen = PatternScanner::ScanAll(reinterpret_cast<std::size_t>(buffer), bufferSize, L"isModalOpen:!0");
if (isModalOpen[0].is_found()) {
for (const auto& it : isModalOpen) {
if (it.offset(13).write<const char>('1')) {
Logger::Log(L"isModalOpen patched!", Logger::LogLevel::Info);
}
else {
Logger::Log(L"isModalOpen - patch failed!", Logger::LogLevel::Error);
}
//if (file_name == L"xpui-routes-profile.js") {
// const auto isModalOpen = PatternScanner::ScanAll(reinterpret_cast<std::size_t>(buffer), bufferSize, L"isModalOpen:!0");
// if (isModalOpen[0].is_found()) {
// for (const auto& it : isModalOpen) {
// if (it.offset(13).write<const char>('1')) {
// Logger::Log(L"isModalOpen patched!", Logger::LogLevel::Info);
// }
// else {
// Logger::Log(L"isModalOpen - patch failed!", Logger::LogLevel::Error);
// }
// }
// }
// else {
// Logger::Log(L"isModalOpen - failed not found!", Logger::LogLevel::Error);
// }
//}

if (file_name == L"xpui.css") {
const auto GenericModal = PatternScanner::ScanFirst(reinterpret_cast<std::size_t>(buffer), bufferSize, L".GenericModal__overlay{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:rgba(0,0,0,.7);bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;");
if (GenericModal.is_found()) {
if (GenericModal.write<const char*>(".GenericModal__overlay{-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;background-color:rgba(0,0,0,.7);bottom:0;display:-webkit-box;display:-ms-flexbox;display:none;")) {
Logger::Log(L"GenericModal patched!", Logger::LogLevel::Info);
}
else {
Logger::Log(L"GenericModal patch failed!", Logger::LogLevel::Error);
}
}
else {
Logger::Log(L"isModalOpen - failed not found!", Logger::LogLevel::Error);
Logger::Log(L"GenericModal - failed not found!", Logger::LogLevel::Error);
}
}

Expand Down Expand Up @@ -501,7 +516,7 @@ DWORD WINAPI EnableDeveloper(LPVOID lpParam)
//const auto developer = PatternScanner::ScanFirst(L"48 8B 95 C0 05 00 00").offset(-3);
const auto app_developer = PatternScanner::ScanFirst(L"app-developer").get_all_matching_codes({ 0x48, 0x8D, 0x15 });
const auto developer = app_developer.size() > 1 ? app_developer[1].scan_first(L"D1 EB").offset(2) : Scan();
if (developer.is_found()) {
if (developer.is_found({ 0x80, 0xE3, 0x01 })) {
if (developer.write<std::vector<std::uint8_t>>({ 0xB3, 0x01, 0x90 })) {
Logger::Log(L"Developer - patch success!", Logger::LogLevel::Info);
}
Expand Down