[Memory] Move new watches to heap-aware Memory from MMIOHandler
This commit is contained in:
@@ -26,11 +26,19 @@ class Exception {
|
||||
kIllegalInstruction,
|
||||
};
|
||||
|
||||
enum class AccessViolationOperation {
|
||||
kUnknown,
|
||||
kRead,
|
||||
kWrite,
|
||||
};
|
||||
|
||||
void InitializeAccessViolation(X64Context* thread_context,
|
||||
uint64_t fault_address) {
|
||||
uint64_t fault_address,
|
||||
AccessViolationOperation operation) {
|
||||
code_ = Code::kAccessViolation;
|
||||
thread_context_ = thread_context;
|
||||
fault_address_ = fault_address;
|
||||
access_violation_operation_ = operation;
|
||||
}
|
||||
void InitializeIllegalInstruction(X64Context* thread_context) {
|
||||
code_ = Code::kIllegalInstruction;
|
||||
@@ -62,10 +70,17 @@ class Exception {
|
||||
// In case of AV, address that was read from/written to.
|
||||
uint64_t fault_address() const { return fault_address_; }
|
||||
|
||||
// In case of AV, what kind of operation caused it.
|
||||
AccessViolationOperation access_violation_operation() const {
|
||||
return access_violation_operation_;
|
||||
}
|
||||
|
||||
private:
|
||||
Code code_ = Code::kInvalidException;
|
||||
X64Context* thread_context_ = nullptr;
|
||||
uint64_t fault_address_ = 0;
|
||||
AccessViolationOperation access_violation_operation_ =
|
||||
AccessViolationOperation::kUnknown;
|
||||
};
|
||||
|
||||
class ExceptionHandler {
|
||||
|
||||
@@ -51,10 +51,26 @@ LONG CALLBACK ExceptionHandlerCallback(PEXCEPTION_POINTERS ex_info) {
|
||||
case STATUS_ILLEGAL_INSTRUCTION:
|
||||
ex.InitializeIllegalInstruction(&thread_context);
|
||||
break;
|
||||
case STATUS_ACCESS_VIOLATION:
|
||||
case STATUS_ACCESS_VIOLATION: {
|
||||
Exception::AccessViolationOperation access_violation_operation;
|
||||
switch (ex_info->ExceptionRecord->ExceptionInformation[0]) {
|
||||
case 0:
|
||||
access_violation_operation =
|
||||
Exception::AccessViolationOperation::kRead;
|
||||
break;
|
||||
case 1:
|
||||
access_violation_operation =
|
||||
Exception::AccessViolationOperation::kWrite;
|
||||
break;
|
||||
default:
|
||||
access_violation_operation =
|
||||
Exception::AccessViolationOperation::kUnknown;
|
||||
break;
|
||||
}
|
||||
ex.InitializeAccessViolation(
|
||||
&thread_context, ex_info->ExceptionRecord->ExceptionInformation[1]);
|
||||
break;
|
||||
&thread_context, ex_info->ExceptionRecord->ExceptionInformation[1],
|
||||
access_violation_operation);
|
||||
} break;
|
||||
default:
|
||||
// Unknown/unhandled type.
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
@@ -62,7 +62,7 @@ bool DeallocFixed(void* base_address, size_t length,
|
||||
// Sets the access rights for the given block of memory and returns the previous
|
||||
// access rights. Both base_address and length will be adjusted to page_size().
|
||||
bool Protect(void* base_address, size_t length, PageAccess access,
|
||||
PageAccess* out_old_access);
|
||||
PageAccess* out_old_access = nullptr);
|
||||
|
||||
// Queries a region of pages to get the access rights. This will modify the
|
||||
// length parameter to the length of pages with the same consecutive access
|
||||
|
||||
Reference in New Issue
Block a user