Jump to content

Any idea why LoadLibrary() would block the network for the loaded DLL?


Josh
 Share

Recommended Posts

 

I am using LibCurl inside of a plugin for our software. The plugin is compiled to a Windows DLL and loaded by the main application with LoadLibrary(). I have determined that the plugin code works fine when compiled as an EXE, but it always fail to resolve the host name when using it as a DLL and times out.

I tried passing the full path to LoadLibrary, with the assumption it was blocking the network to prevent DLL hijacking attacks, but it made no difference.

Has anyone else encountered something like this? How do you get around the problem?

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I did a simple test with exe, works for me also.

typedef CURL* (__stdcall *f_curl_easy_init)(void);
typedef CURLcode (__stdcall *f_curl_easy_setopt)(CURL *curl, CURLoption option, ...);
typedef CURLcode (__stdcall *f_curl_easy_perform)(CURL *curl);
typedef void (__stdcall *f_curl_easy_cleanup)(CURL *curl);
typedef const char* (__stdcall *f_curl_easy_strerror)(CURLcode);

int main()
{
  HINSTANCE hGetProcIDDLL = LoadLibrary("libcurl-d.dll");
  
  if (!hGetProcIDDLL) {
    std::cout << "could not load the dynamic library" << std::endl;
    return EXIT_FAILURE;
  }
  
  f_curl_easy_init cinit = (f_curl_easy_init)GetProcAddress(hGetProcIDDLL, "curl_easy_init");
  if (!cinit) {
    std::cout << "could not locate the function" << std::endl;
    return EXIT_FAILURE;
  }

You built yourself the curl dll or got it from some other place ?

Maybe your curl dont support some protocols ?

curl.exe -V
curl 7.69.1 (Windows) libcurl/7.69.1
Release-Date: 2020-03-11
Protocols: dict file ftp gopher http imap ldap pop3 rtsp smb smtp telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM

 

I think you should check your plugin , my feeling is the problem is there.

Use curl_easy_strerror to get the textual representation of your error.This should give some clues.

CURL_EXTERN const char *curl_easy_strerror(CURLcode);

 

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

Ok , i created a test.dll that does the curl connection.

extern "C" __declspec(dllexport) int test();

Then another exe that load/executes that, works for me.

 

Make such simple test on your machine.

Have a look here maybe is something related to how the plugin,curl are built:

https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019

Update to the latest libcurl, and build the dll on your machine in case you didnt do that allready.

Dont have other ideas sry.

 

http://www.dependencywalker.com/

on your plugin dll , you can see the exported function, but i suppose all is ok.

https://drmemory.org/

on exe , worth a try but i doubt it will say something.

  • Thanks 1

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...