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

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

[复制链接]

164

主题

416

回帖

7820

积分

管理员

积分
7820
金钱
2282
贡献
4958
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ' G2 H* j" V, j4 p

2 u/ P7 {& {. y5 S/ ?5 k! x虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
. d0 x1 E+ o4 m" p! X$ b# A' M/ R' D. N/ j
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。& _# E, ^1 x. }: x+ f) Z
  2. //1 Y4 M  {  F5 ]: g0 ?
  3. ; l% C& I: v! W! @( F# w4 M
  4. #include "stdafx.h"4 s: {2 S1 v- W: W" W4 Z9 r* m+ ^
  5. #include <iostream>
    - g  W. G: c& A# P3 D; O: }
  6. #include <Windows.h>; Z0 p( z' E, Q$ d$ I9 @; @( M
  7. #include <io.h>
    - X7 @$ l& u$ @) {# _" ^3 R

  8. * _8 V& _" E2 K
  9. ; M' C, b1 l( [" ?  Y( d
  10. int _tmain(int argc, _TCHAR* argv[])
    8 P8 f% r  O1 t; e) {
  11. {( k, l$ D; n5 h$ Z2 O
  12.         printf("Dekaron-Server Launcher by Toasty\n");3 X4 I8 K, ]* b  E! T# h% a0 A+ A

  13. ; o% Z- R" \' ?, e7 Z
  14.         //查看文件“DekaronServer.exe”是否存在+ L6 X; F+ m3 F4 J2 \
  15.         if(_access("DekaronServer.exe", 0) == -1)1 ]' a' O6 P( G2 G
  16.         {
    8 [0 x) P% _4 \$ t0 l) _
  17.                 printf("DekaronServer.exe not found!\n");2 e- U+ i6 A: |7 l* t
  18.                 printf("Program will close in 5seconds\n");0 R0 ]' d: r5 Q5 y, \
  19.                 Sleep(5000);  p# l  p% Q1 ]9 b" `
  20.         }
    8 j+ e7 j9 }- u1 u" u5 N6 Z
  21.         else& b2 S% W3 Q% O0 R
  22.         {
    6 `8 b4 c. b  I/ Y' L
  23.                 + c4 l2 h# E  i% K) c: _
  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
    " X; u! n- `( x: \4 I$ N. R
  25.                 STARTUPINFO si;
    6 b* ]& V2 E5 i

  26. % M& ~% y% `8 j& E" m2 D
  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; s$ p( q, l" @; ~: D" x" I" n0 s
  28.                 PROCESS_INFORMATION pi;' t( i1 b  y- H
  29. ; s3 t2 _/ c3 ]! l  y. L3 o" e* c
  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
    4 W+ z- v' g( U) T- g
  31.                 DEBUG_EVENT dbge;3 `) h2 a7 `; Y+ f& \0 x$ c
  32. ! W0 v+ W# t( k! n
  33.                 //Commandline that will used at CreateProcess( W. k- \3 G( t" j  @$ f1 P
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));0 i/ U) P" `) Y& r" _
  35. 6 W$ u, H4 Z- C- P
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    $ K/ Q" S9 z- s3 W0 u
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn): ?0 G6 v# t' ?1 D5 H
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    2 `' Y$ @5 r9 ]! u, U

  39. ; m9 _$ ?8 ~) N2 a" d
  40. 9 E, n2 K$ }, Z  \0 z  |

  41. ' e5 N! G  c0 ?: y+ x
  42.                 //Start DekaronServer.exe
    2 e# M. @- Q' Q# d
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    / W8 Q2 B/ V5 U4 V  o
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    / k$ s6 g5 L; H3 o7 {2 E
  45.                         szCmdline,        // Command line2 b7 q. S3 w& N9 s
  46.                         NULL,           // Process handle not inheritable
    9 X* l, B) y5 ~2 Z9 H. g  `+ J
  47.                         NULL,           // Thread handle not inheritable- ^3 H1 n& `* P3 \* p
  48.                         FALSE,          // Set handle inheritance to FALSE
    + r4 Q: A" {8 E! ^& g8 \/ h4 M
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx, Y7 }, D9 f5 m$ H/ ?
  50.                         NULL,           // Use parent's environment block+ }  x* q0 f2 ^) g9 Q3 m7 I" A
  51.                         NULL,           // Use parent's starting directory
    + K- y; ^! c. Q. O
  52.                         &si,            // Pointer to STARTUPINFO structure
    + `$ Z6 G. a) o
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure% y. a5 G# s' p& K6 y
  54.                 )
    8 h3 G& Z+ F2 j/ a& s6 ]
  55.                 {
    " C* W6 `% q6 p0 u5 n8 a
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    # g5 A! R: X0 s4 B) E/ H: w
  57.                         return 0;+ H! g& ~' R. x7 q! X3 }! s' Z
  58.                 }$ B0 ?( B3 }! P  X  m- u) \+ \  ^
  59.                 //Creating Process was sucessful* I" h4 S; F6 Q1 x+ c& `. W' [  ^
  60.                 else* u) f5 W. |8 k2 H5 W
  61.                 {2 {$ Q! u/ G/ H2 c" z- S- ]& n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");* }$ |4 J0 B: R" n

  63. ) {9 h6 m) U5 A1 Q' u$ w
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    $ J: ^. S; F! ~1 [% c8 {
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ) P$ s7 `$ p4 {: L7 R- j
  66.                         dbge.dwProcessId = pi.dwThreadId;
    + H  d+ |, m& V8 H

  67. # `% V. o3 e& R" O' D
  68.                         while(true) //infinite loop ("Debugger")/ T3 u: C6 D7 y9 y
  69.                         {
    2 U$ f+ v" y* C) y! [
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ' |/ Y% R& e9 w. [& Z

  71. / \% n5 r4 v# j
  72.                                 /*5 ~1 ]' C) o3 P7 E7 P2 @1 X
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

7 C1 e( y( `: w0 k, F* e/ t; |) R# C7 s( l
) ^& m1 X* u0 L* v
商业服务端 登录器 网站 出售

16

主题

262

回帖

1370

积分

金牌会员

积分
1370
金钱
993
贡献
94
注册时间
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

回帖

355

积分

中级会员

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

16

主题

262

回帖

1370

积分

金牌会员

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

3

主题

102

回帖

9057

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-7-3 04:40 , Processed in 0.213131 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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