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

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

[复制链接]

157

主题

362

回帖

6846

积分

管理员

积分
6846
金钱
1946
贡献
4381
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ) w4 W$ B) V+ ]; n4 a. X
/ F) C* P+ a! U$ M
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
- Z# z! \; Z% |
0 U4 Y" K' p. t5 n3 K+ ?! x% U+ i2 a
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。3 _8 m. G8 m$ P3 U* Q
  2. //
    ! t% h  \" t7 u# Y1 p

  3. ) J9 k/ J; p; O; Z
  4. #include "stdafx.h"
    * }2 u9 S5 B, H7 x
  5. #include <iostream>  x* C+ q5 Z, O) m, ?- j- [/ J
  6. #include <Windows.h>
    - l' `# }- h4 y& S  R+ R+ c
  7. #include <io.h>
    1 K$ d) O) I) D- ?

  8. 5 Z6 T! A% _& p1 C- y

  9. 1 J# V1 g0 o( I1 \
  10. int _tmain(int argc, _TCHAR* argv[])$ A0 r3 x5 H+ D5 a6 S  W
  11. {/ L# ]0 h% Q6 L( W) u
  12.         printf("Dekaron-Server Launcher by Toasty\n");2 e) o9 @6 y0 `9 u- w) P+ C
  13. + s( f! q3 A0 T) X; W# i
  14.         //查看文件“DekaronServer.exe”是否存在  ~5 X  i6 H+ Z+ W
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ) [) S3 H$ n& b% m& m
  16.         {9 [. W9 H, m* M! Q. a" ?
  17.                 printf("DekaronServer.exe not found!\n");
    + [8 Y- _2 s" U7 `
  18.                 printf("Program will close in 5seconds\n");
    $ @  F, |# L+ s8 x; G7 \( c4 U" Z. ]& x
  19.                 Sleep(5000);' {$ }7 F6 j% S" w) g  ]
  20.         }
    # j$ l1 ]4 G! d) J' a& Y
  21.         else3 X4 j  P, H- f# K2 J
  22.         {& R1 b+ C, n5 C# e6 Q8 a
  23.                
    % n  h. W3 b" G: k
  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" @( K1 N9 V: g: x% Y- N1 U: ?
  25.                 STARTUPINFO si;; g  ?9 H& P5 K5 v( y8 [7 b' u
  26.   r' q5 m$ x2 w3 N; m1 S" [7 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).aspx
    7 O7 L8 r& v- _5 }  W; p) @& [" x
  28.                 PROCESS_INFORMATION pi;, E' ?" K# X& F! s7 ~1 M4 T
  29. 8 g% y& C. K" y
  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
    : F: L% ^- F- q. b' H
  31.                 DEBUG_EVENT dbge;
    . s) g) M9 c7 Q& V0 V  a% r- D

  32. 0 `. D5 m7 V3 N) w! _
  33.                 //Commandline that will used at CreateProcess4 r5 K2 {9 r6 ~' U
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));* F, v! L- \5 a& n. n# U/ D! I; ^
  35. 1 J+ y! r$ g1 l' k7 c6 n( `2 P' q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)- S5 j- v, n- F* J; v4 \% G
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)! a% A2 h) R. H3 `7 }* x% Q1 u" |
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
      Q4 |+ |  |# j; i; [+ e' M
  39. 0 \5 C4 s' ^8 M

  40. % Y* o& [7 Z# p0 g

  41. - c4 K2 Q0 n; [2 A! V
  42.                 //Start DekaronServer.exe 5 ~, i  l6 R2 r/ Z/ v1 ~- k
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx9 M2 [+ H4 F) `8 u: u
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    6 ^+ h0 h, ]& f5 @% l5 L4 @
  45.                         szCmdline,        // Command line( `/ Q1 d) q# q! W( R
  46.                         NULL,           // Process handle not inheritable, B% f' T2 d7 e2 ^1 }5 u
  47.                         NULL,           // Thread handle not inheritable
    6 g( s$ H. b0 ?9 \  t4 z5 W
  48.                         FALSE,          // Set handle inheritance to FALSE: C% Z; ]6 M8 u& I6 D' \9 C
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ! f, C! f" k1 c, H! I3 d8 m" n
  50.                         NULL,           // Use parent's environment block
    / j  R0 O9 l8 W& k
  51.                         NULL,           // Use parent's starting directory & v: J* \+ [- X9 @% C1 V% M  g
  52.                         &si,            // Pointer to STARTUPINFO structure  u7 U/ N) Z2 [& m* ?1 `) v
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure  A9 y: M3 Y0 c
  54.                 )
    & q4 |  Q- e3 p, a0 `
  55.                 {
    + d7 B* l! A7 s: T* H0 D/ h  \# s
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    4 o) v" C4 \& o4 a1 s- E
  57.                         return 0;
    3 L6 u, d" d7 l1 f
  58.                 }( U$ x* D7 Y! b
  59.                 //Creating Process was sucessful
    , m5 O. Q9 N- |, v+ D( ^" T
  60.                 else+ l; H% R% ~' B6 C' _$ k' x
  61.                 {) V' x2 }( i' _- b4 A
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ) C- J: L& b5 N/ X' R7 e
  63. $ [, U! [. B& L3 e; {- i
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure* }% q7 v5 t* u
  65.                         dbge.dwProcessId = pi.dwProcessId;' i; ?5 z" v$ Z2 y4 h
  66.                         dbge.dwProcessId = pi.dwThreadId;
    5 \7 O* b* N7 v: s0 |% H% e! f) S
  67. 7 R! f8 [4 T7 h' G; G3 K. f" \
  68.                         while(true) //infinite loop ("Debugger")( V! J0 `6 {/ A$ D2 }/ x
  69.                         {
    5 B# i# f6 r: ~) [0 l3 H
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    $ _- K. C; u/ X8 B! l1 G6 U% ]
  71. 9 q- q" @2 n. o$ j6 |( }
  72.                                 /*: X' h/ V! L* q1 \1 S$ x
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
3 C- c9 A8 ]  a( v  p2 B

# k9 I( D0 A  n1 Z  N. O8 R5 O1 ^9 i" X1 r* f
商业服务端 登录器 网站 出售

15

主题

256

回帖

1271

积分

金牌会员

积分
1271
金钱
875
贡献
120
注册时间
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

回帖

1271

积分

金牌会员

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

3

主题

102

回帖

6581

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-19 08:32 , Processed in 0.057998 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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