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

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

[复制链接]

156

主题

352

回帖

6247

积分

管理员

积分
6247
金钱
1884
贡献
3855
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) % C+ N! z/ m6 z5 ]# A. q
3 s. I+ I1 X- i& c4 E# H; V
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
: W2 y8 D. _: y  M" P9 I; M! y* _' K
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。3 ~  j2 u1 m3 v. i1 R0 E
  2. //, W: O- T& U/ M2 M# B
  3. ! Q2 L2 _% o' |; W% p" V9 n+ w
  4. #include "stdafx.h"
    5 u+ d1 j5 |6 @$ z) y# o# t9 |# J
  5. #include <iostream>
    0 B" S% E& i: V6 H4 |; \+ N
  6. #include <Windows.h>
    : U3 N, t/ o. f$ R1 I9 n- N  f" X
  7. #include <io.h>3 t- q- @  w! I# P

  8. . h& O% ~2 K1 j+ u& a: E% r9 e

  9. & v0 \! D5 Q" _9 u0 ]
  10. int _tmain(int argc, _TCHAR* argv[])
    ! c) g* H" y# @
  11. {& f3 I' I3 c) L- q" p- }
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    " X/ c3 V# i! A$ V) U% @) N

  13. . A% ^' A* I( y3 z; O* j
  14.         //查看文件“DekaronServer.exe”是否存在
    2 H' N* |0 \. A0 l
  15.         if(_access("DekaronServer.exe", 0) == -1)
    9 @! J  j4 C# M* e& J. U; H
  16.         {5 z( H( D1 w# c# S, S' m6 u
  17.                 printf("DekaronServer.exe not found!\n");: ]' d( x% N8 G
  18.                 printf("Program will close in 5seconds\n");/ b. q* {9 f; ~8 K
  19.                 Sleep(5000);
    . u# I: O* S' g
  20.         }
    / c& ]/ H) \+ U3 N5 {3 s
  21.         else7 S' L; j8 R, w1 g
  22.         {
    ) Y- v- s( X$ T
  23.                
    - G. Q5 @  h: P# w" f# j3 d! @' 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).aspx1 g& y8 V/ F6 |
  25.                 STARTUPINFO si;$ Q  z& M2 r7 _' E

  26. ) h+ h4 u! h! }# I
  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& t$ w4 j' t( H+ G
  28.                 PROCESS_INFORMATION pi;0 i9 U& R3 F3 N  y! J8 W7 K- r' g

  29. $ X& w1 G7 B! T7 o1 \
  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. L# r0 V: D& ?! v6 i5 u5 C: N3 w
  31.                 DEBUG_EVENT dbge;9 Y* K: |2 A# M' X( U3 U

  32. 6 N/ w& t2 r: V0 w3 v9 P$ X( e
  33.                 //Commandline that will used at CreateProcess! B* n* _) Z* R) M" [  L1 ?8 v
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    3 z6 _9 s, ]6 w

  35. . `5 F/ o/ E4 I) E; a# `  B$ K
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)! }  b1 F, A3 {( V
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)2 q' u  P: g) O  F% x4 V
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    7 p; u4 S5 Y0 {

  39. + [6 `! x+ V9 x# f; F  j3 i- f
  40. $ a* @; i$ h: n  A) r

  41. 2 U: L" |- z& X( u- T
  42.                 //Start DekaronServer.exe
    ; ?* ]8 O7 e0 M/ d4 ~
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx* ?) ]3 R/ b% s# o8 q& y. _  T
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)( H- ]9 X' B9 ]" g9 A
  45.                         szCmdline,        // Command line* K/ N' H9 D2 }
  46.                         NULL,           // Process handle not inheritable
    , }' w3 f, v3 S) J" k4 V) H. E( }
  47.                         NULL,           // Thread handle not inheritable( a5 ^+ i2 O3 L& n4 a
  48.                         FALSE,          // Set handle inheritance to FALSE" N& n: ^9 w. C8 _4 y
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx3 _0 M: C0 ~! A# L0 l7 L" y# n2 H( n
  50.                         NULL,           // Use parent's environment block2 Q9 P: T! f) \# d* S5 l. e1 M
  51.                         NULL,           // Use parent's starting directory * D. t& h9 J" D$ @! X
  52.                         &si,            // Pointer to STARTUPINFO structure
      F+ N  W5 x/ M2 ^+ A
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure, M, q! i% m7 R1 S5 E
  54.                 )
    6 \. v) T0 [& M
  55.                 {
    & T+ }, J, |5 s# q2 V
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );0 c6 B/ q6 Q0 n5 \# G: U0 f, \
  57.                         return 0;
    - g7 `0 L5 p0 D1 S7 n
  58.                 }
    , ]% m. |: n* c6 b
  59.                 //Creating Process was sucessful/ s5 _2 f% u+ S# i2 m8 |
  60.                 else
    * s2 n% L& v0 i% Q
  61.                 {# s4 d* o) p% G6 B# Q
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ) k! c. u! }* M3 }- a2 v; [& N
  63. & X3 f  k  |2 K
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure: C5 E2 g. j3 F, ~( h8 r2 |
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / R; D( N* Q9 j; c& X" J2 ~0 T) {
  66.                         dbge.dwProcessId = pi.dwThreadId;
    9 m2 @. {/ h& `0 z. y2 ^- n6 h

  67. & c/ ~* {% s# n* S" K
  68.                         while(true) //infinite loop ("Debugger"); o) L( d: e" T7 Z* q' C
  69.                         {
    / v& u, m" R0 F+ O# U* }
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx% ]- ]; ^5 N5 _! y# U
  71. + f' c  ^9 M' T. `' a
  72.                                 /*' y' C5 a; g. F
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
: g" p8 W; c: P+ O% q
! T: u  v4 S, @! X
% t' f. _. Q+ w* Z& ~7 N3 p
商业服务端 登录器 网站 出售

13

主题

253

回帖

1255

积分

金牌会员

积分
1255
金钱
832
贡献
152
注册时间
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 | 显示全部楼层
学习学习赞赞赞

13

主题

253

回帖

1255

积分

金牌会员

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

3

主题

102

回帖

5963

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-15 03:36 , Processed in 0.075415 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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