找回密码
 立即注册
查看: 5440|回复: 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 贡献) 9 Q6 W0 Q$ t) Q. P0 G: P

4 E) j7 h( g& h$ m虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
0 C% p! v. G  S! `% {. H6 g
' T  q- e, b3 @7 A+ U* X
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。; i* ?& j' P5 `$ w" t
  2. //. ]6 y: Z! k, A6 \  W
  3. 6 D( b0 a# d8 |) M$ A+ q1 G) Z5 D' ]
  4. #include "stdafx.h"
    - M2 ]8 t: O% J) p, q
  5. #include <iostream>7 n# ^* r! ~- B/ Q
  6. #include <Windows.h>
    # S  b/ i9 [8 l8 u2 B3 V) G
  7. #include <io.h>! I& h' ]! E+ r

  8. 4 [; E4 R  E- _  I9 q  Z5 n
  9. , A6 v& V; _1 c; n: C) a8 C( L0 I7 c
  10. int _tmain(int argc, _TCHAR* argv[])6 [& U6 X! _1 r; y* r
  11. {
    1 }6 _4 F* }# q  a) k" G* ~
  12.         printf("Dekaron-Server Launcher by Toasty\n");6 z, N. {1 z) V/ m' E6 t
  13. + |3 [. i1 R; T0 W- n- @
  14.         //查看文件“DekaronServer.exe”是否存在
    2 g! }) N/ E) [) l! l/ t" [
  15.         if(_access("DekaronServer.exe", 0) == -1); o% Z, u# F  ?* C, B6 }
  16.         {
    , p7 q5 D7 ]6 ~1 u( v$ J
  17.                 printf("DekaronServer.exe not found!\n");6 i0 i6 U; [+ z* J, U
  18.                 printf("Program will close in 5seconds\n");
    , h# W) ?# {5 D3 ^; e& A" w
  19.                 Sleep(5000);$ [# ^7 A7 d9 b' p
  20.         }
    ; i* d4 {. `* z: N& N8 e  H
  21.         else- U, I$ z4 h; x! i2 R
  22.         {  `0 C/ J/ y- d8 K7 l: X
  23.                 " K# z' J3 F' c, y, d
  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).aspx1 J% D# v, v# M
  25.                 STARTUPINFO si;  o' s- o( Z# H' C

  26. / S2 C* a$ t5 T3 S$ E7 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).aspx3 V. E; p' ?  b! ?7 ~/ B
  28.                 PROCESS_INFORMATION pi;
    % ]4 V) F! O! P, y1 I( O1 z
  29. / [" \% U$ Q0 v. 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
    5 C$ ^; o& @" O: a. G8 }5 p1 d
  31.                 DEBUG_EVENT dbge;0 r. [! }7 K; |) _

  32. , D8 ~* W8 G8 d% b5 \/ I6 o8 [/ y
  33.                 //Commandline that will used at CreateProcess; F3 J% ~3 t4 {0 X* v$ p
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    % ^( G3 \" G/ a, N- u( ]$ i

  35. / h, H: f' d/ k" }
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)7 \% [7 f9 k% s& y: e
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    . N" n9 Y6 v4 y7 q& k
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)# s* S+ J  J/ G3 l" {6 b
  39. / v" d5 ~: S. Y7 _6 D

  40. $ s0 J8 q/ z6 z- k2 a
  41. 9 [$ {: v8 p8 v5 F0 b
  42.                 //Start DekaronServer.exe
    3 s$ q& i1 z3 V+ D, @
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx1 Y' j. U' K$ O9 p9 P$ Y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). \& _7 m% k! v. d) ?. K9 s( b
  45.                         szCmdline,        // Command line
    ( O0 H: J6 F+ O# i1 |
  46.                         NULL,           // Process handle not inheritable7 y0 O, D+ v6 P! ?1 N
  47.                         NULL,           // Thread handle not inheritable) @) v# N, T. f2 e
  48.                         FALSE,          // Set handle inheritance to FALSE# d' g1 Z# }1 y* @
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx! y/ o8 [( t. p+ U
  50.                         NULL,           // Use parent's environment block
    6 X) z) r2 |- A" E" P" I* n8 t
  51.                         NULL,           // Use parent's starting directory
    0 u- c( ^# T( R! i# x. w+ a
  52.                         &si,            // Pointer to STARTUPINFO structure
    ) [  u1 F# D/ T/ h+ c5 j1 U8 Z
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure# ]' a# v0 g. b2 d0 c' J
  54.                 ) " A5 ~3 j. S. z+ o
  55.                 {
    5 N" @5 M& H: r) k2 k3 t
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    9 t  {8 L  |0 }; }- Q
  57.                         return 0;
    0 [* D. t- P% ^
  58.                 }1 Y* T1 b) d3 [$ v$ j
  59.                 //Creating Process was sucessful/ H. g$ d# E0 a8 V1 x  |
  60.                 else2 {4 h* l+ e" _+ i; s% \) \4 c
  61.                 {" O: _; P6 N+ I3 Q; G5 m# P
  62.                         printf("Sucessfully launched DekaronServer.exe\n");0 z5 c3 I! d" ]8 [

  63. 9 V+ O5 s% R% u  u0 Q+ J
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure  x, v) b3 R! [1 g8 R; v
  65.                         dbge.dwProcessId = pi.dwProcessId;
    + s% o9 m4 f6 f
  66.                         dbge.dwProcessId = pi.dwThreadId;
    : Y5 z# \  ^$ H! M" A& }3 [9 O% q7 O
  67.   X. D( G  |+ }3 u3 X( G8 f
  68.                         while(true) //infinite loop ("Debugger")+ b3 X5 V( r/ q
  69.                         {
    2 r  ?, Y' E/ K5 Q' `: h
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx( Z% b- S& l2 ]

  71. : q3 ^" g* G! A: a& w! H
  72.                                 /*
    & ^* a' Q/ Q* l" M
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

- X7 R0 r9 d9 K% G' ~9 f# R4 P
" }* E/ A' Q, |: ]  @. d5 V2 w1 Y! |  O) d# S/ |) I1 O
商业服务端 登录器 网站 出售

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

回帖

6581

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-18 06:26 , Processed in 0.062623 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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