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

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

[复制链接]

157

主题

364

回帖

6963

积分

管理员

积分
6963
金钱
1986
贡献
4456
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
- A7 v& s- I  q% ^, d9 T- `* k4 @( w, y/ Q) ?( X
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。  R2 O8 k2 f6 p$ e1 b6 W
5 R- @7 L' A& i/ G8 n" X. ~  E# v
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    4 \/ M  n  s! q
  2. //
    ' H1 L% V1 T! ]

  3. 5 @! G& u) T# _" Q
  4. #include "stdafx.h"$ q( L" }! [0 s0 {- J
  5. #include <iostream>" U3 {) h( D: B; e2 e
  6. #include <Windows.h>9 e* B8 J- C/ l: M; C
  7. #include <io.h>
    # c/ w) j6 Y/ r/ ], Q
  8. ' z; {. }  Z( l/ w4 u4 P
  9.   x3 M5 _  c- Z- C. h, v& T
  10. int _tmain(int argc, _TCHAR* argv[])) N. F6 H+ a: j
  11. {
      s4 p+ V* C% T& s9 M: T
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    2 L9 |! `8 U2 e& ]2 g# _$ p. ]4 ~! D5 h) X

  13. & A  T7 s' l0 ?* R3 Z0 c0 o
  14.         //查看文件“DekaronServer.exe”是否存在
    8 {4 j, ]  P: r' W' f: i0 M
  15.         if(_access("DekaronServer.exe", 0) == -1)
    # N4 P9 ]: h# C& f/ r' Q
  16.         {* e- A! Q8 O, b% G6 N
  17.                 printf("DekaronServer.exe not found!\n");2 C' p/ @, P: H8 ]
  18.                 printf("Program will close in 5seconds\n");7 J  b( y1 \) Y" A+ \( N
  19.                 Sleep(5000);
    / N) z1 ~& N. \' [9 A
  20.         }0 s3 v6 q5 g9 s- y; i. y
  21.         else3 L' L4 O7 }& f- ?
  22.         {; J; N: B% N. z* e& l0 `
  23.                
    $ C- r, P; _' P: \" O
  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! J7 @1 W* i6 M9 y- f' V
  25.                 STARTUPINFO si;0 ]) E! K6 }0 y7 r3 H# W2 U8 D
  26. / u8 y. V  V( f" Q5 t+ \) K
  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
    ! Z2 n( H* R/ _& Z6 o1 u
  28.                 PROCESS_INFORMATION pi;
    & {+ o9 O$ w1 k" a
  29. . c  ~: w( O6 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).aspx7 N4 B5 o8 z+ X5 Y0 Q
  31.                 DEBUG_EVENT dbge;, G, p' J0 @. f+ P- K

  32. 5 j/ N) `3 x: w
  33.                 //Commandline that will used at CreateProcess
    4 u( |4 X  S, A# F, O; R7 Z
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    3 ^# H7 X4 ~7 x

  35. + W4 K; z2 g9 F8 ~
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    7 A6 P$ H  p. V4 G% ~6 B
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)/ ~* j( e6 |6 R; @
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)$ u! C& |" G* K! B/ G0 n" n( t* u
  39. 2 ~' t+ {! k! E! ?5 \7 ^; I

  40. 9 w; }6 D1 e. [  W4 I

  41. 9 H( e, H( ?3 P  J% t( _' w; g$ M
  42.                 //Start DekaronServer.exe 2 x: D0 S% m) b8 E: C, g8 q
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx; J3 W  X4 ?0 m, r; }" u5 R: h
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    4 _2 Q, A" o; k- u5 m1 v- ^. f
  45.                         szCmdline,        // Command line
      t5 H- }# f  X, G7 R1 r5 c5 N
  46.                         NULL,           // Process handle not inheritable1 q3 p3 i4 P! m8 T; L, q) O+ k: W
  47.                         NULL,           // Thread handle not inheritable7 b$ o& S# k$ F$ v. F
  48.                         FALSE,          // Set handle inheritance to FALSE7 P, D3 W, E- i/ M4 V. j
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx( K3 q: @6 r7 d( I0 A
  50.                         NULL,           // Use parent's environment block: h" y, B# m7 P
  51.                         NULL,           // Use parent's starting directory
    " U: v7 W2 b" q. c4 y  V
  52.                         &si,            // Pointer to STARTUPINFO structure
    7 {, L& \2 s. h, b! m' I! G9 F. Q
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure6 t3 A( j2 `4 Y" R3 R
  54.                 ) - z, V: ^$ W$ [5 M9 w/ i. l
  55.                 {! L/ a' ~/ Q# T: M, k" Q3 \& ?. ~! M
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    2 D  c+ Y4 t  ^& \( E* \
  57.                         return 0;/ o7 D" X3 i5 e. ^6 L4 M) q
  58.                 }
    % j7 M7 S( U2 [) t  Q$ \
  59.                 //Creating Process was sucessful4 W; M( s: I' M5 x1 x7 z
  60.                 else
    3 o0 R, h& `; r( j0 W' \
  61.                 {
    : T- e. e3 \" f
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    - ]: v# G; f  i1 x9 ^: ]/ y% x
  63. 5 y( n/ J" j, X, Y
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; B' l) P7 f# z) d
  65.                         dbge.dwProcessId = pi.dwProcessId;2 V- k; {, y) V9 C! H* D
  66.                         dbge.dwProcessId = pi.dwThreadId;7 n8 a, H& l2 ^: Z
  67. ) T' b) y# z: m) _9 v
  68.                         while(true) //infinite loop ("Debugger")  A% c+ w, z, S9 C
  69.                         {, d0 Y6 K6 V1 N: v$ U" J
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ' Y5 M2 L6 ^4 P

  71. 8 T7 \' V* B4 a1 o3 J
  72.                                 /*# A: G# b" j' V; Q- E* S& O
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
7 s9 U9 N5 j2 l  R
; k& d3 L1 Z6 E, C
7 j/ m6 `' Q+ G4 [. I4 I- W  ^$ w
商业服务端 登录器 网站 出售

15

主题

257

回帖

1228

积分

金牌会员

积分
1228
金钱
892
贡献
59
注册时间
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

主题

257

回帖

1228

积分

金牌会员

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

3

主题

102

回帖

6937

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-13 23:39 , Processed in 0.029355 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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