int
main()
{
/
/
TCHAR cmdline[]
=
"D:\\1_aWORK\\detours_dll_inject\\dll_inject\\Debug\\1.exe"
;
/
/
ht[tps:
/
/
www.cnblogs.com
/
linxmouse
/
p
/
14182179.html
DWORD pid
=
4340
;
char dllpath[]
=
"C:\\Users\\admin\\Desktop\\dll\\Dll1.dll"
;
char exepath[]
=
"C:\\Users\\admin\\Desktop\\1\\1.exe"
;
TCHAR _dir[MAX_PATH]
=
"C:\\Users\\admin\\Desktop\\1"
;
STARTUPINFO si
=
{
0
};
si.cb
=
sizeof(STARTUPINFO);
PROCESS_INFORMATION magbox;
ZeroMemory(&si, sizeof(STARTUPINFO));
ZeroMemory(&magbox, sizeof(PROCESS_INFORMATION));
/
*
HANDLE pro
=
OpenProcess(PROCESS_VM_WRITE, TRUE, pid);
if
(pro)
{
printf(
"进程句柄:%d\n"
,pro);
magbox.hProcess
=
pro;
magbox.dwProcessId
=
pid;
}
else
{
printf(
"进程获取失败\n"
);
}
*
/
if
(DetourCreateProcessWithDllEx(exepath, NULL,NULL,NULL,true,CREATE_DEFAULT_ERROR_MODE , NULL, _dir, &si, &magbox, dllpath, (PDETOUR_CREATE_PROCESS_ROUTINEA)CreateProcess))
{
printf(
"注入成功\n"
);
}
else
{
printf(
"注入失败\n"
);
printf(
"error:%d"
, GetLastError());
}
/
*
hDLL
=
LoadLibrary(L
"Dll1.dll"
);
if
(hDLL !
=
NULL) {
/
/
第三步, 获取动态库dll中的函数地址
lpDo_array
=
GetProcAddress(hDLL,
"getmage"
);
}
lpDo_array();
*
/
return
0
;
}