c++ - HTTP request in DLL returns nothing -
i'm trying request dll (which hooked program) no matter try, hangs.
i tried use curl , winhttpclient. both did same thing differently.
curl made program hang long time , displayed nothing (that code isn't commented , contains code other stack overflow questions.)
winhttpclient returns nothing.
// dllmain.cpp : defines entry point dll application. #include "stdafx.h" //#include "winhttpclient/winhttpclient.h" #include <windows.h> #include <iostream> #include <stdio.h> #include <curl/curl.h> using namespace std; // fix later static size_t writecallback(void *contents, size_t size, size_t nmemb, void *userp) { ((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; } extern "c" __declspec(dllexport) void quack(); __declspec(dllexport) void quack() { /*winhttpclient client(l"http://www.google.com"); client.setuseragent(l"mozilla/4.0 (compatible; msie 8.0; windows nt 5.1;...)"); client.sendhttprequest(); wstring httpresponseheader = client.getresponseheader(); wstring httpresponsecontent = client.getresponsecontent(); std::string thingstr((const char*)&httpresponsecontent[0], sizeof(wchar_t) / sizeof(char)*httpresponsecontent.size()); lpcstr thing = (lpcstr)httpresponsecontent.c_str(); messageboxa(null, thing, "quack", mb_ok);*/ curl *curl; curlcode res; std::string readbuffer; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, curlopt_url, "http://www.google.com"); curl_easy_setopt(curl, curlopt_writefunction, writecallback); curl_easy_setopt(curl, curlopt_writedata, &readbuffer); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } messageboxa(null, (lpcstr)readbuffer.c_str(), "quack", mb_ok); } bool apientry dllmain( hmodule hmodule, dword ul_reason_for_call, lpvoid lpreserved ) { switch (ul_reason_for_call) { case dll_process_attach: quack(); case dll_thread_attach: case dll_thread_detach: case dll_process_detach: break; } return true; }
does have solution? answer or suggestion appreciated.
Comments
Post a Comment