找回密码
 立即注册
查看: 814|回复: 4

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

[复制链接]

106

主题

126

回帖

1443

积分

管理员

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

2 p. v/ d  q1 K( @* ]
& {0 R% _3 A) w- a虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。# a6 S. E0 _* k  @- h4 w! ^
5 n* G9 A( q5 M% A
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。/ i& _; M' k* z& \6 E4 ]5 G. S
  2. //$ N% T1 Z+ I$ M% k6 V. d

  3. , b& \/ I# Y: {! o' p1 R
  4. #include "stdafx.h") a' x& W2 y5 c: }' s0 K
  5. #include <iostream>- Q2 E4 o1 M: g0 R6 {( k- A
  6. #include <Windows.h>3 n. B1 p' r. Y7 m  n0 H
  7. #include <io.h>9 I1 u$ u& h) Z, t* T# H
  8. 8 D  C0 g9 ^9 D% l1 K$ N

  9. 9 t+ G4 U6 Y9 B' @. \! t
  10. int _tmain(int argc, _TCHAR* argv[]), D7 {: b  M$ T; m5 |6 j6 v
  11. {
    + I+ k' Y2 R( ], r) c2 y
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    8 ^& c0 w6 P: G! I% Q0 H( q
  13. 3 P, n3 ]* k( ~0 a" ]
  14.         //查看文件“DekaronServer.exe”是否存在: U: |2 M& h: {$ o; g# X: P
  15.         if(_access("DekaronServer.exe", 0) == -1). {- `' B# G6 r3 C2 j, c5 {
  16.         {
    ) H" s! i* f+ t. C
  17.                 printf("DekaronServer.exe not found!\n");9 h; n3 M. E1 H- z
  18.                 printf("Program will close in 5seconds\n");) B/ l* ?% m0 [4 k$ D: Y+ N
  19.                 Sleep(5000);
    4 T; Y2 P* o5 [" Q
  20.         }
    ; }, N9 `) Y  D# w# j. A4 [
  21.         else: `4 x! ^9 g' v" C6 f
  22.         {
    9 h6 A, o4 b5 n) p9 `
  23.                 ( g: g# o- o2 d$ Z8 G# D& k' I, X
  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  I; r4 x  ^- L. J
  25.                 STARTUPINFO si;# S% T, s) s2 ]$ S* r/ V

  26. & p* J* Q, T- @8 h( w
  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& a9 w  m7 U: k. w. A) r
  28.                 PROCESS_INFORMATION pi;2 U' Z$ }9 ]" z% o

  29. 1 T6 v7 ~, n/ d9 ^- u' Z
  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& B# [9 G: X' `% Q3 ]
  31.                 DEBUG_EVENT dbge;
    9 H" \/ a* N; I: |

  32. # F: t0 v. h; j9 P1 h
  33.                 //Commandline that will used at CreateProcess( I+ F3 V. z* {* E
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));4 s, h" M9 t2 E8 @9 v
  35. 5 o* W" q/ ?1 H" [" O
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    7 \. `1 [+ I% ?( V; T
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)( l0 j% f1 t* b4 i3 B6 ~1 X
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)) D  }( U4 z( ^$ o
  39. $ t$ Q3 L$ s  w4 k1 L

  40. 8 L) K9 @$ H" X; y. {! M  @

  41. $ L0 o- Y9 j9 Z" Z
  42.                 //Start DekaronServer.exe ' `6 [) @+ x- H5 C; {
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    0 l  Z  D9 i: O1 E
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)5 s2 t* S* @( v* {9 m2 H' H
  45.                         szCmdline,        // Command line) T8 j* u2 r% g* T3 j5 I4 l
  46.                         NULL,           // Process handle not inheritable+ Y/ \. W+ I* D+ k4 F# F9 U
  47.                         NULL,           // Thread handle not inheritable
    # t# ~7 w: d) [, P9 X" t
  48.                         FALSE,          // Set handle inheritance to FALSE) E; }8 _0 ?# S' f/ @$ Z
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ; M9 i' S" d" m7 Z% ?
  50.                         NULL,           // Use parent's environment block4 {0 F, ?8 _9 J0 u, ?
  51.                         NULL,           // Use parent's starting directory
    : u) e9 I, T% J3 @5 M
  52.                         &si,            // Pointer to STARTUPINFO structure" f: S. d  p# d4 h- d6 s" w* z
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure- w3 q* ?+ {/ P: u3 V; ]4 K
  54.                 ) # E+ C2 p/ ~) ?( U
  55.                 {2 A: {9 O# q( @# J0 i
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );* Z% e# R% C# _
  57.                         return 0;
    - v& `* z  I+ M! E7 f
  58.                 }, K5 R" b6 z  w9 W( b1 k
  59.                 //Creating Process was sucessful" A0 E9 K9 _4 W2 \8 v7 y
  60.                 else
    , a: H, m$ s4 N
  61.                 {
    6 C2 v/ f/ ~& m, m3 L' Z
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
      _* b: Z; A* D9 \2 I8 m$ b& G
  63. 1 u: J. @5 l( I5 J$ J! T
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure$ M0 I: q# [, G! `1 l8 X
  65.                         dbge.dwProcessId = pi.dwProcessId;8 {  V, P, @0 |
  66.                         dbge.dwProcessId = pi.dwThreadId;
    % `1 s1 s* f: l0 U! }
  67. 1 ?; d" J0 ]" N* y3 j
  68.                         while(true) //infinite loop ("Debugger")/ m$ ], X& H9 a7 a9 @
  69.                         {, `' G" e) b8 [; b9 I0 W. s
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx' p# G. z( y, v. q6 p% K3 w# D6 y
  71. 2 K; n" A- x4 c: ]
  72.                                 /*$ {# \+ M$ p! R7 d$ {4 y% R- N
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

1 X  z9 N- g! t$ H6 T/ Q- S9 P6 z+ e9 H/ l- Q7 O% g- C& y
8 y8 f4 ?5 D- Y& Y1 y

本帖子中包含更多资源

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

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

8

主题

188

回帖

447

积分

中级会员

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

21

主题

375

回帖

737

积分

高级会员

积分
737
金钱
262
贡献
79
注册时间
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

回帖

447

积分

中级会员

积分
447
金钱
239
贡献
7
注册时间
2023-11-10
发表于 2024-5-25 11:48:57 | 显示全部楼层
每天报道一次!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-2 04:33 , Processed in 0.178963 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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