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

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

[复制链接]

161

主题

389

回帖

7476

积分

管理员

积分
7476
金钱
2161
贡献
4765
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
6 `7 I9 l" {; E+ Y4 M# G- @$ G. Q. d: N( U4 c# |: M+ @
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
/ _( N& `3 M  u( n/ i( @; }  g; a
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    6 o, `' R3 q- ?# l" V, p* r3 @
  2. //
    & j+ f  |- j' b7 Y8 P
  3. 4 s6 R5 {/ j/ X' @
  4. #include "stdafx.h"
    9 |4 Q) ~7 ^8 v% e5 r
  5. #include <iostream>9 o# S8 g" [3 }) T  p: q
  6. #include <Windows.h>: \; f$ }: G1 j2 X( V# s
  7. #include <io.h>/ \8 J: D" q! g1 O
  8. " C* H( s) v/ {( ~. l
  9. / F6 U9 I2 Z: j4 r; Q
  10. int _tmain(int argc, _TCHAR* argv[])' R* O) g- C' n
  11. {
    9 }' ]1 {! |, X8 s$ F! e; [
  12.         printf("Dekaron-Server Launcher by Toasty\n");* ^% q  M- ?1 Y" q+ {; U* p0 l

  13. 6 ]* _, h1 j4 J2 O0 h" ]" F
  14.         //查看文件“DekaronServer.exe”是否存在$ _  B% o' _& W+ I8 E8 q: N1 R
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ) o0 r2 ]7 L  k
  16.         {
    & n1 l5 p% k0 \7 F
  17.                 printf("DekaronServer.exe not found!\n");" o) B# H+ U5 p# s" i9 B- P# w
  18.                 printf("Program will close in 5seconds\n");
    / l, n/ P  j! \6 [1 d9 ?
  19.                 Sleep(5000);
    * U4 l* w6 Q, h  T0 H/ R
  20.         }
    9 z0 r# a9 v" }, f4 {* R
  21.         else4 f1 e' e- ]* d% j7 Z+ M0 z) j
  22.         {+ {2 Y: d0 Z' v, l4 i+ F% ^
  23.                
    ' w: K# q1 X# [& E7 B5 j8 e& 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  |. G5 T$ p) D. I" @# |" _6 ?
  25.                 STARTUPINFO si;0 I4 c5 |8 s1 s0 o& V, b) C

  26. 9 D4 P: @) B" U: ~( f' y/ c
  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
    4 @9 e7 J9 w6 ~4 D/ Y- C
  28.                 PROCESS_INFORMATION pi;! c" M7 Z3 `( k

  29. ' R& p$ H4 e% ]. ^! F( N8 A
  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# X& `/ W& ]% W. V, v( g) T
  31.                 DEBUG_EVENT dbge;
    1 q. l' O* R6 n. X

  32. ' S- i% _5 j& V& M  }, T
  33.                 //Commandline that will used at CreateProcess
    % s0 @, n; N: H9 h" X
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));" Q1 J6 P+ C, c1 N1 q  W) ~) D3 v
  35. : d6 L$ W, k4 ?/ c. }9 a% F
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    # i/ U% p" Y, O& K, |1 T" ~
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    ' R6 U/ \% I7 t! `9 M
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made). s( V3 J% r. l& l+ H/ d& ~

  39. : }4 ?8 a4 L% H8 e! E% }
  40. $ z3 P+ \+ P+ [. O

  41.   p; y7 `: |( R) x5 ]# K) t) i! G
  42.                 //Start DekaronServer.exe / `3 {" }: n5 B4 s
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    / K) E8 k- N5 M; I( c6 N
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ( u4 b+ l  f( ]% l9 C5 Y, ]/ [, U
  45.                         szCmdline,        // Command line7 V3 Z6 I7 k- ~1 w/ x( w0 |
  46.                         NULL,           // Process handle not inheritable
    / ~4 }7 y3 D: C
  47.                         NULL,           // Thread handle not inheritable
    1 i- K4 h+ j/ Z- ?
  48.                         FALSE,          // Set handle inheritance to FALSE6 t4 W! L5 V1 t8 E
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx' E# j/ K" j3 @6 ^' D1 m# ]0 K) }
  50.                         NULL,           // Use parent's environment block1 o5 q- R- u: ^- \" U3 @' p; B
  51.                         NULL,           // Use parent's starting directory ) I9 @% P5 {! y5 j0 [! [8 m
  52.                         &si,            // Pointer to STARTUPINFO structure
    6 ~7 l* b* r. |
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    3 \9 |7 e, K' }" A  N6 F
  54.                 )
    ' \" Y$ @/ l9 ]6 z" z
  55.                 {( R/ \; u% F8 t" d& O
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    8 ^+ n. j* U2 ]. Y# R
  57.                         return 0;
    4 @& d; x8 U7 a0 C1 P5 ~/ V
  58.                 }# M3 W% n; C' `9 x# z% S5 x
  59.                 //Creating Process was sucessful! ^; }" Z, W" g* j' l. j4 b/ d0 L
  60.                 else0 I. O2 N" x6 S! G/ V0 S
  61.                 {' E% T% h& P- w+ A) y
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    " I2 Y  A' g( K

  63. ; L6 f( U1 ^) k* x: C
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    - Z! l" ]: f' k0 }% l# x2 W4 {$ B
  65.                         dbge.dwProcessId = pi.dwProcessId;
    % v' C7 k' k* v, w: j
  66.                         dbge.dwProcessId = pi.dwThreadId;1 F5 D% J1 K, u, H, J9 l

  67. ! C; I7 Q* f, A' p5 E
  68.                         while(true) //infinite loop ("Debugger")
    * d8 P2 j7 I8 y. F5 f
  69.                         {
    & @' k# q; d. J3 W  T1 ^  u
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    8 T* g8 _& p4 D5 d5 O2 Q, u+ o
  71. 8 q$ g, I$ j' \9 I1 `/ v, q9 G
  72.                                 /*
    " S  O8 \9 p6 R# T
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
# Q; X. _* V) S) F; {# Z6 M0 ^
7 L3 t- [! w) c; `2 q
( b  q/ \; v6 h# f
商业服务端 登录器 网站 出售

15

主题

260

回帖

1313

积分

金牌会员

积分
1313
金钱
945
贡献
88
注册时间
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

主题

207

回帖

355

积分

中级会员

积分
355
金钱
142
贡献
6
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

15

主题

260

回帖

1313

积分

金牌会员

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

3

主题

102

回帖

8157

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-13 21:04 , Processed in 0.057318 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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