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
This commit is contained in:
Liu.andrew.x@gmail.com 2015-06-30 23:22:09 +00:00
parent 12213a5e15
commit e2eb4505d0
7 changed files with 74 additions and 33 deletions

View file

@ -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.