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

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

[复制链接]

155

主题

348

回帖

6179

积分

管理员

积分
6179
金钱
1868
贡献
3808
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
# P! P/ O9 T& U- O  n5 h/ [$ n' {
  u, Z1 v8 p- S虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
) }- F9 q/ F9 |1 ?0 _4 C! r% o
+ U; F+ u/ _$ m1 H! I
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。5 w6 t3 q& p6 s/ Y
  2. //
    " ]6 X  D! S- U# [# [
  3. 7 _! W3 `+ d4 X. L- j/ _- O
  4. #include "stdafx.h"
    ; X# j$ f" l% o6 d) C( s
  5. #include <iostream>; F9 \" ~; U; G! K
  6. #include <Windows.h>2 f  W$ t# W. b' u) |
  7. #include <io.h>) w) y) ]$ w. O, y" Y$ c) V4 a9 W0 ]

  8. ! Y8 l3 l4 }- w+ J2 k

  9. 9 X) \$ P' B3 }6 x7 a% e
  10. int _tmain(int argc, _TCHAR* argv[])
    # e- h0 g& h3 U+ S& u6 S
  11. {2 ?, M# ~3 Y& h$ m+ [/ l4 W
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    % r) ]4 P* P5 N0 Y% ]+ P$ I/ G

  13. 7 N$ v+ E7 m4 [, q( A" t
  14.         //查看文件“DekaronServer.exe”是否存在
    0 A7 j. B7 A, Y7 I( G& H% K& F
  15.         if(_access("DekaronServer.exe", 0) == -1)( g6 ]- o; _0 @
  16.         {$ s3 e7 S( t# U, X. |* Q
  17.                 printf("DekaronServer.exe not found!\n");  @& c/ |# W' C* I% {+ T/ \( ?
  18.                 printf("Program will close in 5seconds\n");; s! G- u" k% f  g  V
  19.                 Sleep(5000);8 t. g0 J7 t1 u+ S6 [; O! k0 A+ S% T+ v
  20.         }
    # T& f5 C3 A3 J: ^7 f
  21.         else7 |, i: [* k- d; l4 ^
  22.         {
    * `8 v9 C# ?- l4 C8 ~" \
  23.                   Y) |: q2 Q( y4 a6 B/ m* F" {
  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).aspx5 v" c/ I5 f0 L* T7 Y* n
  25.                 STARTUPINFO si;
    ) o. e: V8 ]3 B' M! W" ^
  26. # e7 a9 b" i- v; J7 O8 \
  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
      T9 H- _  X5 E& u! B" F
  28.                 PROCESS_INFORMATION pi;
    2 W9 ?2 l4 M& ?5 y. G7 \3 L6 n
  29.   i% x. w6 O+ u. B$ h' a7 b" f
  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  X. C* I) y# Q# y9 O
  31.                 DEBUG_EVENT dbge;
    5 k/ s+ p8 H) q9 N: u7 v

  32. 1 n* |: m1 U* J  ^  }
  33.                 //Commandline that will used at CreateProcess0 U4 }) {0 c7 w4 |  X
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));7 y+ g6 Z# D4 B2 z0 w$ h% R$ {2 D( I

  35. $ J6 D2 w: z  O" b$ z7 h+ k- t
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)! W$ G& @8 o! @' b$ x- E
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)8 P: A" y7 \4 V% b- P, X; c4 I
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)# s8 }& y4 X: U. X6 y0 K
  39. % p) h  T8 d# b+ n. |
  40. $ I1 L* L$ V0 Z8 L" t
  41. 1 g* L1 a: F3 {
  42.                 //Start DekaronServer.exe - [! o8 g" {3 k0 @1 p, D
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx* g) Y; y5 r1 t7 @6 y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ( M/ n; k8 k" d  i
  45.                         szCmdline,        // Command line3 [7 r7 Z' Z! s* O
  46.                         NULL,           // Process handle not inheritable' `8 a7 `' J5 h. I- L3 y% I
  47.                         NULL,           // Thread handle not inheritable6 u' w* y& j- ~& W% m+ T) `
  48.                         FALSE,          // Set handle inheritance to FALSE2 z% k' v; V9 T4 n: F- \
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    + K% {+ M8 k  ~" `- u, G
  50.                         NULL,           // Use parent's environment block
    ' u/ h, i2 n7 _+ n2 q; f/ V9 k
  51.                         NULL,           // Use parent's starting directory
    ( o3 J4 t6 i& p6 r  |  L/ w9 n& A
  52.                         &si,            // Pointer to STARTUPINFO structure9 C* R4 ~# l& \
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    / o9 k, [. C5 V9 U
  54.                 )
    ) S4 a/ }) ?) p' l6 @
  55.                 {
    % w8 t  u- |' t: I( |
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );8 I( j+ l* h  o
  57.                         return 0;) ]1 G7 R- ]5 I5 A7 o* i) X2 Y
  58.                 }
    9 g, r! f* b# X2 {' K. s, m/ Y
  59.                 //Creating Process was sucessful+ N7 M' Z/ P2 W" i# Y7 f
  60.                 else$ C% Y+ C9 Q# x8 H! X; A
  61.                 {
    ! j. Z. V2 Y0 n( L
  62.                         printf("Sucessfully launched DekaronServer.exe\n");3 Q6 |% P, B% Q  `: z
  63. % t* O$ {$ l# H9 s- e5 d
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ! o/ @+ Q& R3 o4 J
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ( |; e( t- M5 M+ R- H
  66.                         dbge.dwProcessId = pi.dwThreadId;; O& e# V! {  _$ D

  67. 6 S8 l) H! I( I0 U0 V: u6 Q5 Z
  68.                         while(true) //infinite loop ("Debugger")
    . j! @& b) m/ i# A7 S1 ?8 }' z9 J% q
  69.                         {
    6 t2 p7 g) n1 X( T% `
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx1 p4 e  V# Y  @  C* q) p& ?
  71. & J. y- w; e4 H6 x
  72.                                 /*# [* T2 M2 D9 s+ W/ i) k/ `
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

  M# A) |5 O5 B. B' ^7 j0 y; E+ y& r2 ~3 K: n. B* E" p
  _( ?$ ]1 m5 v" z( D% C( A
商业服务端 登录器 网站 出售

13

主题

251

回帖

1245

积分

金牌会员

积分
1245
金钱
816
贡献
160
注册时间
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

回帖

1245

积分

金牌会员

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

3

主题

100

回帖

5721

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-1 15:07 , Processed in 0.134669 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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