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

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

[复制链接]

157

主题

362

回帖

6846

积分

管理员

积分
6846
金钱
1946
贡献
4381
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
2 T) x7 T* E) ?7 K6 H" u( S( u) j' i1 _  ]4 F+ v% c0 P
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。# t% c/ C; O# D: I$ s& i5 ?

* h$ `- c: q& p' a+ ?1 a) f) M
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    % t3 J- y! z  y
  2. //
    : p" k1 ~0 J1 N4 V% p) h
  3. ; |/ [1 O. M% Z% p
  4. #include "stdafx.h"8 s, C: L) L( Y, Q: z" ~" D
  5. #include <iostream>
    2 \, v# i4 {6 x
  6. #include <Windows.h>
    0 b; q* r9 S+ C7 W4 G( p  o7 E2 q
  7. #include <io.h>
    ( p$ J! S2 y) N+ a

  8. 2 A: u! Y+ Y: D( k" b% p3 B
  9. # [3 C% w( w0 Z- N/ S5 Z
  10. int _tmain(int argc, _TCHAR* argv[])+ x8 O1 L# M( }+ s1 F' J; }
  11. {
    2 P: T  c/ k1 `
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    + _$ ~4 c' P. [# m+ I! t2 v

  13. " h4 ^+ _* B! U$ ?" a% b& D# l! t
  14.         //查看文件“DekaronServer.exe”是否存在1 Z+ @; w- m4 o
  15.         if(_access("DekaronServer.exe", 0) == -1)2 f2 k( |1 q" w; m  w5 s
  16.         {
    " D4 q" Q; Y" {0 H1 R+ W+ G
  17.                 printf("DekaronServer.exe not found!\n");8 i- i3 E# d+ U& q5 H. Q& B, q
  18.                 printf("Program will close in 5seconds\n");
    " Z- g2 w, d( T2 R7 T7 j
  19.                 Sleep(5000);
    ( u" R+ Z% n: G( e5 H9 [
  20.         }/ l- c$ ?! Z: x% m0 q0 x/ F
  21.         else$ b) U% P1 m$ L% L: s4 u
  22.         {
    ! `4 r5 ?5 W( v8 ~
  23.                
    : P: @$ m" _" E+ P& F( G6 s
  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; W+ p/ Y, ^5 w$ \$ g( A
  25.                 STARTUPINFO si;1 w+ i& {0 O& g6 d
  26. . v6 Y! x7 p2 t, v: }- F0 ]- p+ j
  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
    & {* D# S' f% B+ l2 X8 c$ t
  28.                 PROCESS_INFORMATION pi;
    % c' b3 X5 l/ B1 N2 J' k" {. y

  29. 4 R8 ^9 n$ s3 [: x' c
  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# K! u0 Y5 I8 T" X
  31.                 DEBUG_EVENT dbge;! n% U6 |; l8 D% S3 E+ Z; {& N

  32. ( g8 Z. U% R0 x+ N$ D, a# B
  33.                 //Commandline that will used at CreateProcess
    , o0 u6 h7 J1 _  m* D! ~
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));$ a; Y" i0 @6 d' u  A4 M; H
  35. / u+ f& s4 H# U- F/ a5 }) c, `5 J
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    " z; K  V0 W( H* ]
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)% ?0 F0 A9 v$ I# L1 }
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)) M2 U7 B+ f8 T, P4 c

  39. 1 n' j: @0 x5 c9 q: C( S

  40. 3 {& O5 I9 C6 c" n% S  R8 K& w
  41. 1 w0 q  B6 Y" {  K, {
  42.                 //Start DekaronServer.exe
    5 p; G+ t0 C0 Y/ ^* y$ p
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    4 {# g4 n' a( H. o6 [
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    5 t. b$ H; x% K" g9 y
  45.                         szCmdline,        // Command line3 w$ V2 E4 M5 E3 D
  46.                         NULL,           // Process handle not inheritable
    " _5 q& L% Z* i( {2 G) T
  47.                         NULL,           // Thread handle not inheritable
    % t! ]+ `/ y% n$ ^, ^' R
  48.                         FALSE,          // Set handle inheritance to FALSE# W" ?# k+ q7 X8 P8 X( i
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    . d- r/ D4 P1 \5 z; \' e
  50.                         NULL,           // Use parent's environment block
    4 e6 u, u9 B, m% Q
  51.                         NULL,           // Use parent's starting directory 4 A% C) W( r$ y8 i. B# s
  52.                         &si,            // Pointer to STARTUPINFO structure* q% Q# Y  ^8 R7 u  `! s- W
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure+ L0 i4 S3 M4 b0 U' G: [* s# c
  54.                 ) ' V! K) \' Q5 k1 g0 C4 a
  55.                 {
    % S- i; k' u1 p; C
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    ' t# O3 W2 m! U5 z
  57.                         return 0;$ M. h! }- M1 N; @3 }: s, {, }
  58.                 }
    0 X5 G6 i7 N+ ^6 w6 Y
  59.                 //Creating Process was sucessful! s  V% P7 ?+ t1 v
  60.                 else
    ) r8 e( @; Z0 v/ p' M
  61.                 {
    ' l( D3 K1 R- H+ h" _
  62.                         printf("Sucessfully launched DekaronServer.exe\n");* p  N0 a8 y% c9 x3 x8 F9 {5 @* w

  63. : k( o6 {! w6 e% `
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure# `. e6 N  u! v  @
  65.                         dbge.dwProcessId = pi.dwProcessId;6 Z( l2 A/ Y0 f3 [4 [$ \1 v
  66.                         dbge.dwProcessId = pi.dwThreadId;
    * Y, d$ H/ H9 p+ f
  67. : k2 c2 U; {' ?5 u( I
  68.                         while(true) //infinite loop ("Debugger")5 R1 I' U# T* M3 K5 |
  69.                         {. X2 w9 j& g8 T
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    " y( u( @9 T  x. \$ K" ?
  71.   d& Z; z+ j6 O! L2 C5 |8 [
  72.                                 /*
    7 |+ H$ I$ E. A
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

' N+ N2 E" T6 S7 M* l8 j% ^. z% |
9 N- p- l- D/ y
商业服务端 登录器 网站 出售

15

主题

256

回帖

1271

积分

金牌会员

积分
1271
金钱
873
贡献
122
注册时间
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

回帖

1271

积分

金牌会员

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

3

主题

102

回帖

6561

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-17 12:21 , Processed in 0.062371 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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