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

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

[复制链接]

153

主题

334

回帖

5706

积分

管理员

积分
5706
金钱
1802
贡献
3417
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 2 g4 \+ d/ G9 ]* r% ]
1 ^1 f4 O6 B1 M* \
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
) i- \+ k1 j" Q: ^; q. B- e
8 u1 k9 j% i; Z: _( d7 g
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    # n0 L2 h' n8 y1 M- S# D
  2. //2 o: |3 ?" z2 P
  3. - u3 z( B8 M5 H  R/ a
  4. #include "stdafx.h"2 R- v6 v6 p+ y5 U. ~8 ?
  5. #include <iostream>% C. r) U8 V3 }9 R) X' `
  6. #include <Windows.h>+ S; i$ Z3 _4 i% }. u
  7. #include <io.h>6 \2 {7 U0 _; b2 e) R4 g, Q  P
  8. ! @' G* u% |* X

  9. 1 k0 y7 W* J" G) \: t
  10. int _tmain(int argc, _TCHAR* argv[])- N7 c- I$ K6 Y
  11. {
    ( |: E" n& x7 ], e5 t) Q! M
  12.         printf("Dekaron-Server Launcher by Toasty\n");* d* `! H* h2 L1 u+ d, i3 F. L
  13. ; ~9 }& S7 [$ S; P
  14.         //查看文件“DekaronServer.exe”是否存在  I* m* w: d8 ~
  15.         if(_access("DekaronServer.exe", 0) == -1)
    # U% e' t, t5 f
  16.         {
    / Z8 w, J1 c& a. V  c9 E
  17.                 printf("DekaronServer.exe not found!\n");
    ) P, {! i4 y0 `  u+ v3 q
  18.                 printf("Program will close in 5seconds\n");
    8 ]: S, o: |; K6 F( e4 d8 x9 O0 N. \
  19.                 Sleep(5000);
    ) ~" a  e; V6 w
  20.         }1 I3 p$ J5 |, t: \5 ^
  21.         else2 [9 g3 a* I, z
  22.         {
    ! m: F  c; J% u2 }
  23.                 6 h9 }( |1 @  U% E6 }
  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' C( z3 |5 q: e1 a% V0 q5 x
  25.                 STARTUPINFO si;9 V2 Q3 B2 }9 {6 \

  26. 8 o1 p( y* T' J; e* `2 b" _
  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
    , E3 I6 Q/ @+ V% M. q2 c8 z
  28.                 PROCESS_INFORMATION pi;
    & F( f) z! _' _* w

  29. 4 a& M6 ~9 C  i- w
  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/ t# F, d) \# E; F- M8 ]/ }
  31.                 DEBUG_EVENT dbge;
    . V  N; ^: w7 r# S8 j5 j
  32. 2 U) h. N# V7 J5 ?& f# {; f7 a
  33.                 //Commandline that will used at CreateProcess
    , [$ a" W; F" i- |2 C( @
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));# {. \/ I) V) P+ D
  35. 1 m2 D' [% m  w: }$ [2 C
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)7 @: O8 I2 ?% z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn). l" z+ R! [. C0 a" e- ?. c
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    0 x1 M6 W8 \( c1 P+ l

  39. - D0 x: w- K4 {& U4 G5 L" a$ R- r
  40. . O9 l) [" H2 P- A

  41. , q  v; g" Y5 d$ I0 M  v
  42.                 //Start DekaronServer.exe
    4 G0 ]# V$ D3 i( n/ _4 Z
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx+ C1 X8 R" X4 C/ _1 A! b
  44.                 if( !CreateProcess( NULL,   // No module name (use command line), E9 {2 [9 B  `% R
  45.                         szCmdline,        // Command line# J5 |2 ]! R: p
  46.                         NULL,           // Process handle not inheritable
    % s/ T/ h0 a4 R! f
  47.                         NULL,           // Thread handle not inheritable
    " A! I' t7 W- u- i9 t) I& e
  48.                         FALSE,          // Set handle inheritance to FALSE
    " q' g6 @/ T" ~3 C9 M
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    % p' Z% f" ^6 f
  50.                         NULL,           // Use parent's environment block( L* r& h6 D: h, h
  51.                         NULL,           // Use parent's starting directory . W9 m& E  K: z! z! g' l
  52.                         &si,            // Pointer to STARTUPINFO structure8 D  P, t% M& l
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    2 S  f/ U- y- [; I- [
  54.                 )
    ( X/ }7 ?1 d6 P7 V. H- c
  55.                 {, F9 o8 M; O, c
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );( k+ X( a, o; f5 [. t
  57.                         return 0;" ~. f: S6 D, a$ _
  58.                 }- P  Q1 Q) C9 L9 c2 z
  59.                 //Creating Process was sucessful
    . i; r) ?  `- ]9 A, d7 E
  60.                 else0 _+ t: h: s$ h9 Y- v
  61.                 {  q) j! e( v; _8 P2 B5 a! I
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    - G- W+ C' G: s" L' F' n1 D$ q
  63. ( W' X0 ]" Y" V; E. r& M
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure5 M: f# F0 x* ^6 o, X  h( v! Y
  65.                         dbge.dwProcessId = pi.dwProcessId;9 t9 k+ w3 @# C/ U5 g% J6 @* @
  66.                         dbge.dwProcessId = pi.dwThreadId;+ Z& B0 u1 x+ ^7 D! _1 y! s4 D
  67. . J* f& I; l  Q5 L9 K; p
  68.                         while(true) //infinite loop ("Debugger")! T' m3 F! y$ j7 b5 `5 u
  69.                         {8 c7 Y6 x  I9 K  Y) b/ ?
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ) ]/ E& ]" S7 b# E, [
  71. - |- p4 t7 _# r
  72.                                 /*4 @) [: q* g: g9 P6 T% e1 W
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

) ~; }$ z- B7 \8 X+ ~2 O0 v8 Z& {  W, X: ~) Z
1 X' h+ y7 _* ]
商业服务端 登录器 网站 出售

13

主题

250

回帖

1220

积分

金牌会员

积分
1220
金钱
779
贡献
173
注册时间
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

回帖

1220

积分

金牌会员

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

3

主题

98

回帖

5071

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-25 10:27 , Processed in 0.068062 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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