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

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

[复制链接]

153

主题

333

回帖

5695

积分

管理员

积分
5695
金钱
1795
贡献
3414
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
' Y& l( `; i( x1 K' J! L& i
( @: K- k$ B! `$ U: X' m2 I' [虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。) r7 Q! `# }; @& n
) u' G$ R$ b4 S7 _3 ^) v2 D
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。" d: ~& C1 I5 ?
  2. //) _5 J3 z2 C; _, t: K
  3. 1 W0 I% P. l( [! \6 E2 [4 W+ b
  4. #include "stdafx.h"; ]) d5 Z, ~$ S  C
  5. #include <iostream>
    , o% X: w! q+ z. U4 A7 w
  6. #include <Windows.h>( H' V# [# c3 Z
  7. #include <io.h>. N+ R7 u6 {/ d3 k4 v

  8. 6 h) }( `# X9 C( m

  9. ; C) }: v/ T2 T
  10. int _tmain(int argc, _TCHAR* argv[])
    / w( {! N* t, [7 f
  11. {5 M$ e( X5 K: Z0 T& [
  12.         printf("Dekaron-Server Launcher by Toasty\n");8 {; k* z5 X3 q0 m

  13. 8 s: i; w" [  ?. p
  14.         //查看文件“DekaronServer.exe”是否存在6 U" b# a) s4 H/ c2 y, E7 Y
  15.         if(_access("DekaronServer.exe", 0) == -1)9 F' Z0 N: [/ d: i2 j! S$ M% L
  16.         {6 m" a6 |5 h$ q2 u
  17.                 printf("DekaronServer.exe not found!\n");
    ; f  [% `2 v& ~' X
  18.                 printf("Program will close in 5seconds\n");
    5 ~. @  C0 |9 F' r2 C
  19.                 Sleep(5000);
    1 Q  P8 a" ~4 E/ d, x
  20.         }  M" {: _3 w$ i* W3 |
  21.         else! C6 |; O  ]7 P
  22.         {$ R/ F  T' \% x, Y" c4 G' j
  23.                 ! C- B% g* ?9 {4 O$ K
  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).aspx0 j6 x9 R/ b$ S- K" h
  25.                 STARTUPINFO si;
    0 U6 I3 i6 I; y& Y- n

  26. 9 o% ~2 c9 {6 D6 O- @0 n
  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
    % K# o/ }' [) J9 K8 }9 D3 _6 E
  28.                 PROCESS_INFORMATION pi;: A" |" X. z2 f$ H; d& f

  29. & Y' B  ]. C* Z( D$ G
  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- n6 y; D* a$ _6 D
  31.                 DEBUG_EVENT dbge;  k8 f3 I6 `, l% M
  32. " G) Z8 d! z5 P/ q  m5 X
  33.                 //Commandline that will used at CreateProcess
    $ e/ b1 \; i8 l$ \
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));  R1 Y7 Y: T3 g0 c# j4 @

  35. ; f4 G" }1 r7 I9 m
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    9 f9 w2 O6 V! [7 S
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    & q# `( b( v1 q! t  ~
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    4 y4 t1 `9 l: ?9 d+ K* [

  39. + O$ S5 Q) L# ^& {- {) h
  40. . m; z9 Z# ]8 P1 c" |5 G
  41. ) [) Z- P4 J1 g/ W/ W
  42.                 //Start DekaronServer.exe
    ' [3 w7 ?( Z5 g) F8 Y' [
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx5 W4 T3 r" V7 A% g2 F+ O
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)5 [: ]/ L( Z" _1 X
  45.                         szCmdline,        // Command line, g5 w& F) [0 Y0 y2 O
  46.                         NULL,           // Process handle not inheritable2 s% C+ Y0 S5 W% r$ Z
  47.                         NULL,           // Thread handle not inheritable
    # m1 H" S: L; h: z% g
  48.                         FALSE,          // Set handle inheritance to FALSE. j, g$ f  X7 n' F) B/ c4 R  W5 M/ o
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    3 p  t& A3 _# |- T) x: E2 @
  50.                         NULL,           // Use parent's environment block
    # Q1 `- B0 Q9 \! O' T+ |3 N  ^
  51.                         NULL,           // Use parent's starting directory
    # _5 U- c8 H; b
  52.                         &si,            // Pointer to STARTUPINFO structure
    / _! y0 G6 `* N+ p" V8 ^& S
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure# M# X/ A# q* o0 D" O
  54.                 ) 9 f% x) w8 P( X1 `2 k
  55.                 {
    7 e6 e' F% }! p( ?" q: m+ Y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    & i/ Z, T/ |5 S4 p2 J: F
  57.                         return 0;
    * E7 c! d! S& G: K, Q* n
  58.                 }
    ; ^2 p3 v, ^8 e. U5 i8 f; i
  59.                 //Creating Process was sucessful& U5 k1 H$ x" {
  60.                 else
    : t( P. E5 T! Y- M9 K. v: j
  61.                 {
    " S4 D. b" E, }% u
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    & P2 \: D1 E" S" A
  63. 9 i% F% a$ M. C5 d' L! n! q
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure4 ^' W6 g+ j! }- y( ~
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / W2 r% e+ h1 g6 t3 L  ~' C% u
  66.                         dbge.dwProcessId = pi.dwThreadId;2 M1 y( j! \; J- P
  67. 5 O3 d# W6 U- O0 C9 e9 F
  68.                         while(true) //infinite loop ("Debugger")
    5 L- W( N8 l/ m, u" B
  69.                         {
    . f' P1 P7 S% x( _8 V9 o" `
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx5 r/ p. g' W) Q+ ?

  71. : D5 p1 z. |% [1 w& E% U
  72.                                 /*
    4 n, ]8 s; e, n& [( y  o
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

8 s- v. o7 i( I6 l' F4 d* y
! B9 R: r* v) a4 C$ d/ [6 R+ D/ M& M- C( U
商业服务端 登录器 网站 出售

13

主题

250

回帖

1214

积分

金牌会员

积分
1214
金钱
775
贡献
171
注册时间
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

主题

250

回帖

1214

积分

金牌会员

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

3

主题

98

回帖

4958

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-19 12:09 , Processed in 0.082319 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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