Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Implementation of NtMapViewOfSection intercept for 32 bit builds. | 5 // Implementation of NtMapViewOfSection intercept for 32 bit builds. |
| 6 // | 6 // |
| 7 // TODO(robertshield): Implement the 64 bit intercept. | 7 // TODO(robertshield): Implement the 64 bit intercept. |
| 8 | 8 |
| 9 #include "chrome_elf/blacklist/blacklist_interceptions.h" | 9 #include "chrome_elf/blacklist/blacklist_interceptions.h" |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool IsSameAsCurrentProcess(HANDLE process) { | 164 bool IsSameAsCurrentProcess(HANDLE process) { |
| 165 return (NtCurrentProcess == process) || | 165 return (NtCurrentProcess == process) || |
| 166 (::GetProcessId(process) == ::GetCurrentProcessId()); | 166 (::GetProcessId(process) == ::GetCurrentProcessId()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace | 169 } // namespace |
| 170 | 170 |
| 171 namespace blacklist { | 171 namespace blacklist { |
| 172 // Allocate storage for the pointer to the old NtMapViewOfSectionFunction. | |
| 173 #pragma section(".oldntmap",write,read) | |
| 174 __declspec(allocate(".oldntmap")) | |
| 175 NtMapViewOfSectionFunction g_nt_map_view_of_section_func = NULL; | |
|
robertshield
2014/01/07 18:30:47
#if defined(_WIN64)?
csharp
2014/01/07 20:43:07
Done.
| |
| 172 | 176 |
| 173 bool InitializeInterceptImports() { | 177 bool InitializeInterceptImports() { |
| 174 g_nt_query_section_func = reinterpret_cast<NtQuerySectionFunction>( | 178 g_nt_query_section_func = reinterpret_cast<NtQuerySectionFunction>( |
| 175 GetNtDllExportByName("NtQuerySection")); | 179 GetNtDllExportByName("NtQuerySection")); |
| 176 g_nt_query_virtual_memory_func = | 180 g_nt_query_virtual_memory_func = |
| 177 reinterpret_cast<NtQueryVirtualMemoryFunction>( | 181 reinterpret_cast<NtQueryVirtualMemoryFunction>( |
| 178 GetNtDllExportByName("NtQueryVirtualMemory")); | 182 GetNtDllExportByName("NtQueryVirtualMemory")); |
| 179 g_nt_unmap_view_of_section_func = | 183 g_nt_unmap_view_of_section_func = |
| 180 reinterpret_cast<NtUnmapViewOfSectionFunction>( | 184 reinterpret_cast<NtUnmapViewOfSectionFunction>( |
| 181 GetNtDllExportByName("NtUnmapViewOfSection")); | 185 GetNtDllExportByName("NtUnmapViewOfSection")); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 if (!module_name.empty() && DllMatch(module_name)) { | 226 if (!module_name.empty() && DllMatch(module_name)) { |
| 223 DCHECK_NT(g_nt_unmap_view_of_section_func); | 227 DCHECK_NT(g_nt_unmap_view_of_section_func); |
| 224 g_nt_unmap_view_of_section_func(process, *base); | 228 g_nt_unmap_view_of_section_func(process, *base); |
| 225 ret = STATUS_UNSUCCESSFUL; | 229 ret = STATUS_UNSUCCESSFUL; |
| 226 } | 230 } |
| 227 | 231 |
| 228 } | 232 } |
| 229 return ret; | 233 return ret; |
| 230 } | 234 } |
| 231 | 235 |
| 236 NTSTATUS WINAPI BlNtMapViewOfSection64( | |
|
csharp
2014/01/07 18:02:40
I had thought about moving this into a 64-bit spec
robertshield
2014/01/07 18:30:47
SGTM. Add #ifdefs around it?
csharp
2014/01/07 20:43:07
Done.
| |
| 237 HANDLE section, HANDLE process, PVOID *base, ULONG_PTR zero_bits, | |
| 238 SIZE_T commit_size, PLARGE_INTEGER offset, PSIZE_T view_size, | |
| 239 SECTION_INHERIT inherit, ULONG allocation_type, ULONG protect) { | |
| 240 return BlNtMapViewOfSection(g_nt_map_view_of_section_func, section, process, | |
| 241 base, zero_bits, commit_size, offset, view_size, | |
| 242 inherit, allocation_type, protect); | |
| 243 } | |
| 244 | |
| 232 } // namespace blacklist | 245 } // namespace blacklist |
| OLD | NEW |