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

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

[复制链接]

106

主题

126

回帖

1445

积分

管理员

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

+ x9 U# @) E" ^0 f: H' C( e- D: G& p
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。' A/ ^) G/ h" D& h4 \0 ^2 e

, d, B+ l/ w- N7 R
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。+ j" C6 X) l7 a2 a, L* j0 [
  2. //2 ~' \0 ~0 j- _- d7 L* S4 g

  3. ! B" ]: J2 a) p8 Y- ?/ P0 `* h
  4. #include "stdafx.h"$ M: b8 @3 Z) @3 R4 }& K' q! H
  5. #include <iostream>
    " W7 g% M  Q+ g+ U2 `- r
  6. #include <Windows.h>
    . i$ `) F& L- J  C2 @& P$ i* B& }. {% T
  7. #include <io.h>
    ; `7 S, A. j  _$ H8 j8 W9 e
  8. 7 |* ?0 H' I, n1 _' t; _

  9. 3 L; v/ c; F4 y6 R3 f& ]
  10. int _tmain(int argc, _TCHAR* argv[])/ X. Z3 e' L6 I5 @1 e5 T
  11. {; n9 [! I% y' h
  12.         printf("Dekaron-Server Launcher by Toasty\n");" ^& }/ a* k4 u4 S6 J; H" X  z; L- u
  13. 3 s* L$ a5 J3 _1 q1 I: h; o
  14.         //查看文件“DekaronServer.exe”是否存在7 Y6 f) t( V, N  |, z4 I: A+ K0 Q5 c
  15.         if(_access("DekaronServer.exe", 0) == -1); O% Z0 F3 q- ~. l: w
  16.         {2 I6 g+ k' B! J* g, R# g- [5 P9 y% v
  17.                 printf("DekaronServer.exe not found!\n");
    4 h& S7 ?5 ?0 {3 T2 n+ B
  18.                 printf("Program will close in 5seconds\n");/ d6 ^" g6 F/ V7 y9 z' q
  19.                 Sleep(5000);
    . P) O% X  |# p6 ^. F1 C- W
  20.         }
    $ P8 {1 z) c* u! v) R
  21.         else, C! d6 Z# h1 w1 A# _
  22.         {: o5 Z( X3 A. Z8 g3 D6 v
  23.                
    6 P1 q8 W/ R) s$ V
  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
    + d1 D4 ?, q+ _) M, E* W
  25.                 STARTUPINFO si;. j7 ^: O& a( P. v0 Z! \9 I

  26. " Q; R; a6 s6 Z  |' y3 h5 W
  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).aspx5 `6 w8 H6 \, r; S% F! ~5 |
  28.                 PROCESS_INFORMATION pi;! [! X3 h% y" F7 s" d( E% J6 J

  29. 2 T& g# }: ^7 \9 h
  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
    ( H8 W$ l. U5 E
  31.                 DEBUG_EVENT dbge;
    2 C9 }( @; x+ j: q7 m5 x, Q

  32. ( ?# p% |/ W9 h" e! X' c) A
  33.                 //Commandline that will used at CreateProcess8 j6 n( l4 C4 y) W+ b+ `' s6 T
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));: ?) p# }+ b' W# x
  35. 4 e7 r# N( C2 _1 |8 P$ K. X
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made), f0 o. [: ?/ {5 ^6 T% F
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn): e7 L1 }! p  ^6 L4 h3 b; D
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ' U) }$ s* q# f9 a1 L( [
  39. " d# ]  o- O' `
  40. 6 p$ |3 `0 h1 I, n5 d
  41. 6 C" r6 u% y& N/ a- m3 C
  42.                 //Start DekaronServer.exe ) s3 k: X! m: ~: E
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx# }% }  s& D* @/ I4 P! ?3 y. L
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)! U7 c- t- @# Q, K% m6 [8 m
  45.                         szCmdline,        // Command line
    9 u: ~0 V6 y8 O: K7 S' M! G1 k
  46.                         NULL,           // Process handle not inheritable) m; u" C' t% B
  47.                         NULL,           // Thread handle not inheritable2 g- |* n; I# s  L  l2 p
  48.                         FALSE,          // Set handle inheritance to FALSE+ W! W% G& K& g7 b) l$ c. F+ r
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ( E  ^; }: B$ z& h8 Q9 r
  50.                         NULL,           // Use parent's environment block, q0 g( S$ [: H
  51.                         NULL,           // Use parent's starting directory ' X* S) o& D0 b$ c% K1 `* y( ~
  52.                         &si,            // Pointer to STARTUPINFO structure
    1 ~' O3 U3 V1 G$ o: Z6 o
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure7 W5 {4 v4 i7 R5 b: q: N: f
  54.                 ) 2 w! E% H+ R" `( p3 K
  55.                 {# q( t) {' |1 h" T- i7 a7 [+ ~) \: s
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    & Q: a- w# t+ B& [
  57.                         return 0;# b9 I9 a. e9 A: L% S
  58.                 }% d1 A7 h7 z! n+ R8 U  @
  59.                 //Creating Process was sucessful
    / w- i  ^+ p3 I
  60.                 else
    . T$ J2 X+ }: s' {
  61.                 {
    $ @, h9 S2 s3 Q2 J4 d/ S
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ; f$ D. G( z9 W

  63. 3 U( z( @7 p' ~2 w! o7 l+ O0 F" K" h
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    3 B; O9 k9 @1 f# h. P
  65.                         dbge.dwProcessId = pi.dwProcessId;
    , g3 o/ W( r2 e) y- Y$ I8 }
  66.                         dbge.dwProcessId = pi.dwThreadId;" D: K) d( U; e( f

  67. 7 f4 Z0 B9 X$ v, ?3 G$ V$ Z! a
  68.                         while(true) //infinite loop ("Debugger")
    0 L& Q) D" W! M. i! r/ L5 z
  69.                         {
    ( m! n4 r) {$ q  E9 z
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx8 f$ T7 V8 P: a0 X8 f) P
  71.   q. F  h1 R( ~# r6 d% D
  72.                                 /*7 k& l( g, S1 [& ~/ k  ~0 p- v
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

6 o! h$ {/ g( ~; @4 T. V, e- G0 v3 h! _. y% [& C
, l* }6 Y9 A: ~' A' Y; t  g

本帖子中包含更多资源

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

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

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-2 22:35 , Processed in 0.174365 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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