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 #if defined(_WIN64) | |
173 // Allocate storage for the pointer to the old NtMapViewOfSectionFunction. | |
174 #pragma section(".oldntmap",write,read) | |
175 __declspec(allocate(".oldntmap")) | |
176 NtMapViewOfSectionFunction g_nt_map_view_of_section_func = NULL; | |
robertshield
2014/02/06 20:04:33
Any reason to declare this here rather than where
csharp
2014/02/06 22:29:24
Nope, moved.
| |
177 #endif | |
172 | 178 |
173 bool InitializeInterceptImports() { | 179 bool InitializeInterceptImports() { |
174 g_nt_query_section_func = reinterpret_cast<NtQuerySectionFunction>( | 180 g_nt_query_section_func = reinterpret_cast<NtQuerySectionFunction>( |
175 GetNtDllExportByName("NtQuerySection")); | 181 GetNtDllExportByName("NtQuerySection")); |
176 g_nt_query_virtual_memory_func = | 182 g_nt_query_virtual_memory_func = |
177 reinterpret_cast<NtQueryVirtualMemoryFunction>( | 183 reinterpret_cast<NtQueryVirtualMemoryFunction>( |
178 GetNtDllExportByName("NtQueryVirtualMemory")); | 184 GetNtDllExportByName("NtQueryVirtualMemory")); |
179 g_nt_unmap_view_of_section_func = | 185 g_nt_unmap_view_of_section_func = |
180 reinterpret_cast<NtUnmapViewOfSectionFunction>( | 186 reinterpret_cast<NtUnmapViewOfSectionFunction>( |
181 GetNtDllExportByName("NtUnmapViewOfSection")); | 187 GetNtDllExportByName("NtUnmapViewOfSection")); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 if (!module_name.empty() && DllMatch(module_name)) { | 228 if (!module_name.empty() && DllMatch(module_name)) { |
223 DCHECK_NT(g_nt_unmap_view_of_section_func); | 229 DCHECK_NT(g_nt_unmap_view_of_section_func); |
224 g_nt_unmap_view_of_section_func(process, *base); | 230 g_nt_unmap_view_of_section_func(process, *base); |
225 ret = STATUS_UNSUCCESSFUL; | 231 ret = STATUS_UNSUCCESSFUL; |
226 } | 232 } |
227 | 233 |
228 } | 234 } |
229 return ret; | 235 return ret; |
230 } | 236 } |
231 | 237 |
238 NTSTATUS WINAPI BlNtMapViewOfSection64( | |
239 HANDLE section, HANDLE process, PVOID *base, ULONG_PTR zero_bits, | |
240 SIZE_T commit_size, PLARGE_INTEGER offset, PSIZE_T view_size, | |
241 SECTION_INHERIT inherit, ULONG allocation_type, ULONG protect) { | |
242 return BlNtMapViewOfSection(g_nt_map_view_of_section_func, section, process, | |
243 base, zero_bits, commit_size, offset, view_size, | |
244 inherit, allocation_type, protect); | |
245 } | |
246 | |
232 } // namespace blacklist | 247 } // namespace blacklist |
OLD | NEW |