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

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

[复制链接]

156

主题

354

回帖

6542

积分

管理员

积分
6542
金钱
1910
贡献
4122
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) / p& g, y, V/ C

! d" {5 G; s! {6 |虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。" H) G  g, x2 _5 t, l0 b, [

8 D9 s; b$ M' r* i% m# A' K( o
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    / w, b+ E" [8 C  m* c* S
  2. //6 J6 y2 D0 t1 Q+ }! O

  3. % g5 y, B, @# _
  4. #include "stdafx.h"
    / G( ?7 r4 k! p) V0 C
  5. #include <iostream># T! F$ u) m" }+ u& t, ]
  6. #include <Windows.h>$ t; `5 m( R, U, ]2 v5 |2 y
  7. #include <io.h>) N% I) k' m6 K
  8. ! r- y5 D, P/ U  x: M. [

  9. & n) |5 ]/ W2 ~& C( u
  10. int _tmain(int argc, _TCHAR* argv[])
    6 Q/ Y; O% a2 a! t" @( c
  11. {" ~7 ]+ r0 W0 E8 I8 @! {/ o
  12.         printf("Dekaron-Server Launcher by Toasty\n");' ^9 E' `) a1 T3 ]" Z% x

  13. ! s8 B* e+ a8 G# e# x, U2 S
  14.         //查看文件“DekaronServer.exe”是否存在
    3 b; u% f" e: G& w/ ~
  15.         if(_access("DekaronServer.exe", 0) == -1): q. D; N7 s7 m- n
  16.         {: a$ h0 K8 b4 v6 ?& J
  17.                 printf("DekaronServer.exe not found!\n");) B' @$ G  e* E' G
  18.                 printf("Program will close in 5seconds\n");
    $ I- I6 \5 S. C- y
  19.                 Sleep(5000);
    5 }! `" Y9 z; R  v4 c7 C4 J- G% t
  20.         }
    3 ]* b9 r: E1 D4 O. m- z/ p/ Z
  21.         else
    ( U4 i3 }8 Z7 L9 G+ `6 F4 W9 j* A
  22.         {: q. m. f1 q4 n7 I7 X$ ^
  23.                
    0 E! Z! ^6 E+ K, i4 H( J" z
  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
    6 s  `/ s3 N" ?5 k" f' y
  25.                 STARTUPINFO si;
    8 a* Q4 l( F2 ~% C( k
  26. " D- s) |3 u' s" W" p
  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
      p0 V1 X+ M( O. y' Z+ s% K  m
  28.                 PROCESS_INFORMATION pi;
    9 y8 p! q8 d7 `6 d

  29. * [! }. }1 f. D! H# {0 ~
  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
    ) e/ G5 z1 A& y; i+ @
  31.                 DEBUG_EVENT dbge;% ]/ h. x% S6 Z$ S! j
  32. 4 _- R2 m1 ^2 w. T8 L
  33.                 //Commandline that will used at CreateProcess
    * w6 ~( Z2 Y) U! _& @
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    $ W) a9 E8 [0 n& d  F  \0 \( x! k: ^
  35. 6 H7 f4 W' d' C5 g6 R2 c# G( Q) h
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)' j: ~9 [( V/ I# C3 p7 ~
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    7 Q7 E4 v& S8 M
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    / P, U0 J. v. ]9 ^. k% }' E
  39. 9 m3 |/ M- _/ D

  40. " Z8 j$ H: E% B" i  N; T
  41. - L8 R2 J) _! u' B6 n
  42.                 //Start DekaronServer.exe " w% Y& ~- ?1 ^- W+ O' ^$ s9 ~
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx2 S, Q) u) Y7 Y3 N+ i- {, S- {
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)2 y. y) f5 g+ B( |+ W9 v% o
  45.                         szCmdline,        // Command line* j# g% f% N7 D% D) r
  46.                         NULL,           // Process handle not inheritable' h7 b  y) Q/ A% n! `9 `, g
  47.                         NULL,           // Thread handle not inheritable( a+ v0 |* \9 I8 L+ g
  48.                         FALSE,          // Set handle inheritance to FALSE$ s  r3 H- c4 l6 s: n- }8 a
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ' F- k+ d0 q6 m; {
  50.                         NULL,           // Use parent's environment block! y$ u4 G8 V. ~7 x
  51.                         NULL,           // Use parent's starting directory & }8 \4 z7 I* L5 z" r
  52.                         &si,            // Pointer to STARTUPINFO structure% {. N  L) \0 U5 L* ^
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure# o, A$ k; \: |* X4 S; E& s
  54.                 )
    5 J% o2 Y: }* x
  55.                 {& c: u! }# y: _3 q0 P$ O' z
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );( B' }9 U: M) n% T1 A5 ~% T
  57.                         return 0;1 m9 ~5 Z  |: p0 k. q8 ]2 [+ {
  58.                 }
    # ]& Q' D5 L+ M$ b4 E7 V  m* l  z
  59.                 //Creating Process was sucessful% \; q3 B) ~) k& J2 [- R* d8 @
  60.                 else
    0 S6 s  |7 S" }* G! f' a
  61.                 {
    8 ]  J0 M$ |1 C/ Z9 |3 V# Z
  62.                         printf("Sucessfully launched DekaronServer.exe\n");+ x2 B( ^& q1 V; M0 X+ Z
  63. & y2 @8 y! w9 ^& e6 F
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    9 T7 _) P& D, k5 Y" u
  65.                         dbge.dwProcessId = pi.dwProcessId;% A0 B9 |( B6 V- f, l3 U- ]
  66.                         dbge.dwProcessId = pi.dwThreadId;
    . Q  [$ f/ s* T7 \5 e

  67. & ]( _3 u7 \4 ?& k7 @
  68.                         while(true) //infinite loop ("Debugger")0 y+ a" O7 r( D$ e# ?$ e
  69.                         {
    ) z# f( ]! f8 Z9 [! B
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx  c/ N& U3 b/ H8 i  n: w7 i
  71. 1 u! C, u  T9 ^& y, g  l8 a
  72.                                 /*
    , p( y# K; E. P
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
7 Y# w* r, q' M/ w

  M" J, Z8 G9 Q! |; O* S  m
1 }5 U5 {7 c5 M  P, |& z
商业服务端 登录器 网站 出售

15

主题

256

回帖

1244

积分

金牌会员

积分
1244
金钱
855
贡献
113
注册时间
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

回帖

352

积分

中级会员

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

15

主题

256

回帖

1244

积分

金牌会员

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

3

主题

102

回帖

6141

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-27 07:19 , Processed in 0.076217 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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