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

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

[复制链接]

106

主题

128

回帖

1475

积分

管理员

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

% u* K8 S  H# N) B
* z- b  q# T' T! ^8 Y虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。) ~) Y) i5 P0 {5 q' g0 a7 f

* H" W5 h1 X( X& A
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    4 Y7 ?3 v0 m* C& `* o
  2. //) {; v2 C) X. C" Q$ Q$ z
  3. ) K9 }  U9 S( ~: Y* n, t: W
  4. #include "stdafx.h"- I" u+ `/ b; {8 Z# B+ M. F8 B% |
  5. #include <iostream>
    ) t0 i6 J9 ^4 {0 X2 V
  6. #include <Windows.h>
    0 l$ A7 S$ [1 a& T, P% y. g5 D' k
  7. #include <io.h>' U* R# V, }7 J4 i# r

  8. 1 N, u* U3 L+ K, V7 I& @& \
  9. 0 l2 x  M3 ^9 m! A$ u
  10. int _tmain(int argc, _TCHAR* argv[])% m! |; f& u! O! ]' [. L; I
  11. {
    / I' W$ X7 q1 W& |" l
  12.         printf("Dekaron-Server Launcher by Toasty\n");; L* V+ }6 z6 p3 `: T0 Q

  13. 6 v7 M5 Q0 e3 @, x7 N: |5 p% Q
  14.         //查看文件“DekaronServer.exe”是否存在0 g* a7 r$ o9 C# W, q* L! _9 S1 @" A
  15.         if(_access("DekaronServer.exe", 0) == -1)0 i. K5 ^2 w: n$ B
  16.         {
    ' j, U0 K& J1 g4 Z$ Z
  17.                 printf("DekaronServer.exe not found!\n");
    4 e2 s. f* q- u
  18.                 printf("Program will close in 5seconds\n");
      Y  i" `, J1 c6 a% T# o
  19.                 Sleep(5000);
    0 U1 I( @2 s7 t# J" R: R  f* r
  20.         }. k( ~+ S. M$ q% b- y+ ^
  21.         else. p8 o8 D3 d' t0 O0 A, w. X, S
  22.         {! [3 Y9 ^0 o  P4 g
  23.                 : P2 V1 U- m( w
  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! M' C) l$ ]9 N- g1 @0 l) }
  25.                 STARTUPINFO si;
    5 O1 Y/ Z. d8 b+ n* W

  26. : B/ {; \- F! u6 c8 \4 X& F. I6 T
  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; ~. Z' c2 @; c
  28.                 PROCESS_INFORMATION pi;
    4 e' O& t5 R( V/ U, @

  29. 1 |9 B* y! j/ w0 i( W  o. d7 _2 C( M
  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 U9 m7 Y9 A6 V
  31.                 DEBUG_EVENT dbge;
    * y5 Z) n* X6 [( p

  32. , v, d7 T8 W# s8 H
  33.                 //Commandline that will used at CreateProcess6 S* g: y3 [7 E# i
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    7 _" H' }. O9 z7 R& M1 G% \9 Y

  35. 8 q! o! z. t6 N  L
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)- C$ h1 f. l$ S( j' Q  y4 N2 ?
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    # u! ]1 M9 p- x! i. m! G
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made). R" T& ~  d# v
  39. 6 T( B; t  x, z/ K1 r5 @+ v6 F

  40. 0 _7 W3 h* ^0 E$ n  j- U1 A% j& R
  41. 4 R9 n6 K+ z" i$ l! H/ U
  42.                 //Start DekaronServer.exe 7 Q5 [$ ~. @  S
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
      |3 e+ @5 a$ R' a
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)6 p( s0 S% W' \
  45.                         szCmdline,        // Command line
    # O' x6 z6 ~) Z$ @1 b% a+ r9 }
  46.                         NULL,           // Process handle not inheritable( Q! q3 Z* d7 T9 O0 l5 D: X
  47.                         NULL,           // Thread handle not inheritable% b8 l( _0 G6 Q; {
  48.                         FALSE,          // Set handle inheritance to FALSE
    6 p+ ~$ R/ b8 i; y! m4 ~
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ( W" h' `0 \# r( Q4 u
  50.                         NULL,           // Use parent's environment block
    0 |2 }+ F. \# O0 p& x: L
  51.                         NULL,           // Use parent's starting directory
    & a8 e8 Z7 q" }( C) L
  52.                         &si,            // Pointer to STARTUPINFO structure
    5 W: r( c7 H9 N4 C
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    2 h) m: m% f2 {1 v. E3 r1 ]
  54.                 )
    : v  M, y. p. w$ D  m4 q
  55.                 {
    4 i' N' c) P, F' P/ i  c
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    & L4 Y) K5 f* _- ?4 ]% i
  57.                         return 0;
    & D; C" D1 x! f4 P
  58.                 }$ @$ |+ I3 R; f
  59.                 //Creating Process was sucessful5 O' B! R4 f7 l+ s: n
  60.                 else
    * Z! v) g& E. R. X" O' n
  61.                 {
    6 o# Q6 W. N! f  H- }3 q% M
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    6 D7 l2 T+ R* q

  63. ( B8 K' a& U% o0 M0 F  m6 v
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; H* a3 a! x- L* I4 Z
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / Z" Z1 X5 M" Z' o* }( Y
  66.                         dbge.dwProcessId = pi.dwThreadId;
    - I1 I$ B# G: g3 q

  67.   H; e) K, d' _0 w5 X. F
  68.                         while(true) //infinite loop ("Debugger")& h# c; Z0 ?! ]) t8 O/ U3 o
  69.                         {" r7 H! E% L1 g8 d% T8 O
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx# p8 T6 K: |1 d. C; ?- B
  71. . M9 y1 A, R: s6 D4 [" O
  72.                                 /*
    * V/ P5 u5 q! h8 T/ _% e' [1 b
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
4 j# q$ [' \. r  s- ^) I2 P) p5 L
( d& V- p* r" [* V; c* ]4 a* ^7 }
9 m- L  W( c+ C# {, i& r

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

770

积分

高级会员

积分
770
金钱
284
贡献
90
注册时间
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 01:45 , Processed in 0.116017 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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