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

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

[复制链接]

157

主题

367

回帖

7122

积分

管理员

积分
7122
金钱
2045
贡献
4553
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 4 V& j- o" o" g4 X8 D% {4 V
9 g& D! {$ T8 U+ l% s, _' Z- _
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
; u' o9 j3 V+ i) F1 G; ]+ O0 P" N  }( j3 _- P* z
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    7 x: w9 V4 i+ X! x$ u. U! X) p" b9 c
  2. //( O: G2 W+ c7 {0 y

  3. ) I# h% O5 G6 r, s0 Y
  4. #include "stdafx.h"
    # _& X0 d) L# `: k
  5. #include <iostream>
    + X4 u) ]1 ]& R
  6. #include <Windows.h>
    0 g8 a3 Y. r. L
  7. #include <io.h>
    2 G$ K/ E/ I( b7 E2 |

  8. 2 \) B* S8 c- ?7 O9 {' i
  9. * c& {; e) F( ~$ f- i* I" e6 H
  10. int _tmain(int argc, _TCHAR* argv[])
    # K! L8 W3 Y- I4 h" o" }
  11. {
    6 [; e. m: c3 F6 x' r
  12.         printf("Dekaron-Server Launcher by Toasty\n");' K, y. Y& S' N/ Q* G* l0 {7 y

  13. 5 z2 F1 y7 \* Y% A: x# s2 N$ t
  14.         //查看文件“DekaronServer.exe”是否存在
    ; R8 }; _& v1 V: u7 E6 x
  15.         if(_access("DekaronServer.exe", 0) == -1)
    / J4 |7 ~1 k  W+ q2 X3 I( a
  16.         {: e" o" v7 G) J- `9 }/ \
  17.                 printf("DekaronServer.exe not found!\n");
    ( n: q! }4 R  n
  18.                 printf("Program will close in 5seconds\n");8 I1 Z' K; K9 M6 b9 ?2 q/ M8 I
  19.                 Sleep(5000);
    6 }1 E0 B3 c9 u- D* z. c
  20.         }3 B( N9 R: [$ @6 O/ A1 J5 f
  21.         else
    4 C+ S" h- i4 W, Y
  22.         {
    ( P; @0 g, F' j& u6 A3 Q# V
  23.                
    3 F+ K6 k$ G. {
  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
    ( p2 v- h) C+ ]: A, ]2 L
  25.                 STARTUPINFO si;
    . E* B. w/ F( d, B1 l8 U* ~4 x
  26. / x1 c+ K/ h$ o. T3 k- R' l
  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  r# T& S4 I9 i! D. }( h1 ^
  28.                 PROCESS_INFORMATION pi;: {$ n5 N" s, m: U
  29. $ G; \; R: ^; L/ m! q. \% i
  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) `; Y. s- j8 _# m9 }$ T
  31.                 DEBUG_EVENT dbge;2 O, Q$ L7 u7 s9 N) t4 I! ~8 N# T
  32. % S$ k. V" |0 b
  33.                 //Commandline that will used at CreateProcess# Q( }$ y, S! b) d
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));' r& s9 Y4 v/ K, L3 E! i5 o

  35. ! ]0 G+ r4 @( P( g/ p5 m1 q+ v1 |
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)1 @% R. s; E0 P, N6 a
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)3 g6 i1 ?3 k2 [/ f( \
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made): T/ R! C$ i3 Q# V1 G9 v* {

  39.   L8 F* _! b9 N$ Q, ^
  40. 1 |+ J# O; y" {. [1 F# Q" N

  41. # i1 E6 G9 V: [, q( F7 R
  42.                 //Start DekaronServer.exe , ^  K3 t; O, z" R2 S6 X0 @( `
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx5 |2 |6 }  N% `; r" e' v
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ' B8 v9 l* o4 @1 q2 y/ j* {' w0 x
  45.                         szCmdline,        // Command line, S9 e, P, ^! i' O8 w. W
  46.                         NULL,           // Process handle not inheritable4 j, q  w  U' c7 U9 e+ Q
  47.                         NULL,           // Thread handle not inheritable
    9 a9 O4 c) P$ ]& E7 t- q- M
  48.                         FALSE,          // Set handle inheritance to FALSE7 U8 `/ {# M0 ^2 ?1 `$ |
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    5 w0 {2 k/ u: e- L- t
  50.                         NULL,           // Use parent's environment block
    & P0 r/ B) L% T, k& ~; b# c
  51.                         NULL,           // Use parent's starting directory * H3 M. ^) I' P. y2 g
  52.                         &si,            // Pointer to STARTUPINFO structure. z  N$ O" P" T, j1 T4 s
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
      b6 t  n0 s- l! b1 P
  54.                 )
    3 T9 V$ t2 X6 e" u3 H& |9 d2 l% d
  55.                 {
    . Y- [2 O) W+ W- _+ f9 ]
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    / {, _5 D4 z/ J6 i' A$ J9 A; r
  57.                         return 0;5 Z6 \/ y; y0 P1 ?7 G8 h
  58.                 }
    % e* Q' l! H) a2 \6 W! t
  59.                 //Creating Process was sucessful+ x' _: g. i2 [3 O
  60.                 else9 b! u2 ~& H/ j/ ~. I8 y( p5 D
  61.                 {) y1 c1 `8 A" ^- ~
  62.                         printf("Sucessfully launched DekaronServer.exe\n");" o6 i; `8 }2 W3 I& Y

  63. + {. U8 i8 R0 Z/ u" r
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    1 y' Z9 r2 c9 L( o
  65.                         dbge.dwProcessId = pi.dwProcessId;2 P4 O6 @1 l) S2 ?$ k
  66.                         dbge.dwProcessId = pi.dwThreadId;
    . p8 b, {7 e4 ^
  67. + a. w' P6 l7 v; a; z
  68.                         while(true) //infinite loop ("Debugger")
    6 ~: S# K  @3 x7 v/ r
  69.                         {# }( E, H" l' O: z. p
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
      O" c6 |, N0 o- {
  71. ; ?  h0 g+ D8 A" A/ J: J+ r2 s
  72.                                 /*- F: j) ^8 M7 J9 }: {- F. Z
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
" K! Y5 u; b5 m3 Z' G& F

, M' v& s4 T6 m. A* p- j! m$ b- _) x0 g. d( q
商业服务端 登录器 网站 出售

15

主题

258

回帖

1245

积分

金牌会员

积分
1245
金钱
903
贡献
64
注册时间
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

主题

258

回帖

1245

积分

金牌会员

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

3

主题

102

回帖

7357

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-4 07:24 , Processed in 0.044682 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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