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

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

[复制链接]

153

主题

334

回帖

5706

积分

管理员

积分
5706
金钱
1802
贡献
3417
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
/ ~% m/ h$ j) Z! x- T7 E2 z* f0 @2 n  |+ i$ Q+ z% }
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
+ {3 \; g( {6 j/ a: U
* _9 U3 v; x$ t8 n1 r; M* g
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    0 b9 x0 X* k% l& i' [
  2. //
    5 B$ w  b! K% T1 S0 U
  3. - a! R% R! Y! |
  4. #include "stdafx.h"; G1 ~) `$ o' h9 a  {
  5. #include <iostream>) j! k5 J4 q) H; [. [7 ~
  6. #include <Windows.h>4 S2 r/ C" e1 Y
  7. #include <io.h>
    6 a$ `" M/ @) |  W
  8. " [7 Q- [% I2 T3 c

  9. ( @# M& d" k) I
  10. int _tmain(int argc, _TCHAR* argv[])3 w, m9 R$ t6 Y% y! Z
  11. {- F' i$ |' i6 c& x5 P
  12.         printf("Dekaron-Server Launcher by Toasty\n");% \' S% z; v7 f& L

  13. 5 y7 \7 @! U# {# Z. Y
  14.         //查看文件“DekaronServer.exe”是否存在& s& s/ k) G2 `! r% P  M& E5 Y6 p
  15.         if(_access("DekaronServer.exe", 0) == -1)2 ^( [) I" U7 o# W  L6 z  @
  16.         {, [8 h: b+ ?6 N) A' W$ Z3 w
  17.                 printf("DekaronServer.exe not found!\n");
    7 \. Q& p- T0 W  m& U; W
  18.                 printf("Program will close in 5seconds\n");9 Q% z# S. v2 |' j- G2 X" y
  19.                 Sleep(5000);
    # k0 k3 g" W6 |( q2 o/ g' i
  20.         }2 i' [, D+ U* k
  21.         else
    0 _+ \/ ]9 F! ?4 p2 k0 b
  22.         {: [+ I% m# A! ]
  23.                
    4 X" u2 V$ g0 w+ f% 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).aspx
    & q, R4 j+ g$ x" M, n/ [
  25.                 STARTUPINFO si;
    : O2 N# K/ n; M4 J. s) ~# k

  26. ! l. i/ |( e: E6 z' N" s4 ?% \( P
  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
    7 i% Q) f) `; c4 A) n* ~. w1 Y
  28.                 PROCESS_INFORMATION pi;
    : b/ d8 @% @2 I7 k/ f* q

  29. 1 c9 n4 w  a; W! L0 U8 t5 Y5 d
  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
    1 D5 v, v; Q6 E5 i7 [% d1 T
  31.                 DEBUG_EVENT dbge;/ d  ^7 G3 `6 P3 j3 d& W2 `
  32. ' [: \( f  b5 t' |! |0 W5 b
  33.                 //Commandline that will used at CreateProcess* G: ~5 N' K5 e' w+ g3 u2 e
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    # L0 v6 @3 S/ Y
  35. 5 M6 a6 `0 y$ L9 {( I" b+ Y
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)+ S+ _, s0 _9 }' H
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)$ b% e# b- U0 ~; i* x4 r2 P% t
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    * Q' t! b: A# C

  39. ) D3 k; q/ s7 X1 Q+ m% O/ G; `+ o
  40. 0 q1 x. M! S: p- j
  41. ; j1 R) R! @8 b1 ^7 x7 ~
  42.                 //Start DekaronServer.exe
    1 N0 {" Q9 H: n( v8 M* N# E
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    9 s8 M5 l6 t8 r1 o* T
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
      E* Y* J9 A) h! N
  45.                         szCmdline,        // Command line
      h7 g, U1 x8 G9 @* \8 S
  46.                         NULL,           // Process handle not inheritable* \# d' s9 k" K
  47.                         NULL,           // Thread handle not inheritable
    . S6 p% S8 H7 I( M: g: d' y
  48.                         FALSE,          // Set handle inheritance to FALSE$ D& j/ C1 r) W0 y; u6 Z9 j
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    4 L7 S, p4 U$ W( _- P( m
  50.                         NULL,           // Use parent's environment block
    1 c) T! q& Z2 v, O
  51.                         NULL,           // Use parent's starting directory : D* z- o% o( S: D  P' e
  52.                         &si,            // Pointer to STARTUPINFO structure
    % f9 I- b. I* v, ~# I: R+ i+ q
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure; g7 E7 p: _% z4 _3 N
  54.                 )
    - p" U- J# ]5 z. b0 d
  55.                 {
    ' Q  @2 q- r8 A
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );8 H# r+ q, P8 K3 x* i
  57.                         return 0;3 ^) R! n$ V8 ?" }) P- ?# W8 o
  58.                 }2 z' [' k3 m% w' R2 U  U% u% I1 |
  59.                 //Creating Process was sucessful9 c5 t: a, y: N& b- y. H5 x0 i
  60.                 else
    # V, l# z6 X2 w) t( ^2 u$ J
  61.                 {" }/ ^' V+ E, L. l; G3 a
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    + U7 u6 ^) y; g' [/ T2 y# q

  63. 5 {' k: S% O7 ]% K% `
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    " q* r0 r+ g  e. b* \, u# J
  65.                         dbge.dwProcessId = pi.dwProcessId;
    + A; ^* K* x! F- [/ ?( K  z7 K
  66.                         dbge.dwProcessId = pi.dwThreadId;  u, O5 l; Z& B4 V1 I$ ^

  67. % q+ b( X: y, D+ l' }" P& D
  68.                         while(true) //infinite loop ("Debugger")7 C7 Y& T3 [  p# C
  69.                         {0 l% G1 B2 @; x3 n) o
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    1 C" d" O' i6 a/ M
  71. 7 @$ {+ O/ a, q+ w* K
  72.                                 /*
    # Q3 \4 j3 Q- Y% l2 h- J
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
) [0 C  l7 y& W* w. H+ K) o
1 S# }% g; i; Q4 q8 ?5 _
* M* A$ J+ }8 K" N% T- R3 @& {/ T
商业服务端 登录器 网站 出售

13

主题

250

回帖

1220

积分

金牌会员

积分
1220
金钱
779
贡献
173
注册时间
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

主题

250

回帖

1220

积分

金牌会员

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

3

主题

98

回帖

5071

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-24 18:53 , Processed in 0.067496 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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