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

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

[复制链接]

154

主题

343

回帖

5865

积分

管理员

积分
5865
金钱
1837
贡献
3531
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) & r" R) I9 b' u2 e; k
" T: i9 `1 D5 [2 F* ^5 ~
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
; j, r9 N; A) b7 Q9 G8 a- M
8 N! ], {; c1 ]: }! r  w
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    : ?5 f; ]/ I% Q+ F" M: }3 u
  2. //8 l5 ]; D* |' S* a4 d0 I3 E2 y

  3. ( U* G5 C0 I$ K8 k) t8 o
  4. #include "stdafx.h"
    # X- E# D7 s8 H" S% Z
  5. #include <iostream>9 Q/ x: R5 P/ [6 E0 Q0 ~3 K: u
  6. #include <Windows.h>% m. x. N& s9 \6 E2 [5 t5 x2 |
  7. #include <io.h>
    6 `- m$ X' U" o$ X4 H# R) ^/ e
  8. ; A4 o' X. }: F+ N
  9. / o# p+ k) Y" N$ w( Q9 P
  10. int _tmain(int argc, _TCHAR* argv[])
    ' g5 c, J8 o1 N% w% C$ B
  11. {
    1 v0 D6 a" q- g' `. ^
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ) m8 ?6 u0 i4 Q* m* \4 j+ n

  13. + D; q# ]3 \) \7 W" V7 }: l9 k
  14.         //查看文件“DekaronServer.exe”是否存在" F5 _8 i8 g) a5 J8 g
  15.         if(_access("DekaronServer.exe", 0) == -1)" `0 Y* G/ s. X1 d) F8 U/ ~" z
  16.         {
    2 L9 j' i% S' q7 M4 J: M" Z) W9 @
  17.                 printf("DekaronServer.exe not found!\n");
    ( ]$ y; c/ h2 k' {2 I( }  u
  18.                 printf("Program will close in 5seconds\n");0 A0 o+ G* V8 q. m! L$ Z) v- d' [
  19.                 Sleep(5000);
    $ v! ]0 j5 u* O$ A1 D( A
  20.         }
    6 V. P8 i& }; E" ~+ T
  21.         else
    7 f, I* R- A* v& a
  22.         {
    # m. k8 f" r; W/ c
  23.                
    2 w1 q: g) N: d: X9 u
  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
    , r2 U8 T* h+ Q$ R  c* Z% x, V! i6 ^
  25.                 STARTUPINFO si;
    , Z. X" E6 a4 R* A+ b+ Q7 z' [

  26. 9 H) v' g3 A( k" w1 h, i
  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).aspx0 U' d8 O* R0 }9 [" f
  28.                 PROCESS_INFORMATION pi;
    " s& m8 ~3 D& L6 P/ i

  29. + }% R, B3 y0 p' m9 O+ }/ 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
    * r( K) A/ M; a: V" l9 v1 _+ f3 w
  31.                 DEBUG_EVENT dbge;* n* B7 ?; ]$ H, o

  32. 8 T1 B  a3 d/ d* w
  33.                 //Commandline that will used at CreateProcess" w2 P/ K. j/ R( v
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    - t- b  K( z3 {' h' a
  35. ' v5 a1 E$ q+ h  O; ]  D% \3 [
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    + m5 G6 {( a& H- B, Y
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)& U* S" v4 ]7 }2 ?, {1 z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ! W/ I* |8 r1 a2 R8 D# {

  39. : C7 `' R1 V& M- {8 Q
  40. - D* z; V( t6 k9 K. {
  41. 0 d4 i+ q; k2 Y- Q/ U* O
  42.                 //Start DekaronServer.exe 9 [& X& q; T; ]
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx5 z1 o! ]6 s4 ^7 b8 x& l6 j* T
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    6 O, g3 M+ H; ]: W  Z
  45.                         szCmdline,        // Command line: K6 y4 y% w/ M5 W/ [. X3 z! m. S% f
  46.                         NULL,           // Process handle not inheritable: z  o9 y' h0 J. c9 B
  47.                         NULL,           // Thread handle not inheritable
    ; _- b. q% A( S  {6 V# r
  48.                         FALSE,          // Set handle inheritance to FALSE
    2 c0 b3 {$ s, p( O  ~& L% O" I" t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ' F7 H# P1 O/ R" x8 N
  50.                         NULL,           // Use parent's environment block
    ' Q/ F6 @0 N+ \' `3 [" \
  51.                         NULL,           // Use parent's starting directory
    2 }$ x' |7 h& x& \9 Z
  52.                         &si,            // Pointer to STARTUPINFO structure
    ! G7 \# b4 p3 ]- F0 a- |
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure0 b' v8 T  i- A- R$ ~  m2 w9 a
  54.                 )
    ' \" i7 K; _& I1 f( K/ J
  55.                 {1 s& C$ b2 m5 S& v# j2 O
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    5 b* G2 x8 D  U0 e
  57.                         return 0;
    3 y! [* _# b# _
  58.                 }* i* x: N% n/ e1 t( R2 N% B3 M
  59.                 //Creating Process was sucessful: n( M% F5 o5 \. E
  60.                 else$ G9 ]0 U5 d0 V; Q1 k+ g
  61.                 {
    - J4 o  z% A5 H3 m* q# a
  62.                         printf("Sucessfully launched DekaronServer.exe\n");% ^$ i  }' o" K* @5 n
  63. ; \0 b$ {* H' X# n3 D! J' U% A
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    # A, `: [  e$ h. B" ]  N
  65.                         dbge.dwProcessId = pi.dwProcessId;% ~; t# u. Z+ g6 ?! p
  66.                         dbge.dwProcessId = pi.dwThreadId;# J8 T- q7 r1 U+ Z
  67. ! g8 B$ l5 G0 P: b- f( |0 K& a* B! P
  68.                         while(true) //infinite loop ("Debugger")4 F( D! i0 _) u
  69.                         {8 ~) k1 p% S6 L: v9 }- b6 u
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx/ P6 T% L' ?; ?

  71. & r- x, d% `7 R5 B' H$ {
  72.                                 /*
    9 r. u5 x3 V" ?& |
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. r5 \* P5 P5 M# s5 X$ X
" u* V: D- g0 b5 X. _% O" ^
! i& Q; A) {1 z6 h+ O3 O
商业服务端 登录器 网站 出售

13

主题

251

回帖

1258

积分

金牌会员

积分
1258
金钱
802
贡献
187
注册时间
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

主题

251

回帖

1258

积分

金牌会员

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

3

主题

99

回帖

5433

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-12 16:33 , Processed in 0.063834 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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