Here?s a piece that will get you automagically the last beta version of FASM:


;
; Modifyed from a snippet by Ates
;

format PE GUI 4.0

include 'include\kernel.inc'
include 'include\user.inc'

include 'include\macro\stdcall.inc'
include 'include\macro\import.inc'


invoke MessageBox,0,msg1,cap1,MB_ICONQUESTION+MB_YESNO
cmp eax,IDYES
jne exit

call GetInetFile
cmp eax, TRUE
jne Err

Ok: invoke MessageBox,0,msgOk,msgCap,MB_OK
jmp exit
;FASM will optimize this ;)

Err: invoke MessageBox,0,msgErr,msgCap,MB_OK

exit: invoke ExitProcess,0

GetInetFile:

invoke GetModuleHandle,0
invoke GetModuleFileName,eax,fileName,127

invoke InternetOpen,fileName,0,0,0,0
mov [hSession],eax
cmp eax,INVALID_HANDLE_VALUE
je .exit

invoke InternetOpenUrl,[hSession],fileUrl,0,0,0,0
mov [hUrl],eax
cmp eax,INVALID_HANDLE_VALUE
je .exit

invoke CreateFile,fileSave,GENERIC_READ+GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov [fHand],eax
cmp eax,INVALID_HANDLE_VALUE
je .exit

invoke SetFilePointer,[fHand],0,0,FILE_BEGIN

.download:
invoke InternetReadFile,[hUrl],buffer,1024,buflong
or [buflong],0
jz .close

invoke WriteFile,[fHand],buffer,[buflong],bwrite,0
jmp .download
.close:
invoke CloseHandle,[fHand]
invoke InternetCloseHandle,[hUrl]
invoke InternetCloseHandle,[hSession]
mov eax,TRUE
ret
.exit:
mov eax,FALSE
ret

msg1 db 'Do you want to download FASM 1.40 beta ?',0
cap1 db 'AN IMPORTANT QUESTION',0

fileUrl db 'http://fasm.metro-nt.pl/fasm140b.zip',0
fileSave db 'fasm140b.zip',0
msgOk db 'Download Success!',0
msgErr db 'Download Failed!',0
msgCap db 'Result:',0

fileName: times 127 db ?
buffer: times 1024 db ?

fHand dd ?
bwrite dd ?
buflong dd ?
hSession dd ?
hUrl dd ?


data import

library kernel,'KERNEL32.DLL',\
user,'USER32.DLL',\
wininet,'wininet.dll'

kernel:
import ExitProcess,'ExitProcess',\
GetModuleHandle,'GetModuleHandleA',\
GetModuleFileName,'GetModuleFileNameA',\
CreateFile,'CreateFileA',\
SetFilePointer,'SetFilePointer',\
WriteFile,'WriteFile',\
CloseHandle,'CloseHandle'

user:
import MessageBox,'MessageBoxA'

wininet:
import InternetOpen,'InternetOpenA',\
InternetOpenUrl,'InternetOpenUrlA',\
InternetReadFile,'InternetReadFile',\
InternetCloseHandle,'InternetCloseHandle'

end data

data fixups
end data



And here?s the zip file:
Posted on 2002-07-26 08:40:27 by slop
:)
Posted on 2002-07-26 12:55:35 by zjlcc
Thank you, zjlcc, much better now.

(I?m improving my sloppiness yet ;)
Posted on 2002-07-26 12:59:46 by slop
zjlcc: You have cut the file manually, haven't you? It doesn't work on Win2000 because of that.
Posted on 2002-07-26 13:09:28 by Tomasz Grysztar
Sorry about that, I think the first one posted doesn?t work either?n WIn2000... I just don?t know what I touched last night, before saving.

Sorry(I?m debugging it though with OllyDbg, from your site, looks great the debugger)
Posted on 2002-07-26 13:11:35 by slop
No, the first one works fine. The second one also works fine when you reassemble it, but it has 1536 bytes then.
Posted on 2002-07-26 13:13:28 by Tomasz Grysztar
yes,internet2.exe ` size is 1536 byte,
my os is 98 not 2000
:) sorry
Posted on 2002-07-26 13:14:54 by zjlcc
Okay, thanx Privalov, I wish I had more time to keep asking you, but my girl-friend...
It?s been a great pleasure to talk with a Posted on 2002-07-26 13:15:01 by slop
What happens when the version changes?
Posted on 2002-07-26 13:56:38 by grv575
Well, sometimes it works in 9x and it doesn?t in NT.
The ideal is that works in both of them, that?s what Win32 API means.

(Sometimes it doesn?t work in any, but that?s, er... well, don?t look at me, it?s called sloppiness ;)
Posted on 2002-07-29 10:42:10 by slop
This would be a great addition to the program. It would need to be a little more dynamic. Like it checks for a file online that has the latest realease info and then fills that into the message box and downloadable. Maybe it even self checks and tells you if you need to update.

Great program!
Posted on 2002-08-07 01:23:19 by CsnWltr
No way!

Imagine: maybe the guy does?n't feel like updating, maybe he loves version 1.31 (which I still use sometimes ;)... you never have to think for the guy.
In fact, I love FASM because of the liberty it gives you... this was just a funny thing, so that people could tell me what I was doing wrong, or so (as you can see I?m a newbie), but JUST THAT.

Anyway, your idea reminds me of somebody... do you know Bill? (that?s his method ;))
Posted on 2002-08-08 10:05:11 by slop
Actually, Bill's method is good, and I even plan to write a library for an AutoUpdate system...

The guy who wants to preserve his version won't bother himself to have an update-reminder tool running on his system all the time (nor to check periodically).
And even if he doesn't want to update, but obviously still run the tool all he has to do to not update is answering "No" to the MessageBox question "A new version of FASM (x.xxx) is available. Do you want to update ?"
I am wrong ? :)
Posted on 2002-08-08 10:59:51 by JCP
Okey, I see your point :)
But it?s Tomasz that has to answer to this question ;)

CsnWltr:
Great program!
I agree with you, the program is great, then I only translated it. The original idea from Ates. He?s the great guy :)


Readiosys , avec mes salutations les plus coordielles,
Posted on 2002-08-08 12:32:02 by slop
It's been a couple of months, and I still don?t know what's the bug with this code.
Nobody has reported it yet, so I'm giving a beer to the first that finds it.
I know it's something like a NULL missing or an address instead of a pointer, but I prefer to give the beer.
Because this has several advantages:
1)I get a new friend,
2) I drink another :)
3) I don?t know, I feel lazy.
Posted on 2002-09-30 04:32:36 by slop