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

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

[复制链接]

156

主题

355

回帖

6620

积分

管理员

积分
6620
金钱
1917
贡献
4192
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
2 y; X! t- D* L  V; |
9 b* N/ G  I8 O! {/ y  T6 l. O- E+ {7 F虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
2 |7 {9 G  C, o$ g+ [$ L% M! }9 N6 r0 w# [# A8 |
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。) ~6 w5 m) f+ N/ P& O5 n
  2. //
    7 A, H2 v1 N* Y! [
  3. + ]1 R) w$ |/ r/ _7 @
  4. #include "stdafx.h"3 J. T- x( E/ H+ S
  5. #include <iostream>
    # S( Q/ ?5 T3 r4 L
  6. #include <Windows.h>+ D; ?8 K4 Y8 y$ g3 |+ p9 E
  7. #include <io.h>; l! X% `: D* |% ~, U* ~

  8. ! E( u3 \$ ?) r1 d

  9. 4 k: s& v  _$ I, e
  10. int _tmain(int argc, _TCHAR* argv[])# p0 }" p8 s0 E) G
  11. {& c  G9 n5 I  a6 W2 {6 W
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ! W' E' r! ?3 T" H

  13. 0 Y9 c% i/ Q0 q6 S; O5 F
  14.         //查看文件“DekaronServer.exe”是否存在
    ! f/ }% o: J2 G1 M
  15.         if(_access("DekaronServer.exe", 0) == -1)* _( X. A" S+ a' ]; x" m. D
  16.         {4 w* E9 }/ x* h5 V5 z+ Q5 E6 x
  17.                 printf("DekaronServer.exe not found!\n");
    & s5 g8 y! Z& z8 n% I
  18.                 printf("Program will close in 5seconds\n");
    + Y3 x0 V6 l  i4 N2 z
  19.                 Sleep(5000);% O; Y5 A0 V, t7 U4 ]
  20.         }
    7 v* q9 P1 l4 `
  21.         else
    7 T- j) Q7 G8 m1 Y3 w& J
  22.         {  n. q; ^: [  T8 I" P) j. r
  23.                
    8 k: t' N( x4 I( ^
  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  i* W  l" u1 i* S, l
  25.                 STARTUPINFO si;" ^' W& E8 B) a. \

  26. $ y# p4 Y' i. P5 h' n- o9 m
  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
    * l! o, w/ m* R% C6 s5 y
  28.                 PROCESS_INFORMATION pi;# o0 {$ w9 ]" c- s- N- U& W

  29. 6 Y# y2 f2 a9 a$ ]
  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
    . N. k+ Y) o; s% u5 ~8 i
  31.                 DEBUG_EVENT dbge;) N( w  R; I9 d; e; w' _' g; H
  32. 0 @$ |) x; ^# H9 R+ ?0 L
  33.                 //Commandline that will used at CreateProcess3 J$ ~4 Q5 g. C
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));+ j, A5 d, O6 ^4 ?) Z7 @# {# [; G
  35. $ M* ]+ `' _' K8 S7 G4 P
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    9 ^( P2 i& H& s  f4 Z& J# s
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)0 J, D& Z5 ?% D0 H6 j
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)+ t9 y- _1 n7 w" |& a

  39. 0 R/ w5 x, `# r6 X

  40. / w; i8 q. f) v' B

  41. / K( ?) \5 y' j$ a" m# z
  42.                 //Start DekaronServer.exe
    ! k. s- _% w( q# d$ N/ U8 L
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    / r# U) [7 }2 d5 W/ a$ ?
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)9 e5 }# b) H* _+ n6 H1 x
  45.                         szCmdline,        // Command line0 g" t9 w8 \, Q! {8 ?; g0 _* A
  46.                         NULL,           // Process handle not inheritable7 h% |7 O. d. j. j7 ]" L+ \+ b, b
  47.                         NULL,           // Thread handle not inheritable" o: C2 N2 q8 ~2 h4 D1 ^6 ~3 Z
  48.                         FALSE,          // Set handle inheritance to FALSE
    % ^) H. Q& _8 N: U4 l8 _- K
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    % D/ k- \5 a0 B+ E' s, S" l
  50.                         NULL,           // Use parent's environment block
    4 f0 i& n, t# S4 P- C8 {5 }
  51.                         NULL,           // Use parent's starting directory # j4 P1 m" p/ S7 K
  52.                         &si,            // Pointer to STARTUPINFO structure
    # X3 i6 m) P5 t  I
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    : ]& h# A& R6 r" H
  54.                 )
    7 T$ a. E9 y" p, @: V+ P$ Q0 C
  55.                 {( I7 X$ X% }0 D+ H: A
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );! y. F1 K4 J2 I( q! a4 \6 c& ?
  57.                         return 0;, M9 c8 y9 }% H6 z. c
  58.                 }# Y! d9 r" k6 {% Z' J& w: ^) e
  59.                 //Creating Process was sucessful
    ' a. Y: C3 p# f  V, X
  60.                 else0 a' \" c% ^1 W' ?2 `
  61.                 {
      \- C6 X$ B/ |8 ~4 ^7 s
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    : ~6 ]* b$ D  i( J( y

  63. . A" S" L- [! _
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    7 U. E- I( T7 F1 V% P
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / P1 ~+ l% v) b% r. G, ~9 e
  66.                         dbge.dwProcessId = pi.dwThreadId;
    & m3 ?' S, I' J/ ?2 d
  67. & O, A5 ]5 C& w! t7 ^
  68.                         while(true) //infinite loop ("Debugger")5 D: a1 q/ |, ?, L( h' s/ `$ O
  69.                         {5 `! Y5 |8 h6 f, w9 Q
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ; b: f4 z& V7 R1 @3 K
  71. * c$ E4 I! Q. |4 a, q8 o1 K7 k
  72.                                 /*; Y0 n: n8 C0 G, T# @8 D* c
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. c* e8 x& c# g$ F

9 _& T- {" ]0 K+ F2 |4 {9 p4 t6 T& c) h( T3 l: E9 \5 r
商业服务端 登录器 网站 出售

15

主题

256

回帖

1250

积分

金牌会员

积分
1250
金钱
859
贡献
115
注册时间
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

回帖

1250

积分

金牌会员

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

3

主题

102

回帖

6221

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-30 18:14 , Processed in 0.064324 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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