Advertisement
Guest User

Untitled

a guest
Jul 17th, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. static void flush_gdt(uint16_t cs, uint16_t ds)
  2. {
  3.     uint64_t scratch0;
  4.     __asm goto(
  5.         "lea %l[lngjmp_target](%%rip), %0\n"
  6.         "push %1\n"
  7.         "push %0\n"
  8.         "ljmpq *(%%rsp)"
  9.     : "=&r"(scratch0)
  10.     : "g"(cs)
  11.     : "rax"
  12.     : lngjmp_target);
  13.     __builtin_unreachable();
  14.  
  15. lngjmp_target:
  16.     __asm(
  17.         "add $0x10,%%rsp\n"
  18.         "mov %0, %%ds\n"
  19.         "mov %0, %%es\n"
  20.         "mov %0, %%fs\n"
  21.         "mov %0, %%gs\n"
  22.         "mov %0, %%ss\n"
  23.     :
  24.     : "rm"(ds));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement