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

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

[复制链接]

153

主题

334

回帖

5709

积分

管理员

积分
5709
金钱
1804
贡献
3418
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) $ \' V5 E+ i8 P9 d1 d. d4 h5 M9 s
- l4 J! l8 f; Y
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
; ?! M1 F# J# M) n. K# ]
. ^# x4 d" r1 H4 k
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。( b6 v) M+ A7 j; x% m
  2. //8 h  L* u$ v8 |9 W

  3. + W- ^5 o( @/ ]& t) E/ ~
  4. #include "stdafx.h": S9 X$ n- ]4 B5 t
  5. #include <iostream>) q# J0 z. ?+ k3 ?- E
  6. #include <Windows.h>
    % [; b- ?+ @4 Z) l7 F+ F
  7. #include <io.h>1 Q" Y9 Q4 V% I9 |# |

  8. 4 b: o0 ^" I  J1 e) f9 q
  9. / t) N( [. ^/ J( R  e
  10. int _tmain(int argc, _TCHAR* argv[])9 {! M0 h1 @" {
  11. {
    ! C* r" k- q$ v9 h0 V5 h0 u( R% u- V
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    3 S! z" g0 b% U+ L
  13. 6 v& ?# h1 o) u
  14.         //查看文件“DekaronServer.exe”是否存在
    1 D! X' [( e$ b" \4 h( ~. X5 C
  15.         if(_access("DekaronServer.exe", 0) == -1)
    % A' t  f% F' u9 Z/ T$ f- e) e
  16.         {
    ) c1 B/ z3 s8 C8 y! \
  17.                 printf("DekaronServer.exe not found!\n");" J/ B; _" y( h, q  A8 ?: ~& j0 z
  18.                 printf("Program will close in 5seconds\n");
    & b$ `8 L2 v, k3 R# i; ]  h
  19.                 Sleep(5000);) f0 K  d/ U* Y/ M! Z+ ?+ q
  20.         }
    ) K! ~- G" c! g' G1 x, v
  21.         else: P/ p/ |1 T5 F% e; a
  22.         {$ b6 B0 `' f+ b8 k* S3 |' T
  23.                 ( U* J  e2 x- p) l
  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).aspx2 Y1 k: k) C4 h, F
  25.                 STARTUPINFO si;
    . o5 s$ S* M/ I2 q* c

  26. ' }: l- `2 _4 J# I7 _. o% a
  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! N, @  [4 N$ ?" ~! B, s% W0 n& M
  28.                 PROCESS_INFORMATION pi;, H5 k3 ?% [+ a& M# f7 y% T
  29. 0 a0 N, W- o" W+ T2 A+ 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
    - ]/ D/ `" j( h* w: X* ~6 G/ x
  31.                 DEBUG_EVENT dbge;
    - Z0 g( A7 @# n0 A. o) A" A

  32. # w! U2 O5 z5 R1 p
  33.                 //Commandline that will used at CreateProcess. D" p3 ?3 y- |. h; a5 r' c
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));# Z/ q2 M: l4 ^# r7 T* [. o
  35.   e$ K- ]5 @2 {
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)( G6 C6 C. T# O# u+ t
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)/ P8 P4 P1 m3 k( [, \
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)2 v7 ]) ]+ G: z- V; |9 m. M: z

  39. ) d4 y5 n' x. g) m% s/ }
  40. + H# n" }( D3 s, p) u
  41. - G( X) R/ ?* U/ Y
  42.                 //Start DekaronServer.exe
    ( Q, ~4 N. B8 D% b! g0 i
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx9 N1 E/ B; ?) A0 c  h  v: P" T
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)& a4 T/ ^9 d; [5 P/ y: @
  45.                         szCmdline,        // Command line
    + Q  B" g* @: b
  46.                         NULL,           // Process handle not inheritable
    5 X/ C( w; _& ]! G0 |" u( k: @5 Y; k
  47.                         NULL,           // Thread handle not inheritable
    6 Z! t% _8 e1 o
  48.                         FALSE,          // Set handle inheritance to FALSE+ G, f4 v9 @% m! W
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    & B+ n# L' c9 s/ D# d: g
  50.                         NULL,           // Use parent's environment block& i4 u8 E- g0 z; n& G, x
  51.                         NULL,           // Use parent's starting directory 1 m  K1 b7 H! k! @7 s( F
  52.                         &si,            // Pointer to STARTUPINFO structure/ p% P. K! U+ j% _
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure' b7 c% [8 `! D' ^& k! c) P" e4 ~
  54.                 ) " p- D2 W2 F# t0 w4 K/ f
  55.                 {
    / V3 n# h: x9 ~2 o
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    " I1 f  \( P7 {+ J* x
  57.                         return 0;2 R1 ^0 C9 a' Q
  58.                 }" o) X5 e4 Q/ p( Q) S; V% f( r
  59.                 //Creating Process was sucessful
    : P8 x. o% H: z8 R5 v6 g
  60.                 else1 c% o9 S2 ^6 F2 _
  61.                 {/ x) L$ T. H# _
  62.                         printf("Sucessfully launched DekaronServer.exe\n");9 D# G- U( g, l
  63. % Q; Q; X; G9 k4 v4 Q  i
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure, Z7 {4 S3 |% i- l$ d! A/ z
  65.                         dbge.dwProcessId = pi.dwProcessId;+ C* ^( K+ c4 m, M+ f
  66.                         dbge.dwProcessId = pi.dwThreadId;
    4 Z( E4 |3 B! l. q& `7 b9 Y1 _

  67. % m4 L0 a! C& s; l/ h  c4 I
  68.                         while(true) //infinite loop ("Debugger")
    - M% E$ @0 G3 b% j! K3 ^
  69.                         {; B" c' V6 f3 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
    2 Y- A4 n. {3 F; N6 z+ B5 ]) \( m

  71. ( c3 n$ d3 z7 F9 j
  72.                                 /*
    % V  B2 Z& T) K  z) @& j) W( o* U
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
, h2 D2 |" ^* y- c) [
' d' @" [+ O9 |6 W
) Q) F# o+ _( H# P
商业服务端 登录器 网站 出售

13

主题

250

回帖

1223

积分

金牌会员

积分
1223
金钱
781
贡献
174
注册时间
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

回帖

1223

积分

金牌会员

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

3

主题

98

回帖

5111

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-27 05:22 , Processed in 0.070839 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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