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

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

[复制链接]

106

主题

128

回帖

1466

积分

管理员

积分
1466
金钱
629
贡献
603
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
; m9 ]- q- D; [  ^; G. F& [( b. D
+ W. W5 p7 n5 U7 G% T
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
3 T2 A6 R' r! B# h5 W4 L% ?) |" E4 \2 @' T
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    2 k3 ]* H' V7 T; [+ E+ K( S! L' j
  2. //
    7 I( q- Z* O8 W( `: Z  a, s

  3. . `+ h( o: L8 N0 `
  4. #include "stdafx.h"5 q) T0 A  u. G; m% w) `4 _
  5. #include <iostream>
    6 Y6 B+ W) l+ P2 I$ A
  6. #include <Windows.h># r( h# g5 ~$ `) L# A' j
  7. #include <io.h>
    3 ]- ]1 Q  L6 p4 M6 F
  8. + k0 a5 W' ^9 r- N" a9 \3 [# Q$ q* G1 ]

  9. 1 ]8 G: Y. B% _) ~
  10. int _tmain(int argc, _TCHAR* argv[])
    8 h  q. v; B6 E: H3 G0 k
  11. {# m2 d& C0 m6 |# S! W
  12.         printf("Dekaron-Server Launcher by Toasty\n");1 y, |) O3 Z( R  F

  13. & [% q* r: W1 D- a0 x6 W! |
  14.         //查看文件“DekaronServer.exe”是否存在
    2 |6 o! v* R: a! f; Y% J3 X
  15.         if(_access("DekaronServer.exe", 0) == -1)
    8 j7 G2 `5 m& K1 V
  16.         {8 c' ^4 }* W: d* ^( S- L4 a
  17.                 printf("DekaronServer.exe not found!\n");/ ^2 g# C. X! H7 z2 F. c/ ]
  18.                 printf("Program will close in 5seconds\n");" c8 F' ?( L/ G) n7 B! E
  19.                 Sleep(5000);
    ; H: u4 O" l! ?7 z! c
  20.         }
    / v; P# L$ A6 v1 |
  21.         else
    : V/ s0 G7 b  z0 D6 `# D  N
  22.         {0 ]" n, t# _' ~+ {  ?6 q- u% f2 j
  23.                 0 N( y+ m/ t) z7 N: L
  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).aspx7 K6 u: p/ m8 }* @* O
  25.                 STARTUPINFO si;
    , }4 \4 t$ L* Y8 X! w
  26.   x2 Y. J3 |% 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" J: K2 }% M3 t# J  H
  28.                 PROCESS_INFORMATION pi;, s& X, V7 x3 m1 n3 N1 D* D
  29. 1 K* h) I5 S8 A( 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) @) x9 ~5 v# |8 h, P. @
  31.                 DEBUG_EVENT dbge;# F6 v8 q! j' I+ `: M/ u* ~9 ~
  32. 9 w. f3 n) e% Q- E8 J
  33.                 //Commandline that will used at CreateProcess
    % G5 a3 C" ]( |  w! l
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));7 ?) n, S& P: W1 F. V5 D' l

  35. 8 S6 b0 d5 C! o, I2 x5 R
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    / o0 f3 G0 b: y+ G# a7 \" t
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)5 z1 o' W9 p6 t! d6 ^) Z4 T
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)+ B9 ]7 \3 a: E1 E" G
  39. : p7 l9 U; E% N5 J6 k4 C5 c* j

  40. 2 t4 u4 T$ p& Q% ~; m& Q, v

  41. + t. X6 ^$ U* I9 S" y
  42.                 //Start DekaronServer.exe 9 g$ d6 s  Z- N! E3 n/ ^$ i
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx; x/ l' S( k/ S! Q! A8 @& m
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    $ l9 d1 y' L8 [5 Q/ u
  45.                         szCmdline,        // Command line2 i8 c3 C' I6 W; S4 V
  46.                         NULL,           // Process handle not inheritable  d9 o8 Y) w8 E) L9 ~* d: j7 k' x
  47.                         NULL,           // Thread handle not inheritable- {) b5 }' Y/ k1 F1 e: j
  48.                         FALSE,          // Set handle inheritance to FALSE* M* q3 z) T2 S5 L
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    * s6 _; [& k" l) ]
  50.                         NULL,           // Use parent's environment block
    $ G+ l( @; [! N! [
  51.                         NULL,           // Use parent's starting directory
    % [9 j% A% O) q# p  Z, |
  52.                         &si,            // Pointer to STARTUPINFO structure( |) d9 w. W) M+ Y: v
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure) \( I2 S4 V/ j0 \
  54.                 )
    " w2 y; J* D% J, K
  55.                 {
    # w2 O9 y# |5 C; p0 p
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    7 ]5 Z" C0 E) F  b/ v/ Z
  57.                         return 0;
      D& F+ d3 u+ ^3 E3 \, p
  58.                 }' @# b+ k- l* \# ^. y
  59.                 //Creating Process was sucessful
    : M+ I7 B" Q( d9 T; s1 f
  60.                 else% x! v6 T; q, V  o5 w
  61.                 {) _% D; L4 D) E5 ]
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    . C5 g* r- ?& K# J9 D* |/ F/ V
  63. & ]/ B* h/ V4 a% H8 k5 h
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ' |; b% S& Y. O  A! J' }; X* U
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / S) C6 k4 a8 x: N# i! {
  66.                         dbge.dwProcessId = pi.dwThreadId;
    2 I0 l3 ~7 G' b' h& q

  67. ) z2 I- l" [' s
  68.                         while(true) //infinite loop ("Debugger")6 u( S- d+ Y3 I- [
  69.                         {
      S( X/ A  v. P7 c
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx! \, p2 H# A6 {  P, E  L' p

  71. & s2 ]4 @; n) E. N& S8 ]% N; ?$ {' P
  72.                                 /*4 m& Q& Q- F1 f
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

9 L6 n& K+ M/ L6 f9 m
& F9 W, {1 {! A7 e1 U
7 _8 j) D0 [5 o' T! b

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

755

积分

高级会员

积分
755
金钱
274
贡献
85
注册时间
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
发表于 4 天前 | 显示全部楼层
学些大神分享,受用了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-9 10:38 , Processed in 0.183915 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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