Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created January 15, 2015 09:22
Show Gist options
  • Save RobinDavid/992ad58d55b1a039f02b to your computer and use it in GitHub Desktop.
Save RobinDavid/992ad58d55b1a039f02b to your computer and use it in GitHub Desktop.
Get RFLAGS using inline assembly
#include <iostream>
int main(void)
{
unsigned long long var_RFLAGS = 0;
__asm__ (
"pushfq;" // Put RFLAGS into stack
"pop %%rax;" // Pop them in rax
"mov %%rax, %0" : :"m" (var_RFLAGS) // Retrieve them in a variable
);
std::cout << std::hex << "RFLAGS : 0x" << var_RFLAGS << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment