Switching modes with Style

	pushl $(0xcb<<24)|0x08
	call .-1

What does this instruction sequence do? (This was a collaborative effort by Chuck Gray, Myria and Michael.)

(The solution has been added to the comments.)

pixelstats trackingpixel

10 Responses to “Switching modes with Style”

  1. Michael Steil says:

    In MASM, this would probably be
    push (0xcb<<24)|0×08
    call $-1

  2. JK says:

    OK I solved it but I’m not posting it here :P

  3. sheepmaster says:

    Umm, sure, I have a solution too, but this margin is too narrow to contain it…

  4. ugh says:

    it pushes a selector of your choice (0×8 in this case) into the stack, then it makes a relative call to -1, which contains the 0xcb ocode (far return). 0×8 is the selector of the first usable gdt entry (which has a ring0 DPL in windows).

  5. ivko says:

    Whenever you run this code, a hamster dies out there.

  6. Michael Steil says:

    The full answer is: The code loads CS with 0×08. There is no “mov cs” instruction in the x86 instruction set, so if you just want to reload CS, for example after a GDT reload, you can either do a far jump – or this, which is much more elegant. It requires a working stack, though.

    In my case, I am using this code to switch to 64 bit mode on an x86_64 CPU.

  7. dbpxcydqum says:

    Hello! Good Site! Thanks you! wqelmtrubulvk

  8. TrackbackGenerator…

    TrackbackGenerator…

  9. Muscle Gain Truth…

    Muscle Gain Truth…

  10. Prosecutor says:

    OMFG.. How can this be “more elegant”?
    Let’s compare it in some categories.. Result: exactly the same, Speed: slower, requirements: more (stack), length of source: equal, readability: much worse.
    And now let’s come to the category “elegance”… encoding an instruction into the parameters of another instruction, because it magically fits in there is really ugly practice of pseudo 1337 kiddies and should be punished with eternal epic fail!

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word