|
|
dd89bb |
/********************************************************/
|
|
|
dd89bb |
/* ntapi: Native API core library */
|
|
|
dd89bb |
/* Copyright (C) 2013,2014,2015 Z. Gilboa */
|
|
|
dd89bb |
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
|
|
|
dd89bb |
/********************************************************/
|
|
|
dd89bb |
|
|
|
dd89bb |
#ifndef ___NTAPI_CONTEXT_H_
|
|
|
dd89bb |
#define ___NTAPI_CONTEXT_H_
|
|
|
dd89bb |
|
|
|
dd89bb |
#if defined(__X86_MODEL)
|
|
|
dd89bb |
/* csr port handle */
|
|
|
dd89bb |
#define __GET_CSR_PORT_HANDLE_BY_LOGIC __ntapi_tt_get_csr_port_handle_addr_by_logic_i386
|
|
|
dd89bb |
|
|
|
dd89bb |
/* register names */
|
|
|
dd89bb |
#define STACK_POINTER_REGISTER uc_esp
|
|
|
dd89bb |
#define INSTRUCTION_POINTER_REGISTER uc_eip
|
|
|
dd89bb |
#define FAST_CALL_ARG0 uc_ecx
|
|
|
dd89bb |
#define FAST_CALL_ARG1 uc_edx
|
|
|
dd89bb |
|
|
|
dd89bb |
/* thread context initialization */
|
|
|
dd89bb |
#define __INIT_CONTEXT(context) \
|
|
|
dd89bb |
context.uc_context_flags = NT_CONTEXT_JUST_EVERYTHING; \
|
|
|
dd89bb |
context.uc_seg_gs = 0x00; \
|
|
|
dd89bb |
context.uc_seg_fs = 0x3b; \
|
|
|
dd89bb |
context.uc_seg_es = 0x23; \
|
|
|
dd89bb |
context.uc_seg_ds = 0x23; \
|
|
|
dd89bb |
context.uc_seg_ss = 0x23; \
|
|
|
dd89bb |
context.uc_seg_cs = 0x1b; \
|
|
|
dd89bb |
context.uc_eflags = 0x200
|
|
|
dd89bb |
|
|
|
dd89bb |
#elif defined (__X86_64_MODEL)
|
|
|
dd89bb |
/* csr port handle */
|
|
|
dd89bb |
#define __GET_CSR_PORT_HANDLE_BY_LOGIC __ntapi_tt_get_csr_port_handle_addr_by_logic_x86_64
|
|
|
dd89bb |
|
|
|
dd89bb |
/* register names */
|
|
|
dd89bb |
#define STACK_POINTER_REGISTER uc_rsp
|
|
|
dd89bb |
#define INSTRUCTION_POINTER_REGISTER uc_rip
|
|
|
dd89bb |
#define FAST_CALL_ARG0 uc_rcx
|
|
|
dd89bb |
#define FAST_CALL_ARG1 uc_rdx
|
|
|
dd89bb |
|
|
|
dd89bb |
/* thread context initialization */
|
|
|
dd89bb |
#define __INIT_CONTEXT(context) \
|
|
|
dd89bb |
context.uc_context_flags= NT_CONTEXT_JUST_EVERYTHING; \
|
|
|
dd89bb |
context.uc_seg_cs = 0x33; \
|
|
|
dd89bb |
context.uc_seg_ds = 0x2b; \
|
|
|
dd89bb |
context.uc_seg_es = 0x2b; \
|
|
|
dd89bb |
context.uc_seg_fs = 0x53; \
|
|
|
dd89bb |
context.uc_seg_gs = 0x2b; \
|
|
|
dd89bb |
context.uc_seg_ss = 0x2b; \
|
|
|
dd89bb |
context.uc_eflags = 0x200; \
|
|
|
dd89bb |
context.uc_mx_csr = 0x1f80
|
|
|
dd89bb |
|
|
|
dd89bb |
#endif
|
|
|
dd89bb |
|
|
|
dd89bb |
#endif
|