Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1831)

Unified Diff: sandbox/win/src/app_container.cc

Issue 24296002: Sandbox: Update for Windows 8.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sandbox/win/src/internal_types.h » ('j') | sandbox/win/src/sandbox_nt_util.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/app_container.cc
===================================================================
--- sandbox/win/src/app_container.cc (revision 223979)
+++ sandbox/win/src/app_container.cc (working copy)
@@ -23,6 +23,17 @@
return local_sid;
}
+template <typename T>
+T BindFunction(const char* name) {
+ HMODULE module = GetModuleHandle(sandbox::kKerneldllName);
+ void* function = GetProcAddress(module, name);
+ if (!function) {
+ module = GetModuleHandle(sandbox::kKernelBasedllName);
+ function = GetProcAddress(module, name);
+ }
+ return reinterpret_cast<T>(function);
+}
+
} // namespace
namespace sandbox {
@@ -94,9 +105,8 @@
static AppContainerRegisterSidPtr AppContainerRegisterSid = NULL;
if (!AppContainerRegisterSid) {
- HMODULE module = GetModuleHandle(kKerneldllName);
- AppContainerRegisterSid = reinterpret_cast<AppContainerRegisterSidPtr>(
- GetProcAddress(module, "AppContainerRegisterSid"));
+ AppContainerRegisterSid =
+ BindFunction<AppContainerRegisterSidPtr>("AppContainerRegisterSid");
}
ResultCode operation_result = SBOX_ERROR_GENERIC;
@@ -120,9 +130,8 @@
static AppContainerUnregisterSidPtr AppContainerUnregisterSid = NULL;
if (!AppContainerUnregisterSid) {
- HMODULE module = GetModuleHandle(kKerneldllName);
- AppContainerUnregisterSid = reinterpret_cast<AppContainerUnregisterSidPtr>(
- GetProcAddress(module, "AppContainerUnregisterSid"));
+ AppContainerUnregisterSid =
+ BindFunction<AppContainerUnregisterSidPtr>("AppContainerUnregisterSid");
}
ResultCode operation_result = SBOX_ERROR_GENERIC;
@@ -150,11 +159,10 @@
static AppContainerFreeMemoryPtr AppContainerFreeMemory = NULL;
if (!AppContainerLookupMoniker || !AppContainerFreeMemory) {
- HMODULE module = GetModuleHandle(kKerneldllName);
- AppContainerLookupMoniker = reinterpret_cast<AppContainerLookupMonikerPtr>(
- GetProcAddress(module, "AppContainerLookupMoniker"));
- AppContainerFreeMemory = reinterpret_cast<AppContainerFreeMemoryPtr>(
- GetProcAddress(module, "AppContainerFreeMemory"));
+ AppContainerLookupMoniker =
+ BindFunction<AppContainerLookupMonikerPtr>("AppContainerLookupMoniker");
+ AppContainerFreeMemory =
+ BindFunction<AppContainerFreeMemoryPtr>("AppContainerFreeMemory");
}
if (!AppContainerLookupMoniker || !AppContainerFreeMemory)
« no previous file with comments | « no previous file | sandbox/win/src/internal_types.h » ('j') | sandbox/win/src/sandbox_nt_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698