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

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

[复制链接]

153

主题

335

回帖

5714

积分

管理员

积分
5714
金钱
1807
贡献
3419
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
' N4 s9 c! v5 M; {8 ]& }; \4 d2 G& f/ ~6 S: ?: ]6 w
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。  q) |* B) d; r9 D

  g# Q" g. e1 k$ v7 i* |
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    2 {$ H: q( X7 x0 i+ @; @2 K: C) Q
  2. //
    ; `& e8 T- ^% K0 `; h$ n8 _

  3. ' ^" `: j# \3 F0 t
  4. #include "stdafx.h"& i- m, ?3 y' q' m6 d. p  ~4 p
  5. #include <iostream>& e( p6 Q$ Q+ u* r& w* g
  6. #include <Windows.h>( F$ G( s: G* t+ y
  7. #include <io.h>
    1 p9 _) [5 y  Z4 Q9 b/ l! {
  8. 6 ]- @& e/ b1 {7 X5 n
  9. : D& R! M. `6 V7 V, }- r6 Q& ~  n
  10. int _tmain(int argc, _TCHAR* argv[])
    * F+ V( J4 x( B7 O* ]
  11. {0 h5 T, }( M4 ^- |" ]
  12.         printf("Dekaron-Server Launcher by Toasty\n");; K! x; n+ i- ]% E* `, `+ E# Z5 @
  13. & }: u, X6 ]9 q" W/ z1 v$ i, p2 ?
  14.         //查看文件“DekaronServer.exe”是否存在! f5 Y. l& _# I8 _# x" S
  15.         if(_access("DekaronServer.exe", 0) == -1)# g% I' l* a' K
  16.         {
    $ j3 q; m4 d2 A' K
  17.                 printf("DekaronServer.exe not found!\n");& S2 v0 f6 d4 g' ~
  18.                 printf("Program will close in 5seconds\n");- r& Z7 l3 y7 H+ I. c  \
  19.                 Sleep(5000);. B0 O% R$ v( X* |1 |& y- H: F5 t* G% P
  20.         }
      W; ]% B% S2 d6 ~
  21.         else
    ( @' B- i- [: J
  22.         {% W0 g% o, k' G+ E7 }8 h4 v8 s
  23.                
    2 b4 |+ t0 f" ^3 x3 ~' v' h, F
  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
    + R9 S# a, {2 i( n' |6 \( ?
  25.                 STARTUPINFO si;
    , C! {( [2 C1 `* Z1 [2 P1 W: L

  26. - v0 E$ @# `% d' `) Y" J3 Q
  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
    % D5 [( B" L% N; M% q4 f2 m
  28.                 PROCESS_INFORMATION pi;1 ?0 O) d8 m. q1 O. a

  29. : n3 z, @+ W( r
  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).aspx, y5 P6 t+ e# G- Q3 _( W! T
  31.                 DEBUG_EVENT dbge;# x! Q9 d, h! n  j2 l1 `
  32. % ~* F3 N% |; e/ x- w: _1 b
  33.                 //Commandline that will used at CreateProcess. t* P5 M& o. {) Y, R, z
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));2 P$ R% z9 z9 L4 G( k
  35. 9 ]9 E5 D2 N7 M( p$ v. _$ N6 @
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    2 M2 K8 L5 C  Y
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    3 B, U5 `, C) l4 }# i8 K
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)# ], K; C( `( v/ z& K4 W- F
  39. % M$ `2 D! A6 Q4 X# v9 R) K
  40. , c# ?$ q- y& \$ V
  41. ( w$ t" C- u5 N5 _9 W6 O
  42.                 //Start DekaronServer.exe
    ; W7 Q/ b, a. T2 T# I
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    1 @& K% V, `1 q
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)1 ?) ?$ I" F8 w! }, E5 t
  45.                         szCmdline,        // Command line" B5 I$ W! m4 x; D
  46.                         NULL,           // Process handle not inheritable
    & `/ i' A* a) y  p' Q3 Z
  47.                         NULL,           // Thread handle not inheritable. X: W1 ~- R# j8 L( z% R
  48.                         FALSE,          // Set handle inheritance to FALSE
    3 {2 K- T7 L2 P( V, F
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx3 {, Z" r+ P6 ~3 w8 H5 @% \4 p
  50.                         NULL,           // Use parent's environment block& e5 ~+ w0 ?6 S
  51.                         NULL,           // Use parent's starting directory
    " l! y- i+ O% m( J0 r1 ^
  52.                         &si,            // Pointer to STARTUPINFO structure# g3 s- B2 _! ^: [" w. ?  Q
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
      J, D1 S7 }2 R( {* ^- S
  54.                 )
    3 K" P0 L5 @: n) L: N
  55.                 {
    - i$ G& ^1 U2 `+ g
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    . j# \6 t. f% d) p  s5 r! G$ k
  57.                         return 0;
    * _7 ?( c2 o  }0 a3 h2 E
  58.                 }
    % Y! [& o" n* s: f/ r
  59.                 //Creating Process was sucessful
    ( j9 X% |8 j. g: T* U* ?( T
  60.                 else) d) {4 q- E# y9 ^( t  r
  61.                 {. ^/ p$ n. k2 {1 l- K& o6 `5 ~
  62.                         printf("Sucessfully launched DekaronServer.exe\n");+ D+ m5 |1 I5 e/ z# ?! Y* u4 \( o% ]

  63. $ x' ~  e& K! v0 h! w4 O% |
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure/ l+ R" G3 b" r) B! l6 `9 S9 r
  65.                         dbge.dwProcessId = pi.dwProcessId;) i/ T9 v6 k* _9 w" y" z
  66.                         dbge.dwProcessId = pi.dwThreadId;0 T. W, I' E' V& ^# i0 w

  67. : r" |6 n4 I6 r. p) o( V5 {
  68.                         while(true) //infinite loop ("Debugger")
    , \- Z) e5 ?$ |) l/ G
  69.                         {
    9 B/ B0 E1 }. F0 r9 ^0 e: R9 |- f
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx- S0 _0 j4 u* ^, L
  71. , t! r, A- D2 q7 Z
  72.                                 /*! Y2 o  c) p! a  J+ `
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. s* m2 m, b- o
( L/ y  d# a8 N( E7 T2 u
+ m" z4 E5 E$ J& y$ j8 R  O
商业服务端 登录器 网站 出售

13

主题

250

回帖

1223

积分

金牌会员

积分
1223
金钱
781
贡献
174
注册时间
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

回帖

1223

积分

金牌会员

积分
1223
金钱
781
贡献
174
注册时间
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-27 19:05 , Processed in 0.071448 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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