Josh Posted March 22, 2020 Share Posted March 22, 2020 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? Quote 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 More sharing options...
Ma-Shell Posted March 22, 2020 Share Posted March 22, 2020 Have you tried temporarily turning off windows firewall? Quote Link to comment Share on other sites More sharing options...
aiaf Posted March 22, 2020 Share Posted March 22, 2020 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); Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Josh Posted March 22, 2020 Author Share Posted March 22, 2020 50 minutes ago, Ma-Shell said: Have you tried temporarily turning off windows firewall? Yes. Quote 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 More sharing options...
Josh Posted March 22, 2020 Author Share Posted March 22, 2020 @aiaf If you build your app as a DLL and then load that DLL from another EXE, that is what I am doing. Quote 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 More sharing options...
aiaf Posted March 22, 2020 Share Posted March 22, 2020 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. 1 Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Josh Posted March 22, 2020 Author Share Posted March 22, 2020 Strange. Thanks for the info. Quote 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 More sharing options...
Recommended Posts
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.