CopyContext function

Copies a source context structure (including any XState) onto an initialized destination context structure.


BOOL WINAPI CopyContext(
  _Inout_ PCONTEXT Destination,
  _In_    DWORD    ContextFlags,
  _In_    PCONTEXT Source


Destination [in, out]

A pointer to a CONTEXT structure that receives the context copied from the Source. The CONTEXT structure should be initialized by calling InitializeContext before calling this function.

ContextFlags [in]

Flags specifying the pieces of the Source CONTEXT structure that will be copied into the destination. This must be a subset of the ContextFlags specified when calling InitializeContext on the Destination CONTEXT.

Source [in]

A pointer to a CONTEXT structure from which to copy processor context data.

Return value

This function returns TRUE if the context was copied successfully, otherwise FALSE. To get extended error information, call GetLastError.


The function copies data from the Source CONTEXT over the corresponding data in the Destination CONTEXT, including extended context if any is present. The Destination CONTEXT must have been initialized with InitializeContext to ensure proper alignment and initialization. If any data is present in the Destination CONTEXT and the corresponding flag is not set in the Source CONTEXT or in the ContextFlags parameter, the data remains valid in the Destination.

Windows 7 with SP1 and Windows Server 2008 R2 with SP1:  The AVX API is first implemented on Windows 7 with SP1 and Windows Server 2008 R2 with SP1 . Since there is no SDK for SP1, that means there are no available headers and library files to work with. In this situation, a caller must declare the needed functions from this documentation and get pointers to them using GetModuleHandle on "Kernel32.dll", followed by calls to GetProcAddress. See Working with XState Context for details.


Minimum supported client

Windows 7 with SP1 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 with SP1 [desktop apps only]


WinBase.h (include Windows.h)





See also

Intel AVX
Working with XState Context