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

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

[复制链接]

106

主题

126

回帖

1443

积分

管理员

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

8 S1 N/ p, K; x7 n
  ^6 Z- n' a3 k; E6 q虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。6 h9 U; Y1 D0 c% U

  O( F$ v8 ^% y8 @7 i8 U; Y' V
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。. X7 F( W! A) `$ l
  2. //1 k% ^4 n  {5 `, \8 h" P
  3. ! b$ l) I1 r3 x% E" R) o6 _9 F. j
  4. #include "stdafx.h"1 r' n9 k/ H9 e' q: Z' R
  5. #include <iostream>/ L# d- _) k( s' X& o, M
  6. #include <Windows.h>
    5 e2 g5 w$ p3 H% U4 `+ r
  7. #include <io.h>3 d" a  C% i6 F2 h* L

  8. / @5 ~5 }6 K% L/ U' r
  9. 7 e! n9 a! B) {" Z1 ^! u% N1 g; |0 c
  10. int _tmain(int argc, _TCHAR* argv[]). S$ k2 C( I$ w6 L
  11. {
    ( T2 ^  O( i& M  f' b3 k" P
  12.         printf("Dekaron-Server Launcher by Toasty\n");$ E* x9 Y: B9 |# r; z. m$ \
  13. . g% D; v5 G3 P  u9 ?2 i" ]" p5 ^
  14.         //查看文件“DekaronServer.exe”是否存在$ x; R$ a5 a$ L& H6 F
  15.         if(_access("DekaronServer.exe", 0) == -1)
    & @# ]( \4 {! O$ ^6 a
  16.         {
    # J" B' f7 u" ^4 S
  17.                 printf("DekaronServer.exe not found!\n");! C- j* \8 ]8 @' V7 ]" r
  18.                 printf("Program will close in 5seconds\n");
    4 [0 P6 ~2 f) r. U' c
  19.                 Sleep(5000);
    # G0 O( m" p5 z0 r: \% U
  20.         }3 v: Z4 J0 h! Q  E& o/ K
  21.         else; v. ^' h5 b3 ?4 y4 B  ~2 w9 r
  22.         {
    2 h( n9 j3 J  D4 t" f3 v
  23.                
    4 h+ @) z8 N! ?$ q
  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% ~. S" g- Q( _; J( L8 b
  25.                 STARTUPINFO si;2 U1 ]6 }! U& D+ s5 V
  26. / c# M! _# |$ K0 F* q
  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
    # ^& Z* l, n3 |6 N# z2 A
  28.                 PROCESS_INFORMATION pi;
    0 t1 {9 C3 S' z; v9 N

  29. ' a. m' k1 i3 E. S/ F
  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).aspx1 D" a+ w- V8 h" R# J) j
  31.                 DEBUG_EVENT dbge;
    . x1 S8 _! P7 _- s+ T$ z" \% f
  32. 6 I% j' H9 c  z, x2 G
  33.                 //Commandline that will used at CreateProcess
    ! @+ L$ x6 D; ]" j; w1 |) ]
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));0 u' m) H5 N; x

  35. ; W" P) ^8 D" [
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ' B4 n6 M" d4 t1 Y4 d% e& m
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)$ w5 ?7 c9 C9 V- z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    # {8 D7 B8 ~; b4 G* t

  39. : N) A7 f) w" t$ E! S' \  _
  40. & G8 F  V& J* ?1 a, S$ G
  41. - |& f& t5 H% h6 f, r, e4 W
  42.                 //Start DekaronServer.exe . ?" }4 L  d. T
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx1 o% e9 F& W( |6 H- `( ]  \
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)) n; Q' N4 o* G
  45.                         szCmdline,        // Command line' U6 s: B5 X7 Z' a. ^4 L
  46.                         NULL,           // Process handle not inheritable
    # a4 n8 b" ~/ h
  47.                         NULL,           // Thread handle not inheritable! ]* f6 f8 z5 I( r) v) F9 W
  48.                         FALSE,          // Set handle inheritance to FALSE
    , M: l1 A: O, t/ ?3 P. q; `! `
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ( v: H3 ^/ @; X8 F
  50.                         NULL,           // Use parent's environment block
    ; l3 N( v! E2 Q+ K
  51.                         NULL,           // Use parent's starting directory
    2 i6 K8 g) r5 {1 {2 E- m5 R
  52.                         &si,            // Pointer to STARTUPINFO structure0 M; \6 X6 h+ ~7 X* \
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    9 J# k* E1 o: I# a$ {, K  ^  E
  54.                 ) ) Q+ T  k+ e" l0 J, w
  55.                 {& W4 Y) Y' R, b
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    1 q5 v' U1 M: `! W) e/ l( h
  57.                         return 0;
    - q$ v7 ^- n) _2 C
  58.                 }
    9 `3 `+ V  \" O6 f7 W% N* A$ e* N7 W
  59.                 //Creating Process was sucessful6 s  E& D3 }  X' }7 {
  60.                 else. T1 I' o8 Q7 Z* }- W" k, L; E/ D
  61.                 {0 V1 i# g5 I$ Z0 ?# W" E. M
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ! |  q( g, {% S" B
  63. . D2 Y- @2 S9 _1 Q/ C
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ; C2 e% P; }1 ]! e
  65.                         dbge.dwProcessId = pi.dwProcessId;+ G5 ^/ Z  b/ V! Q) i% n. I
  66.                         dbge.dwProcessId = pi.dwThreadId;# f$ w2 m. T) n4 j. p4 K
  67. 3 w' f2 u5 ?& D3 A0 R& b4 i
  68.                         while(true) //infinite loop ("Debugger")- ]4 c2 @) `* l
  69.                         {, D  D* q, q( N8 N) C+ a0 [
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx" ?) q$ P& t' n# n5 Z; X+ a  W

  71. & h) j) z& v+ M) D5 n# E7 D0 g# w
  72.                                 /*
    2 l4 |" X" c0 H6 `4 {! W' L
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

+ s8 k; |% a) w) e6 N0 I5 }4 G4 J6 }5 X% U
+ A! F0 b5 h$ W; F/ G. h' c

本帖子中包含更多资源

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

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

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
发表于 7 天前 | 显示全部楼层
每天报道一次!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-1 12:37 , Processed in 0.170601 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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