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

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

[复制链接]

155

主题

348

回帖

6155

积分

管理员

积分
6155
金钱
1868
贡献
3784
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 5 a  _. A( V% q4 h  W! U0 x
( P# u0 @+ s& y& \* i4 D
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。, m- D  h! B0 {( u

: X( Q7 H! p1 v& Y. [
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。& u0 t  x0 p) N3 J" x
  2. //4 U; h) N% `# r& T& u
  3. % w0 G7 d" w6 M0 M; |8 b
  4. #include "stdafx.h"
    / p" _6 N2 ^3 t( s1 o
  5. #include <iostream>
    " Q1 C% A, A0 N8 q; s$ T. U9 L
  6. #include <Windows.h>
    ) n' O4 K/ u& w6 A9 F
  7. #include <io.h>
    + u5 W* \' R% `( m0 l5 V
  8. & Q  U/ M7 B" ?1 c3 ?/ M4 K9 {) W

  9.   N( Y& F, ?( M
  10. int _tmain(int argc, _TCHAR* argv[])8 `% \* a. u* N4 ^7 c* l- g
  11. {6 @# w  e6 n7 {
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    5 _) |* z" h/ Q% j

  13. + V- O8 G& k; E- g, {! m
  14.         //查看文件“DekaronServer.exe”是否存在4 f2 Z8 b' d9 \- E0 K
  15.         if(_access("DekaronServer.exe", 0) == -1)7 h$ l3 Q5 A7 f+ L2 N
  16.         {
    5 H+ w$ u* N  g5 }& C% b
  17.                 printf("DekaronServer.exe not found!\n");
    % l4 p2 D2 H. V
  18.                 printf("Program will close in 5seconds\n");3 q6 ~( R9 |6 E2 W8 t4 l
  19.                 Sleep(5000);
    ' s& u  o4 y/ s3 X( F
  20.         }
    * z' L+ X3 f# ^( I5 V
  21.         else
    , N; |- R- N! ]! l! N& Y
  22.         {8 H+ J8 f9 A7 K4 t, H- l3 @( T
  23.                 % u9 l$ N- y. T4 N. k$ E. r7 _
  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; l9 [1 |4 _2 |+ i2 I1 B
  25.                 STARTUPINFO si;
    0 j9 }2 h! B: X8 U3 H- l0 T- i' I

  26. , A8 Z0 ?6 I5 C' ~4 [- w
  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
    4 |9 \4 `1 u  p) X# ^
  28.                 PROCESS_INFORMATION pi;
    / ~/ p0 A- i. ]5 K% f! l# c, t
  29. ) Q9 D! u* g; P
  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! u. w4 o9 ~6 U8 m+ y- D  I
  31.                 DEBUG_EVENT dbge;5 Q: v" w% F, j
  32. 2 I3 m$ Y; N" S: ^0 L3 [. d5 j
  33.                 //Commandline that will used at CreateProcess
    6 D  R$ ?7 f; t) E( i- f
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    5 ]# ^; f- X: B+ a

  35. 5 b+ B& o$ [# Q7 n
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    5 M) ]+ I8 N/ y- A5 R0 _$ v  n. p
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn), V( z3 P1 d- V& r" z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ( W1 R$ H, X# k7 k

  39. 6 V( B- r$ w% S5 ?8 V

  40. - t7 a) W3 Q' O7 C5 F' s9 z
  41. 5 p( A0 G8 b) Q  r9 B6 i
  42.                 //Start DekaronServer.exe . T4 p7 y) d, V" b4 c+ h1 o2 n
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    . W  O8 M5 t6 U1 ^/ {& |$ r- a1 x
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)9 h" q! v0 x* y, Y4 h7 r
  45.                         szCmdline,        // Command line
    ! u' }1 ^0 i0 ?9 i
  46.                         NULL,           // Process handle not inheritable$ K6 u0 h) Q+ G
  47.                         NULL,           // Thread handle not inheritable
    8 d& ]# ^; x* g
  48.                         FALSE,          // Set handle inheritance to FALSE
    & E2 m! O6 f# X
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    # D  I! B4 Z6 g- f
  50.                         NULL,           // Use parent's environment block; M5 ?* h6 h: v) c7 k" [1 `2 l9 C
  51.                         NULL,           // Use parent's starting directory
    * ^/ E2 n1 x/ ~/ y
  52.                         &si,            // Pointer to STARTUPINFO structure. j$ d& v9 B/ h5 m
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure6 r2 `/ A. G  G6 ?$ P
  54.                 ) & M8 D! L! E8 c, L1 S" d
  55.                 {
    9 N8 \2 p# a, A  H5 \
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );* O8 H* ~- p# N  v
  57.                         return 0;
    : P. ~0 F% ?* ~  X; C+ N
  58.                 }
    9 j) H! k& W3 g2 W# U( t/ F& e" M
  59.                 //Creating Process was sucessful
    : u5 y- f& ^- U3 d9 C3 Z
  60.                 else
    - b* C: q! @$ u4 [5 K0 ~
  61.                 {
    0 [9 a, N) _% ^$ I. ?
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
      I3 I! _1 G8 z' Q- ?& b8 _! r7 v
  63. 4 |2 L3 d. X4 o" K  e
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure2 u8 G; m; S( w. N
  65.                         dbge.dwProcessId = pi.dwProcessId;
    # [- K, X- C, D2 S
  66.                         dbge.dwProcessId = pi.dwThreadId;/ \, ], N# m' `

  67.   ~1 O: h1 w' P. X6 `1 L
  68.                         while(true) //infinite loop ("Debugger")# E+ M, w' r( s
  69.                         {" b0 t. M; b0 S2 n6 G0 s9 D
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx0 i. W% J3 o5 Y% o7 Q8 c
  71. 8 r) _6 \1 a6 A: U5 m; R$ s
  72.                                 /*0 M' q8 A: @* F' d- A
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

, c' r! I! p+ c% t: O, ], Q/ f& _% |4 @# B

3 Z1 o4 S3 K9 r
商业服务端 登录器 网站 出售

13

主题

251

回帖

1242

积分

金牌会员

积分
1242
金钱
814
贡献
159
注册时间
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

主题

251

回帖

1242

积分

金牌会员

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

3

主题

100

回帖

5753

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-1 13:43 , Processed in 0.077559 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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