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

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

[复制链接]

106

主题

128

回帖

1472

积分

管理员

积分
1472
金钱
633
贡献
605
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
' j5 m% n  N! f/ X( G! E6 a
4 Y. n2 f8 ~0 R2 X: P
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。' S) Z2 ]! J) f8 O
  X' I& b5 R% l4 O& O
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。7 |! ]1 p$ n7 N+ [# {
  2. //: I6 j3 o( m3 V( `* I% G

  3. * x6 ~/ m( _* w* ]+ e" k
  4. #include "stdafx.h") l( R+ X& P1 _. L1 b
  5. #include <iostream>
    7 M: t( w7 m5 ]  p0 Q$ s. m
  6. #include <Windows.h>
    ' I5 y, L- V$ f* x
  7. #include <io.h>
    8 z7 x2 e! G# r3 z
  8. - }4 F9 r- o! w# |

  9. " a) @+ C+ ~& E/ V& n
  10. int _tmain(int argc, _TCHAR* argv[])2 T4 E; B$ X7 [" v  a7 Z) d
  11. {0 [; {! ~3 Y: e" V0 ^5 o' a9 [! J
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    - T6 {8 i) R7 {0 ]  q
  13. 7 z7 H2 E: ^% z0 g
  14.         //查看文件“DekaronServer.exe”是否存在) g$ a5 m" q. E/ [, H3 M1 G0 z$ ?
  15.         if(_access("DekaronServer.exe", 0) == -1)
      o5 m, h7 `# s3 t2 G4 W5 Z
  16.         {9 F' f: Y  L& P/ u
  17.                 printf("DekaronServer.exe not found!\n");
    ( D- O9 H6 q. b! x2 n) ^# M
  18.                 printf("Program will close in 5seconds\n");
    * P& L; a& p7 ]. @. i
  19.                 Sleep(5000);
    3 |% n3 t! V5 e0 G0 Z5 H. g% v
  20.         }
    # o: L% Z6 H# v3 u# W
  21.         else7 e( A. G5 I9 c/ r* I% a1 C
  22.         {; {; T: d( ?' j7 J
  23.                
    ; q! _6 m5 \7 @/ }
  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. @! m: _. w6 R3 r3 \0 x
  25.                 STARTUPINFO si;# A4 j9 w0 |4 F. O! A

  26. 6 h4 Y. p+ j9 }* o4 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).aspx4 ~5 N5 E6 O3 v! E; g$ T+ P
  28.                 PROCESS_INFORMATION pi;3 q5 f! V7 g* E  o5 l# E$ X6 F6 q

  29. " G: k, Z9 s7 }! u
  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
    1 S' o! V6 l5 t) Y. ~, H0 y9 D
  31.                 DEBUG_EVENT dbge;
      i( Y1 S- u) I( R  K
  32. 4 a1 \+ A9 G" h* z- f" p% P8 T' Z' O
  33.                 //Commandline that will used at CreateProcess1 t' P3 w* f, g8 i1 Y  {3 r
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    # U/ }1 t) G. P( Q( O

  35. # Z5 j+ m3 e4 ^7 p2 I( o( I, y. P6 }
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    " D& w3 U8 _3 ]9 q. b, y  j& r- H
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
      t8 ?: c, e( a6 D# Z5 j, }& k+ |
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    - ]0 c8 A- V) ]

  39. ' y2 G+ R; p$ s) c' I3 L
  40. ' B3 d& E2 M! U4 R3 o% \4 o& [$ {' `
  41. + n6 I- p, _: p) c
  42.                 //Start DekaronServer.exe ( W3 O+ ?/ g0 d+ ~
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx6 v% L+ o6 s5 v) ?1 V* M6 j: p& d5 D+ n
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    + N" F! f6 Z# C
  45.                         szCmdline,        // Command line
    8 X9 ^' a- O0 z/ K
  46.                         NULL,           // Process handle not inheritable! f. l% H5 ]6 u' g* H
  47.                         NULL,           // Thread handle not inheritable
    8 P  a5 _) X6 \* a  P' h2 ~5 H
  48.                         FALSE,          // Set handle inheritance to FALSE
    $ h+ P$ ^& L" F) L( ]1 S
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx1 J; ~1 f2 ]8 w( j
  50.                         NULL,           // Use parent's environment block! s: p) m; R# @: p6 P2 d* e# P& o+ c
  51.                         NULL,           // Use parent's starting directory
    - f- H" Q8 w) \
  52.                         &si,            // Pointer to STARTUPINFO structure
    : r3 K/ r- `+ c) ?. S; R: S
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    9 e" O8 h2 ^1 G2 S
  54.                 )
    5 D+ F8 I4 n/ X  d
  55.                 {
      w( G7 H: g! c5 \$ F- v
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    ( Y' \4 W' ~6 {3 L9 s5 K- y  {
  57.                         return 0;4 E: m' {- r! k; j# j8 A9 Z" Y
  58.                 }
    ) R7 d+ T$ g; l( e
  59.                 //Creating Process was sucessful
    % o* X& G" C! n' }
  60.                 else5 l& ^4 k* C5 A! Z4 }
  61.                 {
    1 E. \' _' W" n. c" J. v
  62.                         printf("Sucessfully launched DekaronServer.exe\n");" ^, D. u; |9 ^! B8 y) ]" |
  63. ! D7 l5 n9 P! |2 k5 G; S
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; e8 ]( ?1 `. Z9 q
  65.                         dbge.dwProcessId = pi.dwProcessId;* p! D" X2 V/ M4 }3 w& x2 u
  66.                         dbge.dwProcessId = pi.dwThreadId;$ `. p% x- M8 M( F

  67. 6 }  Z; `* J  q* \
  68.                         while(true) //infinite loop ("Debugger")
    6 W( T" Z) `2 J7 R' R
  69.                         {: E, E# w" h& Y4 F
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx, @  T. ?; A7 J9 @$ K, K, ]

  71. 0 h" P. ^) S; Q$ {4 R5 V
  72.                                 /*
    : m' @! L6 E" {4 j8 t" i5 y- D
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

  L) }* d  b. ^! y. w! _6 z1 ^& i
& U" a1 X2 j' Z/ y8 z% ^& q; W% Q( n) X- ]* A( G* p

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
商业服务端 登录器 网站 出售

8

主题

188

回帖

454

积分

中级会员

积分
454
金钱
247
贡献
6
注册时间
2023-11-10
发表于 2023-12-18 20:34:07 | 显示全部楼层
我是来学习的!

21

主题

375

回帖

767

积分

高级会员

积分
767
金钱
282
贡献
89
注册时间
2024-1-20
发表于 2024-1-21 13:37:44 | 显示全部楼层
感谢楼主分享,我是来学习的

0

主题

42

回帖

105

积分

注册会员

积分
105
金钱
61
贡献
2
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

8

主题

188

回帖

454

积分

中级会员

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

2

主题

51

回帖

156

积分

注册会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-14 22:34 , Processed in 0.094903 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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