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

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

[复制链接]

153

主题

334

回帖

5706

积分

管理员

积分
5706
金钱
1802
贡献
3417
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) - g1 F% q" X& Z9 f

7 |1 s) u. v* K- Y虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。1 K7 _7 e; i- B" g/ Q
+ P8 L8 |* S+ X' M
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。2 ~8 Z6 U  ]. n; r+ I% u
  2. //
    5 `. O" e+ I1 M$ x

  3. * R0 K3 X) ?8 I/ h2 w( z" T4 n
  4. #include "stdafx.h"  `4 [: c- D  W% U
  5. #include <iostream>
    9 Z! A' }( D7 _! }- `: U
  6. #include <Windows.h>. L6 H. P  U' N% e8 r  Q5 V
  7. #include <io.h>8 l' M+ r% D, X& b' y

  8. - ]* Z3 D8 q! M8 Q) }: h' L1 r
  9. * k% h/ N" ?* h! \! L
  10. int _tmain(int argc, _TCHAR* argv[])
    2 j* z5 C7 t; J
  11. {
    0 Q9 G& o: \& Q9 c& D3 }2 Y, t
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    / y, O  w6 _$ [
  13. 3 M8 i' }: b' K2 F7 Y* g
  14.         //查看文件“DekaronServer.exe”是否存在
    $ K5 G$ E& E5 S& x! L: H
  15.         if(_access("DekaronServer.exe", 0) == -1)
    $ u; g9 ?2 E8 \" @% y$ P
  16.         {
    6 \% c/ b& A# T7 N
  17.                 printf("DekaronServer.exe not found!\n");
    ' U( v' {4 m. x$ x
  18.                 printf("Program will close in 5seconds\n");
    7 d5 z) E/ {" O/ f/ X
  19.                 Sleep(5000);$ s( K" g9 h4 e# z1 Q3 t% t) c
  20.         }: g5 L0 v5 H/ X$ v7 r7 p
  21.         else% T& X. A+ t, P3 C
  22.         {+ _7 V3 d8 l& H  Y' Y$ B# ^5 D+ Y9 [
  23.                 & G8 N8 j; W5 }& E. G- o0 a
  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" N8 L9 N" T7 N. l5 r9 P4 {! A) `
  25.                 STARTUPINFO si;1 h/ X% U* P3 E3 y$ }

  26. ; c  Y  g- S5 L1 s' B0 ?
  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).aspx9 ?) a  \& b) B: h# m) }2 K& |9 H
  28.                 PROCESS_INFORMATION pi;
    ) d; A6 F' v% ?6 X( A& K" u; V
  29. % C6 I3 G8 |) q3 h+ }1 {
  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
    # n1 I3 l' q0 T8 u0 a$ O
  31.                 DEBUG_EVENT dbge;* ~# }  \+ |* _4 |1 D1 F1 ?, l. o
  32. ; h2 r6 \' ^! F4 ]: X! L
  33.                 //Commandline that will used at CreateProcess$ N& }8 d& D% o% K
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));" C$ ~8 d. k* B$ o0 |8 F

  35. , U6 s- h/ P$ j& f: G
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    " E7 H6 \3 w! v$ ~4 s
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    2 {. E( ^; ^3 z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
      J) n% v9 D  Q7 c+ j" {

  39. ; }. s! d3 ~2 w  |! p& S
  40.   d; f) ^8 y. R' T1 @6 ^) V3 _- Q3 O3 z

  41. # P6 X% g. E& {3 ^% {! V
  42.                 //Start DekaronServer.exe # N; `! u, M% Z& w- i
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    2 H2 e8 F9 F$ ?8 v, _+ K: \$ u9 k
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)7 U+ b9 N; c# y4 Z$ @
  45.                         szCmdline,        // Command line6 ?' ~; L: |5 @& J' e& {# @
  46.                         NULL,           // Process handle not inheritable
    ! a: n" [: R0 `3 Q8 ~; T
  47.                         NULL,           // Thread handle not inheritable
    - b  ~6 n7 m4 B3 I2 V
  48.                         FALSE,          // Set handle inheritance to FALSE% w. T1 a2 Z5 `
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    8 H& ~1 d, S5 l* L! F. w, j
  50.                         NULL,           // Use parent's environment block# ?$ Z7 O' R% I. t0 A
  51.                         NULL,           // Use parent's starting directory / |0 N, J$ I$ n" E' f# h* \
  52.                         &si,            // Pointer to STARTUPINFO structure! {3 a- i0 b5 Y% Y& ^, s
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    : v/ i: y9 @9 ]( Q
  54.                 ) 4 G* l4 O  V  X: T% n/ h; _+ _
  55.                 {
    ) @* Q, {$ ]% L9 M* _" _
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    2 ?! ]* b" \$ J7 D
  57.                         return 0;
    , R) E9 A: b; Q4 h
  58.                 }$ a/ J; a) E! Y0 [/ N- `
  59.                 //Creating Process was sucessful
    ' T0 O# O3 z2 t6 c* u# }6 p, d8 s
  60.                 else" V+ l- m: v" |4 h7 |) ~9 q
  61.                 {
    2 x' n1 t! [! u' G; |
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ) ]7 O% r$ Y- d* a5 K

  63. . m' Z7 E1 r  b$ F* w. a1 y# d
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure% R: _5 A- m+ v% z
  65.                         dbge.dwProcessId = pi.dwProcessId;
    2 }1 n$ k( }- e
  66.                         dbge.dwProcessId = pi.dwThreadId;7 u+ H/ D) Q1 Q$ ^$ B/ ~

  67. 8 K2 V6 p0 {" I) y* B
  68.                         while(true) //infinite loop ("Debugger")
    ) \% n. U8 S( y6 ~# [
  69.                         {" {8 M" ~, [. l$ G8 [$ Q
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ; N; k( j" n+ }1 R
  71. ! A: a! O$ \6 x& L0 I. R
  72.                                 /*, W0 @( K/ j- }  s& }
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
/ B8 E  q7 D+ w# O

% P. K' \( Z6 [, Y7 x- }6 k7 O2 N5 z# h4 t% v
商业服务端 登录器 网站 出售

13

主题

250

回帖

1220

积分

金牌会员

积分
1220
金钱
779
贡献
173
注册时间
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

回帖

1220

积分

金牌会员

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

3

主题

98

回帖

5091

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-25 16:58 , Processed in 0.064128 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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