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

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

[复制链接]

160

主题

385

回帖

7430

积分

管理员

积分
7430
金钱
2135
贡献
4750
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) # U* O8 n2 C: V8 \  |( z
3 N8 o$ ?2 l+ s: `0 I
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。' G. o* G4 \+ M* i1 P4 Z& P
3 q1 g) i% o: A
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。( v* G% ~& M! f5 R
  2. //$ v5 _2 z" y4 Q) J! S
  3. : X- K; K* U" O) o" D
  4. #include "stdafx.h"
    2 |. q. \5 i0 X) a7 H
  5. #include <iostream>( i$ X+ ?) l0 e( K  _
  6. #include <Windows.h>7 O8 N% I& H' T
  7. #include <io.h>) n: W6 o' e9 U1 P* I1 R
  8. 3 T6 {& `& c* u/ n
  9. " x' }3 R5 H; Y6 W8 L
  10. int _tmain(int argc, _TCHAR* argv[])
    : Z2 d, |% e' p/ `, O
  11. {) e+ e2 K" K. M/ H4 U
  12.         printf("Dekaron-Server Launcher by Toasty\n");; s6 R% l: I5 t, l  C4 f

  13. * |4 J" r7 t# }1 C- r
  14.         //查看文件“DekaronServer.exe”是否存在4 d# \& y  _) T  r7 e
  15.         if(_access("DekaronServer.exe", 0) == -1)
    3 }. S+ U# |7 b5 S# H
  16.         {
    + m7 ~( d9 h: P4 f& _
  17.                 printf("DekaronServer.exe not found!\n");
    6 a! }8 G( E3 H0 u5 x, G4 p
  18.                 printf("Program will close in 5seconds\n");1 r2 l9 M4 I  V. X  b! [& I
  19.                 Sleep(5000);
    9 g3 t: P1 ~  m# c8 J. b
  20.         }* p3 ?. }; q9 ^* |6 p& l, p# G
  21.         else% c' Y- Q  M' \6 z" a
  22.         {4 s3 f5 w) W4 a
  23.                
    & d& m* E# O4 `
  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) V7 V  D# h4 Z9 P2 r1 p- [  l' s
  25.                 STARTUPINFO si;' O9 _0 _4 ?7 V) Y- j* u* h- P% ]

  26. 0 X; U7 `  n: h* @
  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 r  r2 m7 H, s( X' {
  28.                 PROCESS_INFORMATION pi;
    ; l# K1 j  U' h0 b& C
  29. " \* U1 z! }7 A+ }$ w
  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
    5 V0 R! v4 M" s. |9 K
  31.                 DEBUG_EVENT dbge;9 l3 s' u0 Z+ j  s: N. T+ I

  32. 1 m% Y# ^+ t( X2 C( N; X7 Z7 B
  33.                 //Commandline that will used at CreateProcess; P1 X( n8 ?& N. t4 G
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));+ R; ]1 C0 q4 F5 w2 @, ~
  35.   k+ p- q# X! `: x; u7 ?$ V2 r5 \
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    , V( v$ E* Z+ X7 j3 [
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    / B- {  u$ X  Q4 I. E
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    1 E, B6 D: r- c

  39. * I0 ^  N9 a! a" r: L# v
  40. / `# a4 Y5 }, y- u) d6 S% W& `
  41. / o/ Y5 |4 y7 P( R
  42.                 //Start DekaronServer.exe
      T0 o9 e( t' @, B4 }
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    1 h% q, z! d. V2 L2 P0 l
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    5 |$ S% S. \" M
  45.                         szCmdline,        // Command line2 g" s5 X. j/ b2 j+ [7 ^
  46.                         NULL,           // Process handle not inheritable
    % l' Q, ]2 F. l+ B/ A
  47.                         NULL,           // Thread handle not inheritable
    ) K) K7 \% g0 S  R2 ]# F# C$ [$ G
  48.                         FALSE,          // Set handle inheritance to FALSE
    ! w7 M# A* T! _' R
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    8 m  T, j& o3 g; d+ K
  50.                         NULL,           // Use parent's environment block$ D* h  n0 ]9 \( d- K# @+ J
  51.                         NULL,           // Use parent's starting directory 9 k0 x' u9 V) s. x8 C5 k9 g2 d
  52.                         &si,            // Pointer to STARTUPINFO structure5 h; Y  D: j) W; M7 p% \+ ]1 l
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure; s, Q1 B' ?3 q4 }/ Z0 B
  54.                 ) ) _4 |# c0 G$ c. m- {
  55.                 {
    2 T  I/ `3 B: [6 G8 Y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    ( H+ o2 y7 w% F7 ?" i1 P5 L
  57.                         return 0;
    ( j9 p5 f; w- a- g3 V
  58.                 }
    , U; g+ Y2 [: I$ ^% [0 Y3 T7 z
  59.                 //Creating Process was sucessful
    ( {$ ]+ I. u9 ~; N
  60.                 else
    9 e( j' ^" A1 G: \
  61.                 {
    & F4 Z3 s$ s# L) r+ r7 |* H
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ! p/ \7 V2 r0 z+ O9 f$ q5 O* n

  63. $ ?0 N) j* ^; b% V" R
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    9 p% t) q0 T) B6 x0 A7 x. @  V3 f
  65.                         dbge.dwProcessId = pi.dwProcessId;
    : s1 T) W- [4 Q. S' y3 r" x
  66.                         dbge.dwProcessId = pi.dwThreadId;  G+ t4 \3 {1 v( P& Y+ C
  67. $ L  u% c0 c. q, J
  68.                         while(true) //infinite loop ("Debugger")
    + j7 U- w1 S; p6 |; N9 C
  69.                         {& i  p# H1 i4 S4 x
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx2 l& f7 ?9 V$ q8 T* y
  71. " W/ a* q; w5 s9 r! S: Y- @4 M
  72.                                 /*
    , e8 I- t9 z  h3 G
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

( b9 t( G2 P  l! h/ `- L4 p/ u: X: l2 c+ _% m/ u; ]5 e  L
# q& k$ v* W7 d& o
商业服务端 登录器 网站 出售

15

主题

260

回帖

1295

积分

金牌会员

积分
1295
金钱
933
贡献
82
注册时间
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

主题

207

回帖

355

积分

中级会员

积分
355
金钱
142
贡献
6
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

15

主题

260

回帖

1295

积分

金牌会员

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

3

主题

102

回帖

7957

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-4 03:21 , Processed in 0.035833 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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