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

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

[复制链接]

106

主题

128

回帖

1497

积分

管理员

积分
1497
金钱
637
贡献
626
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
- d; R3 E- N' X- L- o
' l5 R7 A; u% O" i: ]0 F& M6 d
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
! s4 P- O5 f4 d5 }# W' p+ ]+ E# K' k  L+ v
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    / u' ^6 O+ w4 R, f) S- e
  2. //
    " D" A3 A, s) ^; n% p3 j, i

  3. / Q8 q5 O# ~/ v& I6 {4 j
  4. #include "stdafx.h": G0 ]  i# {2 H
  5. #include <iostream>
    ( Y5 ^2 x" u0 X0 c! w4 p
  6. #include <Windows.h>
    ; K* @0 w1 \0 ?) s+ c3 _5 p
  7. #include <io.h>  `! M8 P6 N. L* T8 z

  8. $ s3 _9 P- y7 e! ~

  9. " q' M* O+ o% {) }# Y, ^
  10. int _tmain(int argc, _TCHAR* argv[])6 Y: W, {% q; N! F+ W
  11. {, k' v2 W( k1 y; T6 H
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    9 f* S% C, X9 l" p& X
  13. ( ?, @# f1 e2 x. x
  14.         //查看文件“DekaronServer.exe”是否存在
    . O, O$ C' @9 \( `- E8 v, m3 T
  15.         if(_access("DekaronServer.exe", 0) == -1)! J  \  a; ~9 i3 z2 z0 [+ U
  16.         {
    6 ^) U0 @0 V  `& i# r/ C
  17.                 printf("DekaronServer.exe not found!\n");
    , V/ e8 I3 V6 h- h; z
  18.                 printf("Program will close in 5seconds\n");
    " h8 U, L5 V$ x5 W# q
  19.                 Sleep(5000);
    $ J- g& U% B: g7 S  z
  20.         }2 b" Y8 N1 z. I, b
  21.         else+ K( p5 f5 [5 T; U) c2 f7 ?
  22.         {% u4 |9 c* }& |7 N, _9 W
  23.                 + T( v2 r3 ~4 x( n7 E
  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).aspx5 `; t' W- |, z6 Q* |" `
  25.                 STARTUPINFO si;
    % q7 q! c6 s$ p( N) |

  26. * H  j" t4 Q( u/ a! d6 F, S
  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
    : K3 K' u* B* X, M- f: V3 j
  28.                 PROCESS_INFORMATION pi;& i  r8 \5 s( l  ~, Y3 U

  29. 5 ^/ ~$ z! F5 r6 ~  m( r  v
  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# n" L6 o, D3 R0 X( Z- b$ S
  31.                 DEBUG_EVENT dbge;9 }/ T) O9 y+ |3 o/ X  s& k
  32. * i% s% L; [- M4 N# {5 _
  33.                 //Commandline that will used at CreateProcess$ ]- J. j& b$ m" x9 D
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( O$ M4 H/ O" J- V# U. H% @1 |
  35.   o: T( T; X# B1 T0 c. ]1 Q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)3 w+ f* T* r, Q0 J2 r& a/ @& ]
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    ; U' x2 B9 y: E0 e6 f  W) E  e/ S
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    & F0 Z. L' B) `6 ]5 O5 R: `4 L
  39. / F+ R" o$ @% ?. _/ @

  40. $ F; @8 r) S* P# L" A. f& b1 S" n
  41. : a: K: s/ w' b1 t$ y) p
  42.                 //Start DekaronServer.exe ' {) {$ }( p# a- z% C
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    8 g  i; v4 ?- l8 X
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)" o2 J  U: G( R- T& S
  45.                         szCmdline,        // Command line4 Z# E- {* r( u) O. I. f
  46.                         NULL,           // Process handle not inheritable. s9 O& F9 W: V; n! }+ V
  47.                         NULL,           // Thread handle not inheritable$ Z/ }4 A% s4 S- M
  48.                         FALSE,          // Set handle inheritance to FALSE
    6 r7 C; ~/ X3 d3 l
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx" T; I' k2 X* s2 p* O
  50.                         NULL,           // Use parent's environment block
    - b2 }8 t" C+ I6 a
  51.                         NULL,           // Use parent's starting directory 5 S% F( C$ k* E4 T
  52.                         &si,            // Pointer to STARTUPINFO structure
      }, Z" e1 m2 @. t. w
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    6 z9 h# ]7 ^$ ?" l' Z3 i
  54.                 ) & P; v# R# l* p  {4 U& O7 Y& q
  55.                 {0 n1 ~9 Z9 a- E9 |5 `* @
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );3 B1 d; Y( K' J. r' E
  57.                         return 0;
    : |5 j9 I! u/ @' U, J" d) z  ^
  58.                 }* o7 C7 Z0 y( M9 z  i
  59.                 //Creating Process was sucessful
    3 V% L+ B  k6 b, C1 y) G
  60.                 else9 P5 n- F: N7 J# z# A1 _( \5 _6 O2 N/ i
  61.                 {) m5 u7 E# m! l9 c; R2 P
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    7 a+ A7 P1 d- g8 X9 D' `! r
  63. # u, l' f# k) D6 L. c3 ]0 c
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure! r+ |# ^8 t9 j1 Y' \
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ( U! W. `& I8 {% a1 h/ I& D& P9 h, Y
  66.                         dbge.dwProcessId = pi.dwThreadId;0 P2 V* u) n9 f
  67. . |6 m& Z, I! g( _+ t
  68.                         while(true) //infinite loop ("Debugger")( M! m' ?6 u3 N7 D* ^& S
  69.                         {# S& I1 E) r5 N# R" P% I
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    . ]' v" E# O6 w3 \. l7 k* E2 l3 x5 z
  71.   i1 l- B/ d: c! G. M$ G. Q2 K
  72.                                 /*
    4 L0 O- \8 u/ j* b. `* F
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
; N8 M7 i: I2 a8 i$ |( G0 I
  f; a/ s$ M# T7 K
7 c: Y2 g: ]6 Y+ g* M$ t: `! f2 J

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
商业服务端 登录器 网站 出售

8

主题

189

回帖

459

积分

中级会员

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

21

主题

375

回帖

776

积分

高级会员

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

0

主题

42

回帖

105

积分

注册会员

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

8

主题

189

回帖

459

积分

中级会员

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

2

主题

51

回帖

156

积分

注册会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-19 05:59 , Processed in 0.075635 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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