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

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

[复制链接]

155

主题

348

回帖

5978

积分

管理员

积分
5978
金钱
1862
贡献
3613
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
9 Q3 `8 m  u3 I) e4 _9 m2 I) |& u8 w& m
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。  P' N$ a4 w' [4 |6 a- e" E# B7 d, u% q

' C# o+ U2 A4 ~0 ?
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    3 C0 C+ Y& i; B7 R, d( E
  2. //
    9 u2 l" M2 R- T: d9 ?0 K+ d3 o3 u

  3. ! M  ^. C9 _+ }
  4. #include "stdafx.h"
    ' [1 V4 z1 h* x' U+ e
  5. #include <iostream>
    + c; M3 j+ \$ Q# K) @/ k' ?
  6. #include <Windows.h>1 {! B, O( C  w2 v% H! L% V4 `
  7. #include <io.h>6 x- _) z6 U- R
  8. 2 Z+ Y+ Z  `5 K- Y4 b1 I+ P
  9. - A0 g* ^# N8 k! @* W. ~/ T; S* s
  10. int _tmain(int argc, _TCHAR* argv[])$ ~) \- `1 b5 n2 {3 Y
  11. {( j' t( [7 @+ n* ]6 Y" G; K
  12.         printf("Dekaron-Server Launcher by Toasty\n");1 E) H, ^1 C. J# x2 b

  13. 4 X3 }6 |" |3 R: C1 ?
  14.         //查看文件“DekaronServer.exe”是否存在6 {5 R8 `, r& l: W2 g. }# M8 A
  15.         if(_access("DekaronServer.exe", 0) == -1)! N6 O% G% F* x/ G; f; @5 A
  16.         {; f9 ^2 l6 s% L8 D! r2 T
  17.                 printf("DekaronServer.exe not found!\n");
    - V* _. I8 W5 I: G8 q8 e; C
  18.                 printf("Program will close in 5seconds\n");: c* E( X6 n/ p& p
  19.                 Sleep(5000);
      S8 Q' Q2 P& `- J5 s
  20.         }' r: V" |( U3 q8 y0 ~. X; B7 T) c3 N
  21.         else
    * B" j( f) F1 f' G$ D' O3 c
  22.         {
    / u9 G* o4 o; p
  23.                
    5 d! R& w3 l$ u
  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( v' h1 v$ N
  25.                 STARTUPINFO si;2 a* y& _1 Q+ Y: a6 s" t  u. R4 T  |
  26. 6 F# c$ _/ r9 _
  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).aspx5 j, l+ F: E" G2 ^% J
  28.                 PROCESS_INFORMATION pi;
    $ T8 s* t: |$ f( C" ?) G
  29. 3 y* N6 A. a* S
  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).aspx1 }1 V  J1 G! \6 k7 ~: o% Z
  31.                 DEBUG_EVENT dbge;
    ; a. E  @  n  L. H
  32. ! }4 n9 P% @8 m% G
  33.                 //Commandline that will used at CreateProcess2 A  Z4 ^; T: v- G4 c8 {$ ?
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));8 O  [6 Z4 }( h9 [9 @6 }1 M3 G! \
  35. 8 f" N3 `7 X" n- l) |4 Q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    8 c! N% t, O# B1 U8 g
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)- S- k4 [0 [/ j1 P3 r8 o
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)4 c. `. U# ?4 b

  39. 7 p; s6 ]9 ~% L+ t
  40. ) \5 `1 q/ c) C

  41. ' g. ]! d- ~7 s! h; p
  42.                 //Start DekaronServer.exe
    & q% c3 D6 w9 a9 g3 m; L
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx  ]  u3 z% T; v  }2 c. J
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    $ o# [7 s# R, n, q) @2 v; }
  45.                         szCmdline,        // Command line# w( ]7 @! i% |/ T8 A
  46.                         NULL,           // Process handle not inheritable3 t3 N6 \5 B) }: [! @
  47.                         NULL,           // Thread handle not inheritable& A/ ~1 Z# `7 P$ P9 j9 h
  48.                         FALSE,          // Set handle inheritance to FALSE
    7 `# }' `* b7 [4 k
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx: K- |/ r4 n4 @. R8 t
  50.                         NULL,           // Use parent's environment block
    ! U/ |) H9 D4 Q* ]2 W4 J( \
  51.                         NULL,           // Use parent's starting directory
    * d' x" [$ e' m
  52.                         &si,            // Pointer to STARTUPINFO structure' G4 c8 y% y- I1 n; q# y( C
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure% N# r' s5 m1 m" S3 V. r
  54.                 )
    ! Q1 C8 @, `& F: d. h4 f2 i* Q/ C
  55.                 {- l% w$ |2 O( N. K
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    8 j$ I- T  O! a% x, f0 d* C
  57.                         return 0;
    0 Q* B; K6 w  }# i, L
  58.                 }
    9 q# l3 w+ R6 J+ T( I2 i
  59.                 //Creating Process was sucessful
    3 Q! h6 a- p; \& [! H
  60.                 else
    0 \; |* F# O7 ~& Z1 e
  61.                 {
    1 q( F( A$ o* @1 V
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ( _$ f1 y) T  X6 j. z. c+ a
  63. 8 r& S, g( _: k5 r, i5 q7 A) g: r
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure4 _# V0 Q- a) y! g5 t
  65.                         dbge.dwProcessId = pi.dwProcessId;  Q' z# U' A5 A* U
  66.                         dbge.dwProcessId = pi.dwThreadId;
    0 ]2 n% {6 d* I, g/ A5 T
  67. 1 J/ n, ?* O" j
  68.                         while(true) //infinite loop ("Debugger")
    0 r* u; C& b9 {  |  a1 t# N
  69.                         {# Q0 q- Q! W6 u
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx' q+ F& G  r7 t
  71. , o4 _6 t5 n; ~- z
  72.                                 /*" e4 g: v" _: i% Y8 D, c
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

8 Z0 E4 r- s1 U0 L2 D' t* e
1 @$ j- Q( a) X1 H! z. O+ S/ q. U: }8 R# r; o
商业服务端 登录器 网站 出售

13

主题

251

回帖

1242

积分

金牌会员

积分
1242
金钱
814
贡献
159
注册时间
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

回帖

1242

积分

金牌会员

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

3

主题

100

回帖

5678

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-28 21:02 , Processed in 0.079435 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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