/// <summary> /// Sets the thread's context. /// </summary> /// <param name="context">A CONTEXT struct.</param> public void SetContext(ContextAmd64 context) { // HACK: To avoid a datatype misalignment error, allocate // some aligned memory. using (AlignedMemoryAlloc data = new AlignedMemoryAlloc(Utils.SizeOf(16, ContextAmd64.SizeOf), 16)) { data.WriteStruct(context); Win32.NtSetContextThread(this, data).ThrowIf(); } }
/// <summary> /// Sets the thread's context. /// </summary> /// <param name="context">A CONTEXT struct.</param> public void SetContext(ContextAmd64 context) { NtStatus status; // HACK: To avoid a datatype misalignment error, allocate // some aligned memory. using (var data = new AlignedMemoryAlloc(Utils.SizeOf <ContextAmd64>(16), 16)) { data.WriteStruct <ContextAmd64>(context); if ((status = Win32.NtSetContextThread(this, data)) >= NtStatus.Error) { Win32.Throw(status); } } }