找回密码
 立即注册
查看: 807|回复: 4

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

[复制链接]

106

主题

126

回帖

1443

积分

管理员

积分
1443
金钱
623
贡献
588
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式

! |$ f  P9 s9 m5 O1 H( R4 Z4 Y, v4 m5 g, V  B3 p2 |  f9 A& K
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
5 w: W* y/ x& y3 o0 @/ ]! U0 I! K' W+ M" F1 c
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    . A( F7 k3 f/ F- Y' E5 f- d
  2. /// F! K2 V5 N, Q9 ]5 h" y; Z: J- m

  3. $ N- m/ E6 x. f; K1 @% H
  4. #include "stdafx.h"" \, j/ d& C8 V. h$ L# [+ y7 ]: V3 ^
  5. #include <iostream>1 [: V7 O0 s/ C- k) h5 Y0 p: h7 d
  6. #include <Windows.h>" W8 S! \  C  _  |& F8 A
  7. #include <io.h>+ ~2 D' g& E+ @- x
  8. $ |0 |" E0 t  A, M7 h0 C* z) o4 k& v1 \
  9.   T" o+ H9 H) |3 z, G. \* i
  10. int _tmain(int argc, _TCHAR* argv[])
    3 E' v3 v* g3 L$ z0 }; U, F
  11. {5 B; C4 e. N3 E6 D+ E) t4 @
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    & J/ U8 ?( d% \% q: t! B
  13. 8 e! j* Y+ T$ d/ x6 T2 K
  14.         //查看文件“DekaronServer.exe”是否存在
    ; I: H$ B# M; V7 J. T  a9 i. ^
  15.         if(_access("DekaronServer.exe", 0) == -1)
    9 |! |; l+ ?6 K
  16.         {$ H) ?1 @! k( U5 K1 j3 ^
  17.                 printf("DekaronServer.exe not found!\n");
    6 J. y! n! g6 }- \
  18.                 printf("Program will close in 5seconds\n");) y( J2 V. _  L$ D* P! N
  19.                 Sleep(5000);
    9 S3 K! w: ~& j, [8 U
  20.         }- L  B2 u) ?. \! m0 k/ _
  21.         else
    , U0 S: G' e5 `8 X
  22.         {
    7 I. m6 f) v/ S# `, _! S* c
  23.                
    7 l% a+ ]1 d# m. H4 E3 a! X3 m
  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).aspx6 g" V, q5 s4 \
  25.                 STARTUPINFO si;: y4 S7 i6 X0 D2 {. T8 O

  26. ) ~2 w5 W- r* I0 u
  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
    8 g" _+ P) n; ~' K: q
  28.                 PROCESS_INFORMATION pi;
    5 w: ^( M" r+ L% H# V
  29. 0 q' X1 \# n9 Q" @7 @
  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, c+ n+ F* J4 u
  31.                 DEBUG_EVENT dbge;, w6 ^  s0 F; r/ S

  32. % q8 ?- ]. ?9 x- Q: q5 i) o* o7 u
  33.                 //Commandline that will used at CreateProcess
    + v6 l2 H, X. P* J/ P
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));7 l2 ~; E8 [* \: Q- ^. I
  35. 6 h8 X, `' P8 @6 d& L
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)8 Q# z6 U+ o* W8 ^5 g( j* t
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)0 }% t" H; _4 {2 R9 r5 v0 s  H8 F
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)! `) ?" w7 k% D8 I1 E' |
  39. 1 s! H9 j2 F  s* S

  40. ; w2 s5 @) B2 t  r. }
  41. 9 O' q+ }/ M# N! x
  42.                 //Start DekaronServer.exe
    0 \5 k" m$ g' t8 J+ q5 |
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx7 M: C& y4 K* P* O! K
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    : j9 m4 z9 A) |' Y6 y: w$ f- A
  45.                         szCmdline,        // Command line
    + b/ d, _8 X* ]  e  U& H# c7 b5 Z
  46.                         NULL,           // Process handle not inheritable
    0 G8 P3 g1 ^4 t: e4 s
  47.                         NULL,           // Thread handle not inheritable
    " d- Q0 Q% V2 Z2 w3 K7 Q' y; \$ W0 N+ s
  48.                         FALSE,          // Set handle inheritance to FALSE+ \0 l, D( m/ y# i' z/ l' D
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx6 P5 ^, n1 O; Y/ i% T. [
  50.                         NULL,           // Use parent's environment block
    4 V6 P$ v7 z5 z' |
  51.                         NULL,           // Use parent's starting directory
    6 P  g1 V7 T. b) |4 T
  52.                         &si,            // Pointer to STARTUPINFO structure( L' n& H* x4 r+ a
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure* v4 c4 k: T7 I- W0 g
  54.                 ) 1 K+ X4 L- R( c6 Z$ ]0 r, S; i
  55.                 {
    + F, w/ c. S& E- L8 t' T
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    % t6 U5 R' N6 m! Y
  57.                         return 0;1 w+ l7 M* ]9 P0 @
  58.                 }  b9 X( m. p6 k$ _- M2 d
  59.                 //Creating Process was sucessful
    3 [- V% e; F0 V. A9 v
  60.                 else
    ' n' a( r; f( J* p& Q7 q
  61.                 {+ h' v# n4 L, Q( n3 P! N
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    1 ^8 p/ Y3 z/ W

  63. - _' w/ \5 L! |( h. y
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    & s/ F& m- x* U$ b; k; j
  65.                         dbge.dwProcessId = pi.dwProcessId;& J5 n% d$ ?- l0 A7 b# l6 v9 r
  66.                         dbge.dwProcessId = pi.dwThreadId;
      V; D1 \; i3 Q# {

  67. ' p; F/ U( O5 x# l: `% j
  68.                         while(true) //infinite loop ("Debugger")! i' }- t. u" x7 I5 h* P( m
  69.                         {, N' C" ^3 G7 x/ Q* y
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    7 h% w( z5 b3 K! O2 }8 X: J. z

  71. . U: t3 o% N2 I  m
  72.                                 /*
    : {/ v! t+ o# S" B
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
  m6 f& `2 l; i% h
9 W6 a; w# w! _+ x4 j$ {, V* X" }

. c$ a& \. n$ B' C

本帖子中包含更多资源

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

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

8

主题

188

回帖

447

积分

中级会员

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

21

主题

375

回帖

737

积分

高级会员

积分
737
金钱
262
贡献
79
注册时间
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

回帖

447

积分

中级会员

积分
447
金钱
239
贡献
7
注册时间
2023-11-10
发表于 7 天前 | 显示全部楼层
每天报道一次!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-1 17:54 , Processed in 0.196996 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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