diff options
author | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-18 00:26:01 +0000 |
---|---|---|
committer | cpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-18 00:26:01 +0000 |
commit | 9cd0144cccf979ecce9f193f77e50c05544bc4a7 (patch) | |
tree | 548283eb1965017d2f1c46e9bb63aa8cbc7816d5 /sandbox/src/interception.cc | |
parent | 35aa85ac00fbfa16bd9f52b05e47eb09a3b6a0ce (diff) | |
download | chromium_src-9cd0144cccf979ecce9f193f77e50c05544bc4a7.zip chromium_src-9cd0144cccf979ecce9f193f77e50c05544bc4a7.tar.gz chromium_src-9cd0144cccf979ecce9f193f77e50c05544bc4a7.tar.bz2 |
Add an interface to the sandbox to block dll from loading in the target process
- new interface is TargetPolicy::AddDllToUnload
- Added integration tests and unit tests.
Review URL: http://codereview.chromium.org/2413
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/src/interception.cc')
-rw-r--r-- | sandbox/src/interception.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sandbox/src/interception.cc b/sandbox/src/interception.cc index 198cdbf..8ee56f4 100644 --- a/sandbox/src/interception.cc +++ b/sandbox/src/interception.cc @@ -30,6 +30,9 @@ namespace sandbox { SANDBOX_INTERCEPT SharedMemory* g_interceptions; +// Magic constant that identifies that this function is not to be patched. +const char kUnloadDLLDummyFunction[] = "@"; + InterceptionManager::InterceptionManager(TargetProcess* child_process, bool relaxed) : child_(child_process), names_used_(false), relaxed_(relaxed) { @@ -49,7 +52,6 @@ bool InterceptionManager::AddToPatchedFunctions( function.interceptor_address = replacement_code_address; interceptions_.push_back(function); - return true; } @@ -65,7 +67,19 @@ bool InterceptionManager::AddToPatchedFunctions( interceptions_.push_back(function); names_used_ = true; + return true; +} +bool InterceptionManager::AddToUnloadModules(const wchar_t* dll_name) { + InterceptionData module_to_unload; + module_to_unload.type = INTERCEPTION_UNLOAD_MODULE; + module_to_unload.dll = dll_name; + // The next two are dummy values that make the structures regular, instead + // of having special cases. They should not be used. + module_to_unload.function = kUnloadDLLDummyFunction; + module_to_unload.interceptor_address = reinterpret_cast<void*>(1); + + interceptions_.push_back(module_to_unload); return true; } @@ -204,6 +218,7 @@ bool InterceptionManager::SetupDllInfo(const InterceptionData& data, *buffer = reinterpret_cast<char*>(*buffer) + required; // set up the dll info to be what we know about it at this time + dll_info->unload_module = (data.type == INTERCEPTION_UNLOAD_MODULE); dll_info->record_bytes = required; dll_info->offset_to_functions = required; dll_info->num_functions = 0; @@ -221,6 +236,12 @@ bool InterceptionManager::SetupInterceptionInfo(const InterceptionData& data, DCHECK(buffer); DCHECK(*buffer); + if ((dll_info->unload_module) && + (data.function != kUnloadDLLDummyFunction)) { + // Can't specify a dll for both patch and unload. + NOTREACHED(); + } + FunctionInfo* function = reinterpret_cast<FunctionInfo*>(*buffer); size_t name_bytes = data.function.size(); |