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

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

[复制链接]

160

主题

385

回帖

7389

积分

管理员

积分
7389
金钱
2121
贡献
4723
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) & k9 W1 w$ p; e4 u1 w
: L# R( Z2 ]/ }* m+ X' }  C$ \
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。: ?4 d' L6 a# I) g
' J0 Z+ C3 H, J
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。1 h; g3 \  H1 y4 i+ g8 Z" t
  2. //
    ) ^' p3 o& ]) z/ l$ S6 `1 J  F7 Z6 C
  3. . }( L6 x  I9 T8 a4 Y) r
  4. #include "stdafx.h"
    3 `1 W: a  w- s, n% p# j" F
  5. #include <iostream>7 J7 H! G% n- z
  6. #include <Windows.h>& H; b) p$ m+ j3 X. @
  7. #include <io.h>* Y$ K6 W5 C% {
  8. ! t6 J6 L1 G$ a3 e! g) V( a: b
  9. 1 u& W: R2 Q! p6 e/ h
  10. int _tmain(int argc, _TCHAR* argv[])
    1 v5 f7 ^- A' C: p/ N" j; B5 u
  11. {
    ' m& _; ~2 O; ?- E  b) l1 f
  12.         printf("Dekaron-Server Launcher by Toasty\n");! ?2 p# E" E. W6 D2 `4 e2 T
  13. ) K; m% ~& G2 R! Z
  14.         //查看文件“DekaronServer.exe”是否存在8 g1 z* ?, {: e5 l& F
  15.         if(_access("DekaronServer.exe", 0) == -1)' z3 K- M& l. ?/ E; X
  16.         {
    . z+ a3 ^; ^/ P5 W% y
  17.                 printf("DekaronServer.exe not found!\n");
    & ^2 q2 ]2 n% S
  18.                 printf("Program will close in 5seconds\n");
    ( W- \0 ]  K& t) ]: }6 F
  19.                 Sleep(5000);& s$ u# E5 j: N4 N! G
  20.         }
    ' ?" o: O7 A$ ^+ B3 Y% t. @8 d7 j
  21.         else) I9 l5 A; C- h, ?( a7 N( q
  22.         {3 H9 t: x; y7 s1 P1 l  `- H
  23.                 0 |( C0 m4 t  {0 Y
  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# y. ?/ a0 f+ V+ Z9 i  _
  25.                 STARTUPINFO si;
    ' l1 C: O& o3 J4 Z

  26. 5 F) G. E7 l; h& j: [
  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- @3 V& [1 o2 b! K' D
  28.                 PROCESS_INFORMATION pi;
    * B0 A! j: {; w
  29. 4 t0 t+ s9 H; M+ G# q
  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).aspx4 c" W# W: m; _7 q9 F. L
  31.                 DEBUG_EVENT dbge;
    * u9 W  O4 X8 u
  32. ( P& C! i* q3 Y' I3 a
  33.                 //Commandline that will used at CreateProcess
    $ ~$ u1 @: V- f: q
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    & |1 W. {2 e% q# ~7 ]

  35. 6 u$ {+ l. Z1 M+ S
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)- I4 t) b. X' D- l3 d1 a: F
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn), }" K$ d, Z9 z; j3 W* {
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    4 u  g* b/ S# r2 w

  39. 3 R3 Z$ c$ P1 |8 l  }+ Y

  40. # p0 H' `0 B2 ]2 a

  41. ( R1 ^4 K' T- F2 }% u
  42.                 //Start DekaronServer.exe
    ' v- q: E  T9 r: t' V2 C
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    $ E- Q% Q' L% N
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    2 k5 e0 X  c2 B' M
  45.                         szCmdline,        // Command line
    . f4 ~. L. n1 H/ x% Y
  46.                         NULL,           // Process handle not inheritable
    ) @) {9 K" A# z2 r
  47.                         NULL,           // Thread handle not inheritable2 d5 ]6 @& |8 }7 D: i8 V, B
  48.                         FALSE,          // Set handle inheritance to FALSE
    9 V6 y5 ]% j$ Y1 z  G
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx% c: o+ v$ Q( Y
  50.                         NULL,           // Use parent's environment block
    3 j# }0 b4 R' I7 `5 y/ v- R
  51.                         NULL,           // Use parent's starting directory
    ( v. o5 }* U* c( s) c
  52.                         &si,            // Pointer to STARTUPINFO structure  U9 ^$ P8 h& c( `  E( U2 l: A
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    4 q8 Z3 b1 V- Q" W+ X. o
  54.                 )
    4 y# V: M1 v. P) N% O! K
  55.                 {
    1 E- `" j  x# L) q9 \: D2 M
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );8 P, E3 P! O2 S: |
  57.                         return 0;
    ! g' V. O2 ^+ H9 _' K7 K0 e
  58.                 }* y5 A1 a* Z3 _" l8 q, S
  59.                 //Creating Process was sucessful, h3 U' B2 g$ ~' N1 V, l
  60.                 else8 _. B& C) Z% q5 j) d! E; j
  61.                 {
    ! a6 W& J& s( m/ F& b( w
  62.                         printf("Sucessfully launched DekaronServer.exe\n");3 n/ G. n' S, q( p4 a  ~. q

  63. 1 p+ e" p, D) }1 V: i! S
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ) y, {- q/ }5 @- \% t8 |1 ?
  65.                         dbge.dwProcessId = pi.dwProcessId;/ D; ?. U4 x) \; A6 i$ k: K0 V$ k; c
  66.                         dbge.dwProcessId = pi.dwThreadId;
    3 `4 i% l1 m& T& E
  67. / {3 c, L2 D+ k6 U6 a/ a/ ^+ }
  68.                         while(true) //infinite loop ("Debugger")
    * d2 Y6 n" m' i7 U0 s
  69.                         {3 ^5 U, Z' ^3 i& r
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    % v+ \; [9 A  Q4 i$ D) N, F, v. ^8 c

  71. , E/ X- ?, k+ P! ~0 D# n# M
  72.                                 /*
    8 |3 K' O+ A2 l3 k
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

: |7 x$ f9 M0 {
8 i5 y* E4 L9 U# i# @+ y, h: m; X( n6 q: a# l& _) M1 }
商业服务端 登录器 网站 出售

15

主题

259

回帖

1275

积分

金牌会员

积分
1275
金钱
920
贡献
76
注册时间
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

主题

259

回帖

1275

积分

金牌会员

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

3

主题

102

回帖

7797

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-25 16:08 , Processed in 0.033040 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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