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

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

[复制链接]

157

主题

361

回帖

6832

积分

管理员

积分
6832
金钱
1941
贡献
4373
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
8 }, E# j$ N5 F; n/ _* Z8 B/ Q* J0 B. i; t
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
& s+ f9 H9 o# P" C* f
% M" j- y* ]1 B
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    % N  C7 Q. R; R& F( v
  2. //# c: V& G7 s4 S; H, ^, G6 j/ C

  3.   b0 H: p4 w7 L' Q7 H/ i4 D! W
  4. #include "stdafx.h"$ n8 l% @, T2 \, p/ J; ^
  5. #include <iostream>, O6 y1 a9 Q7 t% }5 ]
  6. #include <Windows.h>
    & m+ M5 V  R/ j9 C+ U% g0 b# Q
  7. #include <io.h>
    5 B6 k& x* _( g) `. q
  8. 3 {: J) p0 g  J; w# v
  9. 2 q. S$ Y1 A' E
  10. int _tmain(int argc, _TCHAR* argv[])
    " S& v; g" ]3 J
  11. {
    + |8 T7 {9 a* p, h* J
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ) y: _8 y0 G* \3 q! ]- ^  ^- D- m. |

  13. 7 I7 ^2 X. ]& ^! ~- g" `/ z& e5 O
  14.         //查看文件“DekaronServer.exe”是否存在
    " |6 ~! S2 c( }( O; m, H
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ! n/ O# f* n+ Z% i
  16.         {
    4 j) J- P. d" y* {/ r
  17.                 printf("DekaronServer.exe not found!\n");1 \! f4 ~$ r- V4 D
  18.                 printf("Program will close in 5seconds\n");
    & w0 [& {, O# y+ v! S  E
  19.                 Sleep(5000);
    ) w/ \* ]& Y- F: ^& |, T! J7 p
  20.         }$ n3 ^& ^" N% c; W& m
  21.         else
    * f) m& K+ x# s/ P9 ]
  22.         {/ S  H7 @  s- V2 @# w2 w' W8 g  D
  23.                
    : p1 H) U4 K6 X$ I& a
  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
    ' u  T) y# s( i9 x# m( L( q
  25.                 STARTUPINFO si;
    . _; h: i; d) p
  26. 8 j: r8 K( j3 y
  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).aspx2 a( ]7 Z0 i0 B7 F
  28.                 PROCESS_INFORMATION pi;2 A4 W) D; P7 O9 o9 d# _

  29.   r$ [* j8 s6 u: {9 ^
  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' `# K6 I! s0 I) |2 L. o: H
  31.                 DEBUG_EVENT dbge;* Y! I# z  Q' m2 Y" F- B) @% U; N* o8 g

  32. ; X7 u6 H# {* C' R  Q/ N
  33.                 //Commandline that will used at CreateProcess% \9 p. C$ `  H( ?
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ' S  d5 ]+ I$ e
  35. - ]1 K/ ?- N: C& ~
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)8 Y) {$ Q' V% r- q
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    ' F) E0 ?0 g. j+ j
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    * Z! k$ b, z$ L7 {

  39. " [( k: ]8 T: y4 D6 P% a9 ^
  40. ; Q& l+ l/ w# E

  41. ( t4 ?6 m7 @" f( e! c6 I' u% D& W
  42.                 //Start DekaronServer.exe 6 i# A7 G( M  R4 B  `/ G
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx3 C7 m9 a, e) ~
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
      s: x5 [# C' g3 |& f
  45.                         szCmdline,        // Command line( ]5 S% J( T! p2 w4 {$ z9 R! p
  46.                         NULL,           // Process handle not inheritable" R' |  i( T. _& b$ R) H
  47.                         NULL,           // Thread handle not inheritable
    9 v  Y3 l" f8 q2 O. w: y; d, E, Q
  48.                         FALSE,          // Set handle inheritance to FALSE
    ; j  @0 `  m9 I" b$ {4 M4 W! k4 J
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    % ~8 @, j  W- k5 ^5 e1 p' q* m) E" p
  50.                         NULL,           // Use parent's environment block! a- d. A5 s3 x: _
  51.                         NULL,           // Use parent's starting directory   o3 P  c$ p4 m. f: E
  52.                         &si,            // Pointer to STARTUPINFO structure4 ]8 ]/ C: A0 |4 |* `3 ~# Y
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    , J  L, u; g2 Q! D0 U& w% u
  54.                 ) . {( \: q8 l  }
  55.                 {0 C$ \- ?6 e: w+ j! B
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );/ \; {+ i4 d+ a- t
  57.                         return 0;
    $ @2 v. Q8 P0 T% g6 t! O0 C. }9 o
  58.                 }
    " S7 Z# L: O  I# x- W5 c* |) M
  59.                 //Creating Process was sucessful
    $ y3 A" L' ~* `- B& l
  60.                 else7 B" v1 K6 j  d9 o0 y9 f0 O
  61.                 {/ w$ W& h1 b: g  n( }: Q
  62.                         printf("Sucessfully launched DekaronServer.exe\n");) M; W! I9 P4 ~1 H# g0 {- L

  63. 5 y1 u: E9 J+ u( m
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure! ^8 T) N. H# |9 w& Z; K
  65.                         dbge.dwProcessId = pi.dwProcessId;
    * o, A8 V, k) X' j+ ]
  66.                         dbge.dwProcessId = pi.dwThreadId;" [$ V) r2 v- p1 R6 i" L
  67. 0 _0 [0 M8 u3 V) ~# ~% g; K4 Z
  68.                         while(true) //infinite loop ("Debugger"): p0 M$ l: n  x2 Q5 ?2 j! y! l
  69.                         {
    2 _  |/ g- S6 p6 k8 K8 q
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    / w3 C1 O# D9 Z) o- S
  71. 4 U3 g' E  W/ e% @
  72.                                 /*
    - J0 d4 M: r2 b2 v6 Q
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. @! i3 S1 ?/ |9 e+ z  O2 p$ }

# F, ]9 @0 j. Z
( s' i; b  X& R  e
商业服务端 登录器 网站 出售

15

主题

256

回帖

1268

积分

金牌会员

积分
1268
金钱
871
贡献
121
注册时间
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

主题

207

回帖

352

积分

中级会员

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

15

主题

256

回帖

1268

积分

金牌会员

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

3

主题

102

回帖

6501

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-13 22:41 , Processed in 0.062237 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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