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

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

[复制链接]

156

主题

352

回帖

6247

积分

管理员

积分
6247
金钱
1884
贡献
3855
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) " p- a- h) I, r# m/ H

0 }6 {2 ]7 F( _% h$ Y0 P7 x虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。8 |1 y( Q6 s. s% r8 f3 r
& U% d1 V* ^! ^5 i, j% g! b
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    ) h3 [' ^/ i2 O- Y4 x
  2. //+ o1 @; t& U' Q
  3. : o. b4 m: c( M3 w% o# Z7 f- t3 w: j
  4. #include "stdafx.h"! V" F/ R/ i1 k- Z. O* ]0 U
  5. #include <iostream>* W/ H& g3 c5 O' p* k- ^
  6. #include <Windows.h>* t8 Z; ^* n9 j: P( W
  7. #include <io.h>
    / ~  a5 a) l8 i3 I8 z
  8. % ~! j9 g4 s6 [* C5 w7 m" j
  9. * }9 J2 S0 f9 e7 T* d$ o
  10. int _tmain(int argc, _TCHAR* argv[])8 C( x- j0 }8 D' n  T9 B) m3 [% F
  11. {" ^/ j: z3 p- D$ _3 F/ |" b8 ]6 m
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    0 L9 K0 g: }* W1 z2 s
  13. 6 J, _4 T- r2 _: t1 j! W
  14.         //查看文件“DekaronServer.exe”是否存在9 {: @0 @& \3 o; u( z3 t# f
  15.         if(_access("DekaronServer.exe", 0) == -1)
    2 k6 |) e8 m: E5 x4 w8 J9 @
  16.         {8 |* L. Y. o  f$ @  f
  17.                 printf("DekaronServer.exe not found!\n");# ?; k1 Z  i; a  {
  18.                 printf("Program will close in 5seconds\n");' c2 M6 \0 V! L5 f0 Z
  19.                 Sleep(5000);. `3 `. C2 k# `# \  }" M, ]  E' c. N
  20.         }: f7 J/ W/ s* [5 V& k
  21.         else
    ( b/ K% O  N: r* C6 O" d
  22.         {9 R7 c0 v, `1 |( ^
  23.                
    # C" T- g3 _/ O8 _  v# U
  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( _3 F: \: \( U1 J3 @6 i! p- {7 b
  25.                 STARTUPINFO si;
    6 X/ \3 p% s8 b5 i3 F9 z# w
  26. 3 v/ U- v& L2 v  a1 }; d, |
  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) O  U6 x4 {/ a' o7 ?
  28.                 PROCESS_INFORMATION pi;- y, r& ?+ v8 N. q  W2 X: A
  29. 9 [) _4 g/ X7 @" ~6 k4 `7 a! w
  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
    5 ~5 Y( D6 \8 g/ z* {( F, K
  31.                 DEBUG_EVENT dbge;+ r) p- {+ `7 Q
  32. 5 P) S& y6 a5 ^( ^& @, u: q# x
  33.                 //Commandline that will used at CreateProcess
    - b9 C! Z4 n* q5 p" U1 u) z
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    + K- c. h+ U8 Y) R8 ]

  35. " W# A' [8 y7 A" |8 C$ n% j
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)0 b; ?0 A2 V0 k0 Q  l
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)/ k& P% e5 i0 ~5 J5 z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)8 j# e0 H, k4 r* b$ ?0 ^% i# Z/ B

  39. 6 v6 y& J9 e; a" n
  40. , x3 J9 _2 S; e
  41. # e3 P  Y. {: P
  42.                 //Start DekaronServer.exe 9 p! K6 g: ]" }5 o( q; Z$ [9 k) n& m
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    4 g' L. z, F" M1 k- M0 D
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)! x# r7 v$ g" L2 z" ~6 c
  45.                         szCmdline,        // Command line: i' g7 r6 E: h) c" I) t9 O* A
  46.                         NULL,           // Process handle not inheritable
    ( k' a6 M* i  `" k
  47.                         NULL,           // Thread handle not inheritable
    9 W7 N# v& ^% }% N" ^! K1 I
  48.                         FALSE,          // Set handle inheritance to FALSE5 q- ~! T2 T6 T2 h
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx1 [$ E2 C& i6 @& i
  50.                         NULL,           // Use parent's environment block; V  O  L: D% V2 z* Z# B8 Y- S
  51.                         NULL,           // Use parent's starting directory
    " [% o; [( h5 V! A( Q& x( y
  52.                         &si,            // Pointer to STARTUPINFO structure7 c4 [# [% `% Y% F" s) B
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure  {+ Q3 f; Q' E- @( a4 J7 r. p9 @
  54.                 )
    . U* e+ f. j$ f7 m4 n9 ^& ?
  55.                 {- s/ P3 s2 w" Y+ v3 o
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    4 j4 R' X4 c' @! w& U; g
  57.                         return 0;* x0 m9 u- F/ l- P8 L
  58.                 }9 x5 z: X; C1 }# z
  59.                 //Creating Process was sucessful
    : a) G2 C2 W8 J7 j# v8 j) y
  60.                 else6 ]* m0 k6 e; A
  61.                 {! \  d. E- d. q7 S( e% ]
  62.                         printf("Sucessfully launched DekaronServer.exe\n");/ f; a+ F( u- r- a+ W# e
  63. # U* d' F# Z8 g' e
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure5 H7 g3 M! \* @* M- I1 ^
  65.                         dbge.dwProcessId = pi.dwProcessId;& G5 t% d" K' X  Z# p: }9 J
  66.                         dbge.dwProcessId = pi.dwThreadId;$ _# `- O6 m! L; J* S" p$ d
  67. / S, {) Z7 Q6 Q6 W
  68.                         while(true) //infinite loop ("Debugger")
    3 f( n- l8 v( x; Z
  69.                         {/ I) U+ `) s5 R* G: u  w! n; P
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    + [, E7 Z3 `; q& ~' p3 ^9 O0 e" D
  71. 3 }6 H1 j% A! e" p
  72.                                 /*; R' z- v. v6 t* F
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. G9 `8 v) n/ J( L" y$ a$ a  Z
& k7 ^6 A) S. C6 |1 X
9 G# |1 {" X6 x, x# l. |  d) I- {
商业服务端 登录器 网站 出售

13

主题

252

回帖

1258

积分

金牌会员

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

21

主题

378

回帖

1013

积分

高级会员

积分
1013
金钱
445
贡献
169
注册时间
2024-1-20
发表于 2024-1-21 13:37:44 | 显示全部楼层
感谢楼主分享,我是来学习的

0

主题

205

回帖

345

积分

中级会员

积分
345
金钱
136
贡献
4
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

13

主题

252

回帖

1258

积分

金牌会员

积分
1258
金钱
831
贡献
157
注册时间
2023-11-10
发表于 2024-5-25 11:48:57 | 显示全部楼层
每天报道一次!

3

主题

102

回帖

5943

积分

论坛元老

积分
5943
金钱
5808
贡献
30
注册时间
2023-11-15
QQ
发表于 2024-6-5 17:06:28 | 显示全部楼层
学些大神分享,受用了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-14 06:08 , Processed in 0.070651 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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