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

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

[复制链接]

160

主题

385

回帖

7421

积分

管理员

积分
7421
金钱
2129
贡献
4747
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
# Y, c' E, f6 Y/ v2 u8 b" n  ^( v6 u) f, ^  |. u
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。4 P% j* D& ]6 o% m' E6 p
. T4 d! B7 x2 E( e) l3 m
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。' L" |8 L8 U/ F; ~, h% m2 d
  2. //+ A* {* ]# q. U/ Y5 k

  3. & L" L3 a. r2 C6 g" x; O
  4. #include "stdafx.h"
    ; _, k8 p: C. n5 t
  5. #include <iostream>
    ( m! I- U% G4 U
  6. #include <Windows.h>
    1 l: j8 a9 I- i. [* t: U
  7. #include <io.h>
    7 ?$ j! _4 n& Z4 N( V% `8 o- _
  8. & |4 a3 w+ |8 P3 p3 J: D# P

  9. 7 ?) ~8 q0 ^- L8 }# x
  10. int _tmain(int argc, _TCHAR* argv[])
    ! S( ?+ ]6 G* `+ C
  11. {  U, \& L5 X6 _
  12.         printf("Dekaron-Server Launcher by Toasty\n");3 e' B0 Y& c) ]+ R% h

  13. / v0 e- s! a* a; ~6 @" w
  14.         //查看文件“DekaronServer.exe”是否存在  g: l  [! Q2 m* _9 b  k
  15.         if(_access("DekaronServer.exe", 0) == -1)1 L) l) x6 U3 p5 t1 ?2 }! g
  16.         {) Z! J( i7 k) m. Q* |6 ^
  17.                 printf("DekaronServer.exe not found!\n");
    3 H4 |  p3 a6 z; S
  18.                 printf("Program will close in 5seconds\n");1 g. i5 v( f+ g2 }& C* I. L3 d$ Q
  19.                 Sleep(5000);
    , R3 z8 s6 {3 ]+ S
  20.         }1 s: U0 i3 D0 u  X5 ]8 b6 p& p# o
  21.         else8 v7 A1 l3 S0 a0 B3 K0 ^# B/ p: Z
  22.         {
    - q  W- d# T  D/ e7 o, L
  23.                
    8 `5 \# h& G! Z! u/ D) q7 }) A
  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
    - R; |% S; c/ J  K. {
  25.                 STARTUPINFO si;: Q) J' m- ?. H& |/ g+ V- U

  26. 3 ?" n$ H7 ^: M( b; `5 @% P
  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
    ! x& W  l) Q( w" K
  28.                 PROCESS_INFORMATION pi;/ Z. u" T2 Y1 w/ \4 V
  29. ; N+ \1 n5 C$ I4 B+ w1 z9 d
  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
    & W' Y  H" l  s  t3 p
  31.                 DEBUG_EVENT dbge;
    7 Y  }' R. _2 G% B

  32. " [& l! _5 q1 d# w
  33.                 //Commandline that will used at CreateProcess
    9 H& H* V6 L6 ?% ?) [9 k, X
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));& N' v' P/ O7 U2 K0 R
  35. 9 s( m  X, w( r9 c% Z9 ], g
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    # Z+ ]! I* _! f" p2 X
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)1 L8 D  n/ D0 ]! a$ N9 r4 }9 m. _* k
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made). D2 X! J- m) U) y7 ^

  39. 9 W( h+ u+ n) v* L% Y* e7 ~, `
  40. $ M) g0 X6 U! j1 N  A

  41. 6 O8 V: g1 g2 ~$ z
  42.                 //Start DekaronServer.exe
    $ y8 N2 H2 i) P* B- U
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    8 n6 t  j" R/ p
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)3 u. n( b7 `" M
  45.                         szCmdline,        // Command line* O8 {; l$ T& F7 j
  46.                         NULL,           // Process handle not inheritable
    ( Q4 q/ X0 f$ ^9 L
  47.                         NULL,           // Thread handle not inheritable7 ^4 V! s8 ^1 @8 `7 b5 ~9 k
  48.                         FALSE,          // Set handle inheritance to FALSE, z1 i& R+ Q7 t+ H' Y
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx; E" C5 Y, z' k- u0 K
  50.                         NULL,           // Use parent's environment block( N) |+ y3 @" U3 a# B
  51.                         NULL,           // Use parent's starting directory
    ' o: r5 W; A: {5 _6 a0 q# V" D! R
  52.                         &si,            // Pointer to STARTUPINFO structure9 `; v( t* |5 f) ]- V
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    : j; d/ r/ r8 i" Q$ X% Q& ]
  54.                 ) . _9 U7 o6 j8 k. P" z& s" L
  55.                 {; n/ p$ L3 }) f: x
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    * g1 I  E+ S* \( Z. O4 k
  57.                         return 0;
    . a# N  C; p: ~: c
  58.                 }: L) X" T' f' G3 _7 q
  59.                 //Creating Process was sucessful
    ! H) d; Z3 L3 u: x
  60.                 else4 ^9 M) n9 f: t8 F, \/ h
  61.                 {7 c2 I+ Y' a! S% B: t# [2 G
  62.                         printf("Sucessfully launched DekaronServer.exe\n");3 R6 [& A. S; K2 r5 h6 w
  63. 1 t8 r" Y2 P7 |
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    - ]: w% {9 l! T; o% ^! E1 l- N
  65.                         dbge.dwProcessId = pi.dwProcessId;" m" F, g6 {8 s4 y8 D5 w7 k
  66.                         dbge.dwProcessId = pi.dwThreadId;- b% V2 i+ w1 b+ F7 c2 O
  67. + @& U. O2 U9 g( L
  68.                         while(true) //infinite loop ("Debugger")4 s" b$ M+ W; _5 z# b
  69.                         {0 ~1 u" v- c/ g7 a: P) _6 i6 u+ A1 Z
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx6 W# i$ l9 D! K8 E! l

  71. / E% t5 \2 B3 ]/ K  ^7 J* s  e* c
  72.                                 /*- p, s7 R7 `/ z' Q; B7 I
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
0 D" u) _/ I+ C7 B( w8 n

; s. O  ^& G' t% F; p
# e6 u6 B' y# l6 I
商业服务端 登录器 网站 出售

15

主题

260

回帖

1286

积分

金牌会员

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

回帖

355

积分

中级会员

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

15

主题

260

回帖

1286

积分

金牌会员

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

3

主题

102

回帖

7917

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-1 13:28 , Processed in 0.038725 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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