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

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

[复制链接]

153

主题

334

回帖

5703

积分

管理员

积分
5703
金钱
1800
贡献
3416
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) + c3 Z8 {) Q0 y! j. [# Q6 [. G

) m+ v3 p6 h$ o2 y4 y0 x! i3 ?虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
  \: g! f: U6 p% S9 b9 Z+ T, R
1 M$ w* V6 h! D7 X% h
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    $ z! N& j" R" z; Y
  2. //) O5 \8 b- M) E4 Q" D+ @

  3. 6 {* Z5 N3 E4 I5 f; }
  4. #include "stdafx.h"7 |( ]" e1 f0 Z; d
  5. #include <iostream>& W  R, y% [- J! Q9 Y0 b
  6. #include <Windows.h>
    7 y; T- S* C, `
  7. #include <io.h>! b7 \: a- s. v( a- [) K8 ~
  8. ! ^/ o( ]  B' W# L, C3 R

  9. ! \7 s3 S; B+ S+ p4 O* e7 Z
  10. int _tmain(int argc, _TCHAR* argv[])! @+ }0 _) w4 C
  11. {
    ' W( [9 E9 i5 Y# l$ B2 C$ E* q
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    1 t. Z9 c& {* K
  13. , B6 J. A8 L; i" g; L; A( ~
  14.         //查看文件“DekaronServer.exe”是否存在
    0 P2 b* z2 c9 y- O5 @* b4 U
  15.         if(_access("DekaronServer.exe", 0) == -1)
    3 G6 B7 H; }( z/ j1 b# P- X  g
  16.         {0 f% G% |! n; ?' U
  17.                 printf("DekaronServer.exe not found!\n");4 B) d1 w3 P( M( B) Y- E7 m- Q) ?
  18.                 printf("Program will close in 5seconds\n");
    ! A* k; O0 B% D# e
  19.                 Sleep(5000);9 u% v9 p4 D, l
  20.         }4 v) O! W- _! P: A  P
  21.         else
    ' |' V* T  f0 `  H
  22.         {9 J( f8 m& s4 B/ y) T6 J
  23.                 " J7 ]" T- U7 E# v8 f' 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) J" d6 s1 x9 d
  25.                 STARTUPINFO si;
    ) d' I! [1 [) k0 i2 F8 a
  26. $ p. X+ I0 V$ q5 ^# 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& S6 y, u$ O/ Q
  28.                 PROCESS_INFORMATION pi;: T2 p7 R5 J0 U8 g& S  V8 C/ b
  29. # v$ l6 e- D1 R
  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
    % b8 L9 `* x( C2 r, U- @* H1 Z
  31.                 DEBUG_EVENT dbge;* W0 u) Z0 S1 `2 r# Z5 F7 d7 n4 ]* O
  32. 3 @  S5 L) j. _8 F9 X, k
  33.                 //Commandline that will used at CreateProcess& C' t% V8 H2 e- w& @  n, g
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));- J3 {! N$ L. A3 T

  35. & q7 Y6 b. {: X; ^0 k. l9 k
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ( s) W) ^0 l! D
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    . D& C4 T/ `4 w* ?. [8 G! P
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)& m, q8 m( p) A4 n

  39. 3 a) @& L$ |: A, z3 X$ U2 i' r! \5 |
  40. 3 K' H! B: s3 B

  41. $ \. J4 ]0 z/ m9 b2 n9 v
  42.                 //Start DekaronServer.exe % M4 H4 K& Q% \
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx0 K& z' }2 ]. m& d( s) a* P# F
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). @, A# m1 R: t/ o
  45.                         szCmdline,        // Command line
    - Y3 y# x2 ~( R
  46.                         NULL,           // Process handle not inheritable
    * E7 R: z9 D3 _% x! g& ~4 A
  47.                         NULL,           // Thread handle not inheritable3 z7 O2 @7 e, Y" K: W9 N
  48.                         FALSE,          // Set handle inheritance to FALSE
    # R  k8 y/ i7 W/ R% o6 |3 B
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx$ Z- Q8 q  d' y. C% k
  50.                         NULL,           // Use parent's environment block- n4 v, {; B2 v' _: P
  51.                         NULL,           // Use parent's starting directory * e9 d" f) Q4 @' z# B
  52.                         &si,            // Pointer to STARTUPINFO structure$ ]9 |5 |% d* @# }& e# w1 \
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure) T( H! w5 {9 H" j
  54.                 ) ) m& V) H, b, @" V8 b- u
  55.                 {
    ' L' [) W. I" o4 z, _6 X4 s
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    5 O( d3 w. C: _( `/ z
  57.                         return 0;" @3 |8 ^  F2 g( H% O
  58.                 }' e; \: u& k; X: k# o, f1 R
  59.                 //Creating Process was sucessful
    $ {) S. n' M+ k8 V- z8 D5 w
  60.                 else& Z7 H1 x9 I( R8 A
  61.                 {
    . T) @9 m6 K/ p. o0 |8 _
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ! ?" A" [7 @! _
  63. . h) X7 a" R" C3 L9 i% {
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    3 t8 r$ g+ w$ ?9 W7 l; s0 |( x
  65.                         dbge.dwProcessId = pi.dwProcessId;# C. ]5 `* _: n+ M3 x7 j+ z' n# n
  66.                         dbge.dwProcessId = pi.dwThreadId;
    " x! G0 ~$ T$ {3 b- @: V# E
  67. 2 l+ g* v: Y" Y% ^' t
  68.                         while(true) //infinite loop ("Debugger")
    8 H. V! N, C2 h0 x
  69.                         {
    + Q. C, D2 y4 D% L& c, J
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    8 W5 q7 \9 {9 ^! N' W; R3 m6 c7 L
  71. ! Z8 D4 ^3 l4 o6 ^: x
  72.                                 /** i0 k" S, g$ Y# W8 O
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

4 o  M* y0 e& G* s+ N3 _3 M" W7 y( w+ \5 y

6 Z& Y# X/ \6 i- t) e; c
商业服务端 登录器 网站 出售

13

主题

250

回帖

1220

积分

金牌会员

积分
1220
金钱
779
贡献
173
注册时间
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

回帖

1220

积分

金牌会员

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

3

主题

98

回帖

5031

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-23 06:20 , Processed in 0.072182 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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