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

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

[复制链接]

160

主题

385

回帖

7427

积分

管理员

积分
7427
金钱
2133
贡献
4749
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 9 n) o6 F, D; M& ]9 `! {
# `) q5 y  T) F
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。" d) U  b& ^7 b& c6 b4 }. `
, N6 d* l& x3 z6 @
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    1 {9 ^1 Z" l# T; `; P
  2. //
    ( S! F* S! i" \5 u

  3. * R8 j( i( _/ v4 W
  4. #include "stdafx.h"2 H. `  |5 l5 F; ^
  5. #include <iostream>
    % E: V( w4 E& Y/ E, T3 E
  6. #include <Windows.h>  H) W3 W$ O( K8 J6 v, Y
  7. #include <io.h>0 c2 {- n. T6 F7 f5 m
  8.   J, C. c  U& W7 }0 F

  9. % L- i+ d. a. T
  10. int _tmain(int argc, _TCHAR* argv[])
    1 f* ~" r: s3 H3 r& J' _1 z, b  i
  11. {2 o) K- Y& x4 S4 P
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ' k" Y/ V3 t6 S: r

  13. ( _* x% v) k, |( M& }$ d* I5 c3 {
  14.         //查看文件“DekaronServer.exe”是否存在9 }* o( m# n: o0 v! m( _# X) Z
  15.         if(_access("DekaronServer.exe", 0) == -1)
    % _. t8 s! Y" h6 T, k' S
  16.         {
    + m, F5 ^" ?3 r. _
  17.                 printf("DekaronServer.exe not found!\n");, Y% B% ~- ^, L! a. q, r* F
  18.                 printf("Program will close in 5seconds\n");4 u! c2 w4 z) l" D
  19.                 Sleep(5000);
    * l8 z) l& S+ C7 p1 Y) N
  20.         }
    ; j2 X! U9 J1 ]
  21.         else7 t3 H2 r  R3 h  B9 J% r/ B
  22.         {
    ) y) |) ~; k3 Y8 C  @+ }
  23.                 8 g* c; M0 ^9 r# }, z7 E6 X
  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
    1 d* I* M. S2 w
  25.                 STARTUPINFO si;+ Q0 ], I$ }$ d3 G. K; a

  26. 6 ]' S- L, @- A* @, Q) t7 h
  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& b" L5 D) \7 b: _& J
  28.                 PROCESS_INFORMATION pi;
    : I6 |6 J7 y6 q  i% T$ X9 H; R

  29. * g. @, A5 M0 x
  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
    9 o9 r; m# Q# d/ L' F
  31.                 DEBUG_EVENT dbge;
    0 B, P- Y; H* W
  32. , Y: U2 M1 b+ O- A0 x8 c/ P: o
  33.                 //Commandline that will used at CreateProcess! F) G" C2 x9 P8 z& t
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( F/ l; y, G' Q. j& @

  35. 6 [' b4 Z, Z# P- t
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ; F5 e8 V, _) H9 ]5 I' G
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn); G0 a& M' q) N
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)- k# r" ]) b" M# v' G( f
  39. ) }) {4 L# k! ^4 j/ [8 C( v9 S

  40. 0 R# x3 _7 W0 Z: v8 @4 @0 y8 q

  41. " F+ C# Y4 }+ o' Y
  42.                 //Start DekaronServer.exe 8 d/ e* L, `+ s8 }% p9 M/ Q7 m
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx6 R8 T. s$ t- a9 F
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    8 p1 @: R3 g- p
  45.                         szCmdline,        // Command line
    ! G! C8 b' ~) H) @/ f, P
  46.                         NULL,           // Process handle not inheritable
    2 V6 t% U/ A& j. n  `
  47.                         NULL,           // Thread handle not inheritable
    ' g1 g+ P1 P, x! E
  48.                         FALSE,          // Set handle inheritance to FALSE
    8 Q# Y- \: y, r- M. c
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    - Q0 s% P, D8 j2 J
  50.                         NULL,           // Use parent's environment block
    3 j' ?( r- U" C5 y
  51.                         NULL,           // Use parent's starting directory
    3 z2 u$ h8 R2 |! A
  52.                         &si,            // Pointer to STARTUPINFO structure
    * ^3 H8 {3 E! L
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure) N* ]: \7 m8 @3 d' _; q# h$ T
  54.                 )
    ! }; V" a+ Q5 @
  55.                 {
    ' w4 `9 w# U; O) K  Y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );2 A# W5 L3 @6 l
  57.                         return 0;
    1 X* P: f  @7 K8 y) ?, ]
  58.                 }8 d/ ?$ Z( H4 j4 D5 l, K
  59.                 //Creating Process was sucessful
    $ H6 @7 o& t* ]+ ^6 H- ^
  60.                 else8 z% q) x$ J4 l6 k  V/ s$ y
  61.                 {
    9 t# q; `' x7 l: W! _9 x
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    4 z7 h7 X9 @& u9 S/ {+ P! Y
  63. 3 E3 O6 l. p7 i- m! e# H
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure( ?  {$ p! V  e) E% j1 V  E" U
  65.                         dbge.dwProcessId = pi.dwProcessId;: u" b/ k% d0 K! P
  66.                         dbge.dwProcessId = pi.dwThreadId;7 G; x8 e2 }$ p% l7 v1 N. O) q
  67. , S0 o0 X) s) U0 q2 n/ n5 z
  68.                         while(true) //infinite loop ("Debugger")
    # w3 Z" L6 x  q+ }
  69.                         {/ }/ t" U" o- I& e  V% L+ {, n
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    . Z* v- w  A# S5 J
  71. & G. c+ Q* K, F+ k* u( K+ A" h
  72.                                 /*$ `/ P' }1 ]" p- l
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

$ n2 G( x$ H: B2 N' r" P. @6 E) n. B" e* Z

* a9 Y" |+ ~5 J0 [9 Q0 R
商业服务端 登录器 网站 出售

15

主题

260

回帖

1295

积分

金牌会员

积分
1295
金钱
933
贡献
82
注册时间
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

回帖

1295

积分

金牌会员

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

3

主题

102

回帖

7957

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-3 18:49 , Processed in 0.035235 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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