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

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

[复制链接]

154

主题

343

回帖

5865

积分

管理员

积分
5865
金钱
1837
贡献
3531
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
2 P; K0 ]+ N6 }  d7 K( ]7 w7 m6 \8 j* I. t, o3 U
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
8 D' N0 V5 w: T6 [$ a- D
; ?6 n; Q1 r8 v, c
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。3 k' B" D6 q6 s
  2. //
    ; t* D& t3 Q1 h, e

  3. 7 F( ^# e$ W! ^& |, U! @1 J  k
  4. #include "stdafx.h"0 q6 x5 W6 S+ G9 B
  5. #include <iostream>
    " V& n+ O  k5 L! ~" x6 B, y. R! C3 @
  6. #include <Windows.h>) j1 X5 k# m$ N1 U
  7. #include <io.h>
    9 T) p6 f* f  l
  8. 2 S. w1 Q% r- d" n2 G. T

  9. , ]# _. W1 ]4 q$ a2 T7 s
  10. int _tmain(int argc, _TCHAR* argv[])$ K: S. a: W' M1 Q& o% @
  11. {/ ?3 }; q) j# Z* {
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    " b6 e/ s% M: {8 B( e7 F  s! c  z

  13. + @! A# v- k4 a/ F9 \
  14.         //查看文件“DekaronServer.exe”是否存在
    9 C# i2 y  f6 D3 W: z, X5 [
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ' y( w9 }' c# v. h/ K4 @
  16.         {
    0 ~. |3 f# R4 U
  17.                 printf("DekaronServer.exe not found!\n");
    ) A) n: U: ]$ N  E0 a
  18.                 printf("Program will close in 5seconds\n");" n, e# X( [6 F# ~$ u( U2 ?
  19.                 Sleep(5000);
    % ]) I# S% i3 I  f  ?+ [9 {
  20.         }/ D4 {% j/ {( [* i
  21.         else0 P! E. G2 Q% {
  22.         {& u+ C2 M% q8 y
  23.                 ! h  p+ [* r4 n  o8 [6 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).aspx, p6 n7 r6 a3 d( ~, u
  25.                 STARTUPINFO si;8 T* m% b. I/ k4 @3 M

  26. 5 o* Q" [0 r' P& O" n3 U. r& X. Q
  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( U; _# p& z- z5 ^0 l9 y8 F3 ~
  28.                 PROCESS_INFORMATION pi;. W) o5 H3 ^. D

  29. . Z/ O: \. T  {! p1 \5 I& f0 g. w
  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- x+ \/ J3 c  c$ H7 w% [* U& P
  31.                 DEBUG_EVENT dbge;
    7 F' f. a& z! e/ R. ?4 Y6 l, l

  32. % n1 \* x  Q, J! M& a; ]; I/ @* }
  33.                 //Commandline that will used at CreateProcess. ]) C, a5 [6 D* ]* b9 [& o2 b
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    9 m( S( ^; x4 [
  35. 0 v% a/ f/ I' |9 C/ l5 H* S/ y
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ; T! B) K. Y; k& p
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)! k4 Y. p- I- t1 L; A+ w
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    % U: s6 g& Y& }5 q, N1 h
  39. ! I$ J+ G* @! o* z' E, n

  40. 1 @; x7 A+ u' E8 e# K; l  P& e
  41. 6 Y: ^6 h/ [7 i( ^& Q
  42.                 //Start DekaronServer.exe + l% O2 T$ G) O% Z
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx- b6 n. X6 ^- @. j  v$ b
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)" \( N! x2 o( x, c# P9 G1 A5 ^# D
  45.                         szCmdline,        // Command line
    / v" |) l8 q" m! a/ h- d
  46.                         NULL,           // Process handle not inheritable$ c$ i5 _8 J# O( {/ U" z
  47.                         NULL,           // Thread handle not inheritable$ S: h8 a; R8 A) k
  48.                         FALSE,          // Set handle inheritance to FALSE
    0 q3 I; O0 u  a8 l, t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx- T; v9 l. ]; n+ N
  50.                         NULL,           // Use parent's environment block& e# r. `1 F% d# g' v2 U
  51.                         NULL,           // Use parent's starting directory 3 t4 j. J4 Y# Q  ^! L
  52.                         &si,            // Pointer to STARTUPINFO structure1 N3 p, u, q" p! z1 F) w: i" }
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure' a* ~8 W. e$ P
  54.                 ) 7 m6 G. z! M' q
  55.                 {
    : _* A" r7 d) Z- ^. a# U1 A
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    # b* Q3 \" W% C8 Q) _* m4 S
  57.                         return 0;
    ! R/ w1 L6 a  X9 f4 [2 j
  58.                 }% Q) \6 C2 a6 k$ P! _) Y6 x
  59.                 //Creating Process was sucessful
    $ {# e1 z8 [0 W! G9 f! }
  60.                 else
    ) v( o: k5 G5 E; o" S& |
  61.                 {
    # K0 d2 }8 v" T( A: d; \) Y5 W4 r
  62.                         printf("Sucessfully launched DekaronServer.exe\n");6 R: R1 D4 _  [  a0 S
  63.   F( v& L7 @  y5 R# ]
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    * X$ b7 v+ U3 Z
  65.                         dbge.dwProcessId = pi.dwProcessId;
    + G/ ]& B- r3 z' E( y. Z9 m$ t
  66.                         dbge.dwProcessId = pi.dwThreadId;% M6 I3 |# `8 l. U: O
  67. 2 F2 e% X  U4 k( `2 S+ A
  68.                         while(true) //infinite loop ("Debugger")" W$ J, v7 j. `0 U. b0 \5 R5 u
  69.                         {
    & H% E* e( Q0 e; j3 G9 l/ C
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx7 Z4 D* @; g+ {6 \5 J

  71. + U2 m# a7 _" X1 z0 I
  72.                                 /*9 U) h% X) [% d3 q
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
4 X/ W( Z; n7 G8 b0 T0 q4 X1 Y1 D

, {: H0 f  w9 c+ P7 l6 }
9 d* `! Q5 i6 f* v+ I( b  S! V
商业服务端 登录器 网站 出售

13

主题

251

回帖

1258

积分

金牌会员

积分
1258
金钱
802
贡献
187
注册时间
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

主题

205

回帖

345

积分

中级会员

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

13

主题

251

回帖

1258

积分

金牌会员

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

3

主题

99

回帖

5453

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-13 13:39 , Processed in 0.055808 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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