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

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

[复制链接]

155

主题

346

回帖

5944

积分

管理员

积分
5944
金钱
1856
贡献
3587
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) & h. i& a# t9 O5 X5 @+ f' p
$ ^6 c% B. t/ b  _. {
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。. F6 v4 _2 E( K8 @
( b2 D# [0 ~/ Y  T6 P/ `( C
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    # i& P$ T; m/ v# |; w# w" J8 c
  2. //4 O2 L! m! Y; u( k
  3. # Q8 |$ c  m( B2 Z4 \( ?
  4. #include "stdafx.h"4 t0 `2 S. F. J
  5. #include <iostream>
    7 p, I0 m7 h( t" D( [! q
  6. #include <Windows.h>9 {1 V7 P5 e+ D6 z0 b- W( q
  7. #include <io.h>
    9 ]" f' x' ]# I' ]; G; B
  8. 8 C% }) P, b4 ~) k& W: f( Y. t! v6 U

  9. 3 o( u5 O& c: A: ^) [
  10. int _tmain(int argc, _TCHAR* argv[])) v/ `! \1 N( _) b5 |
  11. {/ b4 [3 b9 e4 ~7 z' P
  12.         printf("Dekaron-Server Launcher by Toasty\n");/ C8 h5 ?7 O, a  k- \! n: x6 M) A( C
  13. ! A( c4 I: X$ g- O' w0 ?7 m
  14.         //查看文件“DekaronServer.exe”是否存在
    $ c$ R/ @$ p5 J4 @. I
  15.         if(_access("DekaronServer.exe", 0) == -1)) P8 c* C5 f4 `1 `5 s2 I
  16.         {8 e4 o) E; ?2 Z" }2 g, p
  17.                 printf("DekaronServer.exe not found!\n");( w$ h3 [- ~" g, a
  18.                 printf("Program will close in 5seconds\n");# l5 y( r" c" M3 h
  19.                 Sleep(5000);$ }2 k5 r( i1 Y7 j' {5 _. g9 S
  20.         }
      ]: G5 q- ^5 M& f$ M5 Q. D
  21.         else
    ! u5 B, B' b' G
  22.         {4 |6 i! s: Q7 d$ q# I9 s, J, C0 h
  23.                 , V  V: \! p, b
  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+ `6 |) j4 O8 Z$ R+ x' U
  25.                 STARTUPINFO si;! f0 K7 o" e: t' B2 O2 f) D6 J
  26. 5 V2 Y) F9 {3 h% e5 p
  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
    . i9 ?4 u! L# ~' L2 P. v4 w
  28.                 PROCESS_INFORMATION pi;
    6 M4 T" n; L: l" d8 s

  29. & [; p8 k: V# V: ?+ B) Z# L
  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
    7 P3 L) a' s. z$ @$ u
  31.                 DEBUG_EVENT dbge;) ?6 \; h. }7 V4 x

  32. . w7 k8 C% i' A  c' `
  33.                 //Commandline that will used at CreateProcess
    7 ^4 O( p! S) ?) q/ w. l- t
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ! Y4 Z* ^. Q/ I1 d% w* j
  35. % t& R% ~  i/ p0 @/ U, r. T2 v
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)' D, L9 u4 q3 o
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    5 e+ A& t* ?+ R' c8 q! }& m4 W
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    2 G# M$ R: ^9 f4 G) G: ~
  39. 3 Y5 _% d2 ~2 i# A: y; Z% `- K0 N

  40. 3 B' E) T; n. m2 b- {8 r
  41.   n8 S! c& c# l9 D
  42.                 //Start DekaronServer.exe 3 g7 F, w  p- u; O% }- V
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx+ s. T3 z" M/ L6 Z, E
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)' p  O4 a0 |# T9 w$ ~% c/ d9 X2 l
  45.                         szCmdline,        // Command line
    7 X; _2 t# Y) v2 p( u, I1 I
  46.                         NULL,           // Process handle not inheritable% R6 E6 v* g; I$ t' F
  47.                         NULL,           // Thread handle not inheritable( B( Z; K' ]" u$ `
  48.                         FALSE,          // Set handle inheritance to FALSE
    . I- U9 \% d) f8 O% Y
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    9 ?2 w# ]) j7 b7 n. q7 ?; l/ c
  50.                         NULL,           // Use parent's environment block
    ! R, F8 H/ U* A6 F# ^4 {$ k9 a
  51.                         NULL,           // Use parent's starting directory
      z8 `- G! ?$ D( h4 }
  52.                         &si,            // Pointer to STARTUPINFO structure
    * }( j8 ?% c2 o- q6 D% n
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    8 r# e5 j* e7 b0 B/ Q. i
  54.                 ) 5 P% t4 r% Y9 v
  55.                 {3 z7 ^  Q) m1 s+ q! C
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );" K/ ?1 x  Z8 c8 l
  57.                         return 0;3 @0 N7 A) M: F, `! E; o$ l. W
  58.                 }! v  J: z: w8 H' _+ e) u) e
  59.                 //Creating Process was sucessful+ D& A$ C1 n4 s- w5 U2 O
  60.                 else
    9 ^0 S, O# ~; ^1 e
  61.                 {# N. P- f2 g$ I' Q2 C/ b$ q5 n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");, g: \3 W% Z4 C' _" |7 b$ e& T
  63. ' v! H! x; W, z/ F0 {* N" D+ O
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure, _# ^! \& {; i- I$ P
  65.                         dbge.dwProcessId = pi.dwProcessId;
    5 A* z  y: [1 q; W/ G8 ]) B9 |  C6 ?
  66.                         dbge.dwProcessId = pi.dwThreadId;/ @( n: `3 g. o3 l+ ~. u
  67. * |1 W( x3 p1 G+ W
  68.                         while(true) //infinite loop ("Debugger")
    % Y2 E: x; ^7 N
  69.                         {/ k' S1 K0 }6 s! [1 Z9 @: g+ h+ {
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx/ f+ r' I! a+ a4 e. q2 q
  71. ; i* O0 ^6 ^* q
  72.                                 /*! T  x7 K/ g8 g, I* a
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
& j  ^8 ~+ w) R/ h8 C* f

; H6 U. O' e8 V% L" R& ?
  S; V2 q( A. P  G# c
商业服务端 登录器 网站 出售

13

主题

251

回帖

1233

积分

金牌会员

积分
1233
金钱
808
贡献
156
注册时间
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

回帖

1233

积分

金牌会员

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

3

主题

99

回帖

5673

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-24 17:37 , Processed in 0.079806 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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