| View previous topic :: View next topic |
| Author |
Message |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Mon Jul 21, 2008 5:25 am Post subject: [C++][Resolved] URLDownloadToFile or InternetOpenURL |
|
|
Hi,
My program should download a certain file from the internet (small file, few KB). I tried using both URLDownloadToFile (urlmon.lib) and InternetOpenURL (wininet.lib). But somehow when my code calls URLDownloadToFile or InternetOpenURL the function doesn't return. My program is a dll.
The weird thing is that when I compile the exact same project as a .exe it works completely fine. But as soon as one of those internet functions is called from inside a dll they don't return. I've tried setting the timeout and so on, but no luck. I programmed the same project in MASM but also there the functions only work from a .exe.
Any help or solution would be appreciated.
Thanks in advance,
-Tombana
(By the way: The dll must be loaded by LoadLibrary, not linked because I want it to be injectable)
EDIT:
I've found the problem. I feel soooo stupid . I called those functions from inside the DllMain function instead of creating a new thread which calls the functions. (Yes I know the DllMain function should perform as least operations as possible but I didn't do that because I was just testing)
Last edited by tombana on Mon Jul 21, 2008 3:43 pm; edited 2 times in total |
|
| Back to top |
|
 |
b6ooy Grandmaster Cheater
Reputation: 0
Joined: 21 Sep 2006 Posts: 653
|
Posted: Mon Jul 21, 2008 5:33 am Post subject: |
|
|
I never used this method , but i think you have to call InternetOpen before InternetOpenURL ..
Or use ShellExecute and open it directly [ easier ] ..
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Mon Jul 21, 2008 8:09 am Post subject: |
|
|
Yes I used InternetOpen before InternetOpenURL.
And the user isn't meant to see that the file is downloaded.
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Mon Jul 21, 2008 9:46 am Post subject: |
|
|
im not sure, but it may be the fact that its in a dll that it wont work properly, try it in an exe and see
_________________
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Mon Jul 21, 2008 10:39 am Post subject: |
|
|
Sorry if I wasn't clear but that's what I said. It works in an exe but the same code in a dll doesn't work.
So are there more win32 api's that have this or just these? Is there a solution?
(If there's not I think I'll try to download the file through winsock)
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Mon Jul 21, 2008 10:49 am Post subject: |
|
|
Winsock you would probably have to connect to the host and then make a get request. I suggest you do what you're doing now. Winsock would be too much trouble and work.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Mon Jul 21, 2008 3:20 pm Post subject: |
|
|
| What I'm doing now would be very easy if it would work lol.... but if it doesn't I will have to find another way, like manual Winsock stuff.
|
|
| Back to top |
|
 |
|