函数waitpid c中的变量stat_loc
我有一个代码,我不理解变量stat\u loccompare 127(0x7f),然后它比较5。你能给我解释一下吗???非常感谢函数waitpid c中的变量stat_loc,c,wait,ptrace,C,Wait,Ptrace,我有一个代码,我不理解变量stat\u loccompare 127(0x7f),然后它比较5。你能给我解释一下吗???非常感谢 int __fastcall m_loop(__int64 Input) { int result; int stat_loc; void *v3; __pid_t pid_child; void *nanomites_addr; stat_loc = 0; nanomites_a
int __fastcall m_loop(__int64 Input)
{
int result;
int stat_loc;
void *v3;
__pid_t pid_child;
void *nanomites_addr;
stat_loc = 0;
nanomites_addr = mmap(0LL, 0x141, 7, 34, -1, 0);
pid_child = fork();
if ( !pid_child )`// This is the child process`
{
if ( ptrace(0, 0LL, 0LL, 0LL) == -1 )
{ puts("So you want to trace me?!");
exit(42);
}
v3 = nanomites_addr;
((void (__fastcall *)(__int64))nanomites_addr)(Input);
/* Call the first nanomite,
xor rax, rax
xor rcx, rcx
xor rbx, rbx
mov al, byte ptr[rdi]
int 3 */
exit(0);
}
while ( waitpid(pid_child, &stat_loc, 0) != -1 ) // This is in the parent
{
if ( (stat_loc == 127 )
{
if ( BYTE1(stat_loc) == 5 )
parent_read_regs(nanomites_addr, pid_child);
ptrace(PTRACE_CONT, pid_child, 0, 0);
}
}
if ( BYTE1(stat_loc) )
result = puts("You lost !");
else
result = puts("You win! ");
欢迎来到堆栈溢出。请尽快阅读和页面,以及关于如何更紧急地创建MCVE()的内容。您显示的代码充其量是混乱的,而且不完整(无法编译)。你没有给出任何你找到它的背景。目前还不清楚它打算做什么。没有关于字节1作为函数或宏的作用的指示。自由使用
ptrace()
也让生活变得复杂——这不容易理解。看起来父代码和子代码都经历了while
循环条件;孩子不会进入循环。当stat\u loc
中的值可能为0,也可能不为0时,谁知道最后的if/else块在孩子中做了什么?同样,我们也不知道BYTE1
做了什么。您阅读了waitpid()
中的哪些文档?我推荐。顺便说一句,我看不懂屏幕截图。请以文本形式发布文本。web搜索会发现一些稍有不同的代码:if((unsigned u int8)stat_loc==127){if(BYTE1(stat_loc)==5)
此代码似乎会检查stat_loc的最低有效字节和下一个最低有效字节。