管理员
- 积分
- 6511
- 金钱
- 1908
- 贡献
- 4093
- 注册时间
- 2023-11-3

|
SourceCode_Win7DKLauncher.txt
(3.77 KB, 下载次数: 0, 售价: 5 贡献)
* C* Z# C! _8 K8 v0 Q8 S
2 d* h. c7 [6 t5 y
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
7 ]: q3 Q9 D, i9 A% y* n6 B K
1 W" ^' R; Q/ h& y( S9 N6 k- // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
1 v6 Q: D6 b) i - //
9 _6 A* U1 u G: @
0 {1 i. l# P, W5 u* D9 w. ?- #include "stdafx.h"
+ r# \% \' u% J2 R6 A5 d: u" q - #include <iostream>+ u" \/ K1 H# D1 Z
- #include <Windows.h>
5 Y# M- R$ l9 u- \9 O) t5 j9 _ - #include <io.h>
5 _/ G0 ]: |/ o
& j: T' A. a0 D, ^6 i2 @
" h% B9 m5 T7 O0 R- k- int _tmain(int argc, _TCHAR* argv[])
* n; q. T8 e t& W - {8 O- H; M0 a! j6 V4 A
- printf("Dekaron-Server Launcher by Toasty\n");
$ P5 ^. X3 N ^; a
: `- ]3 L% S5 ^4 Y0 I- //查看文件“DekaronServer.exe”是否存在
2 ?" `+ R7 B0 j( ~: ^8 O# y# Y - if(_access("DekaronServer.exe", 0) == -1)
( |- H/ e" Z8 A& a2 b& G - {
4 a) ~0 f& t0 y7 l2 \/ R) z& i - printf("DekaronServer.exe not found!\n");- _: n5 P. |) y9 V( A
- printf("Program will close in 5seconds\n");
' Y7 J ]5 n0 `1 k; K& ] - Sleep(5000);
4 V% ~' W& a4 [+ y: p - }+ F7 j1 u7 n, N0 i4 Y$ P
- else7 n* M# ?0 ?% N9 E9 W6 ~
- {+ n. | P- E; e/ K0 ]5 z* W. ?
- $ }; \8 j+ p; e
- //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% a( K- a; D+ p4 N3 K" e0 ]2 G: b
- STARTUPINFO si;6 A% i4 P3 ] T8 c. Q/ t
- U5 n K8 Z. }, R- //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
+ r1 h* O. V: M; ]4 k' S - PROCESS_INFORMATION pi;
" r$ k `* @4 e
' l' |7 m q/ x0 q) g- //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
+ Y9 C$ ~ T2 n; J* v9 Q% `! K) | - DEBUG_EVENT dbge;
' O* F* F# e* Z; j# ]
" I8 X' N7 U+ r6 Y" }$ C- //Commandline that will used at CreateProcess
+ ~/ \3 E2 ^& x8 S( Y2 r* _ - LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
( ^5 K- d7 \8 A0 u
/ T. h* I0 I" k- f- ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
% M) _9 D* ^, {1 Y6 ? - si.cb = sizeof(si); //Size of the Structure (see msdn)5 a! r% W& K9 ~
- ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)* [, r3 I4 J6 A) e9 Y; }8 ^4 [& {
+ o+ b+ e* \' n# ]7 k- % n8 E/ w- k3 X) i0 e3 V
- 0 e9 Q5 t' j! K. D
- //Start DekaronServer.exe
) D3 u: b7 F7 a. g - //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx) u2 z F7 G2 m- T+ Y) w
- if( !CreateProcess( NULL, // No module name (use command line)2 V% V0 I8 D T1 n0 [
- szCmdline, // Command line
2 z4 z% F, m4 w; l2 `* j( S - NULL, // Process handle not inheritable
, G- m3 D1 m. D7 u - NULL, // Thread handle not inheritable
9 Y. X2 e8 e L1 n' u% q3 g; L - FALSE, // Set handle inheritance to FALSE
/ M0 D4 \( n3 m, d1 g - DEBUG_PROCESS, // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx- _+ C0 A& c0 I5 M" L
- NULL, // Use parent's environment block0 j9 n# J0 L) S8 P8 w6 f
- NULL, // Use parent's starting directory * N) i' w- _6 V& S
- &si, // Pointer to STARTUPINFO structure
$ T. V5 X8 V3 x. ] - &pi ) // Pointer to PROCESS_INFORMATION structure
6 ~- X& x& w. l n4 X% h% \2 g - )
% W5 N! m* g& n( b% f - {/ H" I. l! T4 t* U
- printf( "CreateProcess failed (%d).\n", GetLastError() );- j! K% z# T$ N- A4 r7 ^4 J
- return 0;
n* F: [( }; H9 o - }9 V7 @0 j& z1 N. i8 J! B( h
- //Creating Process was sucessful
, U* L- J+ }. Z, [2 r7 ~ - else! }2 b+ e+ T1 X9 u; V
- { H: V( Y1 q9 B( i1 K
- printf("Sucessfully launched DekaronServer.exe\n");
- F; w: H' ^- ] - 1 x/ O5 G0 }7 C6 s0 d6 T
- //Write ProcessId and ThreadId to the DEBUG_EVENT structure% V% U) Z& x0 I6 u+ _$ g2 V
- dbge.dwProcessId = pi.dwProcessId;
0 v# `) U6 P! z; D0 M7 O - dbge.dwProcessId = pi.dwThreadId;5 ~6 P0 M8 S! r8 Q0 n. K2 G$ c
" @- b8 y, l k6 o5 Q- while(true) //infinite loop ("Debugger")
2 ^- Q, n+ Z K" V4 R - {
, r6 w0 T+ ~# Q - WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
& d4 W: K& p, `4 H! Y# U. x: M l - 7 Q7 r6 W) e8 l3 Y4 L3 V) B
- /*8 ?; R* K; m [5 j
- <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
: N( C8 \: K5 t8 K) t* _& G9 B( F
8 f/ K9 O5 h& U4 n. `" y |
|