#Region 12. FIX NTDLL for Win11 24H2
$WinVer = RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DisplayVersion")
If $WinVer = "24H2" Then
$ntdllbase = _WinAPI_GetModuleHandle("ntdll.dll")
Local $Patch[4] = [0x48, 0x31, 0xC0, 0xC3]
For $i = 0 To 3
$pBuf = DllStructCreate("byte")
DllStructSetData($pBuf, 1, $Patch[$i])
$aCall = DllCall("kernel32.dll", "bool", _RunBinary_LeanAndMean(), _
"handle", $hProcess, _
"ptr", $ntdllbase + 0x7BE0 + $i, _
"ptr", DllStructGetPtr($pBuf), _
"dword_ptr", DllStructGetSize($pBuf), _
"dword_ptr*", 0)
; Check for errors or failure
If @error Or Not $aCall[0] Then
DllCall("kernel32.dll", "bool", "TerminateProcess", "handle", $hProcess, "dword", 0)
Return SetError(12, 0, 0) ; failure while changing ntdll
EndIf
Next
EndIf
#EndRegion 12. FIX NTDLL for Win11 24H2
Do that after you've set the threadcontext and before you resume the thread.