驱动关键部分:
pDriverObj->MajorFunction[IRP_MJ_CREATE] = DispatchCreate;
pDriverObj->MajorFunction[IRP_MJ_CLOSE] = DispatchClose;
pDriverObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoctl;
pDriverObj->DriverUnload = DriverUnload;
汇编代码(I/O操作):
IOControl proc hWin:HWND
local adwInBuffer[1]:DWORD
lea esi, adwInBuffer
assume esi:ptr DWORD
invoke GetDlgItemText,hWin,1006,addr Testdb,255
invoke wsprintf,offset PID,offset Strfmt,offset Testdb
lea eax,offset PID
mov [esi][0*(sizeof DWORD)], eax
invoke CreateFile,offset DriverName,GENERIC_READ+GENERIC_WRITE,0,NULL,TRUNCATE_EXISTING,0,0
.if eax != NULL
mov hFile,eax
invoke MessageBox,hWin,addr Testdb,$CTA0("进程PID:"),MB_OK
mov eax,offset Testdb
invoke DeviceIoControl,hFile,99h,esi,sizeof DWORD,NULL,NULL,NULL,NULL
.if eax>0
invoke MessageBox,hWin,addr PID,$CTA0("调用I/O并返回成功"),MB_OK
.endif
invoke CloseHandle,hFile
.endif
ret
IOControl endp
问题:我用汇编写加载控制程序,驱动安装、启动、停止、卸载,功能正常,只有在I/O操作时,调用DeviceIoControl函数,老是失败,通过DebugView可以看到执行了DispatchCreate和
DispatchClose,而DispatchIoctl执行不到,用delphi全部正常,不知道汇编里面这个函数需要注意什么,请各位大哥大姐批评指教。完整代码联系QQ:4595464(验证:pediy)
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)