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

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

[复制链接]

106

主题

128

回帖

1478

积分

管理员

积分
1478
金钱
635
贡献
609
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式

; s0 |9 h. \+ U$ z$ F- T8 C0 M
* J! q) v- r6 S: a1 ]0 m虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。1 z9 m4 {) w% E+ C2 k. A6 W+ U# Q
3 X% V9 z8 s' s% P1 O1 f
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    1 ?' v' t$ s* z; E8 t% s
  2. //
    4 Z+ G" o* v1 f8 X  `, X7 R
  3. 4 c; \/ h$ r4 B9 M2 z7 s9 k
  4. #include "stdafx.h"
    ( k; d- f. n! a0 P
  5. #include <iostream>. }4 Q* r- R- y1 A7 g( P# }
  6. #include <Windows.h>
    4 z9 b- ]5 X$ y) D5 \
  7. #include <io.h>
    " x( ]3 V- c( Y' s/ y- H* B
  8. : V5 _! Q& F' T' w3 G
  9. ) G! l4 k5 K' ?9 G- x: ]9 n  p
  10. int _tmain(int argc, _TCHAR* argv[])+ C$ \- x6 ^1 p; U0 |7 b. P
  11. {+ n) C: ?# K1 \: {( @9 w1 ~$ c' j
  12.         printf("Dekaron-Server Launcher by Toasty\n");, s1 D6 ^% s: L
  13. 0 M- s  F& Q; i+ }1 ], A0 J( x4 |
  14.         //查看文件“DekaronServer.exe”是否存在
    . e& V% z4 S  v* i) U* y
  15.         if(_access("DekaronServer.exe", 0) == -1)
    1 Y4 r4 v1 n8 H- |2 ^7 w& N
  16.         {9 f5 L3 \2 s3 D, m
  17.                 printf("DekaronServer.exe not found!\n");0 H  X( I8 j; c6 M# D) [8 V
  18.                 printf("Program will close in 5seconds\n");% K, I$ z4 M7 c7 I
  19.                 Sleep(5000);
    6 Z9 M" d$ U2 S. F2 }7 U
  20.         }1 Y& G6 `, c" @$ H- @
  21.         else
    . L& O0 J. v  v4 S1 [" k
  22.         {
    % W$ Q+ l3 T0 F# o- V
  23.                
    9 I7 h  F' [+ N$ _7 Q
  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
    & G1 U& n: H) N. r
  25.                 STARTUPINFO si;
    0 O2 l# A! B% e" h& N" y

  26. % o0 w2 q+ |' n' P8 w" f+ 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
    . ]" J  i1 N" N+ K+ c; a
  28.                 PROCESS_INFORMATION pi;- N; [4 A% t  `7 W5 D0 O

  29. 8 j" r! B4 a' r
  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
    ) o7 S7 L$ a3 x7 c' r' V9 l6 m
  31.                 DEBUG_EVENT dbge;
    % f3 p0 u8 k3 t$ s

  32. 6 t1 ^4 O8 M" [& A9 X% Z
  33.                 //Commandline that will used at CreateProcess2 i* L" A- R& ^" {/ E6 b
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));9 x2 e6 r! i  O3 T. _0 Z

  35. ( S5 J; h8 I- v1 N% ~
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)# Z3 w5 ^! X) E7 O
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    # u. L/ s( o3 O$ s$ \& y
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)7 i% ]5 o* }( g

  39. ; m1 j$ o( }; e! P$ }! J  q
  40. ; L6 Z' [  S# ?) {

  41. 3 O- ^! }" c5 i  s4 b
  42.                 //Start DekaronServer.exe
    ' ~9 C$ f9 {0 A0 ~( O4 Y1 M
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx' d+ _0 k8 t, D
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). S6 L- p' i& O. D2 {
  45.                         szCmdline,        // Command line
    4 k) c8 b  i0 e, _1 B8 `3 C
  46.                         NULL,           // Process handle not inheritable
    8 |, y& U4 X( y6 ?  e4 m
  47.                         NULL,           // Thread handle not inheritable
    6 n, |. d6 B/ f* M+ S/ K6 ^2 |
  48.                         FALSE,          // Set handle inheritance to FALSE8 T+ s  K. H5 o0 p6 |! F4 U
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    7 R# J2 I) a* S. B1 a( Q' Y2 _( o
  50.                         NULL,           // Use parent's environment block# M$ H  F. K; d) n. g! R1 W* s4 [
  51.                         NULL,           // Use parent's starting directory $ W9 x' ?% s! M5 _/ u8 |
  52.                         &si,            // Pointer to STARTUPINFO structure0 e* H9 z9 {$ B' r; r% I. l) @
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure' O) {6 ~. Q3 C! V3 ~  X7 F# {  B) n
  54.                 ) 1 ^# u! Z* y2 ?6 S. v$ b# _
  55.                 {/ C( h) Y5 i" v( P- U
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );. S* B0 T  T: x! V/ U* M# N# Z8 Q
  57.                         return 0;5 j. i7 T' _% w0 X8 i5 S+ M5 @
  58.                 }$ V) O( a% P% b9 k
  59.                 //Creating Process was sucessful
    / d% k/ X; @6 i8 O' N
  60.                 else* Z" v3 X$ H3 b9 n  D
  61.                 {
    $ {7 G( L+ }. C- Z
  62.                         printf("Sucessfully launched DekaronServer.exe\n");3 Q, ]/ C# J8 |4 k% s
  63. 4 e& \% M1 e3 H! h8 F) {7 c
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; a) w! ?, o+ ~/ v
  65.                         dbge.dwProcessId = pi.dwProcessId;  V! N; G; v2 d% B- o
  66.                         dbge.dwProcessId = pi.dwThreadId;, N7 j# L( k7 S1 @

  67. ) C5 W/ m' U. ]4 r5 ?- t
  68.                         while(true) //infinite loop ("Debugger")$ s  v( z$ ?# j0 L: d% o, q
  69.                         {
    * a7 m4 J$ Y6 v3 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
    # d9 v# |; R% I& l# }; ?

  71. * v: _8 q# ^7 W: b- @2 E
  72.                                 /*8 c: e: B8 q' S6 [& M
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

5 U( I* G9 q+ J- i6 _" H) A
" x) c0 R  p& n: H& A# l4 ~. n; q6 f! r' i

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
商业服务端 登录器 网站 出售

8

主题

188

回帖

454

积分

中级会员

积分
454
金钱
247
贡献
6
注册时间
2023-11-10
发表于 2023-12-18 20:34:07 | 显示全部楼层
我是来学习的!

21

主题

375

回帖

776

积分

高级会员

积分
776
金钱
288
贡献
92
注册时间
2024-1-20
发表于 2024-1-21 13:37:44 | 显示全部楼层
感谢楼主分享,我是来学习的

0

主题

42

回帖

105

积分

注册会员

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

8

主题

188

回帖

454

积分

中级会员

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

2

主题

51

回帖

156

积分

注册会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-18 01:27 , Processed in 0.132561 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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