From ce4e1b0221cfebad0325137dc5330495775d97c2 Mon Sep 17 00:00:00 2001 From: "cpu@google.com" Date: Sat, 20 Sep 2008 02:44:30 +0000 Subject: 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 --- sandbox/src/target_interceptions.cc | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'sandbox/src/target_interceptions.cc') 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(*base)); - - if (!module_name) - break; - + UINT image_flags; + UNICODE_STRING* module_name = + GetImageInfoFromModule(reinterpret_cast(*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); -- cgit v1.1