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

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

[复制链接]

160

主题

383

回帖

7366

积分

管理员

积分
7366
金钱
2113
贡献
4710
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
* r/ K6 \$ }! g% }2 P
+ p- L$ c  Y' A9 T" `虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。- L+ H. E8 p9 u0 s
' K  ^2 r8 q4 q8 c; `
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。! ]5 w: i" `/ R7 e8 T' @4 E: ?
  2. //# i" I3 |9 X- o9 G
  3. ! Y7 r7 j5 |$ y+ l* ?" b6 ~7 a% U0 M
  4. #include "stdafx.h"
    5 s7 ~% f  }& n+ w9 d4 [5 [1 Z! {' q
  5. #include <iostream>
    3 S& C9 ?7 d2 s& Q
  6. #include <Windows.h>8 Y0 f, [  C5 ?" R
  7. #include <io.h>) G) X7 q* ]; R. V; A7 S

  8. & z1 F# o6 O3 G9 ~' ~/ b; R0 B! j5 V
  9. ) l' z  ?9 u$ H3 U3 |# f5 n
  10. int _tmain(int argc, _TCHAR* argv[])- O- t; J; p9 c6 N; I, U4 n
  11. {
    5 `3 P  i4 X; h  I/ ?' N" \% Q
  12.         printf("Dekaron-Server Launcher by Toasty\n");& x6 y! j, T9 @2 {5 ?4 V; d
  13. $ X% G" ?2 l  ]  v8 y9 o
  14.         //查看文件“DekaronServer.exe”是否存在# r4 ]7 p/ z/ r6 t* `
  15.         if(_access("DekaronServer.exe", 0) == -1)
    + V4 z. Z9 Q, g) ^" v0 U0 W- x6 z
  16.         {
    ; \% V4 O  k+ _/ M/ ~6 y+ W8 |
  17.                 printf("DekaronServer.exe not found!\n");
    ) e5 r" P" \! l( W
  18.                 printf("Program will close in 5seconds\n");/ U" m# P! U" L+ `; s" o/ P
  19.                 Sleep(5000);
    9 `/ o! k! D- N
  20.         }
    ( V' `7 I. [9 n; Q0 b$ r0 u
  21.         else
    3 q# r1 `# f; l6 N0 @! n
  22.         {( Y: F$ x9 l; S, l  R3 G
  23.                 ! i& g9 o! q( `% ~, n1 I/ d5 a
  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
    ; Q1 s* R, O/ w6 Z1 `; i; R/ Z
  25.                 STARTUPINFO si;
    ) @: z$ L8 c  n6 L

  26. - h3 l" z' X* F* [$ Q/ Z
  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
    $ |$ S, d3 y( c. y2 R
  28.                 PROCESS_INFORMATION pi;
    , v2 \4 y6 [1 t$ [" I
  29. ! G- S4 G# p5 A3 @2 N: C! s7 s
  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" d% N0 c8 e4 M7 M$ q
  31.                 DEBUG_EVENT dbge;
    . S: l! E0 O( P' V2 W7 V/ Q
  32. 6 E! h5 h/ f5 D9 N) j9 {
  33.                 //Commandline that will used at CreateProcess
    ) i1 p/ _) X/ W( y* j
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    * T+ A9 g! G) K, K) k3 `  B. a' v
  35. 8 A1 B# [0 b) Q# ]/ w6 c; W
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ) P& Q- a/ ?% T
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    % X. [% y: r# H. H2 X" l
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)# t1 I, L/ c# f& w. f$ n

  39. 8 O# g- N6 Q/ V8 z

  40. 9 T1 }! j. d! C: {; L
  41. ' c: j0 N. o2 i! c9 _
  42.                 //Start DekaronServer.exe
    : {5 _/ I3 o$ i9 l2 h/ S: Z5 Y, Q' ^
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    + u/ R: c1 D3 T( J, B' \5 a# ^
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)+ v  ?, P' m& _
  45.                         szCmdline,        // Command line! |- B# H( F- P" z/ G) I
  46.                         NULL,           // Process handle not inheritable
    # e$ c' T- N& m. x% E: U
  47.                         NULL,           // Thread handle not inheritable
    ; s% }$ X. S& Z  g: g  z6 }/ F
  48.                         FALSE,          // Set handle inheritance to FALSE
    6 k) ^2 @+ H& G2 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 _+ Q, w, z* @& c5 i. O7 P: |
  50.                         NULL,           // Use parent's environment block2 E  c9 g: Q, b" R6 Z8 |1 Z
  51.                         NULL,           // Use parent's starting directory 8 l5 E7 V) v9 b6 Z  D  d+ @
  52.                         &si,            // Pointer to STARTUPINFO structure% p, B% b- j* T9 t0 }9 h6 D! J& m# Y# ]
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure( q. b# l+ |- ?& b( s
  54.                 ) " s2 X# t6 R5 r0 j* \; X
  55.                 {3 A/ _. A) G/ Q' o$ E$ n) T
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );  z* s, I3 b. S8 [
  57.                         return 0;
    1 I; g& c- ~/ ?& ^" X9 O
  58.                 }& N$ |) _8 |; Q. |* ~/ x' c  l
  59.                 //Creating Process was sucessful
    , Y, S2 @- b7 E0 h0 A* f& M7 u
  60.                 else
    ; {' ^0 k% l% t* T/ ]1 j& w
  61.                 {1 E. [' y* W, |6 \4 r* h) b
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    , p. a- N/ ?! r7 V2 U

  63. 2 `4 e/ g7 k6 m# u' P
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure2 p, {: m) t+ {( [) z
  65.                         dbge.dwProcessId = pi.dwProcessId;
    5 w$ ^. R* A2 u* L' y
  66.                         dbge.dwProcessId = pi.dwThreadId;
    % N8 `: D8 M) l: L  c: p$ e! k6 l

  67. # O1 k$ F# v* N+ E7 f5 C
  68.                         while(true) //infinite loop ("Debugger"); [. a$ y1 p, n6 h
  69.                         {
    / Y1 {0 [$ Q# C3 R3 o$ L% ~+ D4 o9 U- l
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    5 o: \0 O. [1 g7 F( k; C
  71. 8 A% M# t2 w6 P: j# j8 ?0 q6 H) K
  72.                                 /*) E3 Q4 i  U( g
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
$ W! d+ {  j, z" d( g
' a+ x- m+ i: L. H, }- R5 S
6 u: s* R/ w- c! Y$ y+ M' ^
商业服务端 登录器 网站 出售

15

主题

259

回帖

1275

积分

金牌会员

积分
1275
金钱
920
贡献
76
注册时间
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

主题

259

回帖

1275

积分

金牌会员

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

3

主题

102

回帖

7737

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-23 04:06 , Processed in 0.039909 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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