mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1348747 - Part 2: Support stub functions starting with jmp rel8 in WindowsDllDetourPatcher. r=handyman
MozReview-Commit-ID: 5hPBmxtBCnu --HG-- extra : rebase_source : 52a1d43c9f57c9c8b70ded93cbcb76218922ea8b extra : amend_source : 6377d7eb2246b38e69b95b2a7f507a0f86e300b1 extra : histedit_source : 5cc91dfb4613431466ccde12610a36578361bf53
This commit is contained in:
parent
cd7a0759ce
commit
2dc8565a99
@ -332,6 +332,26 @@ public:
|
||||
private:
|
||||
static byteptr_t ResolveRedirectedAddress(const byteptr_t aOriginalFunction)
|
||||
{
|
||||
// If function entry is jmp rel8 stub to the internal implementation, we
|
||||
// resolve redirected address from the jump target.
|
||||
if (aOriginalFunction[0] == 0xeb) {
|
||||
int8_t offset = (int8_t)(aOriginalFunction[1]);
|
||||
if (offset <= 0) {
|
||||
// Bail out for negative offset: probably already patched by some
|
||||
// third-party code.
|
||||
return aOriginalFunction;
|
||||
}
|
||||
|
||||
for (int8_t i = 0; i < offset; i++) {
|
||||
if (aOriginalFunction[2 + i] != 0x90) {
|
||||
// Bail out on insufficient nop space.
|
||||
return aOriginalFunction;
|
||||
}
|
||||
}
|
||||
|
||||
return aOriginalFunction + 2 + offset;
|
||||
}
|
||||
|
||||
// If function entry is jmp [disp32] such as used by kernel32,
|
||||
// we resolve redirected address from import table.
|
||||
if (aOriginalFunction[0] == 0xff && aOriginalFunction[1] == 0x25) {
|
||||
@ -1224,6 +1244,26 @@ protected:
|
||||
|
||||
static void* ResolveRedirectedAddress(const byteptr_t aOriginalFunction)
|
||||
{
|
||||
// If function entry is jmp rel8 stub to the internal implementation, we
|
||||
// resolve redirected address from the jump target.
|
||||
if (aOriginalFunction[0] == 0xeb) {
|
||||
int8_t offset = (int8_t)(aOriginalFunction[1]);
|
||||
if (offset <= 0) {
|
||||
// Bail out for negative offset: probably already patched by some
|
||||
// third-party code.
|
||||
return aOriginalFunction;
|
||||
}
|
||||
|
||||
for (int8_t i = 0; i < offset; i++) {
|
||||
if (aOriginalFunction[2 + i] != 0x90) {
|
||||
// Bail out on insufficient nop space.
|
||||
return aOriginalFunction;
|
||||
}
|
||||
}
|
||||
|
||||
return aOriginalFunction + 2 + offset;
|
||||
}
|
||||
|
||||
#if defined(_M_IX86)
|
||||
// If function entry is jmp [disp32] such as used by kernel32,
|
||||
// we resolve redirected address from import table.
|
||||
|
Loading…
Reference in New Issue
Block a user