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

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

[复制链接]

106

主题

128

回帖

1475

积分

管理员

积分
1475
金钱
633
贡献
608
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
; n7 ]" x. l1 P8 E8 T2 b
0 F  h8 ^6 I% _. ?
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
7 [$ ?% |  s. ~# o/ A
) c0 u  K3 S* N; g9 n& e, \
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
      |4 I, i' k9 R. A) Z# n# ]
  2. //
    0 U1 H; w  j5 ^. |7 b

  3. # E8 t* ?. A9 m1 S
  4. #include "stdafx.h"$ Q5 K) G2 ]+ r: k8 _
  5. #include <iostream>
    ' E6 @3 ?- X2 t' J5 u, R( I/ T
  6. #include <Windows.h>
    6 m$ Y! Y7 ~- l6 P
  7. #include <io.h>9 a0 q! L! J! @2 I

  8. ( w3 F+ m' x: p8 Q2 l2 Z  d

  9. , u2 a& z) a% L, h
  10. int _tmain(int argc, _TCHAR* argv[])5 u& Q) [7 ~( f: @9 ]
  11. {
    - b. M2 |% C( t4 F
  12.         printf("Dekaron-Server Launcher by Toasty\n");* u' E! m; C" V  u% [

  13. 3 m" s1 J7 ?0 X7 H6 w& L3 `
  14.         //查看文件“DekaronServer.exe”是否存在' E! \: y- \2 W4 G
  15.         if(_access("DekaronServer.exe", 0) == -1)
    2 ^$ m4 G9 u) A& p. b2 p7 E
  16.         {
    ' s* p' D* G7 y& y& D  Q
  17.                 printf("DekaronServer.exe not found!\n");
    8 v' q, r  |6 j5 C
  18.                 printf("Program will close in 5seconds\n");
    ' X, M3 D2 P; N. H- B
  19.                 Sleep(5000);! I$ q: E( J* z
  20.         }7 `! k1 d" N+ z; l/ v
  21.         else1 H; u: @9 f7 I4 E& _4 {
  22.         {, J6 E) \$ l0 d7 U- j; e8 X" Y
  23.                 2 _$ G* _1 Y$ Q8 \
  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
    ; T# j: b$ P: X2 t+ i9 d
  25.                 STARTUPINFO si;
    % y9 y' _  w. r2 R  R  x0 R2 w- b

  26. . `; y- [$ n. J) [' N% c8 [) a5 Z
  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. Q: T! ]% m# f( C
  28.                 PROCESS_INFORMATION pi;
    2 ]  D- G, d, H

  29. 6 o8 N4 E3 I. F' |* e# n4 g$ {
  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
    0 d" L2 r1 ]$ T$ F/ u- E
  31.                 DEBUG_EVENT dbge;
    $ F( n7 c5 F1 y5 H
  32. * {7 y7 A2 r  A. |+ [  B2 q0 @& K8 v4 T
  33.                 //Commandline that will used at CreateProcess
    4 y2 X& |, {1 }& h' K9 e& H7 q
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( L9 {( A1 ^/ A6 i" h6 N0 J& m& [

  35. 8 L  W% G$ o- j% K0 G) y$ f
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)0 Q0 B8 k; s+ ]7 }$ Z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    7 n6 N9 x: S* ]! i7 X7 I
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    * y7 N( k5 t; O* n
  39. 3 [% t2 W( z  X! x

  40.   b' p3 l' m" Z* X9 f

  41. 8 h$ T& ]$ }0 D5 D/ _( w; @
  42.                 //Start DekaronServer.exe : L  C% z% \. E. ?. A( M* p
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx; d( x$ w) w1 U' c
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)' v; g9 D% [" O  G8 N7 ]* Y
  45.                         szCmdline,        // Command line
    1 I' y5 [) ]9 A+ S* _
  46.                         NULL,           // Process handle not inheritable# ]5 S& i0 s. Y$ s" P) x
  47.                         NULL,           // Thread handle not inheritable- H7 ~8 M1 ?$ K
  48.                         FALSE,          // Set handle inheritance to FALSE
    ' w3 _" i8 G/ g) e/ G4 d9 r
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx) M5 O5 E7 a7 W, N  ^; O% M1 {  n
  50.                         NULL,           // Use parent's environment block
    . M. @& L: G% B& R& ~  j; Y4 a% `
  51.                         NULL,           // Use parent's starting directory
    & x3 W# i' O& `: W* s. Q  w) ~
  52.                         &si,            // Pointer to STARTUPINFO structure
    7 ]. ?2 g6 F, ^# E
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure; u* w/ J! ^& s8 U0 S+ O9 Q7 d7 n
  54.                 )
    $ y8 Y& ~/ S, k% K+ a. _2 ]1 A
  55.                 {+ k) t! Q. Q+ ^6 ^( ?
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
      Q7 Q$ C# f  \) B3 C
  57.                         return 0;
    4 d' K) v5 H1 G: `. w* u
  58.                 }
    3 ?8 J4 p8 c( P9 R0 \0 F
  59.                 //Creating Process was sucessful, B$ n4 Z8 a6 G1 b/ Z
  60.                 else
    ) g1 g! Y3 q* n
  61.                 {/ e! T3 z! B, p8 q' t" q
  62.                         printf("Sucessfully launched DekaronServer.exe\n");1 E# E! Q& {" V' g1 b7 w2 D
  63. + P" a( r1 D9 C' @/ O
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    # _1 M3 u$ v7 J0 a5 i, h2 D% Y
  65.                         dbge.dwProcessId = pi.dwProcessId;
    # W9 u0 ~, f; ~- t) _# r5 N
  66.                         dbge.dwProcessId = pi.dwThreadId;  m" f, V7 L' B* A8 g1 {4 |1 x
  67. ) b6 z+ J5 O8 T" w2 P! o0 \
  68.                         while(true) //infinite loop ("Debugger")
    7 n7 r( U9 p" t9 C9 i
  69.                         {
    0 X5 f9 a  l1 |
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx* j! c4 d  j% _( W; c/ |

  71. ( m; {8 a! K# k1 W+ [* @( e/ ~6 m
  72.                                 /*+ B, \: G/ w! G2 c/ _  A9 l
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

- J2 m  Q+ s! h# |8 |5 Z; `+ l4 J* J/ m: |* ~( j, e3 a) w
) r" [4 y8 c; _

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

773

积分

高级会员

积分
773
金钱
286
贡献
91
注册时间
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

主题

188

回帖

454

积分

中级会员

积分
454
金钱
247
贡献
6
注册时间
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-16 10:26 , Processed in 0.114820 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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