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

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

[复制链接]

106

主题

128

回帖

1466

积分

管理员

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

. t% C2 Z+ d, ]& |) S# f7 H1 j7 l2 n$ s
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。% S6 O8 H2 k4 n( _+ ]* L% N0 _" f
3 ?* W# C1 [: U1 N
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    / X% b4 N& r: v2 a5 ]  P# i
  2. //
    3 I. s& a- V8 t9 J! z' \
  3. ( L# u7 K+ n1 W
  4. #include "stdafx.h"$ @2 l, q- A/ S; m# ~
  5. #include <iostream>5 S6 B: v; x  w
  6. #include <Windows.h>
    3 p$ P  t9 }! O6 _6 B
  7. #include <io.h>
    / e" T7 Z0 w1 ~+ q; n
  8.   W! K1 K4 _6 K$ [0 h1 x; L7 I
  9. $ h4 Y* ]0 O8 y/ \$ [
  10. int _tmain(int argc, _TCHAR* argv[])# Y- T+ H0 V7 x+ y) ]0 x8 l0 r; {: k
  11. {
    / n6 s: G7 f& F6 v& u1 S9 F2 q0 ?2 r
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    & J5 L7 I5 J+ O  E2 h+ ?
  13. 9 x: E5 W6 t( x
  14.         //查看文件“DekaronServer.exe”是否存在
    + q0 h- ?  S- j9 j2 l! p8 F. E
  15.         if(_access("DekaronServer.exe", 0) == -1)) X0 B7 J" }2 \! d# }* f
  16.         {$ ?4 e5 i8 c4 l7 }% N
  17.                 printf("DekaronServer.exe not found!\n");
    ( g% Z% H0 w) \
  18.                 printf("Program will close in 5seconds\n");8 ~5 V5 g5 R% L$ V4 Y/ j! w! x# Q
  19.                 Sleep(5000);7 G5 x) P) N' B6 w, a% _& ~0 g
  20.         }
    1 i9 A% G+ k+ o. b8 g3 A* \4 p
  21.         else
    6 s& J  |3 r8 o+ j! V4 M" V3 Y
  22.         {
    5 H+ Y) D6 s. u- o! A0 Q
  23.                 , V! m2 Q4 B1 z# N8 ]( E
  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).aspx4 P6 B' U7 H' o6 P) v7 R+ Q
  25.                 STARTUPINFO si;' c. n9 u( i/ S. ~  c" k
  26. 5 u- _+ [, s) f; m
  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! P% {5 U9 U# [5 O; x1 s7 g0 Y: Z
  28.                 PROCESS_INFORMATION pi;
    4 j) P+ A+ Y$ @  |; H9 n% `0 S

  29. 2 W- X5 i( r; [9 z; K1 A
  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
    ( Z+ P* e  b  b. I
  31.                 DEBUG_EVENT dbge;* v; E3 X( W/ @6 T/ G! a

  32. - \" l! @" c' Y$ D8 a8 G
  33.                 //Commandline that will used at CreateProcess
    9 R# f# ~- U/ M8 a
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    . S9 v- t* B# X
  35. ) L$ O% t( Y% `. F5 L) f
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    # d6 W/ v' W: i0 o  c
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)+ Q, S9 N. g; q1 h* b
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    0 s( L* o9 \+ j! m8 `( o- K# Z

  39. ' d  N' Y1 Y% U
  40. 4 S. |2 L( w. v# J" _$ x% H3 t1 ^

  41. : m. b2 w& E! Z8 o( h4 D3 ^
  42.                 //Start DekaronServer.exe
    6 w* E5 N/ F; N
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx+ N  ?( Y1 M5 p
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)0 ~. J, \4 c+ F) g7 V
  45.                         szCmdline,        // Command line: [2 C( v+ b5 J% H$ Z- w
  46.                         NULL,           // Process handle not inheritable% J0 f) L8 o  `! Q
  47.                         NULL,           // Thread handle not inheritable  E3 @& @; T* c
  48.                         FALSE,          // Set handle inheritance to FALSE
    ; n" b7 a% }" Y% o" |
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    : a) W) @5 l% c8 c1 d7 N
  50.                         NULL,           // Use parent's environment block7 n: f" e6 f6 Y- P* ~7 u+ H! n
  51.                         NULL,           // Use parent's starting directory ; x2 `' W( R& T- `# q1 o( W
  52.                         &si,            // Pointer to STARTUPINFO structure
    + |# F+ Y5 o7 ~  ]
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure, a! |+ \" w1 B5 H. e' t# t8 J) V
  54.                 ) , W8 {1 o' m: }# a3 t$ D; j
  55.                 {
    5 J5 ~9 t0 v7 [) I# B- _- a
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    1 K+ y3 |7 A2 p
  57.                         return 0;
    3 a, [8 B" i* h" g$ b! n1 A
  58.                 }
    ' T: ^; P( b/ D
  59.                 //Creating Process was sucessful$ b# ^9 N/ `( y( n+ h- _
  60.                 else
      ^3 Y# j; m5 z% N% C* R3 P5 u
  61.                 {
    3 f! P) W# K. V! r
  62.                         printf("Sucessfully launched DekaronServer.exe\n");: h; o7 E- ~' V) ?
  63. ( K0 ~1 e& F( M, A$ [
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure6 D6 }: M- `4 h* |+ t
  65.                         dbge.dwProcessId = pi.dwProcessId;
    6 ]8 j9 C, ?3 Q, G
  66.                         dbge.dwProcessId = pi.dwThreadId;- N' s% @) ~2 r4 k2 W! c

  67. . Q: a; O, q* w2 A6 e& a
  68.                         while(true) //infinite loop ("Debugger")8 m' k9 n  c; D9 _' t
  69.                         {2 `: s3 C; ~, z, g" ]
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx3 K  t% ]) o3 K6 M

  71. 3 V3 w- y& u0 o2 t4 j0 V$ O
  72.                                 /*& g' ]: {  l, v+ |$ n: ]5 W5 w
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
# V% f7 ~8 ]' U7 ?

) n& E! m8 A6 u  n) e3 u/ T. E5 c% {( E) c4 ]4 q

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

755

积分

高级会员

积分
755
金钱
274
贡献
85
注册时间
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
发表于 4 天前 | 显示全部楼层
学些大神分享,受用了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-9 15:21 , Processed in 0.191159 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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