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

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

[复制链接]

106

主题

128

回帖

1497

积分

管理员

积分
1497
金钱
637
贡献
626
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
5 f) x+ B( M: K" Y5 Z" Y

0 b  k; [6 O; J2 H虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。) r# @4 T3 ?1 `

* W; N. L4 G7 q# d* e
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    . ?  p( h- R( U: o, H; O+ Y' ^
  2. //
    " B- T" U+ I) \

  3. * S, D% J1 B3 s+ B
  4. #include "stdafx.h"
    + E0 O5 e- K& g+ E0 e! a
  5. #include <iostream>/ E! n; j: P( q  ~$ W; E" i5 _
  6. #include <Windows.h>
    6 H, h  T$ ~- F
  7. #include <io.h>
    6 n7 y( X6 ]% ~/ m

  8. # \* ?: t( O9 L
  9. , Z+ Y& [" s) K0 p  M, n7 `) z
  10. int _tmain(int argc, _TCHAR* argv[])* l  B5 O, [) {
  11. {
    ! T  B# S1 V, l4 x8 I/ \, T+ f
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    0 I+ A- {6 o+ {' c# j1 V' t9 O' s' w

  13. ; L% k7 z/ M! q+ R8 m% K8 n/ D
  14.         //查看文件“DekaronServer.exe”是否存在( j+ ]* ?8 h5 Y7 y* _
  15.         if(_access("DekaronServer.exe", 0) == -1)
    - `! f' x) l" J- [: x0 n: Y/ S
  16.         {
    9 Z+ N* h7 @1 D/ k9 h9 T9 Q+ N% Q
  17.                 printf("DekaronServer.exe not found!\n");/ }8 h' `8 J/ r8 t# u3 O# }& N$ q
  18.                 printf("Program will close in 5seconds\n");& ^' ?& T" ?( g$ C6 I. X7 u
  19.                 Sleep(5000);) c9 i5 }$ P2 v! Q  @  R5 C
  20.         }* x  K5 R" F7 z/ t9 w! }8 c# {+ b
  21.         else
    ' i- m, Y9 }% U" Q9 M
  22.         {( P7 u$ S6 }3 X2 X4 ?, x
  23.                 6 M  w8 r! Z  `+ n: e' \! 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).aspx5 h( Q* {8 g$ @& z
  25.                 STARTUPINFO si;- T' A3 q- R7 \" O

  26. 1 g0 E3 C; ]. B3 \' h. Z% o
  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- A- r4 w7 d( O% I. Q4 R
  28.                 PROCESS_INFORMATION pi;
    / U; n2 X. }5 G, U9 N

  29. ( Y/ F/ J- q  }" ?
  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).aspx8 I- Y* x( i) i$ y7 G" ?- C
  31.                 DEBUG_EVENT dbge;2 ^: \/ C& t+ O- V* R
  32. ( E+ Z( p6 q3 `4 ?2 q( Z
  33.                 //Commandline that will used at CreateProcess; k- }9 }3 w' j0 }
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    2 c& K% C: }$ G7 [3 I

  35. + z3 \1 g4 X. B1 a1 f& i
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ( o) }: ]4 c9 i! l  k( _0 w9 }
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    5 e" l7 F# O6 G# Y
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ( D% r( Y4 V/ m6 S, j! G/ @

  39. * D$ e8 _& \/ A' X

  40. # L8 {1 i( T4 n
  41. + O% I2 j3 A/ Y* O/ `/ A5 p  ?
  42.                 //Start DekaronServer.exe
    5 y$ E+ h2 u; w$ h
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx4 H7 |* I' h: l' P% i; ~
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). U$ s& y$ a1 l( x+ i% C4 z2 r
  45.                         szCmdline,        // Command line
    : P' }* q1 X) n  A+ |
  46.                         NULL,           // Process handle not inheritable
    ' l: x" k% n5 z" Q$ ?2 g! h
  47.                         NULL,           // Thread handle not inheritable4 a. ^1 P) H5 N' R9 I8 S$ R+ x
  48.                         FALSE,          // Set handle inheritance to FALSE7 F' Y6 `7 o& U. h5 B2 ]4 i
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    2 Y; Y% Q7 }- v
  50.                         NULL,           // Use parent's environment block
    % k: ]0 j/ X9 C; p# ]9 }8 z
  51.                         NULL,           // Use parent's starting directory % o6 d! {0 m8 Z& j
  52.                         &si,            // Pointer to STARTUPINFO structure; O7 M0 p" h" a0 K* M5 b
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    $ `, B( n7 v# w; @5 I5 F1 L
  54.                 ) 9 w# F9 E* l- F& C( O
  55.                 {
    . V( V5 v9 r  }9 s7 p8 T, i3 J
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );, p# x$ T, R3 x8 U$ i5 H
  57.                         return 0;
    . e- r8 u8 h9 p  K9 ^. `
  58.                 }
    7 ?) x  A' g) d/ ^- b
  59.                 //Creating Process was sucessful) n6 |8 U2 q" w+ a, l* q
  60.                 else9 x7 l. w* ]5 I1 d+ R9 r9 \$ Y2 J
  61.                 {
    9 m4 T8 E: w6 Y+ P( T, m" _2 R
  62.                         printf("Sucessfully launched DekaronServer.exe\n");* S* N! O  m3 E3 h1 N2 D

  63. 2 F9 i. V4 W! f
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    5 O0 i! M( S# j  }4 i
  65.                         dbge.dwProcessId = pi.dwProcessId;) e: V1 a% E- @+ D
  66.                         dbge.dwProcessId = pi.dwThreadId;
    6 Y: m' A6 Y' [
  67. 3 G- {# L+ X$ F6 N
  68.                         while(true) //infinite loop ("Debugger")
    7 n, T+ m6 ]' f- s
  69.                         {
    3 o' ?" w; {0 h9 v/ z
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    9 U) |4 M/ B3 l" e5 B
  71. * ~8 K; @/ ~5 h4 m* V  }2 A; N
  72.                                 /*' Y$ I* [6 w# }1 }& f$ H3 K
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
% z7 Q' Q3 ^5 I( c5 a/ ^$ Y

4 t6 V+ O( w/ o
1 L0 `& L5 Y) J3 x% m, b' i

本帖子中包含更多资源

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

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

8

主题

189

回帖

459

积分

中级会员

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

21

主题

375

回帖

776

积分

高级会员

积分
776
金钱
288
贡献
92
注册时间
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

主题

189

回帖

459

积分

中级会员

积分
459
金钱
250
贡献
7
注册时间
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-19 06:18 , Processed in 0.095592 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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