/** @file\r
Implementation of _LongJump() on IA-32.\r
\r
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
)\r
{\r
_asm {\r
+ mov eax, [PcdGet32 (PcdControlFlowEnforcementPropertyMask)]\r
+ test eax, eax\r
+ jz CetDone\r
+ _emit 0x0F\r
+ _emit 0x20\r
+ _emit 0xE0 ; mov eax, cr4\r
+ bt eax, 23 ; check if CET is enabled\r
+ jnc CetDone\r
+\r
+ mov edx, [esp + 4] ; edx = JumpBuffer\r
+ mov edx, [edx + 24] ; edx = target SSP\r
+ _emit 0xF3\r
+ _emit 0x0F\r
+ _emit 0x1E\r
+ _emit 0xC8 ; READSSP EAX\r
+ sub edx, eax ; edx = delta\r
+ mov eax, edx ; eax = delta\r
+\r
+ shr eax, 2 ; eax = delta/sizeof(UINT32)\r
+ _emit 0xF3\r
+ _emit 0x0F\r
+ _emit 0xAE\r
+ _emit 0xE8 ; INCSSP EAX\r
+\r
+CetDone:\r
+\r
pop eax ; skip return address\r
pop edx ; edx <- JumpBuffer\r
pop eax ; eax <- Value\r