Is this really true? In real mode this is not a problem. Also why can set section '.code' to writeable when is not possible to write into it? Is it possible to set ES = CS and then mov byte [es:.m1+00000001h], (.a1 - .m1) + 02h
Joined: 16 Jun 2003
Location: Kraków, Poland
Is this really true? In real mode this is not a problem.
The fundamental difference between real and protected mode is exactly the protection mechanism (as the name implies), which enforces the permissions set up by structures like descriptor tables and page tables.
The original protected mode, as introduced by 80286, had no paging and all the protections were defined per segment. In protected mode the value you loaded into segment register was called selector and it defined an index in the descriptor table where the detailed information on the segment was set up. It included not only the base address of the segment, but also the limit (which defined how large the segment was, enabling protection against accessing any bytes outside of the defined area) and the permissions. The selector that was set up for CS would allow to execute the bytes as instructions, but would not allow to modify them. The data selector, intended to put into DS or ES, would allow writing but not execution.
Then 80386 came, and next to 32-bit addressing it also allowed paging, and setting up access permissions per page. This quickly led to the abandonment of segmentation, as you could set up all selectors to encompass entire flat 4 GiB addressing space and instead use page attributes to manage permissions on various area of memory.
When you declare section with attributes like "writeable" or "executable" you are setting up permissions on the pages that make up the section. But in addition to that you still have an old-school selector in CS that defines a segment that can be used to execute, but not to write. However, since both CS and DS are defined to encompass an entire flat addressing space starting from 0, you can safely use DS instead of CS on the same address to access exactly the same area of memory but through a different selector, the one that would allow you to write.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum