summaryrefslogtreecommitdiffstats
path: root/sandbox/src/target_interceptions.cc
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-20 02:44:30 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-20 02:44:30 +0000
commitce4e1b0221cfebad0325137dc5330495775d97c2 (patch)
treea60d872b2796754f2ae5a4717e1d9b4403b9d1f4 /sandbox/src/target_interceptions.cc
parent54d80bb02aa71eb957a863109392cd97ea1e2496 (diff)
downloadchromium_src-ce4e1b0221cfebad0325137dc5330495775d97c2.zip
chromium_src-ce4e1b0221cfebad0325137dc5330495775d97c2.tar.gz
chromium_src-ce4e1b0221cfebad0325137dc5330495775d97c2.tar.bz2
Redo change 2413 that I had to back out before
- CL is identical and was already lgtm TBR=rvargas Review URL: http://codereview.chromium.org/3179 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/src/target_interceptions.cc')
-rw-r--r--sandbox/src/target_interceptions.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/sandbox/src/target_interceptions.cc b/sandbox/src/target_interceptions.cc
index 0bf9cd6..8a77533 100644
--- a/sandbox/src/target_interceptions.cc
+++ b/sandbox/src/target_interceptions.cc
@@ -11,6 +11,8 @@
namespace sandbox {
+SANDBOX_INTERCEPT NtExports g_nt;
+
// Hooks NtMapViewOfSection to detect the load of DLLs. If hot patching is
// required for this dll, this functions patches it.
NTSTATUS WINAPI TargetNtMapViewOfSection(
@@ -41,18 +43,26 @@ NTSTATUS WINAPI TargetNtMapViewOfSection(
if (!IsValidImageSection(section, base, offset, view_size))
break;
- UNICODE_STRING* module_name = GetImageNameFromModule(
- reinterpret_cast<HMODULE>(*base));
-
- if (!module_name)
- break;
-
+ UINT image_flags;
+ UNICODE_STRING* module_name =
+ GetImageInfoFromModule(reinterpret_cast<HMODULE>(*base), &image_flags);
UNICODE_STRING* file_name = GetBackingFilePath(*base);
+ if ((!module_name) && (image_flags & MODULE_HAS_CODE)) {
+ // If the module has no exports we retrieve the module name from the
+ // full path of the mapped section.
+ module_name = ExtractModuleName(file_name);
+ }
+
InterceptionAgent* agent = InterceptionAgent::GetInterceptionAgent();
- if (agent)
- agent->OnDllLoad(file_name, module_name, *base);
+ if (agent) {
+ if (!agent->OnDllLoad(file_name, module_name, *base)) {
+ // Interception agent is demanding to un-map the module.
+ g_nt.UnmapViewOfSection(process, *base);
+ ret = STATUS_UNSUCCESSFUL;
+ }
+ }
if (module_name)
operator delete(module_name, NT_ALLOC);