[UEFI] MSVC: Bootloader - Call MS_ABI binary (c++)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
LipkeGu
Posts: 2
Joined: Sun Aug 22, 2021 2:59 pm

[UEFI] MSVC: Bootloader - Call MS_ABI binary (c++)

Post by LipkeGu »

Hello,

Im programming an Operating System and compile my Kernel binary with MSVC underVisual Studio 2019. Now i doesnt know how to call and load that C++ kernel binary.
My bootx64.efi is also compiled and works so far with simple_uefi. Im only found tutorials in c++with gcc and sysv_abi. and mingw-gcc...

Thanks so far...
Kamal123
Member
Member
Posts: 99
Joined: Fri Nov 01, 2019 1:17 am

Re: [UEFI] MSVC: Bootloader - Call MS_ABI binary (c++)

Post by Kamal123 »

Visual Studio uses PE file format for executable files, from your UEFI loader, write a function which loads the executable into a buffer, copy the entire buffer to a virtual address which will be your base address for Kernel, for my case I use x64 bit so my base address is 0xffffc00000000000, then from there extract the entry point of the pe file, then setup stack memory and call the entry point (base_address+entrypoint). Look at the PE file format article.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: [UEFI] MSVC: Bootloader - Call MS_ABI binary (c++)

Post by bzt »

LipkeGu wrote:Im only found tutorials in c++with gcc and sysv_abi. and mingw-gcc...
Check out EDK2 tools and examples. That uses MS_ABI by default, as well as its examples. I don't know how good it is, but there's a PE loader example too.

Cheers,
bzt
Post Reply