flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > [solved] Problem with custom struc and macro |
Author |
|
ProMiNick 08 Apr 2020, 21:38
. not a fasm special symbol & shoud be separated from data directive.
".Signature: EFIInteger64" labelless definition - required EFIInteger64 to be implemented as macro not struc. ".Signature EFIInteger64" labeled definition - required EFIInteger64 to be implemented as struc & as thou see here no colon. |
|||
08 Apr 2020, 21:38 |
|
Fulgurance 08 Apr 2020, 22:57
Thanks, your advice solve my problem
But now i need help. I use my library to set correctly UEFI fonction. It's work fine to print some character string, but when i try to change the console color, nothing work.... Why ? (i have put comment into code) Code: format pe64 efi entry Main section '.text' code readable executable Main: ;mov rcx,[rdx+EFISystemTable.ConOut] ;mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] ;mov rdx,0010000b ;sub rsp,0x20 ;call rax ;add rsp,0x20 mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,SystemMessage sub rsp,0x20 call rax add rsp,0x20 ;mov rcx,[SystemTable+EFISystemTable.ConOut] ;mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] ;mov rdx,Message ;sub rsp,1111000b ;call rax ;add rsp,0x20 mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,Message sub rsp,0x20 call rax add rsp,0x20 jmp $ section '.data' data readable writable include "UEFIDataTypes.fasm" include "EFITableHeader.fasm" include "EFISystemTable.fasm" include "EFISimpleTextOutputProtocol.fasm" SystemMessage: du '* EFI Boot: ' Message: du 'Test OK',0xD,0xA,0x0 |
|||
08 Apr 2020, 22:57 |
|
revolution 08 Apr 2020, 23:01
Fulgurance wrote:
|
|||
08 Apr 2020, 23:01 |
|
Fulgurance 09 Apr 2020, 07:41
Hum yes... I need to sleep i think... I test that
Thanks you ! |
|||
09 Apr 2020, 07:41 |
|
Fulgurance 09 Apr 2020, 08:24
I have updated my code, but the same problem. When i would like to call setAttribute EFI function, nothing append, and i haven't any text in screen... (text function work without)
Code: format pe64 efi entry Main section '.text' code readable executable Main: mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] mov rdx,0010000b sub rsp,0x20 call rax add rsp,0x20 mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,SystemMessage sub rsp,0x20 call rax add rsp,0x20 mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] mov rdx,1111000b sub rsp,0x20 call rax add rsp,0x20 mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,Message sub rsp,0x20 call rax add rsp,0x20 jmp $ section '.data' data readable writable include "UEFIDataTypes.fasm" include "EFITableHeader.fasm" include "EFISystemTable.fasm" include "EFISimpleTextOutputProtocol.fasm" SystemMessage: du '* EFI Boot: ' Message: du 'Test OK',0xD,0xA,0x0 |
|||
09 Apr 2020, 08:24 |
|
Fulgurance 09 Apr 2020, 08:27
My implementation:
Code: struc EFIInteger8 { . db ? } struc EFIInteger16 { align 2 . dw ? } struc EFIInteger32 { align 4 . dd ? } struc EFIInteger64 { align 8 . dq ? } macro EFITable name { virtual at 0 name name end virtual } |
|||
09 Apr 2020, 08:27 |
|
Fulgurance 09 Apr 2020, 08:28
Code: struc EFITableHeader { .Signature EFIInteger64 .Revision EFIInteger32 .HeaderSize EFIInteger32 .CRC32 EFIInteger32 .Reserved EFIInteger32 } EFITable EFITableHeader |
|||
09 Apr 2020, 08:28 |
|
Fulgurance 09 Apr 2020, 08:28
Code: struc EFISystemTable { .Hdr EFITableHeader .FirmwareVendor EFIInteger64 .FirmwareRevision EFIInteger32 .ConsoleInHandle EFIInteger64 .ConIn EFIInteger64 .ConsoleOutHandle EFIInteger64 .ConOut EFIInteger64 .StandardErrorHandle EFIInteger64 .StdErr EFIInteger64 .RuntimeServices EFIInteger64 .BootServices EFIInteger64 .NumberOfTableEntries EFIInteger64 .ConfigurationTable EFIInteger64 } EFITable EFISystemTable |
|||
09 Apr 2020, 08:28 |
|
Fulgurance 09 Apr 2020, 08:28
Code: struc EFISimpleTextOutputProtocol { .Reset EFIInteger64 .OutputString EFIInteger64 .TestString EFIInteger64 .QueryMode EFIInteger64 .SetMode EFIInteger64 .SetAttribute EFIInteger64 .ClearScreen EFIInteger64 .SetCursorPosition EFIInteger64 .EnableCursor EFIInteger64 .Mode EFIInteger64 } EFITable EFISimpleTextOutputProtocol |
|||
09 Apr 2020, 08:28 |
|
Fulgurance 09 Apr 2020, 19:34
Nobody have any idea ?
|
|||
09 Apr 2020, 19:34 |
|
revolution 09 Apr 2020, 20:13
The address in rdx is changed so all those "[rdx+EFISystemTable.ConOut]" return bogus data.
|
|||
09 Apr 2020, 20:13 |
|
Fulgurance 09 Apr 2020, 20:57
I have already thinking about that, but if i replace to memory, nothing work...
I don't understand why ... Code: format pe64 efi entry Main section '.text' code readable executable Main: mov [SystemTable],rdx mov rcx,[SystemTable+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] mov rdx,0010000b sub rsp,0x20 call rax add rsp,0x20 mov rcx,[SystemTable+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,SystemMessage sub rsp,0x20 call rax add rsp,0x20 mov rcx,[SystemTable+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] mov rdx,1111000b sub rsp,0x20 call rax add rsp,0x20 mov rcx,[SystemTable+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,Message sub rsp,0x20 call rax add rsp,0x20 jmp $ section '.data' data readable writable include "UEFIDataTypes.fasm" include "EFITableHeader.fasm" include "EFISystemTable.fasm" include "EFISimpleTextOutputProtocol.fasm" SystemTable: dq ? SystemMessage: du '* EFI Boot: ' Message: du 'Test OK',0xD,0xA,0x0 |
|||
09 Apr 2020, 20:57 |
|
revolution 09 Apr 2020, 21:08
SystemTable is a pointer, not a structure.
Code: mov rcx,[SystemTable] mov rcx,[rcx+EFISystemTable.ConOut] |
|||
09 Apr 2020, 21:08 |
|
Fulgurance 09 Apr 2020, 23:22
I don't understand. rdx isn't pointer to EFI SYSTEM TABLE ?
Last edited by Fulgurance on 09 Apr 2020, 23:38; edited 2 times in total |
|||
09 Apr 2020, 23:22 |
|
revolution 09 Apr 2020, 23:26
You placed rdx into [SystemTable]. So you need to recover the value. But the value isn't the structure, it is a pointer to the structure. The structure is somewhere else in memory. The structure wasn't copied to SystemTable. SystemTable only has eight bytes (dq ?), just enough to hold a pointer and nothing else.
|
|||
09 Apr 2020, 23:26 |
|
Fulgurance 09 Apr 2020, 23:38
But your advice work thanks ! I have doing that:
Code: format pe64 efi entry Main section '.text' code readable executable Main: mov [SystemTable],rdx mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] mov rdx,0010000b sub rsp,0x20 call rax add rsp,0x20 mov rdx,[SystemTable] mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,SystemMessage sub rsp,0x20 call rax add rsp,0x20 mov rdx,[SystemTable] mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.SetAttribute] mov rdx,1111000b sub rsp,0x20 call rax add rsp,0x20 mov rdx,[SystemTable] mov rcx,[rdx+EFISystemTable.ConOut] mov rax,[rcx+EFISimpleTextOutputProtocol.OutputString] mov rdx,Message sub rsp,0x20 call rax add rsp,0x20 mov rdx,[SystemTable] jmp $ section '.data' data readable writable include "UEFIDataTypes.fasm" include "EFITableHeader.fasm" include "EFISystemTable.fasm" include "EFISimpleTextOutputProtocol.fasm" SystemTable: dq ? SystemMessage: du '* EFI Boot: ',0x0 Message: du 'Test OK',0xD,0xA,0x0 Do you think it's possible to optimize that ? |
|||
09 Apr 2020, 23:38 |
|
revolution 09 Apr 2020, 23:43
Fulgurance wrote: Do you think it's possible to optimize that ? You could also copy rdx to another register instead of putting it in memory. Code: mov r14,rdx ; now use r14 mov rcx,[r14+EFISystemTable.ConOut] Code: mov r14,[rdx+EFISystemTable.ConOut] ; do this only once ;... call [r14+EFISimpleTextOutputProtocol.SetAttribute] ;... call [r14+EFISimpleTextOutputProtocol.OutputString] |
|||
09 Apr 2020, 23:43 |
|
Fulgurance 10 Apr 2020, 12:36
Thanks you !
|
|||
10 Apr 2020, 12:36 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.