From e2eb4505d0ea073d031b4a886a35cb3ce0caf197 Mon Sep 17 00:00:00 2001 From: "Liu.andrew.x@gmail.com" Date: Tue, 30 Jun 2015 23:22:09 +0000 Subject: Use general instruction/stack pointer convenience method instead of manually finding the instruction/stack pointer for exploitability rating. There was already a method that found the instruction pointer, so the files for exploitability ratings had repeated code. Also a method for finding the stack pointer is implemented in this CL. R=ivanpe@chromium.org Review URL: https://codereview.chromium.org/1210943005 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1468 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/processor/exploitability_win.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/processor/exploitability_win.cc') diff --git a/src/processor/exploitability_win.cc b/src/processor/exploitability_win.cc index 8a444eb2..a1f8703a 100644 --- a/src/processor/exploitability_win.cc +++ b/src/processor/exploitability_win.cc @@ -106,18 +106,14 @@ ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() { uint64_t stack_ptr = 0; uint64_t instruction_ptr = 0; - switch (context->GetContextCPU()) { - case MD_CONTEXT_X86: - stack_ptr = context->GetContextX86()->esp; - instruction_ptr = context->GetContextX86()->eip; - break; - case MD_CONTEXT_AMD64: - stack_ptr = context->GetContextAMD64()->rsp; - instruction_ptr = context->GetContextAMD64()->rip; - break; - default: - BPLOG(INFO) << "Unsupported architecture."; - return EXPLOITABILITY_ERR_PROCESSING; + // Getting the instruction pointer. + if (!context->GetInstructionPointer(&instruction_ptr)) { + return EXPLOITABILITY_ERR_PROCESSING; + } + + // Getting the stack pointer. + if (!context->GetStackPointer(&stack_ptr)) { + return EXPLOITABILITY_ERR_PROCESSING; } // Check if we are executing on the stack. -- cgit v1.2.1