flat assembler
Message board for the users of flat assembler.

Index > Main > write into file uhh

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
invoke CreateFile,database,GENERIC_ALL, \
NULL, NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE, NULL
mov [datahandle],eax
mov ebx,05h
invoke wsprintf,buffer,shi,ebx

invoke WriteFile,[datahandle],buffer,20h,databytes,0
invoke CloseHandle,[datahandle]

I got this .. How come wsprintf doesnt work for numbers???
Post 22 Dec 2005, 01:59
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Try using "cinvoke" or "ccall" for wsprintf.
You can use the return value of wsprintf to see how long the string is, instead of always writing 20h bytes.
What is "shi"?
Are you saving/restoring ebx after your code is done?

PS: use code tags to paste your code in threads
Post 22 Dec 2005, 03:53
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Code:
invoke  CreateFile,database,GENERIC_ALL, \ 
                NULL, NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE, NULL
               mov [datahandle],eax                                                                                                                                                                                  
              mov ebx,5h
               cinvoke wsprintf,buffer,shi,ebx < ---- crashes here
               
                invoke WriteFile,[datahandle],buffer,20h,databytes,0
                invoke CloseHandle,[datahandle]

shi db "%s",0
database db "collection",0
datahandle dd 0
buffer dd 20
databytes dd ?
    


Last edited by shism2 on 22 Dec 2005, 05:17; edited 1 time in total
Post 22 Dec 2005, 04:29
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
ok, show us declarations of datahandle, buffer, shi, databytes

everything relevant
Post 22 Dec 2005, 04:37
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
there i added it
Post 22 Dec 2005, 05:17
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
i am sure you want:
Code:
buffer rb 20h
and not:
buffer dd 20h
    


you want an array of 32 bytes, not a 4-byte variable that contains the value 32


next time i don't want to see any attitude from you, mmmkay?!
Post 22 Dec 2005, 06:08
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
IceStudent



Joined: 19 Dec 2003
Posts: 60
Location: Ukraine
IceStudent
mov ebx,5h?

So, you want convert number to string? use "%d" instead "%s".
See help for wsprintf.
Post 22 Dec 2005, 10:22
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
what attitude lol?????

but thanks comrade you know your stuff Wink


also thanks ice
Post 22 Dec 2005, 12:05
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
%s with 05h byte would work in a way, that it would try to put ASCII char 05h which is some unprintable, control byte (some tab, space, carriage or other have such low values).
Post 22 Dec 2005, 20:16
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.