Skip to content

Commit 10c3f33

Browse files
fix: seh
1 parent 240c502 commit 10c3f33

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/core/bindings/native_memory.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,21 @@ std::string NativeMemory::readMemory(const std::string &address, int size) {
232232
std::string NativeMemory::safeReadMemory(const std::string &address, int size) {
233233
#ifdef CHROMATIC_WINDOWS
234234
auto addr = reinterpret_cast<const uint8_t *>(parseHexAddress(address));
235-
__try {
236-
return bytesToHex(addr, static_cast<size_t>(size));
237-
} __except (EXCEPTION_EXECUTE_HANDLER) {
238-
return "";
239-
}
235+
std::string result;
236+
237+
auto readMemory = [&]() -> bool {
238+
__try {
239+
result.resize(size * 2);
240+
for (int i = 0; i < size; ++i) {
241+
sprintf(&result[i * 2], "%02x", addr[i]);
242+
}
243+
return true;
244+
} __except (EXCEPTION_EXECUTE_HANDLER) {
245+
return false;
246+
}
247+
};
248+
249+
return readMemory() ? result : "";
240250
#else
241251
auto addr = reinterpret_cast<const uint8_t *>(parseHexAddress(address));
242252

0 commit comments

Comments
 (0)