fix: GDB provider not working nicely anymore
This commit is contained in:
parent
f435191585
commit
f661f4d1d6
@ -41,12 +41,13 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
this->readRaw(offset - this->getBaseAddress(), buffer, size);
|
this->readRaw(offset - this->getBaseAddress(), buffer, size);
|
||||||
|
|
||||||
for (u64 i = 0; i < size; i++)
|
if (overlays) {
|
||||||
if (getPatches().contains(offset + i))
|
for (u64 i = 0; i < size; i++)
|
||||||
reinterpret_cast<u8 *>(buffer)[i] = getPatches()[offset + i];
|
if (getPatches().contains(offset + i))
|
||||||
|
reinterpret_cast<u8 *>(buffer)[i] = getPatches()[offset + i];
|
||||||
|
|
||||||
if (overlays)
|
|
||||||
this->applyOverlays(offset, buffer, size);
|
this->applyOverlays(offset, buffer, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileProvider::write(u64 offset, const void *buffer, size_t size) {
|
void FileProvider::write(u64 offset, const void *buffer, size_t size) {
|
||||||
|
@ -47,7 +47,8 @@ namespace hex::plugin::builtin {
|
|||||||
std::string data = packet.substr(1, packet.length() - 4);
|
std::string data = packet.substr(1, packet.length() - 4);
|
||||||
std::string checksum = packet.substr(packet.length() - 2, 2);
|
std::string checksum = packet.substr(packet.length() - 2, 2);
|
||||||
|
|
||||||
if (checksum.length() != 2 || crypt::decode16(checksum)[0] != calculateChecksum(data))
|
auto decodedChecksum = crypt::decode16(checksum);
|
||||||
|
if (checksum.length() != 2 || decodedChecksum.empty() || decodedChecksum[0] != calculateChecksum(data))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@ -178,12 +179,13 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u64 i = 0; i < size; i++)
|
if (overlays) {
|
||||||
if (getPatches().contains(offset + i))
|
for (u64 i = 0; i < size; i++)
|
||||||
reinterpret_cast<u8 *>(buffer)[i] = getPatches()[offset + PageSize * this->m_currPage + i];
|
if (getPatches().contains(offset + i))
|
||||||
|
reinterpret_cast<u8 *>(buffer)[i] = getPatches()[offset + PageSize * this->m_currPage + i];
|
||||||
|
|
||||||
if (overlays)
|
|
||||||
this->applyOverlays(offset, buffer, size);
|
this->applyOverlays(offset, buffer, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDBProvider::write(u64 offset, const void *buffer, size_t size) {
|
void GDBProvider::write(u64 offset, const void *buffer, size_t size) {
|
||||||
@ -200,7 +202,8 @@ namespace hex::plugin::builtin {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
auto data = gdb::readMemory(this->m_socket, offset, size);
|
auto data = gdb::readMemory(this->m_socket, offset, size);
|
||||||
std::memcpy(buffer, &data[0], data.size());
|
if (!data.empty())
|
||||||
|
std::memcpy(buffer, &data[0], data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDBProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
|
void GDBProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
|
||||||
@ -257,7 +260,13 @@ namespace hex::plugin::builtin {
|
|||||||
if (cacheLine != this->m_cache.end()) {
|
if (cacheLine != this->m_cache.end()) {
|
||||||
auto data = gdb::readMemory(this->m_socket, cacheLine->address, 0x1000);
|
auto data = gdb::readMemory(this->m_socket, cacheLine->address, 0x1000);
|
||||||
|
|
||||||
while (this->m_cache.size() > 10) {
|
if (data.empty()) {
|
||||||
|
this->m_cache.erase(cacheLine);
|
||||||
|
cacheLine = this->m_cache.begin();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (this->m_cache.size() > 5) {
|
||||||
this->m_cache.pop_front();
|
this->m_cache.pop_front();
|
||||||
cacheLine = this->m_cache.begin();
|
cacheLine = this->m_cache.begin();
|
||||||
}
|
}
|
||||||
@ -265,9 +274,10 @@ namespace hex::plugin::builtin {
|
|||||||
std::memcpy(cacheLine->data.data(), data.data(), data.size());
|
std::memcpy(cacheLine->data.data(), data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheLine++;
|
|
||||||
if (cacheLine == this->m_cache.end())
|
if (cacheLine == this->m_cache.end())
|
||||||
cacheLine = this->m_cache.begin();
|
cacheLine = this->m_cache.begin();
|
||||||
|
else
|
||||||
|
cacheLine++;
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(100ms);
|
std::this_thread::sleep_for(100ms);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace hex::plugin::builtin {
|
|||||||
auto provider = ImHexApi::Provider::get();
|
auto provider = ImHexApi::Provider::get();
|
||||||
|
|
||||||
u8 byte = 0x00;
|
u8 byte = 0x00;
|
||||||
provider->readRaw(offset, &byte, sizeof(u8));
|
provider->read(offset, &byte, sizeof(u8), false);
|
||||||
|
|
||||||
const auto &patches = provider->getPatches();
|
const auto &patches = provider->getPatches();
|
||||||
if (patches.contains(offset) && patches.at(offset) != byte)
|
if (patches.contains(offset) && patches.at(offset) != byte)
|
||||||
|
@ -4,7 +4,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
ViewProviderSettings::ViewProviderSettings() : hex::View("hex.builtin.view.provider_settings.name") {
|
ViewProviderSettings::ViewProviderSettings() : hex::View("hex.builtin.view.provider_settings.name") {
|
||||||
EventManager::subscribe<EventProviderCreated>(this, [](hex::prv::Provider *provider) {
|
EventManager::subscribe<EventProviderCreated>(this, [](hex::prv::Provider *provider) {
|
||||||
if (provider->hasLoadInterface())
|
if (provider->hasLoadInterface() && !provider->shouldSkipLoadInterface())
|
||||||
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
|
EventManager::post<RequestOpenPopup>(View::toWindowName("hex.builtin.view.provider_settings.load_popup"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user