From nobody Mon Sep 17 00:00:00 2001 From: Ilya Berezhniuk Date: Mon, 25 Feb 2008 03:52:56 +0300 Subject: [PATCH] --move-- Moved files responsible for context conversion and C handler args preparation renamed: vm/vmcore/src/util/linux/signals_em64t.cpp -> vm/port/src/thread/linux/thread_em64t.c renamed: vm/vmcore/src/util/linux/signals_ia32.cpp -> vm/port/src/thread/linux/thread_ia32.c renamed: vm/port/src/thread/linux/thread_ipf.cpp -> vm/port/src/thread/linux/thread_ipf.c renamed: vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp -> vm/port/src/thread/win/thread_em64t.c --- vm/port/src/thread/linux/thread_em64t.c | 93 ++++++++++++++++++ vm/port/src/thread/linux/thread_ia32.c | 85 +++++++++++++++++ vm/port/src/thread/linux/thread_ipf.c | 30 ++++++ vm/port/src/thread/linux/thread_ipf.cpp | 30 ------ vm/port/src/thread/win/thread_em64t.c | 97 +++++++++++++++++++ vm/vmcore/src/util/linux/signals_em64t.cpp | 93 ------------------ vm/vmcore/src/util/linux/signals_ia32.cpp | 85 ----------------- .../src/util/win/em64t/nt_exception_filter.cpp | 102 ----------------------- 8 files changed, 305 insertions(+), 310 deletions(-) create mode 100644 vm/port/src/thread/linux/thread_em64t.c create mode 100644 vm/port/src/thread/linux/thread_ia32.c create mode 100755 vm/port/src/thread/linux/thread_ipf.c delete mode 100755 vm/port/src/thread/linux/thread_ipf.cpp create mode 100644 vm/port/src/thread/win/thread_em64t.c delete mode 100644 vm/vmcore/src/util/linux/signals_em64t.cpp delete mode 100644 vm/vmcore/src/util/linux/signals_ia32.cpp delete mode 100644 vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp 2bb7fd834d3c9f3378e1744575680e7652a0a011 diff --git a/vm/port/src/thread/linux/thread_em64t.c b/vm/port/src/thread/linux/thread_em64t.c new file mode 100644 index 0000000..fcd3bd0 --- /dev/null +++ b/vm/port/src/thread/linux/thread_em64t.c @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include "vm_core_types.h" +#include "signals_common.h" + + +void ucontext_to_regs(Registers* regs, ucontext_t *uc) +{ + regs->rax = uc->uc_mcontext.gregs[REG_RAX]; + regs->rcx = uc->uc_mcontext.gregs[REG_RCX]; + regs->rdx = uc->uc_mcontext.gregs[REG_RDX]; + regs->rdi = uc->uc_mcontext.gregs[REG_RDI]; + regs->rsi = uc->uc_mcontext.gregs[REG_RSI]; + regs->rbx = uc->uc_mcontext.gregs[REG_RBX]; + regs->rbp = uc->uc_mcontext.gregs[REG_RBP]; + regs->rip = uc->uc_mcontext.gregs[REG_RIP]; + regs->rsp = uc->uc_mcontext.gregs[REG_RSP]; + regs->r8 = uc->uc_mcontext.gregs[REG_R8]; + regs->r9 = uc->uc_mcontext.gregs[REG_R9]; + regs->r10 = uc->uc_mcontext.gregs[REG_R10]; + regs->r11 = uc->uc_mcontext.gregs[REG_R11]; + regs->r12 = uc->uc_mcontext.gregs[REG_R12]; + regs->r13 = uc->uc_mcontext.gregs[REG_R13]; + regs->r14 = uc->uc_mcontext.gregs[REG_R14]; + regs->r15 = uc->uc_mcontext.gregs[REG_R15]; + regs->eflags = uc->uc_mcontext.gregs[REG_EFL]; +} + +void regs_to_ucontext(ucontext_t *uc, Registers* regs) +{ + uc->uc_mcontext.gregs[REG_RAX] = regs->rax; + uc->uc_mcontext.gregs[REG_RCX] = regs->rcx; + uc->uc_mcontext.gregs[REG_RDX] = regs->rdx; + uc->uc_mcontext.gregs[REG_RDI] = regs->rdi; + uc->uc_mcontext.gregs[REG_RSI] = regs->rsi; + uc->uc_mcontext.gregs[REG_RBX] = regs->rbx; + uc->uc_mcontext.gregs[REG_RBP] = regs->rbp; + uc->uc_mcontext.gregs[REG_RIP] = regs->rip; + uc->uc_mcontext.gregs[REG_RSP] = regs->rsp; + uc->uc_mcontext.gregs[REG_R8] = regs->r8; + uc->uc_mcontext.gregs[REG_R9] = regs->r9; + uc->uc_mcontext.gregs[REG_R10] = regs->r10; + uc->uc_mcontext.gregs[REG_R11] = regs->r11; + uc->uc_mcontext.gregs[REG_R12] = regs->r12; + uc->uc_mcontext.gregs[REG_R13] = regs->r13; + uc->uc_mcontext.gregs[REG_R14] = regs->r14; + uc->uc_mcontext.gregs[REG_R15] = regs->r15; + uc->uc_mcontext.gregs[REG_EFL] = regs->eflags; +} + +// Max. 6 arguments can be set up +void regs_push_param(Registers* pregs, POINTER_SIZE_INT param, int num) +{ + switch (num) + { + case 0: + pregs->rdi = param; + return; + case 1: + pregs->rsi = param; + return; + case 2: + pregs->rdx = param; + return; + case 3: + pregs->rcx = param; + return; + case 4: + pregs->r8 = param; + return; + case 5: + pregs->r9 = param; + return; + } +} diff --git a/vm/port/src/thread/linux/thread_ia32.c b/vm/port/src/thread/linux/thread_ia32.c new file mode 100644 index 0000000..5c52f7c --- /dev/null +++ b/vm/port/src/thread/linux/thread_ia32.c @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include "vm_core_types.h" +#include "signals_common.h" + + +#if defined(LINUX) +void ucontext_to_regs(Registers* regs, ucontext_t *uc) +{ + regs->eax = uc->uc_mcontext.gregs[REG_EAX]; + regs->ecx = uc->uc_mcontext.gregs[REG_ECX]; + regs->edx = uc->uc_mcontext.gregs[REG_EDX]; + regs->edi = uc->uc_mcontext.gregs[REG_EDI]; + regs->esi = uc->uc_mcontext.gregs[REG_ESI]; + regs->ebx = uc->uc_mcontext.gregs[REG_EBX]; + regs->ebp = uc->uc_mcontext.gregs[REG_EBP]; + regs->eip = uc->uc_mcontext.gregs[REG_EIP]; + regs->esp = uc->uc_mcontext.gregs[REG_ESP]; + regs->eflags = uc->uc_mcontext.gregs[REG_EFL]; +} + +void regs_to_ucontext(ucontext_t *uc, Registers* regs) +{ + uc->uc_mcontext.gregs[REG_EAX] = regs->eax; + uc->uc_mcontext.gregs[REG_ECX] = regs->ecx; + uc->uc_mcontext.gregs[REG_EDX] = regs->edx; + uc->uc_mcontext.gregs[REG_EDI] = regs->edi; + uc->uc_mcontext.gregs[REG_ESI] = regs->esi; + uc->uc_mcontext.gregs[REG_EBX] = regs->ebx; + uc->uc_mcontext.gregs[REG_EBP] = regs->ebp; + uc->uc_mcontext.gregs[REG_EIP] = regs->eip; + uc->uc_mcontext.gregs[REG_ESP] = regs->esp; + uc->uc_mcontext.gregs[REG_EFL] = regs->eflags; +} + +#elif defined(FREEBSD) +void ucontext_to_regs(Registers* regs, ucontext_t *uc) +{ + regs->eax = uc->uc_mcontext.mc_eax; + regs->ecx = uc->uc_mcontext.mc_ecx; + regs->edx = uc->uc_mcontext.mc_edx; + regs->edi = uc->uc_mcontext.mc_edi; + regs->esi = uc->uc_mcontext.mc_esi; + regs->ebx = uc->uc_mcontext.mc_ebx; + regs->ebp = uc->uc_mcontext.mc_ebp; + regs->eip = uc->uc_mcontext.mc_eip; + regs->esp = uc->uc_mcontext.mc_esp; + regs->eflags = uc->uc_mcontext.mc_eflags; +} + +void regs_to_ucontext(ucontext_t *uc, Registers* regs) +{ + uc->uc_mcontext.mc_eax = regs->eax; + uc->uc_mcontext.mc_ecx = regs->ecx; + uc->uc_mcontext.mc_edx = regs->edx; + uc->uc_mcontext.mc_edi = regs->edi; + uc->uc_mcontext.mc_esi = regs->esi; + uc->uc_mcontext.mc_ebx = regs->ebx; + uc->uc_mcontext.mc_ebp = regs->ebp; + uc->uc_mcontext.mc_eip = regs->eip; + uc->uc_mcontext.mc_esp = regs->esp; + uc->uc_mcontext.mc_eflags = regs->eflags; +} + +#else +#error need to add correct mcontext_t lookup for registers +#endif diff --git a/vm/port/src/thread/linux/thread_ipf.c b/vm/port/src/thread/linux/thread_ipf.c new file mode 100755 index 0000000..7b4b70a --- /dev/null +++ b/vm/port/src/thread/linux/thread_ipf.c @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "open/platform_types.h" + + +void transfer_to_regs(Registers* regs) +{ + // FIXME: not implemented + fprintf(stderr, "FIXME: transfer_to_regs: not implemented\n"); + assert(0); + abort(); +} diff --git a/vm/port/src/thread/linux/thread_ipf.cpp b/vm/port/src/thread/linux/thread_ipf.cpp deleted file mode 100755 index 7b4b70a..0000000 --- a/vm/port/src/thread/linux/thread_ipf.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "open/platform_types.h" - - -void transfer_to_regs(Registers* regs) -{ - // FIXME: not implemented - fprintf(stderr, "FIXME: transfer_to_regs: not implemented\n"); - assert(0); - abort(); -} diff --git a/vm/port/src/thread/win/thread_em64t.c b/vm/port/src/thread/win/thread_em64t.c new file mode 100644 index 0000000..136ea28 --- /dev/null +++ b/vm/port/src/thread/win/thread_em64t.c @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "platform_lowlevel.h" +#include "vm_core_types.h" + + +void nt_to_vm_context(PCONTEXT pcontext, Registers* regs) +{ + regs->rsp = pcontext->Rsp; + regs->rbp = pcontext->Rbp; + regs->rip = pcontext->Rip; + + regs->rbx = pcontext->Rbx; + regs->r12 = pcontext->R12; + regs->r13 = pcontext->R13; + regs->r14 = pcontext->R14; + regs->r15 = pcontext->R15; + + regs->rax = pcontext->Rax; + regs->rcx = pcontext->Rcx; + regs->rdx = pcontext->Rdx; + regs->rsi = pcontext->Rsi; + regs->rdi = pcontext->Rdi; + regs->r8 = pcontext->R8; + regs->r9 = pcontext->R9; + regs->r10 = pcontext->R10; + regs->r11 = pcontext->R11; + + regs->eflags = pcontext->EFlags; +} + +void vm_to_nt_context(Registers* regs, PCONTEXT pcontext) +{ + pcontext->Rsp = regs->rsp; + pcontext->Rbp = regs->rbp; + pcontext->Rip = regs->rip; + + pcontext->Rbx = regs->rbx; + pcontext->R12 = regs->r12; + pcontext->R13 = regs->r13; + pcontext->R14 = regs->r14; + pcontext->R15 = regs->r15; + + pcontext->Rax = regs->rax; + pcontext->Rcx = regs->rcx; + pcontext->Rdx = regs->rdx; + pcontext->Rsi = regs->rsi; + pcontext->Rdi = regs->rdi; + pcontext->R8 = regs->r8; + pcontext->R9 = regs->r9; + pcontext->R10 = regs->r10; + pcontext->R11 = regs->r11; + + pcontext->EFlags = regs->eflags; +} + +// Max. 4 arguments can be set up +void regs_push_param(Registers* pregs, POINTER_SIZE_INT param, int num) +{ // RCX, RDX, R8, R9 + switch (num) + { + case 0: + pregs->rcx = param; + return; + case 1: + pregs->rdx = param; + return; + case 2: + pregs->r8 = param; + return; + case 3: + pregs->r9 = param; + return; + } +} + +void regs_push_return_address(Registers* pregs, void* ret_addr) +{ + pregs->rsp = pregs->rsp - 8; + *((void**)pregs->rsp) = ret_addr; +} diff --git a/vm/vmcore/src/util/linux/signals_em64t.cpp b/vm/vmcore/src/util/linux/signals_em64t.cpp deleted file mode 100644 index fcd3bd0..0000000 --- a/vm/vmcore/src/util/linux/signals_em64t.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include "vm_core_types.h" -#include "signals_common.h" - - -void ucontext_to_regs(Registers* regs, ucontext_t *uc) -{ - regs->rax = uc->uc_mcontext.gregs[REG_RAX]; - regs->rcx = uc->uc_mcontext.gregs[REG_RCX]; - regs->rdx = uc->uc_mcontext.gregs[REG_RDX]; - regs->rdi = uc->uc_mcontext.gregs[REG_RDI]; - regs->rsi = uc->uc_mcontext.gregs[REG_RSI]; - regs->rbx = uc->uc_mcontext.gregs[REG_RBX]; - regs->rbp = uc->uc_mcontext.gregs[REG_RBP]; - regs->rip = uc->uc_mcontext.gregs[REG_RIP]; - regs->rsp = uc->uc_mcontext.gregs[REG_RSP]; - regs->r8 = uc->uc_mcontext.gregs[REG_R8]; - regs->r9 = uc->uc_mcontext.gregs[REG_R9]; - regs->r10 = uc->uc_mcontext.gregs[REG_R10]; - regs->r11 = uc->uc_mcontext.gregs[REG_R11]; - regs->r12 = uc->uc_mcontext.gregs[REG_R12]; - regs->r13 = uc->uc_mcontext.gregs[REG_R13]; - regs->r14 = uc->uc_mcontext.gregs[REG_R14]; - regs->r15 = uc->uc_mcontext.gregs[REG_R15]; - regs->eflags = uc->uc_mcontext.gregs[REG_EFL]; -} - -void regs_to_ucontext(ucontext_t *uc, Registers* regs) -{ - uc->uc_mcontext.gregs[REG_RAX] = regs->rax; - uc->uc_mcontext.gregs[REG_RCX] = regs->rcx; - uc->uc_mcontext.gregs[REG_RDX] = regs->rdx; - uc->uc_mcontext.gregs[REG_RDI] = regs->rdi; - uc->uc_mcontext.gregs[REG_RSI] = regs->rsi; - uc->uc_mcontext.gregs[REG_RBX] = regs->rbx; - uc->uc_mcontext.gregs[REG_RBP] = regs->rbp; - uc->uc_mcontext.gregs[REG_RIP] = regs->rip; - uc->uc_mcontext.gregs[REG_RSP] = regs->rsp; - uc->uc_mcontext.gregs[REG_R8] = regs->r8; - uc->uc_mcontext.gregs[REG_R9] = regs->r9; - uc->uc_mcontext.gregs[REG_R10] = regs->r10; - uc->uc_mcontext.gregs[REG_R11] = regs->r11; - uc->uc_mcontext.gregs[REG_R12] = regs->r12; - uc->uc_mcontext.gregs[REG_R13] = regs->r13; - uc->uc_mcontext.gregs[REG_R14] = regs->r14; - uc->uc_mcontext.gregs[REG_R15] = regs->r15; - uc->uc_mcontext.gregs[REG_EFL] = regs->eflags; -} - -// Max. 6 arguments can be set up -void regs_push_param(Registers* pregs, POINTER_SIZE_INT param, int num) -{ - switch (num) - { - case 0: - pregs->rdi = param; - return; - case 1: - pregs->rsi = param; - return; - case 2: - pregs->rdx = param; - return; - case 3: - pregs->rcx = param; - return; - case 4: - pregs->r8 = param; - return; - case 5: - pregs->r9 = param; - return; - } -} diff --git a/vm/vmcore/src/util/linux/signals_ia32.cpp b/vm/vmcore/src/util/linux/signals_ia32.cpp deleted file mode 100644 index 5c52f7c..0000000 --- a/vm/vmcore/src/util/linux/signals_ia32.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include "vm_core_types.h" -#include "signals_common.h" - - -#if defined(LINUX) -void ucontext_to_regs(Registers* regs, ucontext_t *uc) -{ - regs->eax = uc->uc_mcontext.gregs[REG_EAX]; - regs->ecx = uc->uc_mcontext.gregs[REG_ECX]; - regs->edx = uc->uc_mcontext.gregs[REG_EDX]; - regs->edi = uc->uc_mcontext.gregs[REG_EDI]; - regs->esi = uc->uc_mcontext.gregs[REG_ESI]; - regs->ebx = uc->uc_mcontext.gregs[REG_EBX]; - regs->ebp = uc->uc_mcontext.gregs[REG_EBP]; - regs->eip = uc->uc_mcontext.gregs[REG_EIP]; - regs->esp = uc->uc_mcontext.gregs[REG_ESP]; - regs->eflags = uc->uc_mcontext.gregs[REG_EFL]; -} - -void regs_to_ucontext(ucontext_t *uc, Registers* regs) -{ - uc->uc_mcontext.gregs[REG_EAX] = regs->eax; - uc->uc_mcontext.gregs[REG_ECX] = regs->ecx; - uc->uc_mcontext.gregs[REG_EDX] = regs->edx; - uc->uc_mcontext.gregs[REG_EDI] = regs->edi; - uc->uc_mcontext.gregs[REG_ESI] = regs->esi; - uc->uc_mcontext.gregs[REG_EBX] = regs->ebx; - uc->uc_mcontext.gregs[REG_EBP] = regs->ebp; - uc->uc_mcontext.gregs[REG_EIP] = regs->eip; - uc->uc_mcontext.gregs[REG_ESP] = regs->esp; - uc->uc_mcontext.gregs[REG_EFL] = regs->eflags; -} - -#elif defined(FREEBSD) -void ucontext_to_regs(Registers* regs, ucontext_t *uc) -{ - regs->eax = uc->uc_mcontext.mc_eax; - regs->ecx = uc->uc_mcontext.mc_ecx; - regs->edx = uc->uc_mcontext.mc_edx; - regs->edi = uc->uc_mcontext.mc_edi; - regs->esi = uc->uc_mcontext.mc_esi; - regs->ebx = uc->uc_mcontext.mc_ebx; - regs->ebp = uc->uc_mcontext.mc_ebp; - regs->eip = uc->uc_mcontext.mc_eip; - regs->esp = uc->uc_mcontext.mc_esp; - regs->eflags = uc->uc_mcontext.mc_eflags; -} - -void regs_to_ucontext(ucontext_t *uc, Registers* regs) -{ - uc->uc_mcontext.mc_eax = regs->eax; - uc->uc_mcontext.mc_ecx = regs->ecx; - uc->uc_mcontext.mc_edx = regs->edx; - uc->uc_mcontext.mc_edi = regs->edi; - uc->uc_mcontext.mc_esi = regs->esi; - uc->uc_mcontext.mc_ebx = regs->ebx; - uc->uc_mcontext.mc_ebp = regs->ebp; - uc->uc_mcontext.mc_eip = regs->eip; - uc->uc_mcontext.mc_esp = regs->esp; - uc->uc_mcontext.mc_eflags = regs->eflags; -} - -#else -#error need to add correct mcontext_t lookup for registers -#endif diff --git a/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp b/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp deleted file mode 100644 index 8677921..0000000 --- a/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "platform_lowlevel.h" -#include "vm_core_types.h" - - -void nt_to_vm_context(PCONTEXT pcontext, Registers* regs) -{ - regs->rsp = pcontext->Rsp; - regs->rbp = pcontext->Rbp; - regs->rip = pcontext->Rip; - - regs->rbx = pcontext->Rbx; - regs->r12 = pcontext->R12; - regs->r13 = pcontext->R13; - regs->r14 = pcontext->R14; - regs->r15 = pcontext->R15; - - regs->rax = pcontext->Rax; - regs->rcx = pcontext->Rcx; - regs->rdx = pcontext->Rdx; - regs->rsi = pcontext->Rsi; - regs->rdi = pcontext->Rdi; - regs->r8 = pcontext->R8; - regs->r9 = pcontext->R9; - regs->r10 = pcontext->R10; - regs->r11 = pcontext->R11; - - regs->eflags = pcontext->EFlags; -} - -void vm_to_nt_context(Registers* regs, PCONTEXT pcontext) -{ - pcontext->Rsp = regs->rsp; - pcontext->Rbp = regs->rbp; - pcontext->Rip = regs->rip; - - pcontext->Rbx = regs->rbx; - pcontext->R12 = regs->r12; - pcontext->R13 = regs->r13; - pcontext->R14 = regs->r14; - pcontext->R15 = regs->r15; - - pcontext->Rax = regs->rax; - pcontext->Rcx = regs->rcx; - pcontext->Rdx = regs->rdx; - pcontext->Rsi = regs->rsi; - pcontext->Rdi = regs->rdi; - pcontext->R8 = regs->r8; - pcontext->R9 = regs->r9; - pcontext->R10 = regs->r10; - pcontext->R11 = regs->r11; - - pcontext->EFlags = regs->eflags; -} - -void* regs_get_sp(Registers* pregs) -{ - return (void*)pregs->rsp; -} - -// Max. 4 arguments can be set up -void regs_push_param(Registers* pregs, POINTER_SIZE_INT param, int num) -{ // RCX, RDX, R8, R9 - switch (num) - { - case 0: - pregs->rcx = param; - return; - case 1: - pregs->rdx = param; - return; - case 2: - pregs->r8 = param; - return; - case 3: - pregs->r9 = param; - return; - } -} - -void regs_push_return_address(Registers* pregs, void* ret_addr) -{ - pregs->rsp = pregs->rsp - 8; - *((void**)pregs->rsp) = ret_addr; -} -- 1.3.3