Bug 1230910 Cast GetProcAddress to (void*) draft
authorTom Ritter <tom@mozilla.com>
Wed, 30 Aug 2017 11:21:47 -0500
changeset 656086 95bba1e797682e55f7a13e5139533dc9282b9142
parent 656085 b579918f14260303ffb48b66f13327b3cab2c47d
child 656087 84f4b76f7b08a80440e372fb0359b58c3254b66c
push id77058
push userbmo:tom@mozilla.com
push dateWed, 30 Aug 2017 18:21:00 +0000
bugs1230910, 13958081
milestone57.0a1
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 fixup for itself automatically, while for mingw we need to do it manually. MozReview-Commit-ID: 7HhISnxBLJ9
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/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
@@ -184,17 +184,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;