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

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

[复制链接]

154

主题

340

回帖

5807

积分

管理员

积分
5807
金钱
1828
贡献
3485
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
! R/ P  L3 j8 l) J
- [& w% J3 K6 e虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。, T' w' g  U$ p, b

- ?- n/ h. d4 l( E; d4 h
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    , r) [0 n" @5 @% R9 m, G+ h, z
  2. //; m9 [/ E( B& R* V1 g, F) t. {
  3. 6 ~- S: S0 q1 t, f' i& i  l6 _9 V
  4. #include "stdafx.h"
    ( j/ }1 Z/ B3 z5 ~( p4 g& `) M0 B
  5. #include <iostream>
    4 r% D0 _2 l7 i; B* [
  6. #include <Windows.h>
    2 K% Z5 S; {1 G, c' N4 t: r% k
  7. #include <io.h>, S7 v5 Z' [. S; }/ D$ S. m. k; K

  8. + u- F* f& q- y6 k% G  R

  9. / |  B- V2 A! e9 m. L" n9 \
  10. int _tmain(int argc, _TCHAR* argv[])1 A$ ~+ ], |' Q9 f; @) b
  11. {5 D$ P$ d8 Z8 v8 K! H# ~
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    " A, L& S8 N* W6 p

  13. $ e' o  x- U' P. l/ M9 n
  14.         //查看文件“DekaronServer.exe”是否存在
    " K5 m" i3 k9 c6 {
  15.         if(_access("DekaronServer.exe", 0) == -1)
    5 o- `+ V$ o; r7 Z' x  u) b5 |
  16.         {# F* B; o. E4 t
  17.                 printf("DekaronServer.exe not found!\n");
    ( i3 H0 `" E' k# b+ T1 K" V
  18.                 printf("Program will close in 5seconds\n");* m: s" V5 o1 V% w
  19.                 Sleep(5000);2 n; h7 [, l  ~+ O- x
  20.         }! n& Q, {8 M! `- J4 H$ y* [
  21.         else
    ) _+ d% i( F7 ^, q; \/ ?
  22.         {1 s) s, `8 B& @9 J( J0 P' `/ L
  23.                 1 o- o2 v- X- k9 w# _1 Y7 y
  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).aspx6 M# k+ X  n0 M7 E. C& P
  25.                 STARTUPINFO si;
    : D: i" K, j( d4 N5 r

  26. 3 s& x" B7 Y4 r, S
  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% h1 b; S& i6 Q
  28.                 PROCESS_INFORMATION pi;3 \6 U  M7 \' X" [. q4 a  C

  29. 7 |& p, h- l! ?$ 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/ a5 [6 N2 j% |  G$ K! w
  31.                 DEBUG_EVENT dbge;5 i9 C/ P: \. Z+ m4 W3 K

  32. ' \& }0 `/ M+ y! J# Z0 H
  33.                 //Commandline that will used at CreateProcess; C9 x* h2 Z6 \5 m+ r- S
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    , J3 c7 O3 x& p3 ]: t$ Y( b

  35. ) S! h: S6 e. _; }
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)4 x/ `, }' n  F; g  Y* r: I* O
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)9 e2 N" V( N: K9 u
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)- `( }5 Z& f+ v
  39. 6 _; V  F' p1 {, F1 ~

  40. ' O1 e- M& P4 {/ _! V% t
  41. 8 ^1 p! N0 b3 O" g# j. `
  42.                 //Start DekaronServer.exe
    6 }( Q8 s( n4 X) @# }# f
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    9 C: q$ U4 h3 G, C3 d! U7 t- @
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    , U/ o' q0 T7 U  V  {. L: N
  45.                         szCmdline,        // Command line7 ^8 [3 w$ k. j
  46.                         NULL,           // Process handle not inheritable
    7 p/ L" p+ ~# E" c
  47.                         NULL,           // Thread handle not inheritable# R& M$ i) z, o% O; l& H
  48.                         FALSE,          // Set handle inheritance to FALSE
    % q# O  b" U( g& ~& U/ E
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx& X/ P. h# c" W3 t  W
  50.                         NULL,           // Use parent's environment block
    ' ^# c( Q3 Z8 b' B
  51.                         NULL,           // Use parent's starting directory
    / m( p1 g1 B! w) k1 n
  52.                         &si,            // Pointer to STARTUPINFO structure6 `& E8 u2 @6 G1 X# ?$ `) O; }
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    # L1 O+ i6 Z- e
  54.                 )
    0 |! V& R# x+ i9 D/ {
  55.                 {
    , m' v- Z% n3 f' E  i
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );- K, X0 c8 K0 `* r) ^
  57.                         return 0;
    ! |' ~- j: d+ U. n, J; {
  58.                 }
    ; P# I; v- l  [  c) d7 _+ n
  59.                 //Creating Process was sucessful5 P( h% W& D& v# [2 n; t1 l
  60.                 else
    . b9 t* O, x2 s6 s' S* X0 H
  61.                 {
      \6 s5 F& |! o. J* n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    * q1 a+ T5 a; L. t2 A; `
  63. 1 M1 Z9 o1 {9 z& N8 k
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure+ j8 \6 N0 ^! j2 C
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ; w6 K4 e3 V: C2 m/ k
  66.                         dbge.dwProcessId = pi.dwThreadId;
    " E0 O  |7 Y4 O5 o1 W- ]
  67. / B$ b' _) _* v# c! a+ y3 z
  68.                         while(true) //infinite loop ("Debugger")7 j3 A5 |7 L4 x
  69.                         {
    ; ^8 P$ H6 u, `) b0 ~, O
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx! ~" ~" Z  w6 \
  71. + m  K7 a7 p4 t7 r/ U7 I+ i
  72.                                 /*
    + Q! E1 C6 B1 I
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

6 a4 y/ B! u! v; r6 @4 p4 d7 G9 i9 ^7 D' U5 b. i

, K" }' d6 e' y
商业服务端 登录器 网站 出售

13

主题

251

回帖

1249

积分

金牌会员

积分
1249
金钱
796
贡献
184
注册时间
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

回帖

1249

积分

金牌会员

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

3

主题

99

回帖

5313

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-6 16:25 , Processed in 0.066391 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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