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

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

[复制链接]

157

主题

362

回帖

6880

积分

管理员

积分
6880
金钱
1946
贡献
4415
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
7 ^& N/ u/ ^1 h* x' D7 s. ~+ F( @
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
2 F0 M) r) a) z# j6 t) P4 ]7 v, Y( k7 i4 u8 V- J+ [- V5 a
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    % J% m& a% r" l! p" ?
  2. //5 x& `& J  |0 \; |- C
  3. 0 V- P3 P- K5 |3 x7 }# \6 o
  4. #include "stdafx.h"3 V4 E) s4 V( c; n' F, k
  5. #include <iostream>
      E4 \; C0 m6 f( T+ v
  6. #include <Windows.h>- B. T' |# \; W. T6 ~$ `
  7. #include <io.h>& ^! O" U; r* y1 S8 A6 x# U4 ]
  8. : A9 C2 R& W' q7 c8 o) f

  9. ( I& ~' c  e$ H: h, ^" M& Q
  10. int _tmain(int argc, _TCHAR* argv[])
    % o- P* p9 g3 I2 H
  11. {; ^% m, a. b' [: m/ C2 u# A" _) o
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    1 x( d2 _6 u( w" p

  13. - Y4 S/ _+ U' o' i) a, W5 e
  14.         //查看文件“DekaronServer.exe”是否存在1 j8 O' L0 r% V3 J- E* J
  15.         if(_access("DekaronServer.exe", 0) == -1)# m8 y' E! N$ ]1 T! u+ X
  16.         {/ a) ~6 b( F$ D
  17.                 printf("DekaronServer.exe not found!\n");
    5 C% y6 k! y% I/ r
  18.                 printf("Program will close in 5seconds\n");1 k. L; q; e4 k% V7 }- w3 ^! y9 D
  19.                 Sleep(5000);+ g& X- L( R7 r4 n
  20.         }$ D* v4 f, V: {- S) m
  21.         else7 D) f4 J$ {' j* |* |3 g7 Z  Q
  22.         {
    3 v; ~9 l( j& ?, K1 e
  23.                 : {7 t$ ~. q6 C* v8 S4 d
  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: J; H6 i% Q) S7 m+ _
  25.                 STARTUPINFO si;
    + s: v4 ^9 R7 o& ^4 ~7 v
  26. 3 M( K9 S! [" b2 A+ t& D5 Z  E. o4 G
  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
    ) S6 O7 z* |: j( z- M2 z0 U
  28.                 PROCESS_INFORMATION pi;
    1 R8 ^% z; V1 i! q
  29. . L: z4 K4 w$ U1 |" v9 K! y
  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! s2 ~+ R. `/ m: s( d  b
  31.                 DEBUG_EVENT dbge;
    ( E2 N/ Y2 x( S" R6 E1 I1 T5 M
  32. 0 F* U' I# ?$ Z# n5 P
  33.                 //Commandline that will used at CreateProcess
    % ~7 u" x1 u, n+ j
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));; Z! n+ V4 G8 L3 ?
  35. 9 d, M# f9 H' J! \
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    , \0 g* Q. q/ a" e
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    ( y6 w+ g- `4 j% v$ D& q
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made): D! X4 L7 q" i7 r0 _; R3 A

  39. 5 D3 u8 ?$ x6 u/ e' M0 b
  40. ) u0 n0 s0 b& q5 q) r$ ]

  41. : Q. d3 [0 G- F+ o1 z/ c% D& h; ?
  42.                 //Start DekaronServer.exe
    1 r! \) U" [; ^& t0 u7 M# x7 E* K
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    / J$ K- K5 F8 f6 h$ r4 v8 ~
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    # |2 {. [3 }: V3 O8 B
  45.                         szCmdline,        // Command line
    ) f' K$ I; }  a3 A, k
  46.                         NULL,           // Process handle not inheritable7 }# m6 S6 _/ s5 k  I2 W3 b) x
  47.                         NULL,           // Thread handle not inheritable- R7 s. M% c& u
  48.                         FALSE,          // Set handle inheritance to FALSE1 u$ R! T4 v. {0 A& b" U
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx6 v0 U. I" K/ h$ y
  50.                         NULL,           // Use parent's environment block2 ?0 X4 K. v0 {" ]% j
  51.                         NULL,           // Use parent's starting directory % G. C/ m& c- @% F. @2 U
  52.                         &si,            // Pointer to STARTUPINFO structure' [+ L: b4 C# D4 ^; }
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure, e* o" ~! Y( K+ L: I% [
  54.                 )   o9 d9 y, F' n
  55.                 {7 b( q  f+ U3 V* b3 P* B. X: I3 f% g
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );" N  e0 a# l% e% `& f3 }2 w
  57.                         return 0;
    % O' C" D  {2 O; \5 @( G
  58.                 }
    8 X# G: L3 P* k# S& \9 Z
  59.                 //Creating Process was sucessful
    ' Y6 I% v  ?. _4 f$ j8 {) N
  60.                 else% X1 r9 O( Y5 A. a3 _! a; T7 f% T
  61.                 {8 @2 A  {! X7 P! L
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    5 A2 M* W. R0 j" c

  63. ' @- N' \+ S( ^1 @9 q" j
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    : Z, q& A8 f) g8 F( ?4 s6 `
  65.                         dbge.dwProcessId = pi.dwProcessId;+ }% s' u) r# |' e) s$ f
  66.                         dbge.dwProcessId = pi.dwThreadId;! M2 K, |+ G3 ^/ C8 J

  67. 9 ^5 \1 w( E. \
  68.                         while(true) //infinite loop ("Debugger")- T! {4 ?% J4 y: X5 e6 `: ^4 D: A
  69.                         {9 m# `6 r# o0 r  V) J
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    # w( `  j  J3 D4 w, f( q

  71. 1 |3 X1 u5 ]) R
  72.                                 /*: P7 {. x2 r, p2 d8 C+ `* R  g1 K
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
# B. |# \8 j# B/ a, c6 B7 A: e0 _
# \9 r! R/ \$ c+ Z0 j

$ r% E* C& E, o6 X$ w4 a% P
商业服务端 登录器 网站 出售

15

主题

257

回帖

1252

积分

金牌会员

积分
1252
金钱
882
贡献
93
注册时间
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

主题

207

回帖

352

积分

中级会员

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

15

主题

257

回帖

1252

积分

金牌会员

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

3

主题

102

回帖

6646

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-24 06:08 , Processed in 0.062439 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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