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

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

[复制链接]

156

主题

353

回帖

6483

积分

管理员

积分
6483
金钱
1903
贡献
4071
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 5 c% v: @: R# n
3 R# ]5 ]- Q3 b+ d! Z; T
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
% ~7 j) u5 E! q  }$ S0 \2 x3 L7 r
+ u" D, K, U$ Y
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    $ `" b2 m" _6 X+ Z
  2. //- ?$ T3 m. L/ p% \  L
  3. ( D5 x+ F0 g$ x, Q/ A# a
  4. #include "stdafx.h"% x' u! l+ y1 N) S$ l
  5. #include <iostream>" P) V, W) s4 i2 q* ?8 G
  6. #include <Windows.h>' x3 f; P8 Y. j  \8 U" |
  7. #include <io.h>& p5 D- o5 |" @  V$ P6 g

  8. ) S$ D% P" J* m- b
  9. ) y' _+ t" V- h$ s
  10. int _tmain(int argc, _TCHAR* argv[]), N8 x4 g9 e2 W# i6 W5 I8 C
  11. {9 }7 t* A: F* }+ c7 T- c  j3 [
  12.         printf("Dekaron-Server Launcher by Toasty\n");+ j: n! s+ w, B  a

  13. $ l# K# e( E1 \+ @! H  y+ f) L
  14.         //查看文件“DekaronServer.exe”是否存在
    + Q5 j( U/ n! j7 G8 t
  15.         if(_access("DekaronServer.exe", 0) == -1)
    $ w  X8 |9 }& q' G0 ~
  16.         {8 }6 A: F$ \$ W; t/ A- H5 ~
  17.                 printf("DekaronServer.exe not found!\n");4 s& r3 g5 T, o& e% Q
  18.                 printf("Program will close in 5seconds\n");2 [( K$ G: l( b) a9 ]
  19.                 Sleep(5000);3 R( @9 H* W) v% I1 N
  20.         }0 o- V0 P7 C3 }& G' ?: h1 U
  21.         else1 `; v. j8 J( ]; I
  22.         {
    ' \3 f  B. j# [" q+ b. ^+ P# q
  23.                 0 }' t" ]* `. p9 ^- x0 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).aspx$ _4 _2 U' }/ h6 f  n: J4 h- ?) U
  25.                 STARTUPINFO si;
      `, l) w* L6 E1 u. D3 v9 J

  26. 3 S$ l7 ?  V% M
  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
    3 r8 V, E. g- [
  28.                 PROCESS_INFORMATION pi;
    " N  G( J  W' l1 w- t

  29. / C$ D# N" g* V7 O: \* O1 F- 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
    4 z7 ?2 A( L2 j) A& d* ?% R
  31.                 DEBUG_EVENT dbge;& h0 z: {8 _7 X+ ]
  32. 4 e$ r8 z0 a9 }0 c- }
  33.                 //Commandline that will used at CreateProcess1 P: I& m: Y* f9 ]
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    : ~3 P& {; C+ m! T7 m; q0 h( m
  35. * Y8 e6 j) b4 |5 E% m4 o* A
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    1 n% ~2 q: O' e
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    4 k% l7 z! g5 _1 R3 U$ y1 n
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)/ D, P4 Y; T4 D2 e+ A1 n
  39. ( r6 G1 x$ y5 W5 [5 c" `* c
  40. 2 ^; K/ }# ]2 {9 e; E' C7 K* {
  41. % ~1 [' M$ ^/ q( U9 C5 I& l
  42.                 //Start DekaronServer.exe 8 G; Y2 c$ W" D; O3 G+ q
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    / a3 n* w2 v2 \7 \# R. ^" o
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). [- H4 H# ^1 k5 @& c
  45.                         szCmdline,        // Command line, F9 `0 R0 k7 h# e4 [$ o
  46.                         NULL,           // Process handle not inheritable2 J9 e" ^) F+ V. R
  47.                         NULL,           // Thread handle not inheritable
    ( a8 w+ l5 [9 E
  48.                         FALSE,          // Set handle inheritance to FALSE1 I" b8 D) H6 e* f! b
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx* z/ Q& Q( Y9 i" C6 ?9 ?, \
  50.                         NULL,           // Use parent's environment block
    3 j& f1 [" {0 z
  51.                         NULL,           // Use parent's starting directory
    " r, X4 q% |1 ]9 n7 s2 [
  52.                         &si,            // Pointer to STARTUPINFO structure
    9 m& J) Q! w$ t# F* ~) z. ?
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    + V! e: |2 v' {. D
  54.                 )
      a+ M+ X, z6 E& {
  55.                 {
    1 z" }$ T2 N5 G7 @) M+ _5 k* _7 y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );1 Y$ k% s% t! v/ A0 g) Q
  57.                         return 0;3 }+ Y+ ^7 x# h
  58.                 }
    4 E9 @. u9 e  x
  59.                 //Creating Process was sucessful
    ! _; b- `& O; ]; N8 K. c
  60.                 else
    6 M, |" E. b/ u/ r% [
  61.                 {" C& n3 O: t7 D3 U- s
  62.                         printf("Sucessfully launched DekaronServer.exe\n");9 T7 R  N( }$ r9 d

  63. 2 Q2 N6 }+ z) E# U- ~3 Y+ C
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; W% x/ X9 B( P3 `
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ; n* l+ o( i# w! C: @) `' y0 S
  66.                         dbge.dwProcessId = pi.dwThreadId;# T; |$ X9 z' z/ k  S: y* R
  67. / I& m1 r. |* J2 a4 f7 L  q4 h' B
  68.                         while(true) //infinite loop ("Debugger")
    % u& S5 h: G, T
  69.                         {; @  r# P  r0 ], Z# t2 x
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    + `- F2 P4 q5 L  g7 n  g1 c
  71. ! n$ \( ]6 {4 B# R* w6 `
  72.                                 /*
    7 Y# X- H- h! V  X9 W; C4 s
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

3 z  E+ T% W$ A7 Z
! ~) F6 [7 n1 k9 x& }! _
% q+ G* _) p' x: \7 z
商业服务端 登录器 网站 出售

15

主题

256

回帖

1237

积分

金牌会员

积分
1237
金钱
853
贡献
108
注册时间
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 | 显示全部楼层
学习学习赞赞赞

15

主题

256

回帖

1237

积分

金牌会员

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

3

主题

102

回帖

6055

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-22 10:59 , Processed in 0.067925 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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