'Getting VESA video information with Digital Mars compiler, which doesn't support GNU C packed structs

I'm trying to add VESA video card detection to my system information program and can't seem to even put together code that works. I've looked at this thread: How to get VESA BIOS Information and this page on OSDev: https://wiki.osdev.org/VESA_Video_Modes which has code using __attribute__ ((packed)) written for the gcc compiler that's incompatible with my Digital Mars compiler.

All I really want is the VESA Version, OEMString, Total Memory, and if VESA 2.0 is supported, the OEMModel string, but if I have to process the entire ES:DI stack to get that information, so be it. However, that's where I'm stuck. I simply don't know how to grab that information and put it into a structure despite the example code given.

I know this site isn't for writing code for the questioner, but I'm hoping someone can help get me started so I can study working code and learn how to accomplish this. I don't care if it's in assembly or C++, though I have a tad more experience with C++.

I'm using the MARS C/C++ compiler. The generated programs will be 16-bit DOS programs.



Solution 1:[1]

I was able to get all related VESA information using the following code, no PACKing needed:

typedef struct _VBE_INFO
{
    char VbeSignature[4];
    uint16 VbeVersion;
    char FAR *fpOemString;
    uint32 Capabilities;
    uint16 FAR *fVideoMode;
    uint16 TotalMemory;
    /* VESA 2.x */
    uint16 OemSoftwareRev
    char FAR *fpOemVendorName;
    char FAR *fpOemProductName;
    char FAR *fpOemProductRev;
    char Reserved[222];
    char OemData[256];
} VBE_INFO;

VBE_INFO FAR *VbeInfo;
inregs.x.ax = 0x4F00;
sregs.es    = FP_SEG( VbeInfo );
inregs.x.di = FP_OFF( VbeInfo ):
int86x( 0x10, &inregs, &outregs, &sregs );

Then all your data is sitting in VbeInfo->? where ? is defined in the structure. E.g. VbeInfo->fpOemString contains the VESA v1.x Oem String data for the card. For VESA 2.x information, use the following code:

VBE_INFO FAR *VbeInfo;
_fstrncpy( VbeInfo->VbeSignature, "VBE2", 4 );
inregs.x.ax = 0x4F00;
sregs.es    = FP_SEG( VbeInfo );
inregs.x.di = FP_OFF( VbeInfo );
int86x( 0x10, &inregs, &outregs, &sregs );

Then information below the VESA 2.x comment in the struct will be populated.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Charlie Dobson