title: syscall.MustLoadDll.MustFindProc throws "The specified procedure could not be found"
body: <p>I have written a dynamic link library in c++ and export it correctly, in order to enable Go to fetch adapter infomation using Win32 API. But when I call its function in Go, it throws &quot;The specified procedure could not be found&quot; error.
  I'm totally new with Go, so I have no idea how to solve it. Could anybody help me?</p>
  <p>Here's some infomation about my environment:</p>
  <blockquote>
  <p>platform: windows 10 x64</p>
  <p>CXX compiler: visual c++ 15.3</p>
  <p>go version: go1.11.2 windows/amd64</p>
  </blockquote>
  <p>Here is my code:</p>
  <pre><code>#include &quot;stdafx.h&quot;
  #include &lt;WinSock2.h&gt;
  #include &lt;iphlpapi.h&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  __declspec(dllexport) const char *get_default_gateway();
  
  vector &lt;string&gt; default_gateway;
  
  const char *get_default_gateway()
  {
  
      PIP_ADAPTER_INFO pIpAdapterInfo = new IP_ADAPTER_INFO();
      PIP_ADAPTER_INFO info_p;
  
      unsigned long stSize = sizeof(IP_ADAPTER_INFO);
  
      int nRel = GetAdaptersInfo(pIpAdapterInfo, &amp;stSize);
      info_p = pIpAdapterInfo;
  
      if (ERROR_BUFFER_OVERFLOW == nRel)
      {
          delete pIpAdapterInfo;
      
          pIpAdapterInfo = (PIP_ADAPTER_INFO)new BYTE[stSize];
      
          nRel = GetAdaptersInfo(pIpAdapterInfo, &amp;stSize);
          info_p = pIpAdapterInfo;
      }
      if (ERROR_SUCCESS == nRel)
      {
      
          while (info_p)
          {
          
              IP_ADDR_STRING *pIpAddrString = &amp;(info_p-&gt;IpAddressList);
              do
              {
                  string gateway_tmp = info_p-&gt;GatewayList.IpAddress.String;
                  if (gateway_tmp != &quot;0.0.0.0&quot;) {
                      default_gateway.push_back(info_p-&gt;GatewayList.IpAddress.String);
                  }
                  pIpAddrString = pIpAddrString-&gt;Next;
              } while (pIpAddrString);
              info_p = info_p-&gt;Next;
          }
  
      }
  
      if (pIpAdapterInfo)
      {
          delete []pIpAdapterInfo;
      }
  
      const char *gateway = default_gateway.at(0).c_str();
      return gateway;
  }
  </code></pre>
  <p>Here is my golang code:</p>
  <pre><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;syscall&quot;
      &quot;unsafe&quot;
  )
  
  func main() {
      dll := syscall.MustLoadDLL(&quot;getAdapterInfo.dll&quot;)
      getDefaultGateWay := dll.MustFindProc(&quot;get_default_gateway&quot;)
  
      r, _, _ := getDefaultGateWay.Call()
      p := (*byte)(unsafe.Pointer(r))
      data := make([]byte, 0)
  
      for *p != 0 {
          data = append(data, *p)        
          r += unsafe.Sizeof(byte(0))    
          p = (*byte)(unsafe.Pointer(r)) 
      }
      str := string(data) 
  
      fmt.Printf(&quot;%s\n&quot;, str)
  }
  </code></pre>
  <p>Here is the terminal output info:</p>
  <pre><code>panic: Failed to find get_default_gateway procedure in getAdapterInfo.dll: 
  The specified procedure could not be found.
  
  goroutine 1 [running]:
  syscall.(*DLL).MustFindProc(0xc000056400, 0x4c4934, 0x13, 0xc000081f48)
          E:/Go/src/syscall/dll_windows.go:109 +0x80
  main.main()
          E:/GOPATH/src/github.com/Arktische/test/main.go:11 +0x67
  </code></pre>