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

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

[复制链接]

155

主题

350

回帖

6226

积分

管理员

积分
6226
金钱
1874
贡献
3847
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
- s0 d! M% e$ N7 r  P# }& u) v7 d$ N2 c8 W, Q4 X' x. U
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
8 ^* V6 H2 A( F- b$ z9 _3 @! ?% [+ b: E' P3 j
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。! |' o, \5 _" v4 _3 U# ]
  2. //
    % U, g2 E) R" r
  3. , E. p3 S7 r4 e3 b
  4. #include "stdafx.h"% Q3 ?4 j  ?# U7 C& N# [0 L
  5. #include <iostream>& y3 q. b6 Z  X) }; z& e3 K
  6. #include <Windows.h>
    0 C3 w# J6 r( N3 H6 G( m+ }
  7. #include <io.h>
    - O  |: g& ?& B- Z

  8. * U- Q0 A+ O4 s# I. h- i

  9. 7 K4 j, e& E, A5 Q
  10. int _tmain(int argc, _TCHAR* argv[])
    1 h# C$ ]. x* ~4 U  B: m
  11. {8 \. ?( Z9 ~( [- f7 w% j
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    , E0 L7 w3 @  D/ e1 t0 G3 N+ \) K7 Q
  13. 8 L* e6 W9 u( ~! J, C
  14.         //查看文件“DekaronServer.exe”是否存在
    6 A# X, f1 g0 [. i0 N6 F
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ; D! ?* a; ^3 f. G* c, X$ r
  16.         {
    6 z( p0 z1 G  h) D: l
  17.                 printf("DekaronServer.exe not found!\n");
    0 l/ j4 u6 I: H
  18.                 printf("Program will close in 5seconds\n");
    * s6 }& {5 ^/ x
  19.                 Sleep(5000);2 J: A1 \4 V: S. \- w5 k  a4 p3 t
  20.         }
    ! F, s; ?# m8 w  c1 l
  21.         else1 Q" _, K% ]. l& i
  22.         {
    ) i( j( z* _1 v% {( d
  23.                 9 F& y5 i& i4 ~& X' T
  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 D) m9 f1 r5 [
  25.                 STARTUPINFO si;
    & g6 m/ h* p9 |. ^1 q; \
  26. # Y: S- `. X4 T+ B, U! F% ~9 }4 u
  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
    + N! r5 c+ r3 Y& }
  28.                 PROCESS_INFORMATION pi;
    0 s; k" O2 i2 p% q" R  s% k7 M. P

  29. 8 M! c, E9 P, r8 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) ~; {1 {( a+ ~+ A
  31.                 DEBUG_EVENT dbge;2 q1 Z1 r$ {) z1 p

  32. " Y- d: E: [, h' @0 |$ M4 o8 ?- X
  33.                 //Commandline that will used at CreateProcess
    " Y7 ~8 x* _, o
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    & o+ |; ]* U/ c0 r& x

  35.   c' U" q# u6 x3 U4 Z$ Q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    & m: F" ]5 V+ N, b  ]  T
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    * y' E' _& `* e1 C
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ' s3 D2 w: j4 a9 y  h  P; @

  39. & K* G% |' u% b. ~9 m& L

  40. . O5 Z1 s1 O( V% H

  41. 2 v8 c: i  h1 y  f& _: d
  42.                 //Start DekaronServer.exe
    0 C# }/ E% ~6 w! [% A! P5 a# G
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    * x7 f$ Y. G2 H
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)/ i4 Z: x2 f  X/ c8 J6 R
  45.                         szCmdline,        // Command line% S) F. B4 V$ M# M- C$ S' W  C4 F, Q
  46.                         NULL,           // Process handle not inheritable2 V0 h  @; I7 {  W+ W5 W2 c
  47.                         NULL,           // Thread handle not inheritable% c6 f( u7 L* I4 C4 G6 u
  48.                         FALSE,          // Set handle inheritance to FALSE
    * d! t4 ]6 I  n- k# f, S
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx* M1 x4 @- V& @
  50.                         NULL,           // Use parent's environment block
    & T8 O# }/ \1 X; [; X% ~2 w3 x
  51.                         NULL,           // Use parent's starting directory / m5 ~9 I' ]& J. V: U# v4 F
  52.                         &si,            // Pointer to STARTUPINFO structure; {+ u9 y; Y& f/ F4 m
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure6 P" v+ V0 ~( Q# w2 V
  54.                 ) , e& L) O9 Y* U+ L& q& P
  55.                 {
    3 @3 L9 j+ s8 g& v- W; S/ Z% W
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );8 f6 h6 {' f, R; N, m# Z/ J% }- z
  57.                         return 0;" B" ^" ^( E. b# v
  58.                 }) e4 z" S: \0 y! x$ V* f
  59.                 //Creating Process was sucessful# G% F" ~& k1 q% [, i% B
  60.                 else
    6 ]5 B" J: b- F9 X" m7 f% Z% F
  61.                 {' e. o! r! u3 W
  62.                         printf("Sucessfully launched DekaronServer.exe\n");# z* k6 z2 G6 g, {2 E( Z7 m& g# d
  63. % Z! {0 S3 V7 e$ ?
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure3 X5 l  h' q" U5 C
  65.                         dbge.dwProcessId = pi.dwProcessId;
    & `$ b, i" o+ I' B  g& p* r
  66.                         dbge.dwProcessId = pi.dwThreadId;$ v# W; m/ _+ C0 R; n
  67.   k: X7 _5 }' m+ O6 c% d
  68.                         while(true) //infinite loop ("Debugger"), @  L$ ~# B: M) o! i% F# \3 ^/ i$ s
  69.                         {
    4 B7 y' E7 h7 S
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ( _1 a: P. ?, ~- T9 X

  71. 7 J" ~- L0 \. |. e. E
  72.                                 /*3 y  b  F/ E5 Z* _& f1 _0 K
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
* I" S+ _! J" U5 t2 O* ~

/ Q; S$ B2 M# Q" C% W' }
! |" A) \; L# k
商业服务端 登录器 网站 出售

13

主题

251

回帖

1250

积分

金牌会员

积分
1250
金钱
826
贡献
155
注册时间
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

回帖

1250

积分

金牌会员

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

3

主题

102

回帖

5883

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-10 17:21 , Processed in 0.106782 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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