Date: Mon, 6 Jan 1997 13:55:57 +0200 (IST) From: Eli Zaretskii To: John Eccleston cc: djgpp AT delorie DOT com Subject: Re: Displaying the VESA OEM string In-Reply-To: <5aqgd9$h4i@red.parallax.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 6 Jan 1997, John Eccleston wrote: > I am trying to display the OEM string for the VESA graphics card > in my system. However this always causes the program to > access violate. Could someone please point me in the right > direction. By looking at the FAQ I think I need to use the > _farpeekb (etc) functions but how do I convert the pointer given > in the VESA info structure to the required (segment*16 + offset) > value. The pointers in the VBE structure are real-mode pointers, so you cannot treat them as if they were protected-mode pointers to some buffer inside your program's address space. Instead, you should treat them as a far pointer, i.e. a pair of 16-bit words seg:off and use farptr functions to fetch the buffer contents to a protected-mode buffer. First, the structure should be declared like so: typedef struct VBEInfo { char VESASignature[4] PACKED; /* 'VESA' 4 byte signature */ short VESAVersion PACKED; /* VBE version number */ short OEMStringPtr_Off PACKED; /* Pointer to OEM string - offset */ short OEMStringPtr_Seg PACKED; /* Pointer to OEM string - segment */ long Capabilities PACKED; /* Capabilities of video card */ short VideoModePtr_Off PACKED; /* Pointer to supported modes - offs */ short VideoModePtr_Seg PACKED; /* Pointer to supported modes - segm */ short TotalMemory PACKED; /* Number of 64kb memory blocks */ char reserved[236] PACKED; /* Pad to 256 byte block size */ } VBEInfo; Note how the pointers were converted into a seg:off pair, and in reverse order because the way Intel machines store bytes. (Btw, it's best to declare the segment and offset to be unsigned short.) Then, you should pull the OEM string from the real-mode buffer like so: char OEM_str[MAXOEM_SIZE]; char *d = OEM_str; int i = OEMStringPtr_Seg*16 + OEMStringPtr_Off; _farsetsel (_dos_ds); while ( (*d = _farnspeekb (i++)) != '\0') ; Warning: the above code is untested!