Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How to move structs returned by real-mode services?

0
Posted

How to move structs returned by real-mode services?

0

Q: My program uses the contents of a structure returned by a VBE function, but some of the struct members are garbled! A: Most probably, this happens because of incorrect declaration of the structure in your program. Many people copy a declaration from some real-mode program, and that is exactly what gets them into trouble. Here are some gotchas in this context: • The structure should be declared with __attribute__((packed)), to prevent GCC from inserting gaps between some members to make them properly aligned for faster access (see how gcc aligns structs). C programs can declare the entire struct with the packed attribute, but C++ programs will need to declare each member with it, see __attribute__((packed)). • If the real-mode struct has members which are pointers, you need to replace each pointer with a pair of an offset and a segment (in that order, due to Intel’s little-endian byte order). This is because real-mode far pointers cannot be used as protected-mode pointers: you cannot

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123