全局钩子(HOOK),挂接API,远程线程(100分)

  • 主题发起人 主题发起人 catkiller
  • 开始时间 开始时间
C

catkiller

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位高手,我写了一个dll,想让系统rundll32.exe启动这个dll,该如何实现。虽然我知道那几种方式可以,但不知道怎么开头,请高手能给个例子。谢谢
 
帮顶。。。。。。
 
随便写即可.<br>rundll32.exe c:/p.dll,****<br>其中fuck是你dll导出的过程名称
 
帮顶! <br><br>http://www.source520.com <br><br>站长开发推广同盟 站长朋友的终极驿站 <br>同时拥有海量源码电子经典书籍下载 <br><br>http://www.source520.com/search/search.asp <br><br>&quot;编程.站长&quot;论坛搜索引擎-----为中国站长注入动力!
 
收藏<br><br>我现在只能做到用explorer.exe启动自已的DLL
 
procedure FindAProcess(const AFilename: string; const PathMatch: Boolean; var ProcessID: DWORD);<br>var<br> &nbsp;lppe: TProcessEntry32;<br> &nbsp;SsHandle: Thandle;<br> &nbsp;FoundAProc, FoundOK: boolean;<br>begin<br> &nbsp;ProcessID :=0;<br> &nbsp;SsHandle := CreateToolHelp32SnapShot(TH32CS_SnapProcess, 0);<br> &nbsp;FoundAProc := Process32First(Sshandle, lppe);<br> &nbsp;while FoundAProc do<br> &nbsp;begin<br> &nbsp; &nbsp;if PathMatch then<br> &nbsp; &nbsp; &nbsp;FoundOK := AnsiStricomp(lppe.szExefile, PChar(AFilename)) = 0<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp;FoundOK := AnsiStricomp(PChar(ExtractFilename(lppe.szExefile)), PChar(ExtractFilename(AFilename))) = 0;<br> &nbsp; &nbsp;if FoundOK then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;ProcessID := lppe.th32ProcessID;<br> &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;FoundAProc := Process32Next(SsHandle, lppe);<br> &nbsp;end;<br> &nbsp;CloseHandle(SsHandle);<br>end;<br><br>function EnabledDebugPrivilege(const bEnabled: Boolean): Boolean;<br>var<br> &nbsp;hToken: THandle;<br> &nbsp;tp: TOKEN_PRIVILEGES;<br> &nbsp;a: DWORD;<br>const<br> &nbsp;SE_DEBUG_NAME = 'SeDebugPrivilege';<br>begin<br> &nbsp;Result := False;<br> &nbsp;if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, hToken)) then<br> &nbsp;begin<br> &nbsp; &nbsp;tp.PrivilegeCount := 1;<br> &nbsp; &nbsp;LookupPrivilegeValue(nil, SE_DEBUG_NAME, tp.Privileges[0].Luid);<br> &nbsp; &nbsp;if bEnabled then<br> &nbsp; &nbsp; &nbsp;tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp;tp.Privileges[0].Attributes := 0;<br> &nbsp; &nbsp;a := 0;<br> &nbsp; &nbsp;AdjustTokenPrivileges(hToken, False, tp, SizeOf(tp), nil, a);<br> &nbsp; &nbsp;Result := GetLastError = ERROR_SUCCESS;<br> &nbsp; &nbsp;CloseHandle(hToken);<br> &nbsp;end;<br>end;<br>function AttachToProcess(const HostFile, GuestFile: string; const PID: DWORD = 0): DWORD;<br>var<br> &nbsp;hRemoteProcess: THandle;<br> &nbsp;dwRemoteProcessId: DWORD;<br> &nbsp;cb: DWORD;<br> &nbsp;pszLibFileRemote: Pointer;<br> &nbsp;iReturnCode: Boolean;<br> &nbsp;TempVar: DWORD;<br> &nbsp;pfnStartAddr: TFNThreadStartRoutine;<br> &nbsp;pszLibAFilename: PwideChar;<br>begin<br> &nbsp;Result := 0;<br> &nbsp;EnabledDebugPrivilege(True);<br> &nbsp;Getmem(pszLibAFilename, Length(GuestFile) * 2 + 1);<br> &nbsp;StringToWideChar(GuestFile, pszLibAFilename, Length(GuestFile) * 2 + 1);<br> &nbsp;if PID &gt; 0 then<br> &nbsp; &nbsp; dwRemoteProcessID := PID<br> &nbsp;else<br> &nbsp; &nbsp; FindAProcess(HostFile, False, dwRemoteProcessID);<br> &nbsp;hRemoteProcess := OpenProcess(PROCESS_CREATE_THREAD + {&Ocirc;&Ecirc;&ETH;í&Ocirc;&para;&sup3;&Igrave;&acute;&acute;&frac12;¨&Iuml;&szlig;&sup3;&Igrave;}<br> &nbsp; &nbsp; &nbsp;PROCESS_VM_OPERATION + {&Ocirc;&Ecirc;&ETH;í&Ocirc;&para;&sup3;&Igrave;VM&sup2;&Ugrave;×÷}<br> &nbsp; &nbsp; &nbsp;PROCESS_VM_WRITE, {&Ocirc;&Ecirc;&ETH;í&Ocirc;&para;&sup3;&Igrave;VM&ETH;&acute;}<br> &nbsp; &nbsp; &nbsp;FALSE, dwRemoteProcessId);<br> &nbsp;cb := (1 + lstrlenW(pszLibAFilename)) * sizeof(WCHAR);<br> &nbsp;pszLibFileRemote := PWIDESTRING(VirtualAllocEx(hRemoteProcess, nil, cb, MEM_COMMIT, PAGE_READWRITE));<br> &nbsp;TempVar := 0;<br> &nbsp;iReturnCode := WriteProcessMemory(hRemoteProcess, pszLibFileRemote, pszLibAFilename, cb, TempVar);<br> &nbsp;if iReturnCode then<br> &nbsp;begin<br> &nbsp; &nbsp;pfnStartAddr := GetProcAddress(GetModuleHandle('Kernel32'), 'LoadLibraryW');<br> &nbsp; &nbsp;TempVar := 0;<br> &nbsp; &nbsp;Result := CreateRemoteThread(hRemoteProcess, nil, 0, pfnStartAddr, pszLibFileRemote, 0, TempVar);<br> &nbsp;end;<br> &nbsp;Freemem(pszLibAFilename);<br>end;<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> &nbsp; AttachToProcess('QQ.exe', 'D:/iNDS-Top/Client/NDSDLL.dll');<br>end;
 
后退
顶部