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

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

[复制链接]

157

主题

360

回帖

6652

积分

管理员

积分
6652
金钱
1928
贡献
4207
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
$ C" R' E0 g5 Z3 j4 v
" U$ I1 W6 O) N( [( x! v虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
- \8 `$ O1 ^* Z
6 J  \2 v  c% ~" o" y- B+ X$ e
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。, A3 e2 G/ b6 V7 U4 V" z$ K
  2. //
    / ?, H" g1 e* k4 G# B
  3. ; {; L3 a$ \3 d/ }2 X% B! j
  4. #include "stdafx.h"
    # A( Z) v( U3 m  v
  5. #include <iostream>1 `" ^# D' f# u% c3 K& g% F
  6. #include <Windows.h>0 U' C5 l8 p/ S) f; G' X' h
  7. #include <io.h>
    + K7 f8 e' s* {3 ]# C! k+ l5 _9 @7 {
  8. 2 L% S  z9 \1 b2 ~  b

  9. * [- ?/ a3 b$ Q2 D
  10. int _tmain(int argc, _TCHAR* argv[])1 x- ]" i9 ^" Q1 Q
  11. {9 f7 O' u2 B2 s
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    : k- o# R1 i' K( t

  13. 7 G+ ?" D) f9 \9 j" D" l7 S9 N
  14.         //查看文件“DekaronServer.exe”是否存在1 X9 v" ~: u7 W  [3 ~
  15.         if(_access("DekaronServer.exe", 0) == -1)4 I7 ~$ Z0 Z1 H' ?& q/ n
  16.         {
    ' l2 h8 g  N2 U
  17.                 printf("DekaronServer.exe not found!\n");
    ; l2 ^+ o" A  H
  18.                 printf("Program will close in 5seconds\n");+ \0 E4 E. D3 V% x  W
  19.                 Sleep(5000);2 R$ Y: `  A+ f7 ~: N
  20.         }
    / D/ O- w) o5 Y+ r
  21.         else
    4 {0 t. s  L* O+ J. r1 J& j
  22.         {
    # c1 ]7 ^2 u, m4 u6 G
  23.                
    0 C; C; z5 d* R( a+ c4 R# O' r
  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
    4 p" ~' F% Z0 \5 W, ^
  25.                 STARTUPINFO si;
    ; d. B  S" s5 p, W

  26. 3 t$ B+ T( U" l! K3 D9 e
  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
    , X8 M* ~' J6 p7 S2 P
  28.                 PROCESS_INFORMATION pi;
    7 ]0 T7 c: j( k- y+ }

  29. 3 @- W; q& @  T# s  t
  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: i1 ^4 v/ M6 F4 d* |
  31.                 DEBUG_EVENT dbge;
    ; {. y$ K+ O" l- i9 y9 L

  32. 9 K* u# g0 H+ v" ?) z/ P+ O
  33.                 //Commandline that will used at CreateProcess
    + x5 }5 |7 p" Q* B( M! o- N
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));9 d$ Y+ a/ J/ I' j. F
  35. * Y3 q+ L1 y9 F) H6 B
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)2 V' k/ W2 C5 p- {& g; E
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    $ I2 Q* n- U) [2 M8 |
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ; E9 m+ o0 F+ o

  39. % l/ t% F6 u: P  o
  40. ; @9 s& K: a, U# e: A' i; R! \

  41. / c) D( X3 }0 y1 ^# F
  42.                 //Start DekaronServer.exe
    ( n8 @( ~+ \4 e. U4 F1 {& l$ C
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    1 m, T' n3 \% X2 y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)& J8 x2 x' d. I3 P: L* H) p/ a
  45.                         szCmdline,        // Command line
    6 ]! ~* T! F9 z9 P. N- X, e# y
  46.                         NULL,           // Process handle not inheritable
    : t. V2 }6 r' }; j
  47.                         NULL,           // Thread handle not inheritable- a6 w+ K5 [+ x: V& U, p! M$ A
  48.                         FALSE,          // Set handle inheritance to FALSE  P! O8 o/ J1 G/ F
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx. J! j3 Z. f% ^
  50.                         NULL,           // Use parent's environment block# ~0 [1 r3 b5 `/ {
  51.                         NULL,           // Use parent's starting directory
    9 G2 s2 ~# i+ F( I, |" |) p
  52.                         &si,            // Pointer to STARTUPINFO structure
    + e* Y) m4 J1 w- |% m) _. @
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure* n  Y# C9 `" Y1 N
  54.                 )
    9 p. {! G9 q6 F+ s3 S3 G
  55.                 {
    ) e# l; x8 z- b% \  c1 R( [
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );3 i5 p% V1 t" X8 h" v, h
  57.                         return 0;# ]: g+ G" D# w* b+ p! y4 I( |
  58.                 }
    " Y) ?# T& g% Q6 Z4 Z8 f' d( N$ y
  59.                 //Creating Process was sucessful
    2 Z- A8 b: S6 Y0 [& F
  60.                 else
    # d( y1 ]7 z! |8 \# B
  61.                 {
    2 Q+ b9 G3 d4 Q6 _( g
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    , N. x) u# E9 r& a5 f3 h

  63. 5 \. d4 S0 W& I; z+ M
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure& ]  u( W$ `+ A& I& Z& E2 h
  65.                         dbge.dwProcessId = pi.dwProcessId;! n" o! P/ E" x
  66.                         dbge.dwProcessId = pi.dwThreadId;
    * ~: w3 ^9 w6 P* e7 [! B' a
  67. * M5 ~7 s' K/ M0 E: {
  68.                         while(true) //infinite loop ("Debugger")
    / S& N7 h  N2 D
  69.                         {! l. o, p2 Q4 T) |5 L! A
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx9 o6 J' I. p6 M
  71. 0 C2 `  G! M/ N* y! a5 f9 R
  72.                                 /*
    6 z( p9 i7 S0 L
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

5 a! Q: }9 z0 z' h" t8 d3 r& C; F) G6 c, X8 M$ ~2 t

% b+ U- k2 O, c2 j( A7 g) ^9 z
商业服务端 登录器 网站 出售

15

主题

256

回帖

1259

积分

金牌会员

积分
1259
金钱
865
贡献
118
注册时间
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

主题

256

回帖

1259

积分

金牌会员

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

3

主题

102

回帖

6321

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-5 04:38 , Processed in 0.275110 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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