管理员
- 积分
- 5865
- 金钱
- 1837
- 贡献
- 3531
- 注册时间
- 2023-11-3

|
SourceCode_Win7DKLauncher.txt
(3.77 KB, 下载次数: 0, 售价: 5 贡献)
7 E* _7 m+ @- f% q8 l5 O: p) ?( T) }2 _$ G9 v3 G. ~) y
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
p( I# V' f! @: T7 Q% I" A {
- // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
3 P3 ~3 E6 C% | - //
; X. ^4 l- k) u* a3 H9 E0 x8 X6 R4 S
9 y' ^5 V9 b" a$ q# D- #include "stdafx.h"
$ r1 J/ C% A7 B - #include <iostream>
9 @/ C2 G$ I) a: j1 p5 G/ n - #include <Windows.h>" D5 ? Y, r& x; {% s4 T
- #include <io.h>: `: F4 Q" L0 |
- ( U/ E) g/ L: o+ Y# F5 _* x
- : b! E. P( |2 t! o, j5 E+ e
- int _tmain(int argc, _TCHAR* argv[]). P. z- d9 f }7 S' y; D
- {) b+ k& W! x7 z; e% O8 B
- printf("Dekaron-Server Launcher by Toasty\n");
; d7 ~" e! e' x
0 k$ I, P5 x* ?9 \8 q4 |$ T) i5 _- //查看文件“DekaronServer.exe”是否存在! p5 t3 J S% Z2 f$ b2 M/ W) Z3 x. L, y
- if(_access("DekaronServer.exe", 0) == -1)
: o. ^/ h6 w' j8 E2 {. i# t/ R* t - {
9 t! I0 y1 G8 {* U6 K B - printf("DekaronServer.exe not found!\n");
. U$ Y3 o( h( g1 V3 { - printf("Program will close in 5seconds\n");9 g* [! ?4 j/ V6 v! L& M* d
- Sleep(5000);
% t% [8 _) C4 a9 M2 q/ q0 ~ - }) A4 R3 R" ]6 D$ b% M6 A
- else
: i3 \* d3 {( s/ D6 N - {
1 Y# }! j: A! Y) Z -
& {! \* y I4 O; U1 ` - //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% o3 o" d! S8 s8 J8 }) t; ~7 b5 `
- STARTUPINFO si;
7 Q V0 k- r' z G2 m4 _
/ `- ]4 S. e0 S/ \ l- //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
# G: P% O( u( p$ ^8 \1 i - PROCESS_INFORMATION pi;
4 M C; y. s0 i' m0 n0 l1 I1 m
6 d P. ?# q& P# t1 n) M- //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$ f: g& w# X7 N1 A- T* X7 E
- DEBUG_EVENT dbge;8 `: I$ V' p( a' T' d
% C* O: a0 X: C# p" q- //Commandline that will used at CreateProcess2 U" W3 v6 c3 ]7 i1 m
- LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));# h" T" H* L* l( H# K
& {6 J4 @! [# s$ a& z% m, ^- ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)0 u6 @" W2 Q, I5 @* j- P
- si.cb = sizeof(si); //Size of the Structure (see msdn)
7 T4 f5 R% [% E3 |( t. H. L - ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)- ~+ W8 O) h! }7 I% |0 }3 C
- " R' T2 I+ g# G, w! F. V. A3 r0 J4 J
- Y% V( R7 }7 q* d% h) w3 ~- , i- V7 S$ T h& `7 \" C7 }
- //Start DekaronServer.exe : x5 h4 [6 ^2 Q
- //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx* h( }$ E: ~, b; p$ R( X7 U
- if( !CreateProcess( NULL, // No module name (use command line)
' B! K1 [" O1 v - szCmdline, // Command line3 X5 V" Z" a5 }& w' B2 f& D4 n
- NULL, // Process handle not inheritable
/ u7 }$ n" W7 R& s6 x9 r - NULL, // Thread handle not inheritable
3 q: s- ~8 t5 A& W/ } - FALSE, // Set handle inheritance to FALSE
0 x' z, S- i3 ] - DEBUG_PROCESS, // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx7 i; w. O: y& [( W8 N
- NULL, // Use parent's environment block. S+ l" ^# ?3 t0 i m2 v) m
- NULL, // Use parent's starting directory
3 E" l0 K/ L% y8 ]0 A - &si, // Pointer to STARTUPINFO structure8 ]6 U( y. J( j+ `3 b8 ?
- &pi ) // Pointer to PROCESS_INFORMATION structure) C s/ i' y3 B4 Y
- ) % X' u% _2 x% B3 |( r
- {
4 v9 ^ w F2 |; A' J r7 K - printf( "CreateProcess failed (%d).\n", GetLastError() );
9 x, G. ?& I8 x: M - return 0;# p- |: c1 V% w/ F% Y2 X- w7 ?
- }. ^1 `0 L# h/ n$ [9 u6 x2 w
- //Creating Process was sucessful
- J0 C3 T- n/ s: ^- _, T5 y - else
; n& a; j# H# R6 g, W1 [' Y' F; J - {
7 n5 Y% [9 p" `5 y/ z - printf("Sucessfully launched DekaronServer.exe\n");
0 H- P% E/ H+ W N
, b. a# |# Q' A& I- //Write ProcessId and ThreadId to the DEBUG_EVENT structure
V' C3 @" t* |) k' p# G* Y - dbge.dwProcessId = pi.dwProcessId;
1 b; l' s1 X3 T+ q - dbge.dwProcessId = pi.dwThreadId;# Q7 @2 ` f! R. m3 L& V0 Q
- 9 f! @) u: r+ }7 {0 k
- while(true) //infinite loop ("Debugger")" W/ ]! P b8 _9 G
- {
0 X2 k, J4 s: s9 V% n( d4 v: c' ] - WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
( o$ k, N4 O9 b/ @" a) z& q
% R$ A9 F* `. B8 V- /*0 l x$ _9 Y& V8 U/ q
- <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
1 T& ] U1 v$ ^% T! A8 C' V8 B# {
1 q1 @5 J% N/ e; R
|
|