找回密码
 立即注册
查看: 4545|回复: 5

[技术文章] Dekaron-用于Win7 / Win2k8R2的服务器启动器

[复制链接]

153

主题

335

回帖

5748

积分

管理员

积分
5748
金钱
1807
贡献
3453
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) * X" C- Y* B& [6 {2 \) I# Y* {

6 x6 S( }  d- I# w" h: d虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
' s, r" W8 D6 y& ~
7 a3 `) s" |' k* `$ ^7 {3 Q; q; x0 C
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    & a9 P; Q* f- N
  2. //
    + z6 |0 C0 X; v7 S
  3. - j4 S9 ~" k" L
  4. #include "stdafx.h"; f, m8 k) y% s/ y* T- [" B- j
  5. #include <iostream>
    % i0 K. A% b+ m- [' y/ v
  6. #include <Windows.h>* L- B( J6 C& }; |3 X
  7. #include <io.h>
    0 g  [0 H5 D4 a. d$ v- r% N% ]

  8. 1 i6 Z) h$ ~* `* f5 ~% Y- y0 h
  9. 8 y) u' ?1 z$ e5 N" d1 d: m4 i. H
  10. int _tmain(int argc, _TCHAR* argv[])4 }1 ]8 {: _' e% z% c( O* L, v9 B
  11. {
    8 G* n3 i  ^! j! O, }, z
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    $ r! x- Y$ c7 j* J0 A  ]7 _3 U
  13. 2 r+ }* M7 R' t
  14.         //查看文件“DekaronServer.exe”是否存在
    ' b3 J* E! T5 h9 E: b
  15.         if(_access("DekaronServer.exe", 0) == -1)# }' z; d/ q+ S7 C# O$ U
  16.         {0 n) n6 j( m# \$ P$ z
  17.                 printf("DekaronServer.exe not found!\n");
    $ O& x& G  x- p: P* M
  18.                 printf("Program will close in 5seconds\n");
    & T, Q: r" D- k  [/ O4 w
  19.                 Sleep(5000);
    ) G3 M2 a3 U5 P" H
  20.         }8 U5 s; O- o4 }
  21.         else
    5 h- n: M# s8 q
  22.         {9 N# V+ p$ D, R9 r) D2 D) [
  23.                
    ' {) ^6 s8 R2 H0 Z* f& O
  24.                 //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* h$ @: K1 s+ b& w9 S2 ~; ^  _
  25.                 STARTUPINFO si;! y, j8 R9 B2 ~

  26. 8 X% A5 X3 j  |5 a
  27.                 //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
    : x: K1 \& r' K/ F1 T' i( b
  28.                 PROCESS_INFORMATION pi;
    1 x3 D! c% A- V, P4 r

  29. * K8 g1 ?: b% i& y1 d
  30.                 //Debug event structure, needed for WaitForDebugEvent and ContinueDebugEvent. More info at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms679308(v=vs.85).aspx3 P+ V7 f6 g2 v" s- n
  31.                 DEBUG_EVENT dbge;) ]2 @& B: X7 G2 [

  32. - B& z  T' f, T
  33.                 //Commandline that will used at CreateProcess
    " t+ G& i1 @7 K& {2 j2 Z: }
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));: C: }! G" D9 s" K/ s- N

  35. 7 \9 [  f# O- H
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    . O$ ?0 Q  k  D5 C1 j& ]/ F
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn), c; j/ N1 G% w! H* {- g
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    + z6 {) V/ Y: n% e) i# @0 O7 I" Z3 n

  39. , h$ L$ m; P2 e) G* H' g9 }8 R

  40. . D8 Q! l/ B: |! ~2 [: k/ l& K
  41. ; Z4 R! O% [/ b+ i# |
  42.                 //Start DekaronServer.exe
    ' ]( P  T  o; h" H/ J
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx6 w3 _: O6 C* t% A$ H6 ~6 U
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)& C5 l& G" }! v& w6 @. g1 W
  45.                         szCmdline,        // Command line" i# |# X; R" Q3 T/ d
  46.                         NULL,           // Process handle not inheritable
    ) @; k5 p/ d' l$ h0 _0 d
  47.                         NULL,           // Thread handle not inheritable" ]8 I& C" d! w0 S) [* C: {0 V
  48.                         FALSE,          // Set handle inheritance to FALSE$ j) x) @/ O( i, c4 D' v8 u8 G
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ) V) q* D5 j9 ?1 v. O8 y5 d6 q7 t
  50.                         NULL,           // Use parent's environment block
    $ @+ ]) X2 [, }* o0 G3 N: J
  51.                         NULL,           // Use parent's starting directory ' x8 w  S  A; v' H% P
  52.                         &si,            // Pointer to STARTUPINFO structure8 q. m2 P2 `$ x8 Z  `6 o
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure4 p2 `) e. p% k% X& |5 G& T  {( e9 s5 E
  54.                 )
    . H0 Y; l  ~: ?: i+ [
  55.                 {
    / I4 U/ m6 Z7 h! p; k" A7 g
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    9 J. k6 e& V( S4 b
  57.                         return 0;
    ( l5 W, P5 l/ A
  58.                 }
    1 d% U3 G5 e& ^* ]- V
  59.                 //Creating Process was sucessful
    . W- N# e9 K0 L! ~; e
  60.                 else, ~2 [0 u& M4 i0 b
  61.                 {
    4 b; k0 X9 x5 Z, Z$ s1 n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");' L" V: u( D0 {% b0 }

  63. ) [$ k; N; ?# l* X1 d. n# q& ~1 I
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    9 l9 Z: V; I  a! R6 T% c1 a
  65.                         dbge.dwProcessId = pi.dwProcessId;
    # }. Y" s  M: ~7 ?1 {2 E  O2 M
  66.                         dbge.dwProcessId = pi.dwThreadId;
    / l  p, Q7 K. I. \

  67. $ u$ m0 e# ?3 j7 @+ E2 I0 g" ]! y
  68.                         while(true) //infinite loop ("Debugger")
    9 {1 b# U$ y1 a8 q% p
  69.                         {' i4 _8 b0 b; W4 B% }9 J4 U  o
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    0 s7 P( {/ y2 g' U" ~
  71. 5 I! w& M0 t+ b
  72.                                 /*3 h4 }% ]! [! _
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
( F/ X0 }, Q) u: m8 Q( f9 z

4 M$ g1 u# c- `" B
" S; |; S; U; v2 M
商业服务端 登录器 网站 出售

13

主题

250

回帖

1226

积分

金牌会员

积分
1226
金钱
783
贡献
175
注册时间
2023-11-10
发表于 2023-12-18 20:34:07 | 显示全部楼层
我是来学习的!

21

主题

378

回帖

1013

积分

高级会员

积分
1013
金钱
445
贡献
169
注册时间
2024-1-20
发表于 2024-1-21 13:37:44 | 显示全部楼层
感谢楼主分享,我是来学习的

0

主题

205

回帖

345

积分

中级会员

积分
345
金钱
136
贡献
4
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

13

主题

250

回帖

1226

积分

金牌会员

积分
1226
金钱
783
贡献
175
注册时间
2023-11-10
发表于 2024-5-25 11:48:57 | 显示全部楼层
每天报道一次!

3

主题

99

回帖

5133

积分

论坛元老

积分
5133
金钱
4912
贡献
119
注册时间
2023-11-15
QQ
发表于 2024-6-5 17:06:28 | 显示全部楼层
学些大神分享,受用了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-28 13:51 , Processed in 0.086706 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表