flat assembler
Message board for the users of flat assembler.

Index > Windows > Reading files

Author
Thread Post new topic Reply to topic
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
Hello to all!!! I am newbie on forum))) I have some problems with FASM, because I write programms on Delphi before. So, I have a problems with reading files.

So, I read KFB files. This is fractal file, reads like bitmap.
Read algorithm:
0-3 bytes - signature, I skip it.
4-7 bytes - width (4 bytes)
8-11 bytes - height (4 bytes)
From 12 bytes - data, Width*Height 4-byte array.

So, how to initialize and read file as fastest method??? Please, help me...

Afer I will visualize it (SetDIBitsToDevice method).

So, HOW TO WORK WITH FILES???
Post 06 Apr 2014, 09:15
View user's profile Send private message Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
How to load file on this forum???
Post 06 Apr 2014, 09:18
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Isn't there a Delphi reference that shows how to open, read, write and close files?
Post 06 Apr 2014, 09:58
View user's profile Send private message Visit poster's website Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
revolution wrote:
Isn't there a Delphi reference that shows how to open, read, write and close files?


Yes, but I want to open and visualize on fasm.
Post 06 Apr 2014, 10:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Well you posted in the HLL section so I assumed you wanted Delphi help. So anyway, which OS are you using?

This is not a fasm thing BTW, it is an OS function so we need to know which OS.

Also you can examine the fasm sources (like SYSTEM.INC) to see how files can be read and written in assembly under different OSes.
Post 06 Apr 2014, 10:11
View user's profile Send private message Visit poster's website Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
revolution wrote:
Well you posted in the HLL section so I assumed you wanted Delphi help. So anyway, which OS are you using?

This is not a fasm thing BTW, it is an OS function so we need to know which OS.

Also you can examine the fasm sources (like SYSTEM.INC) to see how files can be read and written in assembly under different OSes.


Delphi works very-very slow, I have some calculations when I visualise the map. It works slow, because I want to rewrite all visualization on fasm, but need some help.

Format is MS COFF
Post 06 Apr 2014, 10:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
SeryZone wrote:
Format is MS COFF
So you are using DOS?
Post 06 Apr 2014, 10:21
View user's profile Send private message Visit poster's website Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
revolution wrote:
SeryZone wrote:
Format is MS COFF
So you are using DOS?


No, i use VCL - it's slow and have big exe size.
I badly know WinAPI, I would rewrite all code on fasm else...
Post 06 Apr 2014, 10:24
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
In that case see the file SYSTEM.INC in the windows fasm version. You will see how invoke is used to work with files.
Post 06 Apr 2014, 10:26
View user's profile Send private message Visit poster's website Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
revolution wrote:
In that case see the file SYSTEM.INC in the windows fasm version. You will see how invoke is used to work with files.


Okay, here from SYSTEM.inc
Code:
read:
        mov     ebp,ecx
        push    0
        push    bytes_count
        push    ecx
        push    edx
        push    ebx
        call    [ReadFile]
        or      eax,eax
        jz      file_error
        cmp     ebp,[bytes_count]
        jne     file_error
        clc
        ret
close:
        push    ebx
        call    [CloseHandle]
        ret
lseek:
        movzx   eax,al
        push    eax
        push    0
        push    edx
        push    ebx
        call    [SetFilePointer]
        ret    
Post 06 Apr 2014, 10:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Yup. That is just a manual version of what invoke does. So now you are good to go.
Post 06 Apr 2014, 10:54
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
SeryZone,

In short, you'll need to:You may read EXAMPLES/DDRAW/GIF87A.INC as the example of file parsing in fasm.

Have you determined why the Delphi code works so slow?
Post 06 Apr 2014, 13:58
View user's profile Send private message Reply with quote
SeryZone



Joined: 20 Dec 2013
Posts: 38
Location: Ukraine, Kryviy Rih
SeryZone
revolution wrote:
Yup. That is just a manual version of what invoke does. So now you are good to go.



How to initialize Openfile dialog (with KFB extension)???
Post 06 Apr 2014, 15:00
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
SeryZone wrote:
How to initialize Openfile dialog (with KFB extension)???
So you've done everything else already and proceed to add bells'n'whistles? GetOpenFileName().
Post 06 Apr 2014, 17:29
View user's profile Send private message 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.