As for Patch Guard bypass it is quite not so obvious like in GData post.
Depending on PatchGuard version there are different approaches for it bypass. On a newer PatchGuard versions
KeBugCheckEx is not used by PG directly but used from a "clean" copy - it was done exactly to defeat older PG bypass methods. However in this case PG can be bypassed (again) by setting a deeper inline hook on one of the routines
KeBugCheckEx uses. This routine is
RtlCaptureContext (it is exported and called in the beginning of
KeBugCheckEx).
Below is example of hook Turla sets on Windows 7 SP1 X64.
KeBugCheckEx function prologue.
Code: Select allnt!KeBugCheckEx:
fffff800`02687640 48894c2408 mov qword ptr [rsp+8],rcx
fffff800`02687645 4889542410 mov qword ptr [rsp+10h],rdx
fffff800`0268764a 4c89442418 mov qword ptr [rsp+18h],r8
fffff800`0268764f 4c894c2420 mov qword ptr [rsp+20h],r9
fffff800`02687654 9c pushfq
fffff800`02687655 4883ec30 sub rsp,30h
fffff800`02687659 fa cli
fffff800`0268765a 65488b0c2520000000 mov rcx,qword ptr gs:[20h]
fffff800`02687663 4881c120010000 add rcx,120h
fffff800`0268766a e861060000 call nt!RtlCaptureContext (fffff800`02687cd0)
fffff800`0268766f 65488b0c2520000000 mov rcx,qword ptr gs:[20h]
fffff800`02687678 4883c140 add rcx,40h
fffff800`0268767c e8ef020000 call nt!KiSaveProcessorControlState (fffff800`02687970)
fffff800`02687681 654c8b142520000000 mov r10,qword ptr gs:[20h]
fffff800`0268768a 4981c220010000 add r10,120h
fffff800`02687691 488b442440 mov rax,qword ptr [rsp+40h]
Turla hook
Code: Select alllkd> u nt!RtlCaptureContext
nt!RtlCaptureContext:
fffff800`02687cd0 6a01 push 1
fffff800`02687cd2 cdc3 int 0C3h
fffff800`02687cd4 90 nop
fffff800`02687cd5 8c593a mov word ptr [rcx+3Ah],ds
fffff800`02687cd8 8c413c mov word ptr [rcx+3Ch],es
fffff800`02687cdb 8c5142 mov word ptr [rcx+42h],ss
fffff800`02687cde 8c613e mov word ptr [rcx+3Eh],fs
fffff800`02687ce1 8c6940 mov word ptr [rcx+40h],gs