|
|
楼主 |
发表于 2013-10-10 22:16:03
|
显示全部楼层
#pragma PAGEDCODE
VOID __declspec(naked) My_IopXxxControlFile()
{
  __asm
  {
    push dword ptr [ebp-40h]
    push dword ptr [ebp-24h]
    mov eax,addr_IopXxxControlFile
    add eax,0xB
    push eax
    mov eax,call_addr_IopXxxControlFile
    jmp eax
  }
}
#pragma PAGEDCODE
VOID Un_IopXxxControlFile()
{
   AGED_Open();
  _pjmp_code_IopXxxControlFile->E9=_jmp_code_IopXxxControlFile.E9;
  _pjmp_code_IopXxxControlFile->Fun_addr=_jmp_code_IopXxxControlFile.Fun_addr;
  _pjmp_code_IopXxxControlFile->nop[0]=_jmp_code_IopXxxControlFile.nop[0];
   AGED_Exit();
}
jmp_code _jmp_code_NtGetContextThread;
pjmp_code _pjmp_code_NtGetContextThread;
#pragma INITCODE
VOID Hook_NtGetContextThread()
{
  ULONG My_Function_Addr;
  BYTE* _bp;
  _bp=(BYTE*)Getssdt_addr(in_NtGetContextThread);
  do
  {
    if((*(_bp-15)==0x50)&&(*(_bp-5)==0x6A)&&(*(_bp-3)==0xFF)&&(*(_bp)==0xE8)&&(*(_bp+5)==0x8B)&&(*(_bp+7)==0x85))
    {
      break;
    }
    _bp++;
  } while (1);
  addr_NtGetContextThread=(ULONG)_bp-5;
  KdPrint(("向NtGetContextThread写跳转的地址为:%x\n",addr_NtGetContextThread));
  _bp=(BYTE*)Getssdt_addr(in_NtTerminateThread);
  do
  {
    if((*(_bp-15)==0x50)&&(*(_bp-5)==0x6A)&&(*(_bp-3)==0xFF)&&(*(_bp)==0xE8)&&(*(_bp+5)==0x8B)&&(*(_bp+7)==0x85))
    {
      break;
    }
    _bp++;
  } while (1);
  call_addr_NtGetContextThread=(ULONG)_bp;
  KdPrint(("NtGetContextThread的call来自于:%x\n",call_addr_NtGetContextThread));
  __asm
  {
    push eax
    push ebx
    mov eax,call_addr_NtGetContextThread
    add eax,1
    mov ebx,[eax]
    add eax,ebx
    add eax,5
    sub eax,1
    mov call_addr_NtGetContextThread,eax
    pop ebx
    pop eax
  }
  call_addr_NtSetContextThread=call_addr_NtGetContextThread;
  KdPrint(("从NtTerminateThread获取的NtGetContextThread的call ObReferenceObjectByHandle的地址为:%x\n",call_addr_NtGetContextThread));
  __asm
  {
    push eax
    mov eax,My_NtGetContextThread
    mov My_Function_Addr,eax
    pop eax
  }
  KdPrint(("自定义NtGetContextThread的地址为:%x\n",My_Function_Addr));
  Game_call_addr_1=addr_NtGetContextThread+5;
  __asm
  {
    push eax
    push ebx
    mov eax,Game_call_addr_1
    add eax,1
    mov ebx,[eax]
    add eax,ebx
    add eax,5
    sub eax,1
    mov Game_call_addr_1,eax
    pop ebx
    pop eax
  }
  KdPrint(("获取NtGetContextThread的call获取的第一个call地址为:%x\n",Game_call_addr_1));
  _pjmp_code_NtGetContextThread=(pjmp_code)addr_NtGetContextThread;
  _jmp_code_NtGetContextThread.E9=_pjmp_code_NtGetContextThread->E9;
  _jmp_code_NtGetContextThread.Fun_addr=_pjmp_code_NtGetContextThread->Fun_addr;
   AGED_Open();
  _pjmp_code_NtGetContextThread->E9=0xE9;
  _pjmp_code_NtGetContextThread->Fun_addr=(ULONG)(My_Function_Addr-addr_NtGetContextThread-5);
   AGED_Exit();
}
PEPROCESS eprocess;
ANSI_STRING GetProcess_1;
ANSI_STRING OD_Name_1;
ANSI_STRING OD_Name_2;
ANSI_STRING OD_Name_3;
#pragma PAGEDCODE
VOID __declspec(naked) My_NtGetContextThread()
{
  __asm
  {
    pushad
    pushf
  }
  eprocess=PsGetCurrentProcess();
  RtlInitAnsiString(&GetProcess_1,(PCSZ)((ULONG)eprocess+0x174));
  RtlInitAnsiString(&OD_Name_1,_Game_Name);
  RtlInitAnsiString(&OD_Name_2,_Game_Name1);
  RtlInitAnsiString(&OD_Name_3,_Game_Name2);
  if(RtlCompareString(&GetProcess_1,&OD_Name_1,TRUE)==0)
  {
    __asm
    {
      popf
      popad
      push 8
      push dword ptr [ebp+8]
      mov eax,addr_NtGetContextThread
      add eax,0xA
      push eax
      jmp call_addr_NtGetContextThread
    }
  }
  else
  {
    if(RtlCompareString(&GetProcess_1,&OD_Name_2,TRUE)==0)
    {
      __asm
      {
        popf
        popad
        push 8
        push dword ptr [ebp+8]
        mov eax,addr_NtGetContextThread
        add eax,0xA
        push eax
        jmp call_addr_NtGetContextThread
      }
    }
    else
    {
      if(RtlCompareString(&GetProcess_1,&OD_Name_3,TRUE)!=0)
      {
        __asm
        {
          popf
          popad
          push 8
          push dword ptr [ebp+8]
          mov eax,addr_NtGetContextThread
          add eax,0xA
          push eax
          jmp call_addr_NtGetContextThread
        }
      }
      else
      {
        __asm
        {
          popf
          popad
          push 8
          push dword ptr [ebp+8]
          mov eax,addr_NtGetContextThread
          add eax,0xA
          push eax
          jmp Game_call_addr_1
        }
      }
    }
    
  }
}
#pragma PAGEDCODE
VOID Un_NtGetContextThread()
{
   AGED_Open();
  _pjmp_code_NtGetContextThread->E9=_jmp_code_NtGetContextThread.E9;
  _pjmp_code_NtGetContextThread->Fun_addr=_jmp_code_NtGetContextThread.Fun_addr;
   AGED_Exit();
}
jmp_code _jmp_code_NtSetContextThread;
pjmp_code _pjmp_code_NtSetContextThread;
#pragma INITCODE
VOID Hook_NtSetContextThread()
{
  ULONG My_Function_Addr;
  BYTE* _bp;
  _bp=(BYTE*)Getssdt_addr(in_NtSetContextThread);
  do
  {
    if((*(_bp-15)==0x50)&&(*(_bp-5)==0x6A)&&(*(_bp-3)==0xFF)&&(*(_bp)==0xE8)&&(*(_bp+5)==0x8B)&&(*(_bp+7)==0x85))
    {
      break;
    }
    _bp++;
  } while (1);
  addr_NtSetContextThread=(ULONG)_bp-5;
  KdPrint(("向NtSetContextThread写跳转地址的:%x\n",addr_NtSetContextThread));
  __asm
  {
    push eax
    mov eax,My_NtSetContextThread
    mov My_Function_Addr,eax
    pop eax
  }
  KdPrint(("自定义NtSetContextThread的地址为:%x\n",My_Function_Addr));
  _pjmp_code_NtSetContextThread=(pjmp_code)addr_NtSetContextThread;
  _jmp_code_NtSetContextThread.E9=_pjmp_code_NtSetContextThread->E9;
  _jmp_code_NtSetContextThread.Fun_addr=_pjmp_code_NtSetContextThread->Fun_addr;
   AGED_Open();
  _pjmp_code_NtSetContextThread->E9=0xE9;
  _pjmp_code_NtSetContextThread->Fun_addr=(ULONG)(My_Function_Addr-addr_NtSetContextThread-5);
   AGED_Exit();
}
#pragma PAGEDCODE
VOID __declspec(naked) My_NtSetContextThread()
{
  __asm
  {
    push 1
    push dword ptr [ebp+8]
    mov eax,addr_NtSetContextThread
    add eax,0xA
    push eax
    mov eax,call_addr_NtSetContextThread
    jmp eax
  }
}
#pragma PAGEDCODE
VOID Un_NtSetContextThread()
{
   AGED_Open();
  _pjmp_code_NtSetContextThread->E9=_jmp_code_NtSetContextThread.E9;
  _pjmp_code_NtSetContextThread->Fun_addr=_jmp_code_NtSetContextThread.Fun_addr;
   AGED_Exit();
}
jmp_code _jmp_code_NtGetContextThread1;
pjmp_code _pjmp_code_NtGetContextThread1;
#pragma INITCODE
VOID Hook_NtGetContextThread1()
{
  ULONG My_Function_Addr;
  BYTE* _bp;
  _bp=(BYTE*)Getssdt_addr(in_NtGetContextThread);
  do
  {
    if((*(_bp-7)==0xBE)&&(*(_bp-2)==0x8B)&&(*(_bp-1)==0xCF)&&(*(_bp)==0xE8)&&(*(_bp+5)==0x5F)&&(*(_bp+6)==0x8B))
    {
      break;
    }
    _bp++;
  } while (1);
  addr_NtGetContextThread1=(ULONG)_bp-9;
  KdPrint(("向NtGetContextThread写跳转地址为:%x\n",addr_NtGetContextThread1));
  _bp=(BYTE*)Getssdt_addr(in_NtTerminateThread);
  do
  {
    if((*(_bp-9)==0xE8)&&(*(_bp-4)==0x8B)&&(*(_bp-2)==0x8B)&&(*(_bp)==0xE8)&&(*(_bp+5)==0x8B)&&(*(_bp+6)==0xC7))
    {
      break;
    }
    _bp++;
  } while (1);
  call_addr_NtGetContextThread1=(ULONG)_bp;
  __asm
  {
    push eax
    push ebx
    mov eax,call_addr_NtGetContextThread1
    add eax,1
    mov ebx,[eax]
    add eax,ebx
    add eax,5
    sub eax,1
    mov call_addr_NtGetContextThread1,eax
    pop ebx
    pop eax
  }
  KdPrint(("从NtTerminateThread获取的NtGetContextThread的第二个call地址为:%x\n",call_addr_NtGetContextThread1));
  __asm
  {
    push eax
    mov eax,My_NtGetContextThread1
    mov My_Function_Addr,eax
    pop eax
  }
  KdPrint(("NtGetContextThread的第二个自写函数地址为:%x\n",My_Function_Addr));
  Game_call_addr_2=addr_NtGetContextThread1+9;
  __asm
  {
    push eax
    push ebx
    mov eax,Game_call_addr_2
    add eax,1
    mov ebx,[eax]
    add eax,ebx
    add eax,5
    sub eax,1
    mov Game_call_addr_2,eax
    pop ebx
    pop eax
  }
  KdPrint(("获取NtGetContextThread的call获取的第二个call地址为:%x\n",Game_call_addr_2));
  _pjmp_code_NtGetContextThread1=(pjmp_code)addr_NtGetContextThread1;
  _jmp_code_NtGetContextThread1.E9=_pjmp_code_NtGetContextThread1->E9;
  _jmp_code_NtGetContextThread1.Fun_addr=_pjmp_code_NtGetContextThread1->Fun_addr;
  _jmp_code_NtGetContextThread1.nop[0]=_pjmp_code_NtGetContextThread1->nop[0];
  _jmp_code_NtGetContextThread1.nop[1]=_pjmp_code_NtGetContextThread1->nop[1];
  PAGED_Open();
  _pjmp_code_NtGetContextThread1->E9=0xE9;
  _pjmp_code_NtGetContextThread1->Fun_addr=(ULONG)(My_Function_Addr-addr_NtGetContextThread1-5);
  _pjmp_code_NtGetContextThread1->nop[0]=0x90;
  _pjmp_code_NtGetContextThread1->nop[1]=0x90;
  PAGED_Exit();
}
PEPROCESS eprocess_temp;
ANSI_STRING GetProcess_temp1;
ANSI_STRING OD_Name_temp1;
ANSI_STRING OD_Name_temp2;
ANSI_STRING OD_Name_temp3;
#pragma PAGEDCODE
VOID __declspec(naked) My_NtGetContextThread1()
{
  __asm
  {
    pushad
    pushf
  }
  eprocess_temp=PsGetCurrentProcess();
  RtlInitAnsiString(&GetProcess_temp1,(PCSZ)((ULONG)eprocess_temp+0x174));
  RtlInitAnsiString(&OD_Name_temp1,_Game_Name);
  RtlInitAnsiString(&OD_Name_temp2,_Game_Name1);
  RtlInitAnsiString(&OD_Name_temp3,_Game_Name2);
  if(RtlCompareString(&GetProcess_temp1,&OD_Name_temp1,TRUE)==0)
  {
    __asm
    {
      popf
      popad
      jmp __tiao2
      mov esi,0C0000008h
__tiao2:
      mov ecx,edi
      mov eax,addr_NtGetContextThread1
      add eax,0xE
      push eax
      jmp call_addr_NtGetContextThread1
    }
  }
  else
  {
    if(RtlCompareString(&GetProcess_temp1,&OD_Name_temp2,TRUE)==0)
    {
      __asm
      {
        popf
        popad
        jmp __tiaotemp1
        mov esi,0C0000008h
__tiaotemp1:
        mov ecx,edi
        mov eax,addr_NtGetContextThread1
        add eax,0xE
        push eax
        jmp call_addr_NtGetContextThread1
      }
    }
    else
    {
      if(RtlCompareString(&GetProcess_temp1,&OD_Name_temp3,TRUE)==0)
      {
        __asm
        {
          popf
          popad
          jmp __tiaotemp2
          mov esi,0C0000008h
__tiaotemp2:
          mov ecx,edi
          mov eax,addr_NtGetContextThread1
          add eax,0xE
          push eax
          jmp call_addr_NtGetContextThread1
        }
      }
      else
      {
        __asm
        {
          popf
          popad
          jmp __tiaotemp3
          mov esi,0C0000008h
__tiaotemp3:
          mov ecx,edi
          mov eax,addr_NtGetContextThread1
          add eax,0xE
          push eax
          jmp Game_call_addr_2
        }
      }
    }
  }
}
#pragma PAGEDCODE
VOID Un_NtGetContextThread1()
{
  PAGED_Open();
  _pjmp_code_NtGetContextThread1->E9=_jmp_code_NtGetContextThread1.E9;
  _pjmp_code_NtGetContextThread1->Fun_addr=_jmp_code_NtGetContextThread1.Fun_addr;
  _pjmp_code_NtGetContextThread1->nop[0]=_jmp_code_NtGetContextThread1.nop[0];
  _pjmp_code_NtGetContextThread1->nop[1]=_pjmp_code_NtGetContextThread1->nop[1];
  PAGED_Exit();
}
jmp_code _jmp_code_NtQueryPerformanceCounter;
pjmp_code _pjmp_code_NtQueryPerformanceCounter;
jmp_code _jmp_code_NtQueryPerformanceCounter_1;
pjmp_code _pjmp_code_NtQueryPerformanceCounter_1;
#pragma INITCODE
VOID Hook_NtQueryPerformanceCounter()
{
  ULONG My_temp;
  BYTE* _bp;
  _bp=(BYTE*)addr_NtOpenThread;
  do
  {
    if((*(_bp-18)==0xC3)&&(*(_bp-14)==0x8B)&&(*(_bp-7)==0xEB)&&(*(_bp)==0xE8)&&(*(_bp+5)==0xC2)&&(*(_bp+6)==0x10))
    {
      break;
    }
    _bp++;
  } while (1);
  call_addr_NtQueryPerformanceCounter=(ULONG)_bp;
  __asm
  {
    push eax
    push ebx
    mov eax,call_addr_NtQueryPerformanceCounter
    add eax,1
    mov ebx,[eax]
    add eax,ebx
    add eax,5
    sub eax,1
    mov call_addr_NtQueryPerformanceCounter,eax
    pop ebx
    pop eax
  }
  call_addr_NtQueryPerformanceCounter=call_addr_NtQueryPerformanceCounter-addr_NtQueryPerformanceCounter;
  KdPrint(("NtQueryPerformanceCounter的call地址为:%x\n",call_addr_NtQueryPerformanceCounter));
  _bp=(BYTE*)Getssdt_addr(in_NtQueryPerformanceCounter);
  do
  {
    if((*(_bp-10)==0x8B)&&(*(_bp-7)==0x89)&&(*(_bp-4)==0x83)&&(*(_bp)==0xEB)&&(*(_bp+2)==0x8B)&&(*(_bp+5)==0x8B))
    {
      break;
    }
    _bp++;
  } while (1);
  addr_NtQueryPerformanceCounter=(ULONG)_bp;
  KdPrint(("第一个NtQueryPerformanceCounter的JMP地址为:%x\n",addr_NtQueryPerformanceCounter));
  _bp=(BYTE*)addr_NtQueryPerformanceCounter;
  do
  {
    if((*(_bp-11)==0xC3)&&(*(_bp-10)==0x8B)&&(*(_bp-7)==0x83)&&(*(_bp-3)==0x8B)&&(*(_bp)==0xEB)&&(*(_bp+5)==0x50)&&(*(_bp+6)==0xFF))
    {
      break;
    }
    _bp++;
  } while (1);
  addr1_NtQueryPerformanceCounter=(ULONG)_bp;
  KdPrint(("第二个NtQueryPerformanceCounter的JMP地址为:%x\n",addr1_NtQueryPerformanceCounter));
  __asm
  {
    push eax
      mov eax,My_NtQueryPerformanceCounter_1
      mov My_temp,eax
      pop eax
  }
  KdPrint(("NtQueryPerformanceCounter第一个自定义函数地址为:%x\n",My_temp));
  _pjmp_code_NtQueryPerformanceCounter=(pjmp_code)addr_NtQueryPerformanceCounter;
  _jmp_code_NtQueryPerformanceCounter.E9=_pjmp_code_NtQueryPerformanceCounter->E9;
  _jmp_code_NtQueryPerformanceCounter.Fun_addr=_pjmp_code_NtQueryPerformanceCounter->Fun_addr;
  PAGED_Open();
  _pjmp_code_NtQueryPerformanceCounter->E9=0xE9;
  _pjmp_code_NtQueryPerformanceCounter->Fun_addr=(ULONG)(My_temp-addr_NtQueryPerformanceCounter-5);
  PAGED_Exit();
  __asm
  {
    push eax
    mov eax,My_NtQueryPerformanceCounter_2
    mov My_temp,eax
    pop eax
  }
  KdPrint(("NtQueryPerformanceCounter第二个自定义函数地址为:%x\n",My_temp));
  _pjmp_code_NtQueryPerformanceCounter_1=(pjmp_code)addr1_NtQueryPerformanceCounter;
  _jmp_code_NtQueryPerformanceCounter_1.E9=_pjmp_code_NtQueryPerformanceCounter_1->E9;
  _jmp_code_NtQueryPerformanceCounter_1.Fun_addr=_pjmp_code_NtQueryPerformanceCounter_1->Fun_addr;
  PAGED_Open();
  _pjmp_code_NtQueryPerformanceCounter_1->E9=0xE9;
  _pjmp_code_NtQueryPerformanceCounter_1->Fun_addr=(ULONG)(My_temp-addr1_NtQueryPerformanceCounter-5);
  PAGED_Exit();
}
#pragma PAGEDCODE
VOID __declspec(naked)My_NtQueryPerformanceCounter_1()
{
  __asm
  {
    mov eax,addr_NtQueryPerformanceCounter
    add eax,0x47
    push eax
    xor eax,eax
    jmp call_addr_NtQueryPerformanceCounter
  }
}
#pragma PAGEDCODE
VOID __declspec(naked)My_NtQueryPerformanceCounter_2()
{
  __asm
  {
    pushad
    mov eax,addr1_NtQueryPerformanceCounter
    add eax,0x2D
    push eax
    popad
    jmp call_addr_NtQueryPerformanceCounter
  }
}
#pragma PAGEDCODE
VOID Un_NtQueryPerformanceCounter()
{
  PAGED_Open();
  _pjmp_code_NtQueryPerformanceCounter->E9=_jmp_code_NtQueryPerformanceCounter.E9;
  _pjmp_code_NtQueryPerformanceCounter->Fun_addr=_jmp_code_NtQueryPerformanceCounter.Fun_addr;
  _pjmp_code_NtQueryPerformanceCounter_1->E9=_jmp_code_NtQueryPerformanceCounter_1.E9;
  _pjmp_code_NtQueryPerformanceCounter_1->Fun_addr=_jmp_code_NtQueryPerformanceCounter_1.Fun_addr;
  PAGED_Exit();
}
struct _str_index
{
  ULONG KiDispatchException;        //1处
  ULONG NtQueryInformationProcess;      //1处
  ULONG PspCreateProcess;        //1处
  ULONG PsGetProcessDebugPort;      //1处
  ULONG PsIsProcessBeingDebugged;      //1处
  ULONG NtTerminateProcess;        //1处
  ULONG PspTerminateProcess;      //1处
  ULONG PspExitThread;        //1处
  ULONG PspProcessDelete[2];       //3处
  ULONG ObpCloseHandleTableEntry;      //1处
  ULONG ObpCloseHandle;        //1处
  ULONG MmCreatePeb;        //1处
  ULONG DbgkCreateThread;        //1处
  ULONG DbgkExitThread;        //1处
  ULONG DbgkExitProcess;        //1处
  ULONG DbgkMapViewOfSection;      //1处
  ULONG DbgkUnMapViewOfSection;      //1处
  ULONG DbgkpMarkProcessPeb;      //1处
  ULONG DbgkpCloseObject[2];        //3处
  ULONG DbgkCopyProcessDebugPort[3];      //4处
  ULONG DbgkOpenProcessDebugPort[1];      //2处
  ULONG DbgkpQueueMessage;        //1处
  ULONG DbgkClearProcessDebugObject[1];      //2处
  ULONG DbgkpSetProcessDebugObject[4];      //5处
  ULONG DbgkForwardException;      //1处
}str_index,*pstr_index;
BYTE debugport_in[2]={0xBC,0x00};   //还原修改的函数
BYTE debugPort_out[2]={0x5C,0x02};  //将DebugPort+bc移至DebugPort+25C
#pragma PAGEDCODE
VOID Hook_DebugPort()
{
  /*
  1.枚举模块获取首地址
  2.定位函数地址
  3.修改函数
  */
  NTSTATUS status;
  ULONG len;
  PVOID Buffer=NULL;
  PCHAR GamePath;
  ULONG addr_start;
  ULONG addr_size;
  PSYSTEM_MODULE_INFORMATION enum_module;
  ZwQuerySystemInformation((SYSTEM_INFORMATION_CLASS)11,NULL,0,&len);
  Buffer=ExAllocatePool(NonPagedPool,len);
  if(Buffer==NULL)
  {
    KdPrint(("分配内存失败!\r\n"));
    return ;
  }
  status=ZwQuerySystemInformation((SYSTEM_INFORMATION_CLASS)11,Buffer,len,NULL);
  enum_module=(PSYSTEM_MODULE_INFORMATION)Buffer;
  addr_start=(ULONG)enum_module->Module[0].Base;
  addr_size=addr_start+(ULONG)enum_module->Module[0].Size;
  ExFreePool(Buffer);
  KdPrint(("模块名:%s   入口地址为:%x   模块结束地址:%x\r\n",enum_module->Module[0].ImageName,addr_start,addr_size));
  BYTE* _bp;
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0x64)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x39)&&(*(_bp+6)==0x74)&&(*(_bp+8)==0x6A)&&(*(_bp+10)==0x8D))
    {
      str_index.KiDispatchException=(ULONG)_bp+2;
      KdPrint(("KiDispatchException访问DebugPort的地址为:%x\n",str_index.KiDispatchException));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-19)==0xE8)&&(*(_bp-14)==0x85)&&(*(_bp-12)==0x0F)&&(*(_bp-6)==0x8B)&&(*(_bp)==0x8B)&&(*(_bp+6)==0xF7))
    {
      str_index.NtQueryInformationProcess=(ULONG)_bp+2;
      KdPrint(("NtQueryInformationProecss访问DebugPort的地址为:%x\n",str_index.NtQueryInformationProcess));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-13)==0x8B)&&(*(_bp-11)==0x3B)&&(*(_bp-9)==0x0F)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x89)&&(*(_bp+6)==0xF6)&&(*(_bp+10)==0x74))
    {
      str_index.PspCreateProcess=(ULONG)_bp+2;
      KdPrint(("PspCreateProess访问DebugPort的地址为:%x\n",str_index.PspCreateProcess));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0x8B)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x80)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x5D)&&(*(_bp+7)==0xC2)&&(*(_bp+8)==0x04))
    {
      str_index.PsGetProcessDebugPort=(ULONG)_bp+2;
      KdPrint(("PsGetProcessDeubugPort访问DebugPort的地址为:%x\n",str_index.PsGetProcessDebugPort));
      break;
    }
    _bp++;
  }while(1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0x8B)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x83)&&(*(_bp+1)==0xB8)&&(*(_bp+7)==0x0F)&&(*(_bp+10)==0x5D)&&(*(_bp+11)==0xC2))
    {
      str_index.PsIsProcessBeingDebugged=(ULONG)_bp+2;
      KdPrint(("PsIsProcessBeingDebugged访问DebugPort的地址为:%x\n",str_index.PsIsProcessBeingDebugged));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0x81)&&(*(_bp-2)==0x74)&&(*(_bp)==0x83)&&(*(_bp+1)==0xBB)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x74)&&(*(_bp+9)==0x80))
    {
      str_index.NtTerminateProcess=(ULONG)_bp+2;
      KdPrint(("NtTerminateProecss访问DebugPort的地址为:%x\n",str_index.NtTerminateProcess));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x8B)&&(*(_bp-4)==0x85)&&(*(_bp-2)==0x75)&&(*(_bp)==0x39)&&(*(_bp+1)==0x86)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x74)&&(*(_bp+8)==0x56))
    {
      str_index.PspTerminateProcess=(ULONG)_bp+2;
      KdPrint(("PspTerminateProecss访问DebugPort的地址为:%x\n",str_index.PspTerminateProcess));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0xE8)&&(*(_bp)==0x83)&&(*(_bp+1)==0xBF)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x74)&&(*(_bp+9)==0xF6))
    {
      str_index.PspExitThread=(ULONG)_bp+2;
      KdPrint(("PspExitThread访问DebugPort的地址为:%x\n",str_index.PspExitThread));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-8)==0x8B)&&(*(_bp-5)==0xE8)&&(*(_bp)==0x83)&&(*(_bp+1)==0xBF)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x74)&&(*(_bp+9)==0xF6))
    {
      str_index.PspProcessDelete[0]=(ULONG)_bp+2;
      KdPrint(("第一处PspProcessDelete访问DebugPotr的地址为:%x\n",str_index.PspProcessDelete[0]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-11)==0xE8)&&(*(_bp-6)==0x89)&&(*(_bp-4)==0x66)&&(*(_bp)==0x8D)&&(*(_bp+1)==0xBE)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x8B))
    {
      str_index.PspProcessDelete[1]=(ULONG)_bp+2;
      KdPrint(("第二处PspProcessDelete访问DebugPotr的地址为:%x\n",str_index.PspProcessDelete[1]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0x81)&&(*(_bp-2)==0x74)&&(*(_bp)==0x83)&&(*(_bp+1)==0xBB)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x74))
    {
      str_index.PspProcessDelete[2]=(ULONG)_bp+2;
      KdPrint(("第三处PspProcessDelete访问DebugPotr的地址为:%x\n",str_index.PspProcessDelete[2]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0x64)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x83)&&(*(_bp+1)==0xB8)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x74))
    {
      str_index.ObpCloseHandleTableEntry=(ULONG)_bp+2;
      KdPrint(("ObpCloseHandleTableEntry访问DebugPort的地址为:%x\n",str_index.ObpCloseHandleTableEntry));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0xF6)&&(*(_bp-2)==0x75)&&(*(_bp)==0x39)&&(*(_bp+1)==0x8B)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x74))
    {
      str_index.ObpCloseHandle=(ULONG)_bp+2;
      KdPrint(("ObpCloseHandle访问DebugPort的地址为:%x\n",str_index.ObpCloseHandle));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-8)==0x8B)&&(*(_bp-5)==0x89)&&(*(_bp-2)==0x33)&&(*(_bp)==0x39)&&(*(_bp+1)==0x9E)&&(*(_bp+6)==0x0F))
    {
      str_index.MmCreatePeb=(ULONG)_bp+2;
      KdPrint(("MmCreatePeb访问DebugPort的地址为:%x\n",str_index.MmCreatePeb));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x50)&&(*(_bp-5)==0xE8)&&(*(_bp)==0x39)&&(*(_bp+1)==0x9E)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x0F)&&(*(_bp+12)==0x39))
    {
      str_index.DbgkCreateThread=(ULONG)_bp+2;
      KdPrint(("DbgkCreateThread访问DebugPort的地址为:%x\n",str_index.DbgkCreateThread));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0xF6)&&(*(_bp-2)==0x75)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x89)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x85))
    {
      str_index.DbgkExitThread=(ULONG)_bp+2;
      KdPrint(("DbgkExitThread访问DebugPort的地址为:%x\n",str_index.DbgkExitThread));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)str_index.DbgkExitThread+10;
  do
  {
    if((*(_bp-9)==0xF6)&&(*(_bp-2)==0x75)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x89)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x85))
    {
      str_index.DbgkExitProcess=(ULONG)_bp+2;
      KdPrint(("DbgkExitProcess访问DebugProt的地址为:%x\n",str_index.DbgkExitProcess));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x74)&&(*(_bp-4)==0x33)&&(*(_bp-2)==0xEB)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x89)&&(*(_bp+6)==0x3B))
    {
      str_index.DbgkMapViewOfSection=(ULONG)_bp+2;
      KdPrint(("DbgkMapViewOfSection访问DebugPort的地址为:%x\n",str_index.DbgkMapViewOfSection));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0xF6)&&(*(_bp-2)==0x75)&&(*(_bp)==0x83)&&(*(_bp+1)==0xB9)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x74))
    {
      str_index.DbgkUnMapViewOfSection=(ULONG)_bp+2;
      KdPrint(("DbgkUnMapViewOfSection访问DebugPort的地址为:%x\n",str_index.DbgkUnMapViewOfSection));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-11)==0xFF)&&(*(_bp-5)==0x89)&&(*(_bp-2)==0x33)&&(*(_bp)==0x39)&&(*(_bp+1)==0xBE)&&(*(_bp+6)==0x0F)&&(*(_bp+9)==0x8B))
    {
      str_index.DbgkpMarkProcessPeb=(ULONG)_bp+2;
      KdPrint(("DbgkpMarkProcessPeb访问DebugPort的地址为:%x\n",str_index.DbgkpMarkProcessPeb));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0xEB)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x81)&&(*(_bp+1)==0xC3)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x39)&&(*(_bp+8)==0x75))
    {
      str_index.DbgkpCloseObject[0]=(ULONG)_bp+2;
      KdPrint(("第一个DbgkpCloseObject访问DeBugPort的地址为:%x\n",str_index.DbgkpCloseObject[0]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0xFF)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x05)&&(*(_bp+1)==0xBC)&&(*(_bp+5)==0x8B)&&(*(_bp+7)==0x33))
    {
      str_index.DbgkpCloseObject[1]=(ULONG)_bp+1;
      KdPrint(("第二个DbgkpCloseObject访问DebugPort的地址为:%x\n",str_index.DbgkpCloseObject[1]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0xC6)&&(*(_bp-2)==0xFF)&&(*(_bp)==0x39)&&(*(_bp+1)==0x9F)&&(*(_bp+6)==0x75)&&(*(_bp+8)==0x8B))
    {
      str_index.DbgkpCloseObject[2]=(ULONG)_bp+2;
      KdPrint(("第三个DbgkpCloseObject访问DebugPort的地址为:%x\n",str_index.DbgkpCloseObject[2]));
      break;
    }
    _bp++;
  }while(1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x55)&&(*(_bp-5)==0x8B)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x83)&&(*(_bp+1)==0xA0)&&(*(_bp+2)==0xBC)&&(*(_bp+7)==0x56))
    {
      str_index.DbgkCopyProcessDebugPort[0]=(ULONG)_bp+2;
      KdPrint(("第一个DbgkCopyProcessDebugPort访问DebugPort的地址为:%x\n",str_index.DbgkCopyProcessDebugPort[0]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-4)==0x56)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x81)&&(*(_bp+1)==0xC6)&&(*(_bp+2)=0xBC)&&(*(_bp+6)==0x83)&&(*(_bp+9)==0x74))
    {
      str_index.DbgkCopyProcessDebugPort[1]=(ULONG)_bp+2;
      KdPrint(("第二个DbgkCopyProcessDebugPort访问DebugPort的地址为:%x\n",str_index.DbgkCopyProcessDebugPort[1]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-8)==0xE8)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x89)&&(*(_bp+1)==0xB0)&&(*(_bp+2)==0xBC)&&(*(_bp+6)==0x8B))
    {
      str_index.DbgkCopyProcessDebugPort[2]=(ULONG)_bp+2;
      KdPrint(("第三个DbgkCopyProcessDebugPort访问DebugPort的地址为:%x\n",str_index.DbgkCopyProcessDebugPort[2]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0x51)&&(*(_bp-4)==0x56)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x81)&&(*(_bp+1)==0xC6)&&(*(_bp+6)==0x83)&&(*(_bp+9)==0xC7))
    {
      str_index.DbgkCopyProcessDebugPort[3]=(ULONG)_bp+2;
      KdPrint(("第四个DbgkCopyProcessDebugPort访问DebugPort的地址为:%x\n",str_index.DbgkCopyProcessDebugPort[3]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0x51)&&(*(_bp-4)==0x56)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x81)&&(*(_bp+1)==0xC6)&&(*(_bp+6)==0x83)&&(*(_bp+9)==0xC7))
    {
      str_index.DbgkOpenProcessDebugPort[0]=(ULONG)_bp+2;
      KdPrint(("第一个DbgkOpenProcessDebugPort的访问地址为:%x\n",str_index.DbgkOpenProcessDebugPort[0]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0xFF)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x80)&&(*(_bp+6)==0x89)&&(*(_bp+9)==0x8B))
    {
      str_index.DbgkOpenProcessDebugPort[1]=(ULONG)_bp+2;
      KdPrint(("第二个DbgkOpenProcessDebugPort访问DebugPort的地址为:%x\n",str_index.DbgkOpenProcessDebugPort[1]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-9)==0xFF)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x80)&&(*(_bp+6)==0x89)&&(*(_bp+9)==0x8B))
    {
      str_index.DbgkpQueueMessage=(ULONG)_bp+2;
      KdPrint(("DbgkpQueueMessage访问DebugPort的地址为:%x\n",str_index.DbgkpQueueMessage));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-5)==0xFF)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x05)&&(*(_bp+1)==0xBC)&&(*(_bp+5)==0x8B)&&(*(_bp+7)==0x33))
    {
      str_index.DbgkClearProcessDebugObject[0]=(ULONG)_bp+1;
      KdPrint(("DbgkClearProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkClearProcessDebugObject[0]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0xC6)&&(*(_bp-2)==0xFF)&&(*(_bp)==0x39)&&(*(_bp+1)==0x9F)&&(*(_bp+6)==0x75)&&(*(_bp+8)==0x8B))
    {
      str_index.DbgkClearProcessDebugObject[1]=(ULONG)_bp+2;
      KdPrint(("DbgkClearProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkClearProcessDebugObject[1]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0xC6)&&(*(_bp-2)==0xFF)&&(*(_bp)==0x39)&&(*(_bp+1)==0x9F)&&(*(_bp+6)==0x75)&&(*(_bp+8)==0x8B))
    {
      str_index.DbgkpSetProcessDebugObject[0]=(ULONG)_bp+2;
      KdPrint(("第一个DbgkpSetProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkpSetProcessDebugObject[0]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x8B)&&(*(_bp-3)==0x8B)&&(*(_bp)==0x89)&&(*(_bp+1)==0x87)&&(*(_bp+6)==0xE8)&&(*(_bp+11)==0xFF))
    {
      str_index.DbgkpSetProcessDebugObject[1]=(ULONG)_bp+2;
      KdPrint(("第二个DbgkpSetProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkpSetProcessDebugObject[1]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x8B)&&(*(_bp-4)==0x85)&&(*(_bp-2)==0x74)&&(*(_bp)==0x83)&&(*(_bp+1)==0xA7)&&(*(_bp+7)==0xB9))
    {
      str_index.DbgkpSetProcessDebugObject[2]=(ULONG)_bp+2;
      KdPrint(("第三个DbgkpSetProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkpSetProcessDebugObject[2]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0xC6)&&(*(_bp-2)==0xFF)&&(*(_bp)==0x83)&&(*(_bp+1)==0xBF)&&(*(_bp+7)==0x74)&&(*(_bp+9)==0xC7))
    {
      str_index.DbgkpSetProcessDebugObject[3]=(ULONG)_bp+2;
      KdPrint(("第四个DbgkpSetProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkpSetProcessDebugObject[3]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-7)==0xE8)&&(*(_bp-2)==0xEB)&&(*(_bp)==0x83)&&(*(_bp+1)==0xA7)&&(*(_bp+7)==0xC7))
    {
      str_index.DbgkpSetProcessDebugObject[4]=(ULONG)_bp+2;
      KdPrint(("第五个DbgkpSetProcessDebugObject访问DebugPort的地址为:%x\n",str_index.DbgkpSetProcessDebugObject[4]));
      break;
    }
    _bp++;
  } while (1);
  _bp=(BYTE*)addr_start;
  do
  {
    if((*(_bp-6)==0x74)&&(*(_bp-4)==0x33)&&(*(_bp-2)==0xEB)&&(*(_bp)==0x8B)&&(*(_bp+1)==0x81)&&(*(_bp+6)==0x32)&&(*(_bp+8)==0xEB))
    {
      str_index.DbgkForwardException=(ULONG)_bp+2;
      KdPrint(("DbgkForwardException访问DeubugPort的地址为:%x\n",str_index.DbgkForwardException));
      break;
    }
    _bp++;
  } while (1);
  PAGED_Open();
  RtlCopyMemory((PVOID)str_index.KiDispatchException,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.NtQueryInformationProcess,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PspCreateProcess,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PsGetProcessDebugPort,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PsIsProcessBeingDebugged,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.NtTerminateProcess,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PspTerminateProcess,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PspExitThread,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PspProcessDelete[0],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PspProcessDelete[1],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.PspProcessDelete[2],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.ObpCloseHandleTableEntry,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.ObpCloseHandle,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.MmCreatePeb,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkCreateThread,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkExitThread,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkExitProcess,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkMapViewOfSection,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkUnMapViewOfSection,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpMarkProcessPeb,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpCloseObject[0],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpCloseObject[1],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpCloseObject[2],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[0],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[1],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[2],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[3],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkOpenProcessDebugPort[0],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkOpenProcessDebugPort[1],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpQueueMessage,debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkClearProcessDebugObject[0],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkClearProcessDebugObject[1],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[0],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[1],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[2],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[3],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[4],debugPort_out,2);
  RtlCopyMemory((PVOID)str_index.DbgkForwardException,debugPort_out,2);
  PAGED_Exit();
}
#pragma PAGEDCODE
VOID Un_DebugPort()
{
  PAGED_Open();
  RtlCopyMemory((PVOID)str_index.KiDispatchException,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.NtQueryInformationProcess,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PspCreateProcess,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PsGetProcessDebugPort,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PsIsProcessBeingDebugged,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.NtTerminateProcess,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PspTerminateProcess,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PspExitThread,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PspProcessDelete[0],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PspProcessDelete[1],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.PspProcessDelete[2],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.ObpCloseHandleTableEntry,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.ObpCloseHandle,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.MmCreatePeb,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkCreateThread,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkExitThread,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkExitProcess,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkMapViewOfSection,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkUnMapViewOfSection,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpMarkProcessPeb,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpCloseObject[0],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpCloseObject[1],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpCloseObject[2],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[0],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[1],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[2],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkCopyProcessDebugPort[3],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkOpenProcessDebugPort[0],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkOpenProcessDebugPort[1],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpQueueMessage,debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkClearProcessDebugObject[0],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkClearProcessDebugObject[1],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[0],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[1],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[2],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[3],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkpSetProcessDebugObject[4],debugport_in,2);
  RtlCopyMemory((PVOID)str_index.DbgkForwardException,debugport_in,2);
  PAGED_Exit();
}
#pragma INITCODE
VOID Hook_NtSetInformationThread()
{
  addr_NtSetInformationThread=(ULONG)Getsset_this(in_NtSetInformationThread);
  addr1_NtSetInformationThread=(ULONG)Getssdt_addr(in_NtSetInformationThread);
  _NtSetInformationThread=(NtSetInformationThread*)addr1_NtSetInformationThread;
  PAGED_Open();
  *((ULONG*)addr_NtSetInformationThread)=(ULONG)My_NtSetInformationThread;
  PAGED_Exit();
}
#pragma PAGEDCODE
extern "C"
NTSTATUS __stdcall My_NtSetInformationThread  ( __in HANDLE  ThreadHandle,  
                        __in THREADINFOCLASS  ThreadInformationClass,  
                        __in_bcount(ThreadInformationLength) PVOID  ThreadInformation,  
                        __in ULONG  ThreadInformationLength  
                           )
{
  if(ThreadInformationClass==0x11)
  {
    KdPrint(("发现ANTI行为!\r\n"));
    KdPrint(("NtSetInformationThread的参数:%8x %8x %8x %8x",ThreadHandle,ThreadInformationClass,ThreadInformation,ThreadInformationLength));
    ThreadInformationClass=(THREADINFOCLASS)0xFF;
    KdPrint(("NtSetInformationThread的修改后的参数:%8x %8x %8x %8x",ThreadHandle,ThreadInformationClass,ThreadInformation,ThreadInformationLength));
    return STATUS_SUCCESS;
  }
  return ((NtSetInformationThread)_NtSetInformationThread)(ThreadHandle,ThreadInformationClass,ThreadInformation,ThreadInformationLength);
}
#pragma PAGEDCODE
VOID Un_NtSetInnformationThread()
{
  PAGED_Open();
  *((ULONG*)addr_NtSetInformationThread)=addr1_NtSetInformationThread;
  PAGED_Exit();
}
#endif |
|