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

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

[复制链接]

155

主题

344

回帖

5930

积分

管理员

积分
5930
金钱
1850
贡献
3581
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
5 M6 O/ T4 a5 X3 s2 [+ ~( L, l" F0 i6 i% ?' L
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
" c4 D. G2 g% f. f1 C) G" \0 w4 j% E% W! x; t7 P
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。9 X. L$ f6 C% D4 c+ l1 G$ G+ ^
  2. //
    9 f6 E6 Y/ ]+ [6 T; g
  3. , C/ G( j) b2 }9 ?3 p- i* F4 S
  4. #include "stdafx.h"3 \# a$ t- R; z: q3 Y: t
  5. #include <iostream>5 b* o8 x" G; P) W
  6. #include <Windows.h>
    & \5 |4 K8 h7 B8 E% n
  7. #include <io.h>
    ; u  ?# q4 O' m8 G; k" h
  8. ) Q" A$ X) G" m6 z. s- W! c

  9. 7 Z/ t' C" {7 s
  10. int _tmain(int argc, _TCHAR* argv[])! }% {6 Y- r2 @) }6 h. u& f
  11. {
    4 m( x2 O  Q1 R. L! Z6 X9 R
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    $ X. {) f6 z& F$ v/ q

  13. ! X. R+ r0 n0 z; M) |
  14.         //查看文件“DekaronServer.exe”是否存在0 _" V) V$ o, x4 M
  15.         if(_access("DekaronServer.exe", 0) == -1)
    7 J0 c, i! s# {& F" V
  16.         {
    & z% w: S0 |5 ~
  17.                 printf("DekaronServer.exe not found!\n");' A/ v+ Q( f& i: V# D9 T
  18.                 printf("Program will close in 5seconds\n");
    ' l) ^5 w& D* r2 Y/ U
  19.                 Sleep(5000);0 [! z8 I( t9 V9 m6 k% e6 p. d
  20.         }
    - Y$ C& _" `0 Z) [- e* w
  21.         else" X" Z* ]2 g% u2 z
  22.         {
    3 l# N# B: E% [1 N3 i; x1 V
  23.                
    9 |. k& I" I1 R6 f) M; x. O
  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).aspx2 B& \) J! C2 d9 b4 Q' y9 j
  25.                 STARTUPINFO si;
    , E' l, J7 w% K: S/ D- l9 y9 H1 K
  26. 6 |9 D. d; s" n9 u6 U7 F7 X
  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
    , R$ v8 ?4 }. C1 p5 D6 c
  28.                 PROCESS_INFORMATION pi;
    7 U" d. J3 D) e# E
  29. $ g3 J8 J. x3 h+ h7 ^. _4 M: t
  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# C& N+ o* p+ T5 H7 B" _1 V
  31.                 DEBUG_EVENT dbge;
    0 ]" [5 X3 [4 {7 G1 b

  32. / N$ j- i9 ^  k1 N" P
  33.                 //Commandline that will used at CreateProcess
    1 g2 A" e0 w( _0 [9 f
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    $ [9 b- R- Y# K& l5 v  j& a# g

  35. ; J5 d$ S& H4 F
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    7 |! Z5 T8 R, ^8 q" |$ Q3 v
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    3 b: F% j! x- u7 L, S' M
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)2 v5 n; o6 K% U. u( g- S% Y

  39. 0 e4 k: Z7 @- c3 k4 k% T; N

  40. 5 o) a& }' t1 A% w
  41. + O2 f+ S/ I* w) p  G' I3 R5 a
  42.                 //Start DekaronServer.exe
    % c3 W& b% }% {
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    + j* S# H0 [, p0 R
  44.                 if( !CreateProcess( NULL,   // No module name (use command line): b5 @! q: ^) [
  45.                         szCmdline,        // Command line
    - |/ Q1 M/ y! M' m7 z3 H! u3 d
  46.                         NULL,           // Process handle not inheritable
    1 b) Y! {# y7 z, M0 H4 f
  47.                         NULL,           // Thread handle not inheritable3 c9 F+ ^9 v( j  l) Y
  48.                         FALSE,          // Set handle inheritance to FALSE5 R* n. t! H- B
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx7 f$ k7 |( E5 h$ d7 R% n
  50.                         NULL,           // Use parent's environment block
    ( `* g# W. o2 {; X2 Y9 g9 m' o$ _
  51.                         NULL,           // Use parent's starting directory
    % m7 J4 K6 @1 v# {: @4 T0 {) |
  52.                         &si,            // Pointer to STARTUPINFO structure
      Z- f; ^9 |% ^; N: {2 Z* Q: J) y
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure9 W1 T7 a! v. e5 \
  54.                 )
    . R3 R% O6 d* Q+ ]$ p
  55.                 {; z) c, p9 Q* q( j; I3 w
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );. O6 b+ G/ F+ ^0 r) ^: Q3 F
  57.                         return 0;2 W1 s( d0 T" p& p
  58.                 }8 W) M- r. z- G: O4 j, p2 Y% r& O6 i
  59.                 //Creating Process was sucessful
    9 G! p, X9 ]- x5 R" N1 G* A  s
  60.                 else
    8 [% W. y, h% e
  61.                 {
    , y+ c* |+ ~/ `
  62.                         printf("Sucessfully launched DekaronServer.exe\n");; ?7 @, n& {% r
  63. ' j- W! X6 g3 z0 J' K, r: T
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
      {$ |$ @5 R% d: a1 ^& U% }
  65.                         dbge.dwProcessId = pi.dwProcessId;
    " Z9 q7 f% T3 P( v0 D5 W
  66.                         dbge.dwProcessId = pi.dwThreadId;
    " ^; H! ~; S4 K& m$ R) w

  67.   n) p4 E5 m3 V% z' N8 ~
  68.                         while(true) //infinite loop ("Debugger")9 D' G' [, w7 P, @" ^" m8 {, X* `
  69.                         {
    ; y! U0 @: M6 o4 l
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    1 Q% e$ d  k1 i# _( Q3 h+ r+ q3 Y: _

  71. & H! F+ U' Z' H8 N# Y3 Q) H# |9 ]
  72.                                 /*3 B( V7 O/ l9 t; C
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
/ D5 ^8 [) E+ I' N* ?! ~9 p9 h3 L, J

9 W5 s# O% F( J9 ?8 O; e0 b& P2 d/ \  o8 ?6 k5 @# D& e/ t
商业服务端 登录器 网站 出售

13

主题

251

回帖

1233

积分

金牌会员

积分
1233
金钱
808
贡献
156
注册时间
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

回帖

1233

积分

金牌会员

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

3

主题

99

回帖

5633

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-22 17:29 , Processed in 0.080223 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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