flat assembler
Message board for the users of flat assembler.

Index > Windows > How to send the ATA command 34h with DeviceIoControl

Author
Thread Post new topic Reply to topic
Atlas



Joined: 05 Jun 2017
Posts: 7
Atlas 05 Jun 2017, 11:44
How to send the ATA command 34h(write sector(s) with DeviceIoControl using the ATA_PASS_THRU structure? I dont know how to declare this struct in FASM but im MASM i declare:
Code:
ATA_PASS_THRU STRUCT DWORD
        Length1                         WORD  ?
        AtaFlags                        WORD  ?
        PathId                          BYTE  ? 
        TargetId                        BYTE  ?
        Lun                             BYTE  ?
        Reserved1                       BYTE  ?
        DataTransferLength              DWORD  ?
        TimeOutValue                    DWORD  ?
        Reserved2                       DWORD  ?
        DATABUFFEROFFSET                DWORD  ?
        align 8
        Ata1                            ATA_STRUCT1 <>
        align 8
        Ata2                            ATA_STRUCT2 <>
        ATA_PASS_THRU ENDS
        PTE1 ATA_PASS_THRU <>
    

How to declare this structure in FASM and how to use the ATA command write sector LBA-48?
Post 05 Jun 2017, 11:44
View user's profile Send private message Reply with quote
Atlas



Joined: 05 Jun 2017
Posts: 7
Atlas 06 Jun 2017, 08:40
Aaahhrrr! If nobody answer I will have a hysterical attack. I am being mad!
Post 06 Jun 2017, 08:40
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 06 Jun 2017, 09:10
Very Happy
Post 06 Jun 2017, 09:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20309
Location: In your JS exploiting you and your system
revolution 06 Jun 2017, 09:20
Atlas == Apolo
Post 06 Jun 2017, 09:20
View user's profile Send private message Visit poster's website Reply with quote
Atlas



Joined: 05 Jun 2017
Posts: 7
Atlas 06 Jun 2017, 10:41
I just want to know how to declare struct inside struct as I show above. How to issue ATA command 34h with an IOCTL_ATA_PASS_THROUGH_DIRECT request to write at hard disk sector ?
Post 06 Jun 2017, 10:41
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 06 Jun 2017, 10:51
Atlas wrote:
I just want to know how to declare struct inside struct as I show above. How to issue ATA command 34h with an IOCTL_ATA_PASS_THROUGH_DIRECT request to write at hard disk sector ?


You can declare structures inside structures in FASM, regardless of whether you use the native "struc{}" form or any of the "struct" macro forms.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 06 Jun 2017, 10:51
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Atlas



Joined: 05 Jun 2017
Posts: 7
Atlas 06 Jun 2017, 11:02
JohnFound wrote:
use the native "struc{}" form or any of the "struct" macro forms.


How to use struct{} and struct macro? Please give me an example
Post 06 Jun 2017, 11:02
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 06 Jun 2017, 11:09
Why not to read the FASM manual?

Here for structures: https://flatassembler.net/docs.php?article=manual#2.3.4
Here for general data definitions: https://flatassembler.net/docs.php?article=manual#1.2.2

Well, simple example:
Code:
struc POINT {
  .x dd ?
  .y dd ?
}

struc RECT {
  .p1 POINT
  .p2 POINT
}    


With "struct" in FreshLib definition:
Code:
struct POINT
  .x dd ?
  .y dd ?
ends

struct RECT
  .p1 POINT
  .p2 POINT
ends    
Post 06 Jun 2017, 11:09
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Atlas



Joined: 05 Jun 2017
Posts: 7
Atlas 06 Jun 2017, 13:08
How to get size of these structs? I already try sizeof.RECT but I kant get the size.
Post 06 Jun 2017, 13:08
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 06 Jun 2017, 14:10
sizeof.RECT will work only for the "struct ends" macros. For pure "struc" it is a little bit more complex:
Code:
virtual at 0
  RECT RECT
  sizeof.RECT = $
end virtual    


Read about "virtual" in the manual.
Post 06 Jun 2017, 14:10
View user's profile Send private message Visit poster's website ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.