I'm trying to understand what MOV RAX,qword ptr FS:[0x28]
means. I get that FS:[0x28]
is a stack canary. If my understanding is correct the data from RAX
gets copied by MOV
. Then there's a comma which separates the first operand MOV RAX
from the second one qword ptr FS:[0x28]
. What exactly does does qword ptr FS:[0x28]
do?
2 Answers
It is not clear from the context of the question but it depends on the platform, if you are on Windows then fs:[0x28] is the field ArbitraryUserPointer according to the following data structure.
ntdll!_NT_TIB
+0x000 ExceptionList : Ptr64 _EXCEPTION_REGISTRATION_RECORD
+0x008 StackBase : Ptr64 Void
+0x010 StackLimit : Ptr64 Void
+0x018 SubSystemTib : Ptr64 Void
+0x020 FiberData : Ptr64 Void
+0x020 Version : Uint4B
+0x028 ArbitraryUserPointer : Ptr64 Void
+0x030 Self : Ptr64 _NT_TIB
You can find some information about this field in the TEB here:
The assembly you posted is in Intel syntax.
MOV RAX, qword ptr FS:[0x28]
The sentinel value stored is being copied into RAX
, not from it. This code is part of a setup for copying the value into a stack canary.
RAX
, not from.qword ptr FS:[0x28]
just means it references a quadword at memory location 0x28 in the FS segment.