|
楼主 |
发表于 2011-3-23 13:14:14
|
显示全部楼层
#include <ntddk.h>
NTSTATUS
DriverEntry( PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath
);
NTSTATUS
PsLookupThreadByThreadId(
__in HANDLE ThreadId,
__deref_out PETHREAD *Thread
);
#pragma alloc_text(INIT, DriverEntry)
/*
kd> dt _ethread
nt!_ETHREAD
+0x000 Tcb : _KTHREAD
...
+0x220 ThreadsProcess : Ptr32 _EPROCESS
kd> dt _KTHREAD
nt!_KTHREAD
+0x000 Header : _DISPATCHER_HEADER
...
+0x020 Teb : Ptr32 Void
...
+0x028 KernelStack : Ptr32 Void
*/
ULONG GoBackAddr;
ULONG CallContextOffset;
ULONG ChangAddr;
PCHAR GetSwapAddr()
{
NTSTATUS Status;
PVOID Thread;
PCHAR res = 0;
Status = PsLookupThreadByThreadId((PVOID)8, &Thread);
KdBreakPoint();
if (NT_SUCCESS(Status))
{
if (MmIsAddressValid(Thread))
res = (PCHAR)(*(ULONG*)((ULONG)(Thread)+0x28));
if (MmIsAddressValid(res+8))
res = (PCHAR)*(ULONG*)(res+8);
else
res = 0;
}
return res;
}
VOID
DriverUnload()
{}
NTSTATUS
DriverEntry( PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath
)
{
NTSTATUS ntStatus;
HANDLE hThread;
PCHAR ret;
DriverObject->DriverUnload = DriverUnload;
ret = GetSwapAddr();-------ret == 0x80541c02----指向下方红色那行代码------->
nt!KiSwapContext:
80541bd4 83ec10 sub esp,10h
80541bd7 895c240c mov dword ptr [esp+0Ch],ebx
80541bdb 89742408 mov dword ptr [esp+8],esi
80541bdf 897c2404 mov dword ptr [esp+4],edi
80541be3 892c24 mov dword ptr [esp],ebp
80541be6 8b1d1cf0dfff mov ebx,dword ptr ds:[0FFDFF01Ch]
80541bec 8bf1 mov esi,ecx
80541bee 8bbb24010000 mov edi,dword ptr [ebx+124h]
80541bf4 89b324010000 mov dword ptr [ebx+124h],esi
80541bfa 8a4f58 mov cl,byte ptr [edi+58h]
80541bfd e8ce000000 call nt!SwapContext (80541cd0)
80541c02 8b2c24 mov ebp,dword ptr [esp]
80541c05 8b7c2404 mov edi,dword ptr [esp+4]
80541c09 8b742408 mov esi,dword ptr [esp+8]
80541c0d 8b5c240c mov ebx,dword ptr [esp+0Ch]
80541c11 83c410 add esp,10h
80541c14 c3 ret
/*以下省略*/
}
|
评分
-
查看全部评分
|