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

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

[复制链接]

106

主题

128

回帖

1475

积分

管理员

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

% Q' _. l" E4 ]9 F- p+ ~0 d, A# I9 c  [$ a% k) x/ J' Z& J* G5 \9 p
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。! K" @0 }( ]6 u
6 t2 q1 H. B1 C3 Y$ U
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    7 `; H- V1 r) g. c& u) g
  2. //, |3 v& A0 ~, V" W7 e* Z( w

  3. . h, w, F$ C' N" j
  4. #include "stdafx.h"% S* W  b+ b! y/ C" g
  5. #include <iostream>
    $ W* f) \- k, Q3 t
  6. #include <Windows.h>
      O9 O$ h& k# s8 D" S: H
  7. #include <io.h>8 |, ~6 Q  y  w+ x8 }' n

  8. 6 u9 P# G/ N7 D

  9. * n& n! b* Q# p5 {5 Y. P$ ~, p
  10. int _tmain(int argc, _TCHAR* argv[]). \5 |0 A, t- K4 e
  11. {
    3 v" @4 d% N# g9 W0 F
  12.         printf("Dekaron-Server Launcher by Toasty\n");( v, J; c; D# Q9 r8 y& F2 _

  13. 3 _/ `, D' V! |' q' r
  14.         //查看文件“DekaronServer.exe”是否存在9 H/ L/ B2 M- S, V$ ^" {! Q
  15.         if(_access("DekaronServer.exe", 0) == -1)3 N5 o% W/ ?+ W" c$ P
  16.         {( O3 o3 _  q6 g, ~
  17.                 printf("DekaronServer.exe not found!\n");
    6 P, y, V& F; B, t
  18.                 printf("Program will close in 5seconds\n");
    7 W6 T- d5 M! M
  19.                 Sleep(5000);
    4 s8 U6 n1 E. H) [) x* g/ ^! \
  20.         }( T, `0 ?1 ~2 S# d! R* B
  21.         else* [$ L6 h7 V* |4 m5 z
  22.         {
    : B, Q7 [  b' R, U% N
  23.                
    ' b  a, U: m- s
  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).aspx0 d9 j  @8 G! U% W
  25.                 STARTUPINFO si;8 L  E& N) R2 j  I  m4 U9 M
  26. 8 J9 z* G" ~! R# T
  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" v' }/ k4 F* G7 o3 q; d
  28.                 PROCESS_INFORMATION pi;# g% o6 ?: Y5 i* f3 G

  29. ( `& y+ f; I' m
  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% p6 y4 E3 K+ ~$ u6 L
  31.                 DEBUG_EVENT dbge;
    . m3 r5 E; v1 e  Y( X: p- c( g- U
  32. . ^" x/ g& g- U- {8 |- Y
  33.                 //Commandline that will used at CreateProcess
    5 R1 k( L4 J$ S, ~& ]
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    / q& I3 D7 Z& C' p, C* M8 q
  35. : r1 H6 {: ^# f7 C  r  |
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)) ?6 B7 E2 M7 P+ |+ y- P/ s
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    0 b9 V- y4 f$ q# \# H
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    # M* \  d% t6 a$ A4 j- `
  39. / p; A. v# Z! P. d

  40. , B: ?7 i0 m# U$ O; [7 H+ H

  41. , f  S' k) s: r) F* o) p
  42.                 //Start DekaronServer.exe
    " S, f  P/ _# j% g* y& B* T
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx$ c* X( f/ {! H# F2 T9 s  o: z2 N
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ! N9 ?" s' p3 h! ?$ Z$ k
  45.                         szCmdline,        // Command line
    ! g$ T! T  `3 R1 P  K
  46.                         NULL,           // Process handle not inheritable2 c3 \; P3 ^; r! {8 D
  47.                         NULL,           // Thread handle not inheritable' q  d) d. |3 P
  48.                         FALSE,          // Set handle inheritance to FALSE0 R6 {, a1 ?8 W
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    3 R) A# k/ I& Q% N3 }$ Z' E
  50.                         NULL,           // Use parent's environment block
    8 g$ s5 T; |( q& A4 w) l% ^
  51.                         NULL,           // Use parent's starting directory
    6 K6 l+ F& G' T, n. c; W' r5 V
  52.                         &si,            // Pointer to STARTUPINFO structure) `- M) n% B* H  d) V0 J0 P! ]2 ]/ Z! q
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ; X' e& C4 H3 g' }- `
  54.                 ) 1 \. O2 F8 M' q2 g$ [' [5 k
  55.                 {1 U5 P* m0 T$ x3 v. R; B
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    , b/ q* E( s3 l4 k1 B3 ^& {
  57.                         return 0;
    % F+ g2 T- n, y% d9 |
  58.                 }
    ! I3 i. `" G+ W7 m& B3 ?- j* W
  59.                 //Creating Process was sucessful6 k2 Z" U/ T. L! A; d
  60.                 else
    * |9 B9 C) e2 }
  61.                 {
    " W# ?& V2 d# C# ]3 v
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    5 n+ a9 s, j' {3 D
  63. 4 W) ^+ F2 [' s  e, h) ^, h: s! V( t
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    8 D1 f* \+ _' ~. G0 b
  65.                         dbge.dwProcessId = pi.dwProcessId;5 ]: m& @* X, D, @4 W
  66.                         dbge.dwProcessId = pi.dwThreadId;) K* e. y! `9 s$ H  H9 E. F
  67. 0 O: W) `! @3 V: ?7 A
  68.                         while(true) //infinite loop ("Debugger")
    9 g1 F+ K8 _+ w4 N1 K
  69.                         {" {3 Z5 `7 j9 x4 Z
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx9 v( E! [  p& r  b

  71. " l. {( |- P1 w+ c* [1 @
  72.                                 /*" v. h: _) U' _! x6 g- b
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
3 W9 O- A  h; ~  F2 A+ w8 M
! c3 ]; M9 c/ m0 J5 W; j
  X, R; Q1 ^* ]+ d' t. s+ w

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

770

积分

高级会员

积分
770
金钱
284
贡献
90
注册时间
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

回帖

454

积分

中级会员

积分
454
金钱
247
贡献
6
注册时间
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-16 07:11 , Processed in 0.088148 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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