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

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

[复制链接]

157

主题

364

回帖

6949

积分

管理员

积分
6949
金钱
1982
贡献
4446
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ! J0 X0 J; A* }8 u1 C6 m6 V
& F& K) l! ?5 e( O4 ~( S0 x
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
# H' }' C$ m4 T
/ J- Q: v1 t. |
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。: f( K7 O0 h2 t! w
  2. //. |& f3 ?2 C, T( g4 E, \) t( x' e
  3. 0 [7 u7 s4 W' F
  4. #include "stdafx.h"; }( Z* U6 `  W1 g8 K0 U. D
  5. #include <iostream>
    " T9 R1 U1 z# k# f0 h3 e
  6. #include <Windows.h>! q  Y4 R, V# K- Y
  7. #include <io.h>
    / M/ X# z) ~* H- k5 G
  8. 3 V3 {0 [% R( ]8 r6 P; O* R: S  s
  9. 9 E& s# ^% S- L. e- c) b5 n
  10. int _tmain(int argc, _TCHAR* argv[])
    % Y, d2 J; U$ f  K1 V2 J% [
  11. {9 W# d) W4 w) e7 j2 A: {
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    $ x# U  }" e  `

  13. 1 @1 z: F: l6 x! C; W1 P7 O
  14.         //查看文件“DekaronServer.exe”是否存在
    " N' X' B# o0 V
  15.         if(_access("DekaronServer.exe", 0) == -1)
    & F+ y) M) I1 Q0 H: `
  16.         {
    0 u$ G" o. K) r& e" e& ^
  17.                 printf("DekaronServer.exe not found!\n");- E$ ]% ^4 n) L2 G' ?
  18.                 printf("Program will close in 5seconds\n");& j1 b) ~! w& ]) g
  19.                 Sleep(5000);
    ' R9 y' g0 u# c' c
  20.         }+ Q' L9 R& x, w- m2 p
  21.         else+ F$ h* o, W  H+ z# c, z2 N! f
  22.         {
    - H+ u- {" _0 Y
  23.                
    . J5 l5 [# k' n6 Y
  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. e6 w( z0 E3 E7 @/ L- X
  25.                 STARTUPINFO si;
    6 O( A: Y8 `7 m% }

  26. - C# Z( ?8 O1 D! T) T3 o
  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
    9 \' q8 v  O- l) `" [9 b2 P6 ?0 u
  28.                 PROCESS_INFORMATION pi;
    1 k2 M8 i3 Z5 J' k! z! \
  29. % u% e! r7 X4 j' }; h  {
  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).aspx9 I+ b5 k- d+ v# m
  31.                 DEBUG_EVENT dbge;
    5 ^; b  q: K. ?8 J+ J

  32. - E( M# t$ G  u% y1 y+ y: F! M
  33.                 //Commandline that will used at CreateProcess
    ; |' y, L/ X) @/ O8 L8 I
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));- ^$ W( ]; D/ P' F7 B+ v

  35. 0 `: D1 V: D; t8 [
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)7 w3 {$ r. f  V5 S! [* _3 D" B2 z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)/ U7 A7 y4 ^: S, b' U# Q, z8 k
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)& t% P& s" [/ H/ q3 v8 c
  39. 5 o0 F. F2 L' O6 R
  40. : P# W; W' `0 s- C
  41. 2 ]- R/ i1 F# @0 o7 Z( ^! {
  42.                 //Start DekaronServer.exe * p+ `7 u5 {1 z) A. |+ ^
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx# j6 w  K" f' M  r, [' I
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ) Z+ I) w& Q5 x1 `& o
  45.                         szCmdline,        // Command line5 |+ }1 A  x! M" X, P
  46.                         NULL,           // Process handle not inheritable3 T* v/ Z0 D( [: Y. i$ o
  47.                         NULL,           // Thread handle not inheritable5 B9 a) \/ b; |) N/ n' U
  48.                         FALSE,          // Set handle inheritance to FALSE
    ' U& q8 F/ T1 y& V' m- S0 O( t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    : o5 f8 z7 A9 S9 Y
  50.                         NULL,           // Use parent's environment block$ Q) i. p$ L" S; b5 R) c
  51.                         NULL,           // Use parent's starting directory
    4 i" z: k* b4 J
  52.                         &si,            // Pointer to STARTUPINFO structure
    + w; O- T- j0 }1 v* H. l! `9 q3 Y
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure& o, M& i1 m2 b+ U2 K
  54.                 )
    / f' K  Z( ^* e) B9 X9 b
  55.                 {3 Y& U2 w6 B; [  X1 O( K
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );. _8 f  r' B+ I, x4 a. u  q: Y
  57.                         return 0;
    # g  t/ \. k! J( z# z- {( J) N9 S
  58.                 }4 k8 R/ [. r2 k' M- s- p
  59.                 //Creating Process was sucessful; M8 M0 t$ u9 L5 o2 A
  60.                 else
      }4 a* s2 P8 G! i% P
  61.                 {1 V5 N$ z. n# e3 F' D; y# h) a2 W+ y
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    $ K1 i* n: ~8 t! A, c. T$ e6 K
  63. , _* |+ Z. D( r2 Y$ s+ F' f
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure- C4 V9 [# [" T( S' p' |6 V
  65.                         dbge.dwProcessId = pi.dwProcessId;9 E0 t% G& d) V" K) t: Z
  66.                         dbge.dwProcessId = pi.dwThreadId;
    0 P; y& X5 b, h' p

  67.   r7 G5 `. ]+ E2 [0 a! f
  68.                         while(true) //infinite loop ("Debugger")! O9 p' C; b& o( c# A& O
  69.                         {% i- X0 F* r; F8 k! @" p  r
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    & C5 j! V  j. V  H. }! V
  71. / ]; n5 k- J# F+ F; X
  72.                                 /*, p8 t1 c. m3 n& `5 m7 N. A3 V
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
" Q3 ^$ o/ O  v" x  |1 b0 `' {

. O1 d1 g, J% v% `
: B' x4 V' T( @; l! j
商业服务端 登录器 网站 出售

15

主题

257

回帖

1229

积分

金牌会员

积分
1229
金钱
888
贡献
64
注册时间
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

回帖

1229

积分

金牌会员

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

3

主题

102

回帖

6864

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-10 00:06 , Processed in 0.025752 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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