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

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

[复制链接]

155

主题

344

回帖

5927

积分

管理员

积分
5927
金钱
1848
贡献
3580
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
& x" d, E) m5 c; ~3 s; \
* V" C4 q, }% H# E$ V0 V虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
3 b! Y$ Y+ p, T7 V9 b  C, T% I
3 D; e/ N  I  V) j, }( _7 y
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    ! \/ \: p' ~, T, r6 d" \
  2. /// `) X! W' g! U- a, h7 h* }
  3. 7 E9 U9 U7 I1 g& d$ g5 I1 W
  4. #include "stdafx.h"
    6 a( e4 |3 D) K: X& r* \& O* {
  5. #include <iostream>
    6 I9 f' l9 u0 l) A. K; }- h- V
  6. #include <Windows.h>/ x0 n/ X: G( o: M
  7. #include <io.h>
    0 Y' `3 Z( R/ B; N6 V4 t3 ~+ D
  8. " z$ A6 b0 Y) m; e
  9. 1 x4 s- E6 K! w3 [0 |
  10. int _tmain(int argc, _TCHAR* argv[])
    4 ~+ z+ I& s) \3 C" }
  11. {
    $ s+ C/ T% r% c- R3 k1 f3 k
  12.         printf("Dekaron-Server Launcher by Toasty\n");! |0 V! r$ i" M

  13. 7 ~( p& R5 ]9 D- {  G3 l) m/ r
  14.         //查看文件“DekaronServer.exe”是否存在
    0 N8 Q& I% L, `% O4 |" L1 y
  15.         if(_access("DekaronServer.exe", 0) == -1)
    9 r0 r4 }+ I0 ]0 T0 A& b2 a6 ]
  16.         {6 d( U# k1 `* t* t. I
  17.                 printf("DekaronServer.exe not found!\n");
    6 U  e4 U& U/ v& Y3 `% M
  18.                 printf("Program will close in 5seconds\n");
    " [  s' f' @! I0 S' N* @
  19.                 Sleep(5000);' r" Y9 Q: q" g* L! n# _" i
  20.         }
    : C! l% A( X; Y& t6 y
  21.         else
    * x+ K5 f0 d, p2 l
  22.         {
    ' K' x1 f) n, ~) L
  23.                 * q4 @0 x' T1 t3 Q  Z
  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; a/ I0 t) H0 @1 ?, y! {4 w. z
  25.                 STARTUPINFO si;
    ! M) d5 ~3 \, ?$ Z" R5 F3 L% N

  26. * Q$ t: z# ]; y4 M" h
  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$ g& I2 ]/ u+ x3 n# Y
  28.                 PROCESS_INFORMATION pi;! C$ i- P& g7 ~

  29. 2 y5 `( Y+ _4 b( Z& 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
    - d# c& [" S+ \8 {/ U
  31.                 DEBUG_EVENT dbge;; Y1 q# C6 p- T# \3 z" x

  32. ; P, F# B+ h6 s9 Z: a" u" ]
  33.                 //Commandline that will used at CreateProcess; ^* }' J% }. _& l! y) A0 z3 |
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));  f5 b' _% E6 j+ j: R9 H; f

  35.   Z) P7 a, i. [
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    1 E9 f6 ?1 ?; _; X# X. V2 Z2 Q5 m
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)( C0 D8 q0 N) t4 }$ }# T
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    , x! l3 [2 g( F
  39. 9 F9 \3 o; c' a( v/ Z
  40. + r. V1 p8 C' P/ \

  41. - C; Q* j. K5 p# h
  42.                 //Start DekaronServer.exe   Q6 c0 e9 Q, K8 ~
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx, j+ r  S: d2 A. J9 |
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    0 O+ \5 m8 b3 p/ b! K5 B
  45.                         szCmdline,        // Command line
    - }2 `, L7 Y, f8 f3 }# s
  46.                         NULL,           // Process handle not inheritable2 o+ y8 p' P, u4 M, |" G4 W
  47.                         NULL,           // Thread handle not inheritable; Q" S, {' d9 y' `* M, R6 \- R# r
  48.                         FALSE,          // Set handle inheritance to FALSE
    4 c7 W2 Q% W4 |  a2 X
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ; F3 ~, a/ }6 y7 N1 Z, o. J5 d8 w! r  L3 N
  50.                         NULL,           // Use parent's environment block
    : ?& Y4 k8 f; o. L2 `6 I
  51.                         NULL,           // Use parent's starting directory
    9 X. M& |# c0 ?! ^1 P1 I) ^5 q# X
  52.                         &si,            // Pointer to STARTUPINFO structure
    ! e, ^4 P$ W5 w+ |- A4 m3 U" O
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    . h4 W$ n* M  i. s
  54.                 ) 6 V: w  A& u. S/ A( e. Y! O
  55.                 {
    ) W$ a6 a( S6 G- n
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
      [0 M6 w# v3 L( b/ ^
  57.                         return 0;/ d7 U8 |* d( T  h6 S3 b# Y( Z
  58.                 }
    - Y; R6 t- e- `) t/ w, B% U) ?0 F
  59.                 //Creating Process was sucessful$ w. m# T5 v8 F9 s  x' z" h  h
  60.                 else: q% u4 E) G) E: X' D, Y7 X
  61.                 {# K5 L3 m4 o1 `9 w+ j. ~
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ) l! X+ P! t; u6 z4 n

  63. " p/ D3 i2 c* n$ X- A
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure0 ]0 P) u  }. l
  65.                         dbge.dwProcessId = pi.dwProcessId;, a: Z7 P- Z0 }8 N8 z  {
  66.                         dbge.dwProcessId = pi.dwThreadId;' D) m& k/ k: _
  67. - e3 j( s2 M  }6 i4 D
  68.                         while(true) //infinite loop ("Debugger")
    , r; `8 {1 x1 |1 m2 q
  69.                         {2 u( K0 Y% f5 W7 A' T) w2 Z3 S3 J2 _
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx4 |# g8 I% _0 U& k* T+ D
  71. : y! a- q  a" N
  72.                                 /*
    % q, I9 a+ |% B" m! |0 J/ T# R( ^
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
- y( o6 B$ z! o

" D: i4 o- T8 y" Y2 B+ q, H  r- Z, j& p9 o# J4 s- ?' G, {
商业服务端 登录器 网站 出售

13

主题

251

回帖

1233

积分

金牌会员

积分
1233
金钱
808
贡献
156
注册时间
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

主题

251

回帖

1233

积分

金牌会员

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

3

主题

99

回帖

5613

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-21 14:33 , Processed in 0.077994 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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