mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 19:41:49 +00:00
Backed out changeset 23de710cae6f (bug 1322554) for breaking at least Windows 8 x64 builds (likely all Windows builds). r=backout on a CLOSED TREE
This commit is contained in:
parent
74e36e1adb
commit
f7bdfd47a4
@ -282,10 +282,6 @@ printf_stderr(const char *fmt, ...)
|
||||
|
||||
namespace {
|
||||
|
||||
typedef void (__fastcall* BaseThreadInitThunk_func)(BOOL aIsInitialThread, void* aStartAddress, void* aThreadParam);
|
||||
|
||||
static BaseThreadInitThunk_func stub_BaseThreadInitThunk = nullptr;
|
||||
|
||||
typedef NTSTATUS (NTAPI *LdrLoadDll_func) (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileName, PHANDLE handle);
|
||||
|
||||
static LdrLoadDll_func stub_LdrLoadDll = 0;
|
||||
@ -706,43 +702,7 @@ continue_loading:
|
||||
return stub_LdrLoadDll(filePath, flags, moduleFileName, handle);
|
||||
}
|
||||
|
||||
static bool
|
||||
ShouldBlockThread(void* aStartAddress)
|
||||
{
|
||||
// Allows crashfirefox.exe to continue to work. Also if your threadproc is null, this crash is intentional.
|
||||
if (aStartAddress == 0)
|
||||
return false;
|
||||
|
||||
bool shouldBlock = false;
|
||||
MEMORY_BASIC_INFORMATION startAddressInfo = {0};
|
||||
if (VirtualQuery(aStartAddress, &startAddressInfo, sizeof(startAddressInfo))) {
|
||||
shouldBlock |= startAddressInfo.State != MEM_COMMIT;
|
||||
shouldBlock |= startAddressInfo.Protect != PAGE_EXECUTE_READ;
|
||||
}
|
||||
|
||||
return shouldBlock;
|
||||
}
|
||||
|
||||
// Allows blocked threads to still run normally through BaseThreadInitThunk, in case there's any magic there that we shouldn't skip.
|
||||
static DWORD WINAPI
|
||||
NopThreadProc(void* /* aThreadParam */)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MOZ_NORETURN void __fastcall
|
||||
patched_BaseThreadInitThunk(BOOL aIsInitialThread, void* aStartAddress,
|
||||
void* aThreadParam)
|
||||
{
|
||||
if (ShouldBlockThread(aStartAddress)) {
|
||||
aStartAddress = NopThreadProc;
|
||||
}
|
||||
|
||||
stub_BaseThreadInitThunk(aIsInitialThread, aStartAddress, aThreadParam);
|
||||
}
|
||||
|
||||
WindowsDllInterceptor NtDllIntercept;
|
||||
WindowsDllInterceptor Kernel32DllIntercept;
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -776,16 +736,6 @@ DllBlocklist_Initialize()
|
||||
sBlocklistInitFailed = true;
|
||||
#ifdef DEBUG
|
||||
printf_stderr("LdrLoadDll hook failed, no dll blocklisting active\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
Kernel32DllIntercept.Init("kernel32.dll");
|
||||
ok = Kernel32DllIntercept.AddHook("BaseThreadInitThunk",
|
||||
reinterpret_cast<intptr_t>(patched_BaseThreadInitThunk),
|
||||
(void**) &stub_BaseThreadInitThunk);
|
||||
if (!ok) {
|
||||
#ifdef DEBUG
|
||||
printf_stderr("BaseThreadInitThunk hook failed\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,6 @@ int main()
|
||||
#ifdef _M_IX86
|
||||
TestHook(TestSendMessageTimeoutW, "user32.dll", "SendMessageTimeoutW") &&
|
||||
#endif
|
||||
TestDetour("kernel32.dll", "BaseThreadInitThunk") &&
|
||||
TestDetour("ntdll.dll", "LdrLoadDll")) {
|
||||
printf("TEST-PASS | WindowsDllInterceptor | all checks passed\n");
|
||||
return 0;
|
||||
|
@ -577,7 +577,6 @@ protected:
|
||||
|
||||
enum JumpType {
|
||||
Je,
|
||||
Jne,
|
||||
Jmp,
|
||||
Call
|
||||
};
|
||||
@ -601,11 +600,6 @@ protected:
|
||||
aCode[offset] = 0x75;
|
||||
aCode[offset + 1] = 14;
|
||||
offset += 2;
|
||||
} else if (mType == JumpType::Jne) {
|
||||
// JE RIP+14
|
||||
aCode[offset] = 0x74;
|
||||
aCode[offset + 1] = 14;
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
// Near call/jmp, absolute indirect, address given in r/m32
|
||||
@ -889,8 +883,8 @@ protected:
|
||||
MOZ_ASSERT_UNREACHABLE("Unrecognized opcode sequence");
|
||||
return;
|
||||
}
|
||||
} else if ((origBytes[nOrigBytes] & 0xfa) == 0x48) {
|
||||
// REX.W | REX.WR | REX.WRB | REX.WB
|
||||
} else if ((origBytes[nOrigBytes] & 0xfb) == 0x48) {
|
||||
// REX.W | REX.WR
|
||||
COPY_CODES(1);
|
||||
|
||||
if (origBytes[nOrigBytes] == 0x81 &&
|
||||
@ -1069,9 +1063,6 @@ protected:
|
||||
return;
|
||||
}
|
||||
COPY_CODES(2 + nModRmSibBytes);
|
||||
} else if (origBytes[nOrigBytes] == 0x85) {
|
||||
// test r/m32, r32
|
||||
COPY_CODES(2);
|
||||
} else if (origBytes[nOrigBytes] == 0xd1 &&
|
||||
(origBytes[nOrigBytes+1] & kMaskMod) == kModReg) {
|
||||
// bit shifts/rotates : (SA|SH|RO|RC)(R|L) r32
|
||||
@ -1093,13 +1084,6 @@ protected:
|
||||
origBytes[nOrigBytes] == 0xe8 ? JumpType::Call : JumpType::Jmp);
|
||||
nTrampBytes = jump.GenerateJump(tramp);
|
||||
nOrigBytes += 5;
|
||||
} else if (origBytes[nOrigBytes] == 0x75) {
|
||||
// jne rel8
|
||||
char offset = origBytes[nOrigBytes + 1];
|
||||
JumpPatch jump(nTrampBytes, (intptr_t)(origBytes + nOrigBytes + 2 +
|
||||
offset), JumpType::Jne);
|
||||
nTrampBytes = jump.GenerateJump(tramp);
|
||||
nOrigBytes += 2;
|
||||
} else if (origBytes[nOrigBytes] == 0xff) {
|
||||
COPY_CODES(1);
|
||||
if ((origBytes[nOrigBytes] & (kMaskMod|kMaskReg)) == 0xf0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user