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

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

[复制链接]

156

主题

352

回帖

6345

积分

管理员

积分
6345
金钱
1888
贡献
3949
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
3 U$ P- q% O; r8 N- x* R- h1 e4 g4 f' k
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
2 o- n" p- w/ v7 r) Q( F, n5 l/ W  r& b1 {9 _9 p7 D, L
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。2 m' M0 z- f' U7 ]1 ?# K
  2. //
    ! z0 G9 V; i  B/ c/ A! O+ t  ^) O
  3. . ?) v: Y9 u" b4 @3 s
  4. #include "stdafx.h"% J  g6 J; `% D# A1 m
  5. #include <iostream>' w+ v3 Z$ e: m# l. A. o
  6. #include <Windows.h>
    9 x" }$ S" O( n' b8 f& g: T
  7. #include <io.h>
    $ v# u4 w5 w1 P/ U  j

  8. . K# ~. L& f" j# e' t9 n7 H
  9. % T: G' I# L( @
  10. int _tmain(int argc, _TCHAR* argv[])
    - l. [3 A0 o* J5 n* n
  11. {! M; ~9 T- J! S( d4 s* r, M
  12.         printf("Dekaron-Server Launcher by Toasty\n");8 d3 C7 _7 S( U8 K4 j" C  t
  13. / M' f8 ~, j0 f
  14.         //查看文件“DekaronServer.exe”是否存在
    ; c7 a3 n( u) i# ~( i' s
  15.         if(_access("DekaronServer.exe", 0) == -1)4 m  i* x" U1 u7 P
  16.         {  S$ v3 t$ o  h* y- p
  17.                 printf("DekaronServer.exe not found!\n");
    3 v1 X: i6 N  y
  18.                 printf("Program will close in 5seconds\n");
    % b# [: {  h/ \. x( T, L
  19.                 Sleep(5000);9 m- D' l# k2 `3 p
  20.         }, F1 Z( X7 [; P: j5 b" I/ i
  21.         else3 W4 m4 t! Z1 o1 L- _9 \# }
  22.         {
    + d7 U: c$ s4 u0 u- J
  23.                
    8 H" A8 S$ R- C/ [' z
  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).aspx9 P* H4 N  j2 F4 O) }1 J$ C
  25.                 STARTUPINFO si;
    6 d- w" k; ^! E$ D' C
  26. ' H! `/ H( A3 H2 m) K% i5 N
  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).aspx0 a$ V6 w- j3 G1 J3 M% H
  28.                 PROCESS_INFORMATION pi;2 v% _1 J0 R- N$ p9 {

  29. ' ~# ^* k% s/ e4 e2 i
  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( O  q* I0 \3 K2 v6 w, H! B
  31.                 DEBUG_EVENT dbge;
    2 g% s. y- H. C, n

  32. . g% x6 ~* d6 V2 P  r5 f6 a
  33.                 //Commandline that will used at CreateProcess3 @; u% `& E" `2 c
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    4 D$ t3 t9 U2 V$ v( T  q

  35. . j& J7 l8 C6 x3 {! Y: l
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)$ ~5 m5 f0 \4 ]8 g+ I4 Q# _- y% V2 R
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)/ H8 T# }' `0 A3 _
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    , r6 i: l5 V+ l, |! P

  39. 6 D  J) Z& [1 H. r1 X5 S
  40. 2 t8 g, W  `, |- b; {% B" L+ K

  41. + a* a2 e* c3 N' K0 T
  42.                 //Start DekaronServer.exe
    / ~. @8 r" J, _! c' Y
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    6 Q3 o, r" Y; l9 y2 R
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)# ^( I3 g( q) k  u+ A& E, x/ J$ e5 ]
  45.                         szCmdline,        // Command line3 ?' v; T7 B4 v, T, w/ L$ q2 P
  46.                         NULL,           // Process handle not inheritable
    / t+ Q+ v. n0 Z* U8 L2 b
  47.                         NULL,           // Thread handle not inheritable; J# l* @& T" n! d6 ^
  48.                         FALSE,          // Set handle inheritance to FALSE
    ( D& W0 i8 o3 |) Z. ]
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx# T6 n/ ~/ ~/ N0 {
  50.                         NULL,           // Use parent's environment block/ |* M, e/ _* J/ X4 N
  51.                         NULL,           // Use parent's starting directory . W* A& Z! u& x
  52.                         &si,            // Pointer to STARTUPINFO structure6 S6 v) o- w# B7 v3 L% K
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure' D' [# z6 h, J2 y  t/ W8 [+ |
  54.                 ) " {( b6 o( G% L: _4 G" B+ Y+ G5 v
  55.                 {
    : X; ?* u! Z' X! ~% y; U- b
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );+ T4 p2 \! D% g) X
  57.                         return 0;
    9 y9 S  ~3 f& F7 `% p
  58.                 }
    , G/ U. n# |9 [/ ?  d) e
  59.                 //Creating Process was sucessful
      ~9 v. N% x, B, Q7 F9 m) K
  60.                 else
    $ h) i) `6 {/ L
  61.                 {
    3 {  j7 N/ z% J& W7 g
  62.                         printf("Sucessfully launched DekaronServer.exe\n");+ |5 }' S, R% D$ l5 n2 I

  63. 6 N9 n$ Y0 t. a$ J+ V
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    * C0 ^) g; {. e) w% k! _
  65.                         dbge.dwProcessId = pi.dwProcessId;
    * k( Q8 r% e' _: p# _' x1 ^2 C  E( K
  66.                         dbge.dwProcessId = pi.dwThreadId;# U& }" k! ^: U% y

  67. 6 U, }1 t5 k1 p/ C
  68.                         while(true) //infinite loop ("Debugger"), u  g& {. [! x2 I4 C2 U7 ~! D
  69.                         {
    ( j+ f4 O0 {; W4 E  L  I& S2 J
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx2 N5 s9 ~) z- c" ^! v( w3 D
  71.   B% ?4 [: P, D2 u
  72.                                 /*
    5 \$ L: ?: n) Y; C) H
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
  g6 [9 B7 x0 P! y( e
3 x' {; J' l; ?8 {8 N; U
1 x7 Y9 A& j" b/ ^! [
商业服务端 登录器 网站 出售

14

主题

253

回帖

1227

积分

金牌会员

积分
1227
金钱
840
贡献
115
注册时间
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

主题

205

回帖

345

积分

中级会员

积分
345
金钱
136
贡献
4
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

14

主题

253

回帖

1227

积分

金牌会员

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

3

主题

102

回帖

6003

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-17 22:14 , Processed in 0.078178 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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