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

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

[复制链接]

166

主题

426

回帖

8149

积分

管理员

积分
8149
金钱
2380
贡献
5177
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
" U$ U) R, v7 W' X3 Z- R: o& z. W1 R8 |1 T7 J" \
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
$ f5 q* h* K, m/ S* h2 ^4 Z$ T3 s& A9 [' N0 i
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    % ]6 m- ~; Z; }* q2 h
  2. //
    8 {' e8 F' A2 ?, p" t

  3. " X- p) Y1 O9 h
  4. #include "stdafx.h"
    . @, Z. u+ K! f4 [
  5. #include <iostream>: W* q, s4 o! |- ]
  6. #include <Windows.h>3 g9 f$ g4 x, d3 X! J, _/ v
  7. #include <io.h>
    6 L' ?6 a- A$ j8 E/ h

  8. : Y) _- q: g4 K8 r& C

  9. 4 t+ n( _9 y. ?% |( }
  10. int _tmain(int argc, _TCHAR* argv[])1 Y$ T+ h/ F6 j. N
  11. {
    1 @2 i: ]/ t1 c; t0 F4 w
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ; T. `$ ~0 d2 w0 \$ J1 M! i& v+ E- J
  13. 7 E  |0 V% C7 E' A2 H
  14.         //查看文件“DekaronServer.exe”是否存在* Z3 e( ?% ]4 p/ Q, }, ~5 F
  15.         if(_access("DekaronServer.exe", 0) == -1)8 Y" g# a( ?9 Y6 N) w6 v
  16.         {6 m( [/ r$ N1 r  Z; M
  17.                 printf("DekaronServer.exe not found!\n");
    & A9 U: X3 ^9 i  b& k' ^; E
  18.                 printf("Program will close in 5seconds\n");
    - A2 P+ Q9 n' o: V2 A
  19.                 Sleep(5000);
    : s4 U8 F* x! t% e1 y2 D' z
  20.         }
    ( E/ Y; Z- }) Z1 D; R1 V5 s& {0 ?5 y
  21.         else
    " h# f( H: ?8 C0 I; r! J- }3 P- d& C
  22.         {# g7 A! k# {" `" k8 V0 H0 n
  23.                 $ ^. @% B0 n9 F
  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
    ) M- h# D9 G! Q# B- x
  25.                 STARTUPINFO si;
    + t3 t* D( G4 L5 u
  26. 6 _+ t$ E* }! g- 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
    ; `0 v1 @* l2 s! G
  28.                 PROCESS_INFORMATION pi;4 Z5 W9 u4 S5 @+ o" r

  29. ( n- L/ }% ?. ~& L
  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
    ) P$ U# G; R# L& ?
  31.                 DEBUG_EVENT dbge;
    , q9 D! h& V! v& s4 \5 ^; T

  32. 1 a' Y* q. `9 V$ Z
  33.                 //Commandline that will used at CreateProcess8 b5 v. M& \6 A2 G, ?5 l0 J- W: a
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    9 B3 E6 [1 p! c- n' R$ Z+ Z
  35. % J7 J8 q" D1 ]  d, J2 e# K
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)5 g. R. J4 V: a! s" r5 s
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    # s7 f: r- ~% r
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made). t9 n0 h, G- N

  39. 8 m5 e, C% i# C$ _, H+ G! f6 L

  40. % v$ e, b8 F& _  ?

  41. 9 W( S0 f: H- T4 e, }* \+ E
  42.                 //Start DekaronServer.exe
    5 K8 A+ e) t) K0 S' h
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx3 ~% k+ P& E6 z0 u
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    - m  t* B+ ]3 m8 n- ?, y
  45.                         szCmdline,        // Command line
    . s( N7 f) \% {% E& k) c1 T
  46.                         NULL,           // Process handle not inheritable( v2 F# \- P( M- g3 S" m$ S
  47.                         NULL,           // Thread handle not inheritable
    * E  A5 ^% c# S: F; B% i1 G
  48.                         FALSE,          // Set handle inheritance to FALSE* v9 ?1 S! g% E  [$ q
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    + [% K- [# ?8 B  }2 I' V! ?
  50.                         NULL,           // Use parent's environment block
    & {% A6 B/ Z: J* ~) _7 O4 z9 v
  51.                         NULL,           // Use parent's starting directory
    ; @' C: `0 M( L" j& p- F. a* ]# S
  52.                         &si,            // Pointer to STARTUPINFO structure: F0 `+ M. v" {: H1 D
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ! p+ c3 q' s/ D- H2 g
  54.                 )
    , O: Y0 r! q, A4 u; }0 [5 G& \
  55.                 {* B; B9 x4 E& G* S& M
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    ! Z' @- ~3 n! Q$ m: C) B6 t
  57.                         return 0;$ t  ~3 i6 c* Z4 _& }' p% m
  58.                 }
    * ~! q/ x6 \2 R5 w
  59.                 //Creating Process was sucessful
    * F' o# N- Z; c* O" k$ e* n, @: B3 \
  60.                 else4 u8 e4 a$ Q8 T$ D! h! R
  61.                 {
    3 W, c4 K! X9 R) R" L* W2 m
  62.                         printf("Sucessfully launched DekaronServer.exe\n");& M; n1 I' p# h1 K8 _, k7 q
  63. " ?! N% P! V3 y4 V9 K
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure3 g& [6 u' c4 v1 ~
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ; Y0 A2 A) ^5 Q7 I+ p% f$ Z
  66.                         dbge.dwProcessId = pi.dwThreadId;
    8 ]; A* V/ q  u; H6 Y; d  H6 w! I

  67. 9 ^. b7 M. ?2 K% J2 f7 ^3 t
  68.                         while(true) //infinite loop ("Debugger")& s; }0 g3 R! l4 |7 V
  69.                         {$ s9 g* E$ d4 p/ I! l- ]- N
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    # `! u* d  s$ k$ m5 x- g0 W% a9 n

  71. 6 z& Y' c$ I0 a
  72.                                 /*8 t. q) i; @, }9 R( x
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
( I! S* i+ r' m6 N' ?

( i2 l4 [; W  F2 ~# o6 b9 ^9 \
商业服务端 登录器 网站 出售

16

主题

268

回帖

1484

积分

金牌会员

积分
1484
金钱
1081
贡献
114
注册时间
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

主题

211

回帖

365

积分

中级会员

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

16

主题

268

回帖

1484

积分

金牌会员

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

3

主题

103

回帖

9323

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-10-3 12:49 , Processed in 0.052825 second(s), 30 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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