News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

FTP crash issue

Started by drarem, December 22, 2004, 06:33:54 PM

Previous topic - Next topic

drarem

This is a question I probably won't be able to research thoroughly but need some help with..  I read somewhere on the MSDN site the other day, I had to do something with the FTP, otherwise if there is a timeout then the program crashes.. low and behold, it is true when I create the time-out thread, but I don't know what that one thing is..

I have a separate thread as the MSDN site describes for timing-out a FTP connection/read and I think I close everything ok - if there is a timeout which is set to 5000 msecs (dwTimeoutValue), the program crashes.  Below is the code:


invoke InternetOpen,addr appName,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0
.if eax==NULL
invoke MessageBox,NULL,addr lpconnect, etitle,MB_OK
.else
mov hOpen,eax
.endif

invoke CreateThread,NULL,1000,OFFSET INETCONNECT,NULL,0,threadID
mov hTimeout,eax
invoke WaitForSingleObject, hTimeout, dwTimeoutValue
cmp eax,WAIT_TIMEOUT
jne @F
invoke MessageBox,NULL,addr lpconnect, etitle,MB_OK
.if hOpen != NULL
invoke InternetCloseHandle,hOpen
.endif

mov hval,0
invoke GetExitCodeThread,hTimeout,hval
.if eax==NULL
invoke MessageBox,NULL,addr lpExitProcess, addr etitle,MB_OK
.endif

invoke CloseHandle,hTimeout
mov FGF,0
jmp exit_func
@@:


And here is my INETCONNECT proc:
INETCONNECT proc vParam:DWORD


invoke InternetConnect,hOpen,addr serverName, INTERNET_DEFAULT_FTP_PORT, addr userName, addr userPassword,INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,addr Crap
.if eax==NULL
invoke GetLastError
invoke wsprintf,addr lpOut, addr lpFmt, FGF
invoke MessageBox,NULL,addr lpOut, addr lpOut,MB_OK
.endif

mov ftpHandle,eax

ret
INETCONNECT endp