能力值:
( LV13,RANK:410 )
|
-
-
7 楼
就这样吧,我也不会Delphi,由于VC2011默认Unicode规范,所以,你看着办吧。
通过编译,但是功能应该不会有问题。
#include <windows.h>
#include <WinBase.h>
#include <TlHelp32.h>
bool EnabledDebugPrivilege()
{
TOKEN_PRIVILEGES tp;
HANDLE hToken;
DWORD temp;
bool return_value=FALSE;
if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&hToken))
{
tp.PrivilegeCount=1;
LookupPrivilegeValue(NULL,L"SeDebugPrivilege",&tp.Privileges[0].Luid);
tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,&temp);
if (ERROR_SUCCESS==GetLastError())
{
return_value=TRUE;
}
CloseHandle(hToken);
}
return return_value;
}
int InjectProcess(PWCHAR FileName,PWCHAR MatchPath,DWORD ProcessID,PWCHAR strInjectDll)
{
int return_value=0;
BOOL bInject=FALSE;
BYTE InjectPreLoad[]={
0x55, 0x8B, 0xEC, 0x83, 0xC4, 0xF0, 0x60, 0x64, 0xA1, 0x30, 0x00, 0x00, 0x00, 0x8B, 0x40, 0x0C, 0x8B, 0x40, 0x0C, 0x8B,
0x00, 0x8B, 0x00, 0x8B, 0x58, 0x18, 0x8B, 0x43, 0x3C, 0x03, 0xC3, 0x8B, 0x40, 0x78, 0x03, 0xC3, 0xFF, 0x70, 0x14, 0x8F,
0x45, 0xF0, 0x8B, 0x78, 0x1C, 0x03, 0xFB, 0x8B, 0x70, 0x20, 0x03, 0xF3, 0x56, 0xAD, 0x03, 0xC3, 0x33, 0xC9, 0x33, 0xD2,
0x8A, 0x10, 0x40, 0x03, 0xCA, 0xC1, 0xC1, 0x07, 0x80, 0xFA, 0x00, 0x75, 0xF3, 0x81, 0xF9, 0xAB, 0x53, 0x4E, 0x73, 0x75,
0x11, 0x8B, 0xC6, 0x2B, 0x04, 0x24, 0x03, 0xC7, 0x83, 0xE8, 0x04, 0x8B, 0x00, 0x03, 0xC3, 0x89, 0x45, 0xFC, 0x81, 0xF9,
0x61, 0x97, 0x2B, 0xDD, 0x75, 0x11, 0x8B, 0xC6, 0x2B, 0x04, 0x24, 0x03, 0xC7, 0x83, 0xE8, 0x04, 0x8B, 0x00, 0x03, 0xC3,
0x89, 0x45, 0xF8, 0x81, 0xF9, 0x37, 0xC4, 0xF7, 0xFF, 0x75, 0x11, 0x8B, 0xC6, 0x2B, 0x04, 0x24, 0x03, 0xC7, 0x83, 0xE8,
0x04, 0x8B, 0x00, 0x03, 0xC3, 0x89, 0x45, 0xF4, 0xFF, 0x4D, 0xF0, 0x75, 0x9C, 0x5E, 0x64, 0xA1, 0x18, 0x00, 0x00, 0x00,
0x83, 0xC0, 0x20, 0x50, 0x6A, 0x00, 0x6A, 0x00, 0xFF, 0x55, 0xF8, 0x83, 0xF8, 0x00, 0x75, 0x20, 0x64, 0xA1, 0x18, 0x00,
0x00, 0x00, 0x83, 0xC0, 0x20, 0x50, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0xFF, 0x55, 0xFC, 0xE8, 0x00, 0x00, 0x00, 0x00,
0x83, 0x04, 0x24, 0x0A, 0xFF, 0x55, 0xF4, 0x61, 0xC9, 0xC3};
PROCESSENTRY32 pe;
HANDLE hSnapshot;
hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if (Process32First(hSnapshot,&pe))
{
do
{
bInject=FALSE;
WCHAR *pExeFileName=pe.szExeFile;
while (*pExeFileName!='\\') pExeFileName--;
*(pExeFileName-1)=0;
if (lstrcmpi(pExeFileName,FileName))
{
if (MatchPath && lstrcmpi(pe.szExeFile,MatchPath))
{
return_value++;
bInject=TRUE;
}
}
if (!bInject && pe.th32ProcessID==ProcessID)
{
return_value++;
bInject=TRUE;
}
if (bInject)
{
HANDLE hProcess;
if (hProcess=OpenProcess(PROCESS_CREATE_THREAD + PROCESS_VM_OPERATION,false,pe.th32ProcessID))
{
PBYTE PreloadBuffer=(PBYTE)(VirtualAllocEx(hProcess,NULL,sizeof(InjectPreLoad),MEM_COMMIT,PAGE_EXECUTE_READWRITE));
DWORD temp;
WriteProcessMemory(hProcess,PreloadBuffer,InjectPreLoad,sizeof(InjectPreLoad),&temp);
WriteProcessMemory(hProcess,PreloadBuffer+sizeof(InjectPreLoad),strInjectDll,lstrlen(strInjectDll),&temp);
CloseHandle(CreateRemoteThread(hProcess,NULL,NULL,(LPTHREAD_START_ROUTINE)PreloadBuffer,NULL,NULL,NULL));
CloseHandle(hProcess);
}
}
} while (Process32Next(hSnapshot,&pe));
}
CloseHandle(hSnapshot);
}
|