Skip to main content
LoadEnclaveData function

Loads data into an uninitialized enclave that you created by calling CreateEnclave.

Syntax


BOOL WINAPI LoadEnclaveData(
  _In_      HANDLE  hProcess,
  _In_      LPVOID  lpAddress,
  _In_      LPCVOID lpBuffer,
  _In_      SIZE_T  nSize,
  _In_      DWORD   flProtect,
  _In_      LPCVOID lpPageInformation,
  _In_      DWORD   dwInfoLength,
  _Out_     PSIZE_T lpNumberOfBytesWritten,
  _Out_opt_ LPDWORD lpEnclaveError
);

Parameters

hProcess [in]

A handle to the process for which the enclave was created.

lpAddress [in]

The address in the enclave where you want to load the data.

lpBuffer [in]

A pointer to the data the you want to load into the enclave.

nSize [in]

The size of the data that you want to load into the enclave, in bytes. This value must be a whole-number multiple of the page size.

flProtect [in]

The memory protection to use for the pages that you want to add to the enclave. For a list of memory protection values, see memory protection constants. This value must not include the following constants:

  • PAGE_GUARD
  • PAGE_NOCACHE
  • PAGE_WRITECOMBINE
  • PAGE_NOACCESS

This value can include the enclave specific constants that the following table describes.

ConstantDescription
PAGE_ENCLAVE_THREAD_CONTROLThe page contains a thread control structure (TCS).
PAGE_ENCLAVE_UNVALIDATEDThe page contents that you supply are excluded from measurement with the EEXTEND instruction of the Intel Software Guard Extensions programming model.

 

lpPageInformation [in]

A pointer to information that describes the pages that you want to add to the enclave. The lpPageInformation parameter is not used.

dwInfoLength [in]

The length of the structure that the lpPageInformation parameter points to, in bytes. This value must be 0.

lpNumberOfBytesWritten [out]

A pointer to a variable that receives the number of bytes that LoadEnclaveData copied into the enclave.

lpEnclaveError [out, optional]

An optional pointer to a variable that receives an enclave error code that is architecture-specific. The lpEnclaveError parameter is not used.

Return value

If all of the data is loaded into the enclave successfully, the return value is nonzero. Otherwise, the return value is zero. To get extended error information, call GetLastError.

For a list of common error codes, see System Error Codes. The following error codes also apply for this function.

Return codeDescription
ERROR_BAD_LENGTH

The value of the dwInfoLength parameter did not match the value expected based on the value specified for the lpPageInformation parameter.

 

Remarks

To initialize the enclave after you load data into the enclave, call InitializeEnclave.

LoadEnclaveData is only supported enclaves that have the ENCLAVE_TYPE_SGX enclave type.

Requirements

Minimum supported client

Windows 10 [desktop apps | UWP apps]

Minimum supported server

Windows Server 2016 [desktop apps | UWP apps]

Header

Enclaveapi.h (include Winbase.h)

Library

Kernel32.lib

DLL

Api-ms-win-core-enclave-l1-1-0.dll;
Kernel32.dll;
KernelBase.dll

See also

CreateEnclave
InitializeEnclave