Page 1 of 1

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

Posted: Mon Aug 23, 2021 10:10 am
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...

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

Posted: Mon Aug 23, 2021 11:42 pm
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.

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

Posted: Tue Aug 24, 2021 8:46 am
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