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

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

[复制链接]

106

主题

128

回帖

1497

积分

管理员

积分
1497
金钱
637
贡献
626
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
/ z1 `3 k3 D6 j8 q
9 d1 c! o0 F8 K1 {1 D
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
* ^  @6 H4 i5 S; A9 F) h- m8 _3 n( X5 i/ @1 X; C$ m& U
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    6 Z4 {5 f# w; o  C( ~% l  t
  2. //5 L/ x$ ]; B5 S( E
  3. - i7 g# C, d% J$ y& S' H
  4. #include "stdafx.h"( S4 P: u! c; a! q: s$ b% {
  5. #include <iostream>9 A2 J9 ~% r3 K1 b  N! ]. N5 d
  6. #include <Windows.h>
    " k& j9 |$ O$ X0 n7 K1 c5 i
  7. #include <io.h>
    . c& K( l+ d: v8 C$ h

  8. 4 T; b0 V9 t) `+ S

  9. 6 j0 l- n% r8 P8 E6 |, s+ J
  10. int _tmain(int argc, _TCHAR* argv[])3 p6 N: W( r4 L( p
  11. {0 o1 a" h" \5 z/ y) X2 f+ S
  12.         printf("Dekaron-Server Launcher by Toasty\n");; c2 j+ t0 v& s( {) C$ n* f

  13. 0 l0 q. N! J( `. C9 y% ^" O
  14.         //查看文件“DekaronServer.exe”是否存在7 x4 ]# p, K/ t8 N& a
  15.         if(_access("DekaronServer.exe", 0) == -1)
    $ ?% ?! ~2 f1 u: Z2 `" k- o
  16.         {
    ( N4 u! d/ g' c8 Z
  17.                 printf("DekaronServer.exe not found!\n");  _9 K3 w" N; G
  18.                 printf("Program will close in 5seconds\n");
    ' Y4 Y5 f, ~2 y) A2 n; |. ~
  19.                 Sleep(5000);
    5 i1 n# U# N& p  E1 N/ C
  20.         }
    * p" ?/ ]; w. V( d1 H4 L: \
  21.         else
    - Q5 V: ?9 R9 l2 s2 v: S
  22.         {1 f" Q8 y. h) }& G* @/ ]
  23.                 * t) D% c$ Y; I' U- \
  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: N$ _5 m, S+ y
  25.                 STARTUPINFO si;$ _! U$ _1 {7 ?- [

  26. $ G% `) y5 j$ y
  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
    ; ~, k- {, A- p3 u$ @; \; y
  28.                 PROCESS_INFORMATION pi;* `! e, Z7 o# I2 s3 G* W

  29. % e9 m# c8 A% f5 k' `" 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
    4 W) b/ M0 w) Z; f$ I
  31.                 DEBUG_EVENT dbge;
    . R' \. B3 x( y5 k: s# v" m: a$ U& a  d
  32. 3 @7 E, u4 `4 D
  33.                 //Commandline that will used at CreateProcess  S  y  I( b) y* c0 b- P
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));1 a+ _' P# a, S" n8 X4 Z3 `" U5 ^
  35. ; V! r! A: }, l
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    9 _7 e" I* p+ ~* @7 M2 h/ N. m
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)9 W8 ?' }8 u$ g: G% M5 m) U
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ' A( `2 g- B6 P$ j$ Z: C

  39. 2 b/ J% D/ a3 J5 {- D
  40. ) |; L7 U3 O& s0 D

  41. 2 {" V6 f# V3 j7 b  c2 _. n/ F1 A
  42.                 //Start DekaronServer.exe 6 |, W7 o  |, d( Y( ~# n
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    2 C( g3 p) f, w- c: _
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)- F& B+ Y2 b5 G2 I) Z2 j
  45.                         szCmdline,        // Command line; f5 ?  J" I8 G) t2 a6 q% p- |) i
  46.                         NULL,           // Process handle not inheritable
    $ j, T8 k- L  g5 I
  47.                         NULL,           // Thread handle not inheritable7 F/ C2 G9 O7 w) ?7 l: ?3 {
  48.                         FALSE,          // Set handle inheritance to FALSE7 s) Q) G2 }8 H6 d3 u* f6 n% B
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx7 K- S  g" [3 [1 u! ?
  50.                         NULL,           // Use parent's environment block
    # @+ d4 U: M0 K4 ^- j( k+ X
  51.                         NULL,           // Use parent's starting directory
    4 e( T* ]: M4 j  k  ^& y
  52.                         &si,            // Pointer to STARTUPINFO structure5 k$ b) L' D% P/ b+ F
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure5 k7 p+ U/ b0 Z% F
  54.                 ) 1 l* S1 z% r0 U6 Q; M
  55.                 {
    / P# n: v1 \5 j6 ]1 r
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    + O- w  {" K# \+ M4 k) B' @+ k
  57.                         return 0;
    , K! G# _' x6 j6 u: F
  58.                 }: L. c  L( a- ?: ^* G
  59.                 //Creating Process was sucessful
    6 q: F4 S- V$ A+ X# o0 T* l
  60.                 else
    / d4 w4 b- b( D- e: w* e6 `' v" K
  61.                 {
    # F2 B9 }, S# F, [+ M9 E# m8 l
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    $ d) ~) m- O2 l- i) f
  63. 9 d3 h, X+ O" Y
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    9 t: ?( n+ r. B0 q( @, P
  65.                         dbge.dwProcessId = pi.dwProcessId;( D8 i  g6 m# }- C  t1 ?
  66.                         dbge.dwProcessId = pi.dwThreadId;
    , N1 |, N" j( q9 ^2 V+ ^3 O
  67.   P- D! f% J9 ~0 d- G2 a9 Z
  68.                         while(true) //infinite loop ("Debugger")) x' J& ~: d7 J" M; f, C
  69.                         {# W+ J- s& U# I& |5 W9 j: P
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    6 q3 e- m% d2 U& h% y5 M
  71. % v$ k+ X- V: P0 {; i
  72.                                 /*
    5 M( t0 c: _  C. G
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

# c& H7 v8 J: @3 d. H4 }7 i# {! z$ J2 B2 P, C6 k5 X7 K

* x- i( |& q  `' E' W

本帖子中包含更多资源

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

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

8

主题

189

回帖

459

积分

中级会员

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

21

主题

375

回帖

776

积分

高级会员

积分
776
金钱
288
贡献
92
注册时间
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

主题

189

回帖

459

积分

中级会员

积分
459
金钱
250
贡献
7
注册时间
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-18 21:20 , Processed in 0.071737 second(s), 32 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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