flat assembler
Message board for the users of flat assembler.

Index > OS Construction > My first UEFI app...

Author
Thread Post new topic Reply to topic
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 07 May 2024, 17:39
I posted in Discord before but not here.
Anyway, here it is: The shortest "Hello, world" UEFI app, bypassing various structure.

EDIT: Thank you @revolution for the suggestion of "du" instead of "dw".

Code:
format PE64 EFI DLL on 'nul'

section '.code' code readable executable

entry $

       sub     rsp, 40
       mov     rcx, qword [rdx + 0x40]
       lea     rdx, [_message]
       call    qword [rcx + 0x08]
       add     rsp, 40
       retn

_message du 'Hello World',13,10,0         


Description:
Filesize: 21.55 KB
Viewed: 729 Time(s)

GMXqL8_a4AAetXu.jpeg




Last edited by MatQuasar on 08 May 2024, 01:52; edited 1 time in total
Post 07 May 2024, 17:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20215
Location: In your JS exploiting you and your system
revolution 07 May 2024, 22:11
You can use du instead of dw.
Code:
_message du 'Hello World',13,10,0    
Post 07 May 2024, 22:11
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3977
Location: vpcmipstrm
bitRAKE 08 May 2024, 00:29

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 08 May 2024, 00:29
View user's profile Send private message Visit poster's website Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 08 May 2024, 01:53
revolution wrote:
You can use du instead of dw.
Code:
_message du 'Hello World',13,10,0    


Nice, I thought it required include file from "encodings". Just now I tested, it doesn't need one. Thank you for the suggestion.
Post 08 May 2024, 01:53
View user's profile Send private message Reply with quote
MatQuasar



Joined: 25 Oct 2023
Posts: 105
MatQuasar 08 May 2024, 01:55


Yes! Actually I referred to your this particular example before doing my own similar one. I use the offset in EFI_SYSTEM_TABLE and EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL directly, skipping the need of include files.

Very Happy
Post 08 May 2024, 01:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20215
Location: In your JS exploiting you and your system
revolution 08 May 2024, 02:03
By declaring constants, and expanding the rsp value, this code can be made more reader friendly.
Code:
format PE64 EFI DLL on 'nul'

section '.code' code readable executable

EFI_SYSTEM_TABLE.ConOut                         = 0x40
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString    = 0x08

entry $

        sub     rsp, 8 * 5
        mov     rcx, qword[rdx + EFI_SYSTEM_TABLE.ConOut]
        lea     rdx, [_message]
        call    qword[rcx + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.OutputString]
        add     rsp, 8 * 5
        ret

_message du 'Hello World',13,10,0    
Post 08 May 2024, 02:03
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.