Chromium Code Reviews| Index: chrome_elf/blacklist/blacklist.cc |
| diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc |
| index c7d1a5d77d16857dff3c874dc103c5b68c1ddad7..6a982cf0b60aa5ee9981ee96accb5b45727f4ebb 100644 |
| --- a/chrome_elf/blacklist/blacklist.cc |
| +++ b/chrome_elf/blacklist/blacklist.cc |
| @@ -197,12 +197,6 @@ bool RemoveDllFromBlacklist(const wchar_t* dll_name) { |
| } |
| bool Initialize(bool force) { |
| -#if defined(_WIN64) |
| - // TODO(robertshield): Implement 64-bit support by providing 64-bit |
| - // interceptors. |
| - return false; |
| -#endif |
| - |
| // Check to see that we found the functions we need in ntdll. |
| if (!InitializeInterceptImports()) |
| return false; |
| @@ -229,8 +223,11 @@ bool Initialize(bool force) { |
| // Create a thunk via the appropriate ServiceResolver instance. |
| sandbox::ServiceResolverThunk* thunk; |
| #if defined(_WIN64) |
|
robertshield
2014/01/07 18:30:47
This looks very similar to the 32-bit code.
Can w
csharp
2014/01/07 20:43:07
Done.
|
| - // TODO(robertshield): Use the appropriate thunk for 64-bit support |
| - // when said support is implemented. |
| + if (os_info.version() >= VERSION_WIN8) { |
| + thunk = new sandbox::Win8ResolverThunk(current_process, kRelaxed); |
| + } else { |
| + thunk = new sandbox::ServiceResolverThunk(current_process, kRelaxed); |
| + } |
| #else |
| if (GetWOW64StatusForCurrentProcess() == WOW64_ENABLED) { |
| if (os_info.version() >= VERSION_WIN8) |
| @@ -257,16 +254,37 @@ bool Initialize(bool force) { |
| thunk->AllowLocalPatches(); |
| - // Get ntdll base, target name, interceptor address, |
| + // Replace the default NtMapViewOfSection with our patched version. |
| +#if defined(_WIN64) |
| NTSTATUS ret = thunk->Setup(::GetModuleHandle(sandbox::kNtdllName), |
| reinterpret_cast<void*>(&__ImageBase), |
| "NtMapViewOfSection", |
| NULL, |
| - &blacklist::BlNtMapViewOfSection, |
| + &blacklist::BlNtMapViewOfSection64, |
| thunk_storage, |
| sizeof(sandbox::ThunkData), |
| NULL); |
| + // Keep a pointer to the original code, we don't have enough space to |
| + // add it directly to the call. |
| + g_nt_map_view_of_section_func = reinterpret_cast<NtMapViewOfSectionFunction>( |
| + thunk_storage); |
| + |
| + // Ensure that the pointer to the old function can't be changed. |
| + VirtualProtect(&g_nt_map_view_of_section_func, |
|
robertshield
2014/01/07 18:30:47
consider using the result of this as part of the I
csharp
2014/01/07 20:43:07
Done.
|
| + sizeof(g_nt_map_view_of_section_func), |
| + PAGE_EXECUTE_READ, |
| + &old_protect); |
| +#else |
| + NTSTATUS ret = thunk->Setup(::GetModuleHandle(sandbox::kNtdllName), |
| + reinterpret_cast<void*>(&__ImageBase), |
| + "NtMapViewOfSection", |
| + NULL, |
| + &blacklist::BlNtMapViewOfSection, |
| + thunk_storage, |
| + sizeof(sandbox::ThunkData), |
| + NULL); |
| +#endif |
| delete thunk; |
| // Mark the thunk storage as executable and prevent any future writes to it. |