gpt4 book ai didi

c - ubuntu中如何用C语言给EIP赋值

转载 作者:太空宇宙 更新时间:2023-11-04 11:41:07 24 4
gpt4 key购买 nike

哪里错了?如何给eip赋值改变程序运行位置?

请帮忙!!!!

错误:无法在赋值中将‘mcontext_t*’转换为‘sigcontext*’

struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
sigset_t uc_sigmask; /* mask last for extensibility */
};

#include <stdio.h>
#include <signal.h>
#include <asm/ucontext.h>
void handler(int signum, siginfo_t *siginfo, void *uc0){
struct ucontext *uc;
struct sigcontext *sc;

uc = (struct ucontext *)uc0;
sc = &uc->uc_mcontext;

sc->eip = target;
//uc->uc_mcontext.gregs[REG_EIP]
}

int main (int argc, char** argv){
struct sigaction act;
act.sa_sigaction = handler;
act.sa_flags = SA_SIGINFO;
sigaction(SIGTRAP, &act, NULL);

asm("movl $skipped, %0" : : "m" (target));

asm("int3"); // cause SIGTRAP
printf("to be skipped.\n");
asm("skipped:");
printf("Done.\n");
}

最佳答案

仅供引用。检查 man setjmpman longjmp

关于c - ubuntu中如何用C语言给EIP赋值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2997954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com