管理员
- 积分
- 6692
- 金钱
- 1933
- 贡献
- 4241
- 注册时间
- 2023-11-3

|
SourceCode_Win7DKLauncher.txt
(3.77 KB, 下载次数: 0, 售价: 5 贡献)
- O" Q% |/ [9 L+ l8 ^$ x
$ |4 W; R1 u8 _; ] z5 ^/ c虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
" N# A% p a( Y. ~0 p3 T `$ [# b, V2 d* y Q+ @
- // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
- i/ Q: X' |# s - // K7 e4 R$ c1 p& n+ f- W1 _
- ; d( i1 w, Q! c8 T" q4 @
- #include "stdafx.h"
* @) r; P7 @; h1 j9 C) g' W - #include <iostream>* H1 f c E. ?# S( P6 l2 ^
- #include <Windows.h>
5 D# M# x# R8 ? - #include <io.h>
4 @. k) ]% w: G' l! B - ; f9 s0 i4 e) g2 `# J) l6 j
* R e, c& p+ }# r0 Y( t& V2 |0 p- int _tmain(int argc, _TCHAR* argv[])
: ~0 B& P+ u5 n$ R( w - {6 c" R0 [* e& A2 ]5 {$ b4 @' _6 K
- printf("Dekaron-Server Launcher by Toasty\n");
* o9 A5 h3 @- O/ I
! R% M1 }) ?. G. ]' `- //查看文件“DekaronServer.exe”是否存在
: U1 @7 ?) ]* t. Y. G - if(_access("DekaronServer.exe", 0) == -1)
2 Q2 p) N6 ~' h2 ]: I' Q3 f - {8 G% P3 P7 E- J% X J0 l2 F
- printf("DekaronServer.exe not found!\n");% `" `9 v: M2 f5 A
- printf("Program will close in 5seconds\n");0 G# F0 g3 ?2 u' h) I) h
- Sleep(5000);! y( H4 ?( B7 E M* L
- }
6 f) t. {6 u3 @/ | - else1 F: u2 g" ]/ d8 J2 v- Y& |
- {3 \5 ^" c% l2 l; ` C% X" J. G% E
-
: E# ]# R% n4 S! ?6 s& w - //Only needed for the CreateProcess function below, no more use in this programm. More info at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686331(v=vs.85).aspx# T/ S6 r7 q6 ^: ], k
- STARTUPINFO si;# }% _% u+ W/ V$ f4 C; Z y3 S
s) V: S T0 a/ b2 [9 D- //Structure where the CreateProcess function will write the ProcessID and ThreadID of the created Process. More info at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684873(v=vs.85).aspx
& @3 g# A% Q7 M% P! N; w - PROCESS_INFORMATION pi;% a1 N& }& D% t4 G
5 Y0 n( J9 W2 v/ s. D8 j- //Debug event structure, needed for WaitForDebugEvent and ContinueDebugEvent. More info at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms679308(v=vs.85).aspx
, C/ W: D7 w4 w) x; ? - DEBUG_EVENT dbge; q6 B# g8 P$ U0 `
Z$ ]! f+ q# t m* L$ d( w X& V- //Commandline that will used at CreateProcess
; B8 ?$ p7 O3 q4 {2 M2 r s) x - LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
( j" E- e; u, f/ y- P% r" F - : u6 s" J5 o% L
- ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)0 L% I1 V# I" n$ Z" ]( D' q1 ?- J
- si.cb = sizeof(si); //Size of the Structure (see msdn)! \5 F+ r4 i+ _: ^( j" }* g) G6 S7 C
- ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
6 A5 q0 J3 R5 `# W6 O: C - + B, K2 y- @% L# z& l$ ?, _6 J
# [ R/ X a" t
( O0 k+ C1 Q/ Z& Z5 H$ n" z- //Start DekaronServer.exe
% J6 S; j N' h. A( s - //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
& ] x; E- \( G' w - if( !CreateProcess( NULL, // No module name (use command line)
; u6 }7 q8 A8 T! ^ - szCmdline, // Command line
; S6 M3 D0 D/ T- y) v9 V9 S( t - NULL, // Process handle not inheritable
" h) l$ i* |8 k# o) @, O - NULL, // Thread handle not inheritable
, I; c& q4 z; I6 z - FALSE, // Set handle inheritance to FALSE
( V2 o: m- u. i2 {, B- i - DEBUG_PROCESS, // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx. [4 X3 p- n$ q% I0 D
- NULL, // Use parent's environment block
$ o; S6 u8 Q: c& d4 }& w - NULL, // Use parent's starting directory
8 t2 s% A/ s( W" O - &si, // Pointer to STARTUPINFO structure4 _) y! Y0 L) R5 c0 ?' r
- &pi ) // Pointer to PROCESS_INFORMATION structure4 e) }$ `$ q2 k, l' j( p: R
- ) 5 Q9 }4 U/ T( P0 ]8 _+ U
- {
; }) Q- N6 p# k7 U( ^4 @# L - printf( "CreateProcess failed (%d).\n", GetLastError() );
7 X1 m, h% U& P1 @; N# e2 P - return 0;
) ~( b% H( \8 [; f0 k - }
* v' f+ l) Q( _7 c8 t) p6 q - //Creating Process was sucessful4 N6 @7 j6 R8 R6 a! q8 r+ v
- else$ z9 B0 t) V' a- B9 C+ N8 ]
- {
. x) k& ~& {2 s6 z0 | - printf("Sucessfully launched DekaronServer.exe\n");* R9 R- g: n9 l1 C
- 2 B% G' p# V% f- y5 {% \
- //Write ProcessId and ThreadId to the DEBUG_EVENT structure
3 p. P6 s5 c3 `& w# a3 V3 A) k - dbge.dwProcessId = pi.dwProcessId;
% \9 S7 m: \& g3 ?6 h - dbge.dwProcessId = pi.dwThreadId;9 O8 ?. c5 ?7 F2 {. I
7 q/ g1 k" ?9 J& @. u( {, o- P- while(true) //infinite loop ("Debugger")/ `3 k3 ~3 {0 T3 E8 ~6 F
- {
. }8 i7 y! l; d( a3 q8 @& c - WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
; j6 [0 d8 A5 C1 k. C4 T
1 B9 ^( h. J; c8 D1 Y7 v- /*$ X3 v) R: Q# k
- <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码 , r4 A3 ^. }8 r! D
& w9 r% _. f1 w% p9 `) x* N) z1 b
& y6 S8 z7 W. T" I: O |
|