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

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

[复制链接]

157

主题

361

回帖

6692

积分

管理员

积分
6692
金钱
1933
贡献
4241
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) - O" Q% |/ [9 L+ l8 ^$ x

$ |4 W; R1 u8 _; ]  z5 ^/ c虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
" N# A% p  a( Y. ~0 p3 T  `$ [# b, V2 d* y  Q+ @
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    - i/ Q: X' |# s
  2. //  K7 e4 R$ c1 p& n+ f- W1 _
  3. ; d( i1 w, Q! c8 T" q4 @
  4. #include "stdafx.h"
    * @) r; P7 @; h1 j9 C) g' W
  5. #include <iostream>* H1 f  c  E. ?# S( P6 l2 ^
  6. #include <Windows.h>
    5 D# M# x# R8 ?
  7. #include <io.h>
    4 @. k) ]% w: G' l! B
  8. ; f9 s0 i4 e) g2 `# J) l6 j

  9. * R  e, c& p+ }# r0 Y( t& V2 |0 p
  10. int _tmain(int argc, _TCHAR* argv[])
    : ~0 B& P+ u5 n$ R( w
  11. {6 c" R0 [* e& A2 ]5 {$ b4 @' _6 K
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    * o9 A5 h3 @- O/ I

  13. ! R% M1 }) ?. G. ]' `
  14.         //查看文件“DekaronServer.exe”是否存在
    : U1 @7 ?) ]* t. Y. G
  15.         if(_access("DekaronServer.exe", 0) == -1)
    2 Q2 p) N6 ~' h2 ]: I' Q3 f
  16.         {8 G% P3 P7 E- J% X  J0 l2 F
  17.                 printf("DekaronServer.exe not found!\n");% `" `9 v: M2 f5 A
  18.                 printf("Program will close in 5seconds\n");0 G# F0 g3 ?2 u' h) I) h
  19.                 Sleep(5000);! y( H4 ?( B7 E  M* L
  20.         }
    6 f) t. {6 u3 @/ |
  21.         else1 F: u2 g" ]/ d8 J2 v- Y& |
  22.         {3 \5 ^" c% l2 l; `  C% X" J. G% E
  23.                
    : E# ]# R% n4 S! ?6 s& w
  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# T/ S6 r7 q6 ^: ], k
  25.                 STARTUPINFO si;# }% _% u+ W/ V$ f4 C; Z  y3 S

  26.   s) V: S  T0 a/ b2 [9 D
  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
    & @3 g# A% Q7 M% P! N; w
  28.                 PROCESS_INFORMATION pi;% a1 N& }& D% t4 G

  29. 5 Y0 n( J9 W2 v/ s. D8 j
  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
    , C/ W: D7 w4 w) x; ?
  31.                 DEBUG_EVENT dbge;  q6 B# g8 P$ U0 `

  32.   Z$ ]! f+ q# t  m* L$ d( w  X& V
  33.                 //Commandline that will used at CreateProcess
    ; B8 ?$ p7 O3 q4 {2 M2 r  s) x
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( j" E- e; u, f/ y- P% r" F
  35. : u6 s" J5 o% L
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)0 L% I1 V# I" n$ Z" ]( D' q1 ?- J
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)! \5 F+ r4 i+ _: ^( j" }* g) G6 S7 C
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    6 A5 q0 J3 R5 `# W6 O: C
  39. + B, K2 y- @% L# z& l$ ?, _6 J

  40. # [  R/ X  a" t

  41. ( O0 k+ C1 Q/ Z& Z5 H$ n" z
  42.                 //Start DekaronServer.exe
    % J6 S; j  N' h. A( s
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    & ]  x; E- \( G' w
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ; u6 }7 q8 A8 T! ^
  45.                         szCmdline,        // Command line
    ; S6 M3 D0 D/ T- y) v9 V9 S( t
  46.                         NULL,           // Process handle not inheritable
    " h) l$ i* |8 k# o) @, O
  47.                         NULL,           // Thread handle not inheritable
    , I; c& q4 z; I6 z
  48.                         FALSE,          // Set handle inheritance to FALSE
    ( V2 o: m- u. i2 {, B- i
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx. [4 X3 p- n$ q% I0 D
  50.                         NULL,           // Use parent's environment block
    $ o; S6 u8 Q: c& d4 }& w
  51.                         NULL,           // Use parent's starting directory
    8 t2 s% A/ s( W" O
  52.                         &si,            // Pointer to STARTUPINFO structure4 _) y! Y0 L) R5 c0 ?' r
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure4 e) }$ `$ q2 k, l' j( p: R
  54.                 ) 5 Q9 }4 U/ T( P0 ]8 _+ U
  55.                 {
    ; }) Q- N6 p# k7 U( ^4 @# L
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    7 X1 m, h% U& P1 @; N# e2 P
  57.                         return 0;
    ) ~( b% H( \8 [; f0 k
  58.                 }
    * v' f+ l) Q( _7 c8 t) p6 q
  59.                 //Creating Process was sucessful4 N6 @7 j6 R8 R6 a! q8 r+ v
  60.                 else$ z9 B0 t) V' a- B9 C+ N8 ]
  61.                 {
    . x) k& ~& {2 s6 z0 |
  62.                         printf("Sucessfully launched DekaronServer.exe\n");* R9 R- g: n9 l1 C
  63. 2 B% G' p# V% f- y5 {% \
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    3 p. P6 s5 c3 `& w# a3 V3 A) k
  65.                         dbge.dwProcessId = pi.dwProcessId;
    % \9 S7 m: \& g3 ?6 h
  66.                         dbge.dwProcessId = pi.dwThreadId;9 O8 ?. c5 ?7 F2 {. I

  67. 7 q/ g1 k" ?9 J& @. u( {, o- P
  68.                         while(true) //infinite loop ("Debugger")/ `3 k3 ~3 {0 T3 E8 ~6 F
  69.                         {
    . }8 i7 y! l; d( a3 q8 @& c
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ; j6 [0 d8 A5 C1 k. C4 T

  71. 1 B9 ^( h. J; c8 D1 Y7 v
  72.                                 /*$ X3 v) R: Q# k
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
, r4 A3 ^. }8 r! D
& w9 r% _. f1 w% p9 `) x* N) z1 b

& y6 S8 z7 W. T" I: O
商业服务端 登录器 网站 出售

15

主题

256

回帖

1259

积分

金牌会员

积分
1259
金钱
865
贡献
118
注册时间
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

主题

256

回帖

1259

积分

金牌会员

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

3

主题

102

回帖

6381

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-8 09:08 , Processed in 0.084036 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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