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

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

[复制链接]

152

主题

325

回帖

5593

积分

管理员

积分
5593
金钱
1773
贡献
3343
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
; ~$ S: I7 {: N, N& Z5 z' u& ?/ [& r
4 L4 _! h0 g' C2 D! ]  @虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。% \3 ?/ w; V& }  e

4 g9 ?# W2 i; ~+ H
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    - N! F; m7 L9 h6 T4 g; s
  2. //& b# \" x7 j* v" O4 c* O
  3. " R8 m; [6 W% N1 x+ K1 b
  4. #include "stdafx.h"
    & g5 `' i6 d4 l0 @  c' e
  5. #include <iostream>, j: V0 {% e$ w* q9 g" f  [9 ?
  6. #include <Windows.h>. A& o$ W# \1 w: e/ w
  7. #include <io.h>/ `+ J6 o) a$ T/ F; I
  8. 9 q) f# M$ i. T( D* l1 v+ p8 w
  9. , _; u7 z! c3 K0 u# V
  10. int _tmain(int argc, _TCHAR* argv[])8 I0 r" M. |8 e
  11. {9 E% }1 r& c8 S! [0 `3 s
  12.         printf("Dekaron-Server Launcher by Toasty\n");. V" l# v* `5 Z! E* f
  13. % f. Y8 u/ x( \2 X) \
  14.         //查看文件“DekaronServer.exe”是否存在
    ; A: ^+ ?4 C/ f( N, {+ _% f
  15.         if(_access("DekaronServer.exe", 0) == -1)& }; V! |/ o( N$ ~5 r5 c+ B" r0 W
  16.         {! D2 g" O7 Z" N. E( X$ \
  17.                 printf("DekaronServer.exe not found!\n");
    ; A9 v3 C& x  i2 t# e7 B5 k  A9 H
  18.                 printf("Program will close in 5seconds\n");/ u* |4 d' w9 d8 X1 i" u
  19.                 Sleep(5000);! T" R- A. P$ ^  E0 k% M) ?7 R8 A
  20.         }) i$ t2 n2 p8 E, A
  21.         else9 r" Z, v8 i7 B/ X; c% m
  22.         {3 j2 D8 \6 r- W2 ?7 D& f6 y
  23.                 1 V$ I7 A& z4 [% `3 w6 \
  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).aspx9 A# \2 v6 h) {( v- F7 t7 I2 }+ u3 ]
  25.                 STARTUPINFO si;. O' K! T( F2 A" T6 b5 ^7 D6 _
  26. 3 Q6 b% y. G% A0 V' M
  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
    ; X2 p8 G# E" B: d- J. _
  28.                 PROCESS_INFORMATION pi;3 j* o' Z4 r: ?! W+ w- L* D

  29. ) x9 z  ?) P3 e* n
  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# F5 f/ ]5 z! B! E
  31.                 DEBUG_EVENT dbge;
    2 h  Y! |- b1 }% L6 @

  32. 9 R# q* k% G2 s
  33.                 //Commandline that will used at CreateProcess
    % A$ e, ]4 l/ Z, s* ]
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    % y- H7 a2 q4 T; q8 S

  35. 0 w3 l; B' v( @1 F# P/ T
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ( p# x0 I$ E1 W. P6 z: n" S2 _1 K
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)6 ]3 U/ @( r  p/ f2 J
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    : Q3 E( z2 U3 u

  39. 5 c9 S% a; l' A$ `6 ]9 \& e
  40. 6 j8 ]( d# ]& I3 p# f3 G
  41. 3 }" A" {$ w% D8 }  D# q
  42.                 //Start DekaronServer.exe : w3 R) k% z+ m# m1 N# O7 G; l
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx% S$ u0 e7 W; c& \
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)+ D; ]: l0 j$ T  L8 B
  45.                         szCmdline,        // Command line
    $ t# Q: c6 r* `) b  E7 f( f# S
  46.                         NULL,           // Process handle not inheritable
    7 ~% v. h5 J3 {5 ?4 ]+ k( T6 f
  47.                         NULL,           // Thread handle not inheritable
    ! f9 n4 z( Z4 s# c* y! L$ `
  48.                         FALSE,          // Set handle inheritance to FALSE
    * f& m6 Y# ~0 I7 D/ x3 p, D
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ; }6 A! }, w3 @4 E0 d* H
  50.                         NULL,           // Use parent's environment block
    ( s8 ]! b; @8 ^" l. W4 f
  51.                         NULL,           // Use parent's starting directory 0 j4 Y. T; t% j7 d( C9 @% i
  52.                         &si,            // Pointer to STARTUPINFO structure7 R/ E7 J. r7 b
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    $ k) g" X) J' c
  54.                 )
    6 m3 ~8 i# u  N. a! F4 f
  55.                 {
    ; l& e3 Y# l( u. V) ]& @
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );" m' A+ Z7 z6 u' H: e0 a
  57.                         return 0;
    - a7 J. ^" B' ?8 h/ J* c- g* Q9 `
  58.                 }
    . ?3 k, ^5 ?# L0 W
  59.                 //Creating Process was sucessful
    " o- B. d0 b& g8 E
  60.                 else
    / E( X4 Q& ^' c9 x7 B8 ?+ z# Y
  61.                 {6 l$ ?- l. A3 g6 K- ?& d: q$ y) S
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    7 g! K7 c; m# P
  63. 8 v2 m  \0 b& `2 Y
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure* Q# J4 I0 ^4 K
  65.                         dbge.dwProcessId = pi.dwProcessId;: m+ C: N7 v/ P/ H) W* p  g5 k
  66.                         dbge.dwProcessId = pi.dwThreadId;. I5 @5 a* v6 v% V3 o

  67. . d- w$ c, E& v: a$ z" n
  68.                         while(true) //infinite loop ("Debugger")
    ! X+ b+ g4 K9 K, H1 M- v4 }4 j8 o
  69.                         {
    : h. L6 q) C7 J  s3 z
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx; V& ]8 w# ]2 [

  71. + J2 `0 Z. k! b1 h0 L
  72.                                 /*4 X1 }9 T/ \4 w- M) c( d/ Y. y
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
) Q& B1 B) }. g2 w1 C) y# Z+ _
, e2 k, N/ L7 D! o
/ X/ D: G+ P4 G) P$ A
商业服务端 登录器 网站 出售

13

主题

250

回帖

1199

积分

高级会员

积分
1199
金钱
765
贡献
166
注册时间
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

主题

205

回帖

345

积分

中级会员

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

13

主题

250

回帖

1199

积分

高级会员

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

3

主题

97

回帖

4811

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-8 18:56 , Processed in 0.060118 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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