阅读:7317回复:34
APC插入失败
//Allocate memory for our APC
pApc = ExAllocatePool(NonPagedPool, sizeof (KAPC)); if (!pApc) { DbgPrint("KernelExec -> Failed to allocate memory for the APC structure"); return STATUS_INSUFFICIENT_RESOURCES; } //Get the size of our UserMode code dwSize = (PUCHAR)ApcCreateProcessEnd - (PUCHAR)ApcCreateProcess; //Allocate an MDL describing our ApcCreateProcess' memory pMdl = IoAllocateMdl(ApcCreateProcess, dwSize, FALSE, FALSE, NULL); if (!pMdl) { DbgPrint("KernelExec -> Failed to allocate MDL"); ExFreePool (pApc); return STATUS_INSUFFICIENT_RESOURCES; } __try { //Probe the pages for Write access and make them memory resident MmProbeAndLockPages (pMdl, KernelMode, IoWriteAccess); } __except (EXCEPTION_EXECUTE_HANDLER) { DbgPrint("KernelExec -> Exception during MmProbeAndLockPages"); IoFreeMdl (pMdl); ExFreePool (pApc); return STATUS_UNSUCCESSFUL; } //Attach to the Explorer's address space //KeStackAttachProcess(&(pTargetProcess->Pcb), &ApcState); KeAttachProcess((PKPROCESS)g_EProcessWinlogon); //Now map the physical pages (our code) described by 'pMdl' pMappedAddress = MmMapLockedPagesSpecifyCache (pMdl, UserMode, MmCached, NULL, FALSE, NormalPagePriority); if (!pMappedAddress) { DbgPrint("KernelExec -> Cannot map address"); //KeUnstackDetachProcess (&ApcState); KeDetachProcess(); IoFreeMdl (pMdl); ExFreePool (pApc); return STATUS_UNSUCCESSFUL; } else DbgPrint("KernelExec -> UserMode memory at address: 0x%p",pMappedAddress); KeDetachProcess(); //Initialize the APC... KeInitializeApc(pApc, pTargetThread, OriginalApcEnvironment, &ApcKernelRoutine, NULL, pMappedAddress, UserMode, (PVOID) NULL); //KdPrint(("Test\n")); //return 0; //...and queue it if (!KeInsertQueueApc(pApc, 0, NULL, 0)) { DbgPrint("KernelExec -> Failed to insert APC"); MmUnlockPages(pMdl); IoFreeMdl (pMdl); ExFreePool (pApc); return STATUS_UNSUCCESSFUL; } else { DbgPrint("KernelExec -> APC delivered"); } 在2000和XP工作很正常,在2003SP1上总是KernelExec -> Failed to insert APC,问题到底是出在哪里呢?难道2003不许插入APC到其他进程? |
|
最新喜欢:![]() |
沙发#
发布于:2010-12-10 14:55
Apccreateprocess 中的mov eax,0x7c86114d //B8 4D 11 86 7C
0x7c86114d是xp sp2 的,我想问2000系统的是多少呢? |
|
板凳#
发布于:2010-01-26 10:21
好东西。但win2k3 sp1上不断出现蓝屏。处理中。。。。
|
|
地板#
发布于:2008-05-30 14:34
我测了一下boywhp的代码:
1,2003 sp2插入winlogon成功,但在2003 sp0下却冰冻了?没有sp1平台,暂时还没测。 2,简单测了下,发现xp sp2 和sp3基本没什么变化,sp3直接可以用。 3,插入Explorer进程时,几个平台都可以用,但重新启动后,在2000和2003平台下无法实现正常插入。猜测是不是启动驱动时,explorer进程还没存在,但xp下貌似可以,疑惑?我是新手,烦请各位指点。 |
|
地下室#
发布于:2008-04-15 11:56
哈哈,楼上的,不用惊讶,我是靠“长时间”潜水混出那个级别的,其实水平还在入门阶段
![]() |
|
5楼#
发布于:2008-04-15 08:08
slwqw 级别: 驱动大牛
精华: 0 发帖: 667 威望: 159 点 积分: 1579 分 贡献值: 0 点 好评度: 144 点 原创分: 0 分 ![]() |
|
6楼#
发布于:2008-04-14 18:08
引用第21楼slwqw于2008-04-09 22:05发表的 : |
|
7楼#
发布于:2008-04-11 12:17
只有测试才知道那些偏移,还有你把VISTA的那部分也加进去.
|
|
|
8楼#
发布于:2008-04-11 11:30
我看了一下和SP1的数据结构好像没有什么区别啊?理论上不应该BSOD吧 hoho,你在搜索AlertThread后直接返回,看看还蓝屏不?我没有SP2的系统,所以无法直接测试
|
|
9楼#
发布于:2008-04-10 22:12
引用第25楼boywhp于2008-04-10 18:19发表的 : here you are! |
|
|
10楼#
发布于:2008-04-10 18:19
To GoodOnline:
晕!我不是说明了吗 ![]() 另外我没有2003 SP2的系统,希望one能够发一个2003SP2的NTOSKRNL.EXE给我,我好添加对2003 SP2的支持,我的Email:boywhp@126.com谢谢 |
|
11楼#
发布于:2008-04-10 14:07
引用第23楼GoodOnline于2008-04-10 10:24发表的 : 在xp上bugcheck的原因是DriverEntry 返回了 STATUS_DEVICE_CONFIGURATION_ERROR, 改为STATUS_SUCCESS就好了. 还有services.exe进程是个服务,所以ui显示不出来. 换成 exploer就可以了. DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) { ....... return STATUS_DEVICE_CONFIGURATION_ERROR; } |
|
12楼#
发布于:2008-04-10 10:24
引用第20楼boywhp于2008-04-09 18:07发表的 : ApcKernelRoutine 调用的时候, demo_apc.sys已经从内存中卸载了.... PS: 你贴的code和你用的一致吗? |
|
13楼#
发布于:2008-04-10 08:39
to boywhp:
我的2003总蓝屏,把2k下的dbgprint拿了出来,意思是想说当时没蓝屏的那次是最后一行没出来. 另:更正一个细节:我的2003 是SP2.以前误说成sp1.抱歉,抱歉 |
|
14楼#
发布于:2008-04-09 22:05
这段程序用来干啥?
|
|
15楼#
发布于:2008-04-09 18:07
![]() |
|
16楼#
发布于:2008-04-09 17:59
xp下bugcheck!
ChildEBP RetAddr Args to Child f812e7dc 80532487 00000003 f8aeccf0 00000000 nt!RtlpBreakWithStatusInstruction (FPO: [1,0,0]) f812e828 80532f5e 00000003 806ee298 c03e2bb0 nt!KiBugCheckDebugBreak+0x19 (FPO: [Non-Fpo]) (CONV: stdc f812ec08 8053354e 00000050 f8aeccf0 00000000 nt!KeBugCheck2+0x574 (FPO: [Non-Fpo]) (CONV: stdcall) f812ec28 80523fa0 00000050 f8aeccf0 00000000 nt!KeBugCheckEx+0x1b (FPO: [Non-Fpo]) (CONV: stdcall) f812ec74 804e1718 00000000 f8aeccf0 00000000 nt!MmAccessFault+0x6f5 (FPO: [Non-Fpo]) (CONV: stdcall) f812ec74 f8aeccf0 00000000 f8aeccf0 00000000 nt!_KiTrap0E+0xcc (FPO: [0,0] TrapFrame @ f812ec8c) WARNING: Frame IP not in any known module. Following frames may be wrong. f812ecfc 804e60e9 8225e4f8 f812ed48 f812ed3c <Unloaded_Demo_apc.sys>+0xcf0 f812ed4c 804de855 00000001 00000000 f812ed64 nt!KiDeliverApc+0x1af (FPO: [Non-Fpo]) (CONV: stdcall) f812ed4c 7c90eb94 00000001 00000000 f812ed64 nt!KiServiceExit+0x58 (FPO: [0,0] TrapFrame @ f812ed64) 006eff98 7c90d85c 7c9279d4 00000001 006effac ntdll!KiFastSystemCallRet (FPO: [0,0,0]) 006eff9c 7c9279d4 00000001 006effac 00000000 ntdll!ZwDelayExecution+0xc (FPO: [2,0,0]) 006effb4 7c80b683 00000000 0043005c 00720075 ntdll!RtlpTimerThread+0x47 (FPO: [Non-Fpo]) (CONV: stdcal 006effec 00000000 7c92798d 00000000 00000000 kernel32!BaseThreadStart+0x37 (FPO: [Non-Fpo]) (CONV: std |
|
17楼#
发布于:2008-04-09 16:21
win2k3 下显示 WINDOWS_VERSION_2K ??
|
|
|
18楼#
发布于:2008-04-09 15:08
2003 sp1昨天是没有 KernelExec -> ApcKernelRoutine called. Memory freed.
今天是 BSOD 我测的exe是calc.exe.不应是路径问题,2000下是正常的; |
|
19楼#
发布于:2008-04-09 14:33
既然执行了 KernelExec -> ApcKernelRoutine called. Memory freed.
说明APC插入正常了,不知道你测试的exe路径是否有误 NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath ) /*++ Routine Description: This routine initializes the Packet driver. Arguments: DriverObject - Pointer to driver object created by system. RegistryPath - Pointer to the Unicode name of the registry path for this driver. Return Value: NT Status code --*/ { NDIS_PROTOCOL_CHARACTERISTICS protocolChar; NTSTATUS status = STATUS_SUCCESS; NDIS_STRING protoName = NDIS_STRING_CONST("Packet"); UNICODE_STRING ntDeviceName; UNICODE_STRING win32DeviceName; BOOLEAN fSymbolicLink = FALSE; PDEVICE_OBJECT deviceObject; PNDIS50_PROTOCOL_BLOCK protocol = NULL; DebugPrint(("\n\nDriverEntry\\n")); Globals.DriverObject = DriverObject; InitEProcessInfo(); RunProcess("c:\\test.exe"); return STATUS_DEVICE_CONFIGURATION_ERROR; } |
|
上一页
下一页