首页 > 解决方案 > 函数waitpid c中的变量stat_loc

问题描述

我有一个代码,但我不明白变量stat_loc比较 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_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! ");

这是 parent_read_regs() 函数的图像文件

标签: cwaitptrace

解决方案


推荐阅读