First post, by videogamer555
I've been reading about setting up protected mode, and I found this good article about the GDT (Global Descriptor Table) http://wiki.osdev.org/Global_Descriptor_Table , but I noticed something peculiar. It says that data segments can be set to read-write, or read-only, while code segments can be read-execute or execute-only. So it's not possible to write to a code segment in protected mode? I'm pretty sure it is possible, because I know there many programs that use self-modifying code, even in Windows (often times this is used for compressed EXE files, where it has a small initial unzipper code that decompresses the main code, and then writes the decompressed code into the code segment to be executed). If writing to a code segment was not possible, compressed EXE files wouldn't be possible.
Can somebody explain how this works, such as how to set the flag bits in the GDT to permit writing to a data segment?