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

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

[复制链接]

152

主题

325

回帖

5593

积分

管理员

积分
5593
金钱
1773
贡献
3343
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
7 x5 D) c5 X' F& J( `  b4 }7 H6 j( l* A) X  U
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。) ]# V" M0 t8 {6 `" i* i$ Q& d* P/ v8 g
; v- @5 c- B9 A4 W
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    3 Y; x8 ^) h: H8 K; k# i6 n
  2. //7 {: n* j* j5 t1 a& S
  3. ! [/ c& q6 X; ^8 `/ o
  4. #include "stdafx.h"
    ! o4 n: h8 s" z/ {0 u
  5. #include <iostream>
    # g: ^0 |. g) t; n" J: b
  6. #include <Windows.h>
    # G- l& ^/ g2 S* D% |% V, Q
  7. #include <io.h>) W$ R6 W0 ]' H2 R6 N5 [$ S# _

  8. 8 p/ l: l  ~! t1 U+ d, x
  9. 1 M+ T5 \# F; N. c9 C4 S1 A
  10. int _tmain(int argc, _TCHAR* argv[])
    0 \) M; s8 [" o) B
  11. {
    3 F3 l' `3 L2 Q' b9 }& e
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    4 E8 i8 F) A# E% L! n: m: V5 ?+ ~; Z

  13. ) f  v3 {( t6 i$ A
  14.         //查看文件“DekaronServer.exe”是否存在6 H0 d( F# w* A) f& a' w
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ( N3 K0 k# [' ^: B# b% W0 }
  16.         {
    3 ]4 W& F. O+ _( l
  17.                 printf("DekaronServer.exe not found!\n");
    ; _8 p* A$ w; q0 Y2 W9 t9 Z0 o, g
  18.                 printf("Program will close in 5seconds\n");( S: k4 N+ X$ T; G2 `0 X
  19.                 Sleep(5000);3 l5 y- t! \+ Y$ `$ E; }3 x
  20.         }
    ( ?4 X0 O  I0 w4 u
  21.         else2 c/ m4 ~1 H; k% ^
  22.         {4 g+ D3 R- N7 ?
  23.                
    - _1 F" D4 P/ @/ `+ F/ N/ 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).aspx9 _% E. b8 x$ R/ i$ q
  25.                 STARTUPINFO si;6 Z" z% z( \1 @
  26. ) M% `* r- z0 r& _8 D* M( n
  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
    5 b0 Y% i6 W3 }5 y0 I9 P. Y
  28.                 PROCESS_INFORMATION pi;
    0 t) d( u  C( ^& e
  29. 6 ~* L, C) g, r! ~( T1 m
  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) o: j% m/ C& J; T
  31.                 DEBUG_EVENT dbge;0 x+ _4 v9 l( g( @( t1 l
  32. - |* I" z& h* f8 j5 S
  33.                 //Commandline that will used at CreateProcess
    4 ^* ]6 q- i5 S; v
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    + V4 a2 c* e9 X' M& o
  35. 4 o5 |8 i2 e1 O- l! ]6 s0 N! I
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ( z" q% d4 S2 g1 ]2 h
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    : H6 O9 |- V* ?6 m' k
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)6 ^% F1 m$ n5 L$ ^, I$ K+ |! f! Q# u

  39. 2 Z, O& `* n- s

  40. 0 Z8 o: U, ]- N$ o7 Y

  41. ( i0 c: G+ m5 n: K4 ]% H3 u9 f; \
  42.                 //Start DekaronServer.exe
    & i0 p8 j1 c) b3 q# b
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    ( q+ L4 m: W9 {; K
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    & P+ p  \6 ?: D% r8 ?, N6 D
  45.                         szCmdline,        // Command line
    6 L( Q/ y: b& o. d1 w- z
  46.                         NULL,           // Process handle not inheritable7 M! }( C4 k& U
  47.                         NULL,           // Thread handle not inheritable1 ~% g7 d5 _8 @# b& x% \7 g5 _
  48.                         FALSE,          // Set handle inheritance to FALSE8 B& w4 \9 q# y3 x  z
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ' q- f* v( I$ v$ f: ^! m
  50.                         NULL,           // Use parent's environment block- x4 A( O$ b8 n7 P0 U) q1 v; k
  51.                         NULL,           // Use parent's starting directory 2 |8 {! U, q/ c8 |1 Y; S, V: Y
  52.                         &si,            // Pointer to STARTUPINFO structure
    , B, y9 m4 C2 A2 z) e( x
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure& v3 w& a! |  w5 p7 g4 p
  54.                 )
    $ Q: g6 ~: S4 O( k* M0 F% h. e; _
  55.                 {
    : b6 c9 X4 `% Y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );3 N/ M- @7 Z& M  g* }
  57.                         return 0;+ M6 c1 u- [: k7 X9 m+ F/ G9 ~. y6 n
  58.                 }
    ! d( ~0 O/ A6 {- `2 R- @& `' ?
  59.                 //Creating Process was sucessful% C3 n( Z1 L9 x+ s' T+ [# ?
  60.                 else1 N  N5 h  R& [) E' d2 r7 X% r
  61.                 {
    ( R6 X. D3 q, ^% m3 p- X* T
  62.                         printf("Sucessfully launched DekaronServer.exe\n");9 W1 S0 N% Q$ p# X5 H6 ~- R, x

  63.   f& o8 j! L3 [4 L% S
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure4 f& q* {' K8 ]7 y; @; t
  65.                         dbge.dwProcessId = pi.dwProcessId;
    0 _/ ~2 ]. s* R$ P3 B+ q
  66.                         dbge.dwProcessId = pi.dwThreadId;
    4 I- |  [  i- i7 p, |9 i* g
  67. 6 u$ T0 V% i  ]
  68.                         while(true) //infinite loop ("Debugger")/ K5 `. {; i: U' G
  69.                         {/ z1 f# B1 {) |5 L
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx5 w# w9 u4 w+ \2 S5 X7 D, X: X3 Y2 v

  71. 0 w/ ^" N7 q' K! `* S
  72.                                 /*
    - ]- t# x; w. ]: I! w1 P9 k
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
" ]' y: v6 i( T) _, m2 s. |1 e2 u. i

0 Y& U0 D$ B( E, s* x( a; G9 L7 z4 D3 ]" x1 ~
商业服务端 登录器 网站 出售

13

主题

250

回帖

1199

积分

高级会员

积分
1199
金钱
765
贡献
166
注册时间
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

回帖

1199

积分

高级会员

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

3

主题

97

回帖

4811

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-8 23:28 , Processed in 0.058615 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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