Bug 1230910 Cast GetProcAddress to (void*) draft
authorTom Ritter <tom@mozilla.com>
Wed, 08 Mar 2017 22:28:21 +0000
changeset 496066 4b5f0764277f6788f6978fb282ea472c3c6be94c
parent 496065 4a5417371651ea8a2e7fd6d82fd9b6ae4ca14d7e
child 496067 f34b617d41f893eb917e6fe6716cd533cccc9aa9
push id48518
push userbmo:tom@mozilla.com
push dateThu, 09 Mar 2017 19:30:51 +0000
bugs1230910, 13958081
milestone52.0.1
Bug 1230910 Cast GetProcAddress to (void*) error: invalid conversion from 'FARPROC {aka int (__attribute__((__stdcall__)) *)()}' to 'void*' [-fpermissive] According to http://stackoverflow.com/questions/13958081/, msvc does the fixuo for itself automatically, while for mingw we need to do it manually. MozReview-Commit-ID: LkMeeAQnkLU
security/sandbox/chromium/sandbox/win/src/app_container.cc
security/sandbox/chromium/sandbox/win/src/resolver.cc
security/sandbox/chromium/sandbox/win/src/service_resolver.cc
security/sandbox/chromium/sandbox/win/src/target_process.cc
--- a/security/sandbox/chromium/sandbox/win/src/app_container.cc
+++ b/security/sandbox/chromium/sandbox/win/src/app_container.cc
@@ -22,20 +22,20 @@ PSID ConvertSid(const base::string16& si
   if (!ConvertStringSidToSid(sid.c_str(), &local_sid))
     return NULL;
   return local_sid;
 }
 
 template <typename T>
 T BindFunction(const char* name) {
   HMODULE module = GetModuleHandle(sandbox::kKerneldllName);
-  void* function = GetProcAddress(module, name);
+  void* function = (void*)GetProcAddress(module, name);
   if (!function) {
     module = GetModuleHandle(sandbox::kKernelBasedllName);
-    function = GetProcAddress(module, name);
+    function = (void*)GetProcAddress(module, name);
   }
   return reinterpret_cast<T>(function);
 }
 
 }  // namespace
 
 namespace sandbox {
 
--- a/security/sandbox/chromium/sandbox/win/src/resolver.cc
+++ b/security/sandbox/chromium/sandbox/win/src/resolver.cc
@@ -48,17 +48,17 @@ NTSTATUS ResolverThunk::ResolveIntercept
   DCHECK_NT(address);
   if (!interceptor_module)
     return STATUS_INVALID_PARAMETER;
 
   base::win::PEImage pe(interceptor_module);
   if (!pe.VerifyMagic())
     return STATUS_INVALID_IMAGE_FORMAT;
 
-  *address = pe.GetProcAddress(interceptor_name);
+  *address = (void*)pe.GetProcAddress(interceptor_name);
 
   if (!(*address))
     return STATUS_PROCEDURE_NOT_FOUND;
 
   return STATUS_SUCCESS;
 }
 
 }  // namespace sandbox
--- a/security/sandbox/chromium/sandbox/win/src/service_resolver.cc
+++ b/security/sandbox/chromium/sandbox/win/src/service_resolver.cc
@@ -24,17 +24,17 @@ NTSTATUS ServiceResolverThunk::ResolveIn
 // just a simple GetProcAddress.
 NTSTATUS ServiceResolverThunk::ResolveTarget(const void* module,
                                              const char* function_name,
                                              void** address) {
   if (NULL == module)
     return STATUS_UNSUCCESSFUL;
 
   base::win::PEImage module_image(module);
-  *address = module_image.GetProcAddress(function_name);
+  *address = (void*)module_image.GetProcAddress(function_name);
 
   if (NULL == *address) {
     NOTREACHED_NT();
     return STATUS_UNSUCCESSFUL;
   }
 
   return STATUS_SUCCESS;
 }
--- a/security/sandbox/chromium/sandbox/win/src/target_process.cc
+++ b/security/sandbox/chromium/sandbox/win/src/target_process.cc
@@ -239,17 +239,17 @@ ResultCode TargetProcess::TransferVariab
 
   void* child_var = address;
 
 #if SANDBOX_EXPORTS
   HMODULE module = ::LoadLibrary(exe_name_.get());
   if (NULL == module)
     return SBOX_ERROR_GENERIC;
 
-  child_var = ::GetProcAddress(module, name);
+  child_var = (void*)::GetProcAddress(module, name);
   ::FreeLibrary(module);
 
   if (NULL == child_var)
     return SBOX_ERROR_GENERIC;
 
   size_t offset = reinterpret_cast<char*>(child_var) -
                   reinterpret_cast<char*>(module);
   child_var = reinterpret_cast<char*>(MainModule()) + offset;