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

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

[复制链接]

106

主题

126

回帖

1445

积分

管理员

积分
1445
金钱
623
贡献
590
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
1 p& X2 _6 R4 k7 y# d9 C

+ A( {0 Z% Z9 F8 D4 `, B虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。: O, i4 n3 I- n0 q" R) @0 b

' K) G$ N7 i4 ~6 C1 J
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。% _5 d/ E1 I$ b- ~
  2. //; s0 l! t  I6 C: ~

  3. : h. l# _( N2 e+ }3 R+ V
  4. #include "stdafx.h"5 v+ _* H$ v& o# t' Y& U
  5. #include <iostream>! F( T- b. z5 J
  6. #include <Windows.h>% V( D% d8 {, V9 B
  7. #include <io.h>) y5 X4 W  J1 m; F" W

  8. $ I% I5 o4 a( U3 U

  9. 6 _; i. ?0 F8 P2 F8 p# E! y
  10. int _tmain(int argc, _TCHAR* argv[])
    3 L6 Q5 z5 v4 ]. K, O
  11. {9 C1 {' m' p6 o( ]
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    . D' Z# n' d0 t! a
  13. " Y; s: z% h8 N3 [( v
  14.         //查看文件“DekaronServer.exe”是否存在
    * f; j9 a  m- p8 g3 M( y* l/ R
  15.         if(_access("DekaronServer.exe", 0) == -1)
    1 H3 Q1 j# m: }; E" d4 \
  16.         {  Z$ d' P4 F% p7 D1 M
  17.                 printf("DekaronServer.exe not found!\n");" i  W" @) p) v9 T
  18.                 printf("Program will close in 5seconds\n");* h! K, n7 p7 ^$ w" l4 L
  19.                 Sleep(5000);
    6 l8 G8 ?4 b. F9 _& T/ D: P
  20.         }
    & E( }7 w1 L8 U/ _
  21.         else
    & d) g2 d0 E9 w. W( x
  22.         {
      n  N. R' r5 `4 z$ e
  23.                
    2 `3 X5 y2 a' k2 S. V! H- O  |
  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
    1 L. T: M( u# _' S0 D8 A6 J
  25.                 STARTUPINFO si;
    4 q0 k! a, F9 k9 L4 @% g5 @

  26. . y1 y0 y( m" V) J
  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% [" d3 p& C6 L7 g+ ]( x
  28.                 PROCESS_INFORMATION pi;
      N0 p' F1 N6 V
  29. : d& N2 x+ }- N
  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
    ! I! F* q8 X  N0 h
  31.                 DEBUG_EVENT dbge;- |* t% M* A  P' r1 c, u- z; G
  32. % m, w+ v! N! d$ H- Y1 L
  33.                 //Commandline that will used at CreateProcess" b$ g" U4 _6 d4 p* F, R
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));+ {3 ^: j8 M( A9 e; ^9 H! z
  35. - p9 Q" L0 ^$ K4 g& f( b, p" y6 M
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ; t- p/ `4 }7 I% n: A3 r9 t
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn), c& r( M, r; ]$ Z, T+ F
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    2 G7 ^8 a9 E# r9 m1 a; ^! ?
  39. " |9 j6 }- K1 G
  40. 4 L3 U2 I8 J) K$ @- p9 X- Z0 `
  41. % ^8 [' ^' i( z9 _6 A1 J) A/ o
  42.                 //Start DekaronServer.exe
    + k6 v, i0 r1 v/ y+ v- W
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx+ P1 R* K3 u" a5 I) R
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)  J" R# l! d6 Z7 V) w. B" M
  45.                         szCmdline,        // Command line4 {' c6 t  s2 W0 v* b. ~; E
  46.                         NULL,           // Process handle not inheritable
    4 @! g3 H9 _' J8 S4 F8 K
  47.                         NULL,           // Thread handle not inheritable
    ) H! c' @+ D/ D) J. n
  48.                         FALSE,          // Set handle inheritance to FALSE+ J" r$ {5 X+ z( O6 |% R
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx  T8 ?4 ]% G; F2 i
  50.                         NULL,           // Use parent's environment block
    5 V% E- n/ P. E$ n
  51.                         NULL,           // Use parent's starting directory
    1 Y- [. w) c. X9 x$ P
  52.                         &si,            // Pointer to STARTUPINFO structure
    , K4 k+ o+ d7 N, i* x
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    2 W% N/ v/ d+ P: d( v: Z$ K; b
  54.                 ) / E* k9 G+ e3 O
  55.                 {
    : S8 t* z9 N! S2 S
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );: X8 _' J- |; g( ^
  57.                         return 0;
    " N/ ?) u* x+ V
  58.                 }
    & f1 g8 ]' T, K3 C, {2 k% M
  59.                 //Creating Process was sucessful1 ~8 I1 b8 }$ u& D6 l
  60.                 else
    , ~1 ?; M( d  U  U; L5 J
  61.                 {8 O1 J6 Y1 K: K
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    1 Q. m; l. C; R6 V

  63. , O4 J: F9 ]/ y- M* J/ P; ~
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure% `% U4 b8 t3 Q, C2 T
  65.                         dbge.dwProcessId = pi.dwProcessId;8 c6 j6 q1 l- z: M: a
  66.                         dbge.dwProcessId = pi.dwThreadId;, C2 E$ I. o! E% h2 Q, \
  67. / w( c; t3 w4 `% ^% d
  68.                         while(true) //infinite loop ("Debugger"). @! q0 W4 E0 N% A/ O! x% C
  69.                         {  m. ^9 r8 V, L5 N! L
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx9 A( U. a' H2 Q
  71. 6 P2 S& ^# M* o& z+ X# v* j
  72.                                 /*
    1 U) I( ]6 r( H
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
, j9 s, p2 |8 ?, t6 ?+ Y
* w4 ]2 C; U  z) K% m  \& n
4 b! Z$ }! Y; A9 f( Y' [& Q

本帖子中包含更多资源

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

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

8

主题

188

回帖

445

积分

中级会员

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

21

主题

375

回帖

740

积分

高级会员

积分
740
金钱
264
贡献
80
注册时间
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

回帖

445

积分

中级会员

积分
445
金钱
241
贡献
3
注册时间
2023-11-10
发表于 2024-5-25 11:48:57 | 显示全部楼层
每天报道一次!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-3 07:43 , Processed in 0.239421 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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