找回密码
 立即注册
查看: 815|回复: 4

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

[复制链接]

106

主题

126

回帖

1443

积分

管理员

积分
1443
金钱
623
贡献
588
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式

- m* `4 }7 C7 n
1 d% Z, }. Z  \1 x虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。' h; A6 g" k2 u! B6 x# D3 b7 o

8 F7 I/ l' H# m7 M; s2 Q" y; C* s8 G
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    4 _2 e' t- t& b2 b7 c% r* S
  2. /// v+ t) ~) a/ t: ~7 _' u8 a
  3. 1 Q/ t& k, p2 D$ B( n3 w9 ~
  4. #include "stdafx.h"" o0 f7 C  @8 f
  5. #include <iostream>
    ; k/ j3 t; Z* B6 J0 }# U6 v3 |  G" e
  6. #include <Windows.h>
    9 R7 }( r0 O6 Q/ R1 o# ~% `
  7. #include <io.h>
    * D6 D6 A# h0 K

  8. - Z2 C; w, G# H* N6 _' g
  9. ( _* C4 ?1 z3 F
  10. int _tmain(int argc, _TCHAR* argv[])) e% l3 c) j( u* g! T' r
  11. {
    - r. v; a2 F' L: F
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    * S4 q7 ~$ h) F2 q+ F- v
  13. : Z9 Z9 o& O8 X: x
  14.         //查看文件“DekaronServer.exe”是否存在' [7 J2 R+ c: u+ r1 {5 J$ L
  15.         if(_access("DekaronServer.exe", 0) == -1)
    & q6 R; k+ E3 I8 e7 N
  16.         {9 w% c& o$ b2 ~
  17.                 printf("DekaronServer.exe not found!\n");% M6 M& e! ^! o) o- F) W
  18.                 printf("Program will close in 5seconds\n");# J. j, x* t7 S& ^! A
  19.                 Sleep(5000);
    7 r7 e2 V9 i: A6 K' {* P$ e
  20.         }- ?# j' h7 _: q! g$ I+ W/ E) i0 `
  21.         else
    ; F+ Q( w8 s% D$ P( w4 q, m
  22.         {
    / a$ L( ?7 Y( Q  i
  23.                 * v% Q4 f  |/ ^6 h$ w. J
  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
    4 v9 x$ [+ O1 ~/ z0 w
  25.                 STARTUPINFO si;/ I: |0 D8 N# {3 y

  26. 1 v9 _& a! U3 h8 g( a* @
  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 o  F2 _7 [0 f+ q3 y6 V' L
  28.                 PROCESS_INFORMATION pi;( \$ |) B5 t) L, p$ ?0 t/ b

  29. ( Q9 _  _5 n% g
  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
    + C2 Y) N! g- i3 }  o
  31.                 DEBUG_EVENT dbge;
    1 n6 z/ e) m! t2 h5 Z1 P" E, e

  32.   v& ^; S: V4 e# ~& n% P5 l3 ?
  33.                 //Commandline that will used at CreateProcess% q* T8 {/ F( z: i2 k
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    1 Y. |3 @" Q' T" n# n
  35. * p) Q7 k. W& d# P9 K- I+ ~
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)& `1 R1 g( g* w& y* }% u9 P, X
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)) K5 v6 k2 G! W8 O
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    5 o6 _7 C+ L: \7 H4 ~' v
  39. 0 @- C3 S" B! h% v% R$ K4 M" y- |

  40.   M6 [! ^5 D3 y' q8 k; ?& Y
  41. " i$ y8 t+ G+ p
  42.                 //Start DekaronServer.exe
      M1 d. ^$ x7 l6 Y9 D. [
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    4 p9 ~6 `8 i: }4 d  A
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    . `9 n" Z! n( x  _; |: I
  45.                         szCmdline,        // Command line
    ) f6 b+ @/ B  o9 Q3 ?- \; z
  46.                         NULL,           // Process handle not inheritable
    6 ^/ G+ b: X8 x: p$ N5 _) q
  47.                         NULL,           // Thread handle not inheritable
    $ P: Q9 v3 m8 P) r* [
  48.                         FALSE,          // Set handle inheritance to FALSE2 J  V! |3 n1 L# ?9 C$ G. R
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx9 J; Y+ d0 h8 V+ W# a, g/ P# k
  50.                         NULL,           // Use parent's environment block
    $ p) B$ K; }) }" X8 ^5 u. M
  51.                         NULL,           // Use parent's starting directory 5 g- V& m2 S9 b$ g# i& x
  52.                         &si,            // Pointer to STARTUPINFO structure
    ; q3 Q: V; ^6 Y
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    + o# M/ ~. Q/ E6 C
  54.                 ) " s6 c0 F( u+ n8 M; W2 t
  55.                 {
    * R" h6 C  k7 S, P
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );/ ^* G$ N9 d0 K2 _, N
  57.                         return 0;7 y. o) d; D- Y' L* l
  58.                 }
    : k' C3 _( D& U0 I2 \
  59.                 //Creating Process was sucessful
    . X2 W0 Q, P2 }1 @. f: ^/ e
  60.                 else
    5 \. g8 s, D& {' p# a) T- j2 a
  61.                 {
    ! `# u) M& c, G
  62.                         printf("Sucessfully launched DekaronServer.exe\n");) K: w+ m0 k/ a* H& p! V

  63. $ K+ V4 `2 f1 O5 X+ M/ t/ U
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure! t# _- k! ?% B: F
  65.                         dbge.dwProcessId = pi.dwProcessId;
    " Z* W/ q- L$ y! X1 i& l0 p
  66.                         dbge.dwProcessId = pi.dwThreadId;
    5 N, a" B6 H" N& M2 @

  67. & `& Z) a! Q3 S' |. u
  68.                         while(true) //infinite loop ("Debugger")
    - c0 o" Q4 D% k/ [8 I
  69.                         {
    * x4 o$ b( F9 m$ q+ T- _! |
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx6 _0 f* r$ E% B) V
  71. 6 m0 i. Y9 P9 r1 I4 W
  72.                                 /*1 F, V) _& F4 A# S0 ^/ H% e, o, L
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

7 e0 K" [' M* m  g, h6 @0 }- E1 V. ~- t4 ]: V3 x! v

9 Q3 ^8 b) s8 p) U5 Q

本帖子中包含更多资源

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

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

8

主题

188

回帖

447

积分

中级会员

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

21

主题

375

回帖

737

积分

高级会员

积分
737
金钱
262
贡献
79
注册时间
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

回帖

447

积分

中级会员

积分
447
金钱
239
贡献
7
注册时间
2023-11-10
发表于 2024-5-25 11:48:57 | 显示全部楼层
每天报道一次!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-2 07:23 , Processed in 0.182237 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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