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

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

[复制链接]

154

主题

343

回帖

5872

积分

管理员

积分
5872
金钱
1839
贡献
3536
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) & l$ N. b  k5 }" h4 ]+ \9 A8 L1 r

* Q: O8 V. G  s, s' Q: r& O4 g; X虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。9 J) n( r( T! M1 @3 U: r

: U% L; V+ c/ ?4 [! [+ F7 K
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    0 M$ k4 d- E. \2 ~$ I
  2. //1 D1 Q# N3 c$ S5 O* h

  3. * W- y5 a" x- v: @
  4. #include "stdafx.h"
    - ]5 D6 A& j% g
  5. #include <iostream>, B, T' O5 W& f9 p  a
  6. #include <Windows.h>& M, W& V! w/ n2 {, {& ^4 k
  7. #include <io.h>: E- `; p8 E; X' B- L, Y
  8. - M" P2 g. H0 @$ d
  9. ' O4 w. O4 g9 U
  10. int _tmain(int argc, _TCHAR* argv[])
    - e. ^2 z- R/ {7 u7 G7 f: u$ n
  11. {6 r8 y( J' m4 X5 p7 H( c
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    + n: W3 H# ~8 ^; I" l; j

  13. 5 w- T8 p! `+ [) x8 E1 Q
  14.         //查看文件“DekaronServer.exe”是否存在
    / o  q5 g! T* a( P7 L
  15.         if(_access("DekaronServer.exe", 0) == -1)
    6 U! h' R- `$ t: k/ [
  16.         {
    1 Z. w" d# i1 q+ r; Q
  17.                 printf("DekaronServer.exe not found!\n");
    ! s+ t9 Z; A: {& D1 n
  18.                 printf("Program will close in 5seconds\n");
    8 H* ~( Y8 B% v# [* E1 P
  19.                 Sleep(5000);
    3 q6 }8 q; v# H: q  g
  20.         }
    * H9 l) j- r/ e4 ], y
  21.         else
    ( N. ^% B" r4 y
  22.         {
    4 I: {. _6 y: g. h
  23.                
    ; l# n9 {' `: {; S: }: x+ X9 _8 g
  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
    - b8 E/ n2 A1 v  n1 z2 _% j
  25.                 STARTUPINFO si;( q% z9 I/ u; A4 M1 `4 p. v3 v' f3 }

  26. # R5 \5 D% d8 t% O: \+ o
  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
      e1 E$ g% }5 m+ V, }0 d
  28.                 PROCESS_INFORMATION pi;$ t6 c- z) {+ n2 b. b8 I0 W

  29. % `/ l; k9 G* G: ~% h
  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
    7 B5 r! M9 Y6 P1 w6 [( C* Q
  31.                 DEBUG_EVENT dbge;7 {5 H6 w% Y# f2 Q

  32. % s2 k" Z, h5 G% i$ g: \
  33.                 //Commandline that will used at CreateProcess
    6 |0 t6 B8 ]& n
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    " `2 K$ O1 ^, v9 m) M  O6 Z+ ~( h# P

  35. # R- J# W( i& [% G  `0 E
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    1 ^0 n# ]( z) |' n$ F  ]! t
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    - q/ t/ A- w% d% C
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ( m: ^8 r4 F8 x2 ?! \( D
  39. 7 u0 z  g/ p, r6 c- R3 d; {2 ]

  40. 5 y; q# W  _2 i, M0 m2 |
  41. 0 B( p! u9 \; W; w8 s6 A
  42.                 //Start DekaronServer.exe
    4 K' a( E2 M- A8 W6 O5 i4 b  E9 {/ N- |
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    + @3 p' S4 P( R* A
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    . U# T# O8 K2 f" C) t0 O
  45.                         szCmdline,        // Command line
    1 a/ H6 q& D' |
  46.                         NULL,           // Process handle not inheritable$ v5 \% J# k8 X, U* U, U4 c
  47.                         NULL,           // Thread handle not inheritable6 @1 @8 s' h# g/ b
  48.                         FALSE,          // Set handle inheritance to FALSE! _  ]0 }, J' _" }3 _1 {* o* P- K% E- v
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx7 \: o1 v$ C2 M8 n1 T
  50.                         NULL,           // Use parent's environment block' s3 U8 |5 k3 t( v
  51.                         NULL,           // Use parent's starting directory 4 R; j0 I5 _- u9 g( O  \9 D2 ?( m
  52.                         &si,            // Pointer to STARTUPINFO structure
    + [. t5 [* t+ S! m: _" O3 K6 r
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    % }3 _) j( F: d. _* b+ Z* b# X
  54.                 ) 0 D& V; b$ r. r/ W& _* j8 A; o
  55.                 {
    & I1 n) a4 w- Z
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    9 N3 c8 T! w0 y$ m5 W" z* y8 k* H
  57.                         return 0;
    3 P9 w& A0 i5 |* Y( ~2 v, a
  58.                 }6 d2 l( m6 |% N( c, j
  59.                 //Creating Process was sucessful
    7 n& B( k2 z: d7 y4 A$ c* L
  60.                 else
    $ T( p( ^: m0 S1 s: R  L
  61.                 {
    - z2 V) \6 \1 c8 I) Y
  62.                         printf("Sucessfully launched DekaronServer.exe\n");# c2 S+ f6 ^/ V8 T9 U

  63. # R7 |4 C$ W; y  U! T' V0 b1 g
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    & q: S2 y+ Q$ E' ]8 I/ B& p- T
  65.                         dbge.dwProcessId = pi.dwProcessId;
    , W" T* t6 Z3 Z7 u# q! z  q
  66.                         dbge.dwProcessId = pi.dwThreadId;
    9 \! f5 G+ u1 Q* t' J/ v" S

  67. 6 \# W3 L1 [: i1 Y7 ?. I7 n
  68.                         while(true) //infinite loop ("Debugger")  t0 N3 Z+ g! Q0 \, D( j7 k/ d
  69.                         {
    + y. ?7 e  `# N% f( [( ^+ @
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    # M+ z4 c0 P! z1 J8 Z

  71. 0 P" Z0 D& ?$ L+ X5 `
  72.                                 /*
    5 ~# W: Y3 l  x- s; o1 h( \5 W
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
$ K+ e1 T1 S4 u$ D( x

' E0 Q( s3 h( S% ^
7 h& m6 O' S/ I
商业服务端 登录器 网站 出售

13

主题

251

回帖

1258

积分

金牌会员

积分
1258
金钱
802
贡献
187
注册时间
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

主题

251

回帖

1258

积分

金牌会员

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

3

主题

99

回帖

5513

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-16 19:00 , Processed in 0.085091 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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