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

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

[复制链接]

152

主题

325

回帖

5593

积分

管理员

积分
5593
金钱
1773
贡献
3343
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 7 B7 a4 B  M. o

# n9 B. G/ d6 `2 a7 @虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。( T1 a! n7 e1 N: a8 j6 F

' [  c9 R: k- U+ D$ U5 n: P2 }
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    5 `0 w3 H% r3 }4 g6 Z' A2 s
  2. //
    ; C! b" f. t1 h! H6 [
  3. ) S- z, \' f4 D' ]  o1 O+ M
  4. #include "stdafx.h"
    4 q) N! Y) }. c
  5. #include <iostream>( F' [. \: ^0 }  \, E
  6. #include <Windows.h>2 k4 ^' W  g/ N+ g1 j  k; j
  7. #include <io.h>7 n' G" G+ F' o" A* {+ q

  8. ; `* Q) \$ t) T7 g& A' V* {! N
  9. 6 g5 @0 O; k: M: ^/ B
  10. int _tmain(int argc, _TCHAR* argv[])9 k- H& U3 v$ R2 K3 F  h6 C% W. Q3 N
  11. {
    - p' x( g9 E/ G5 d
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    + j" v' u3 c: T# U$ J+ M6 m" B* i
  13. . S' C( @5 [& X  P. n9 R  }' K
  14.         //查看文件“DekaronServer.exe”是否存在+ C: r+ q* t( g1 s" Q
  15.         if(_access("DekaronServer.exe", 0) == -1)/ q7 l9 _  Z  j& r$ V
  16.         {1 A& A4 H8 g' T% d- _* y5 Z
  17.                 printf("DekaronServer.exe not found!\n");
    1 ~* c3 t$ x8 d/ h- i4 Q! f  U+ r
  18.                 printf("Program will close in 5seconds\n");5 G& X6 b& Z$ }7 K) F  ?! q9 @
  19.                 Sleep(5000);! L/ l  l& w% S0 I& `( M/ |" A
  20.         }6 D! v7 B! d) a
  21.         else" ]% |# _# ?8 {+ @
  22.         {
    4 h& E% O( Y& o3 a' @
  23.                 8 a# B# t" u. H/ T  n8 Y. {$ K
  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
    . w! `2 b& R! k  e/ p
  25.                 STARTUPINFO si;
    9 ]- N  `: P: o
  26. . m. f: s" S/ i( A9 m) P1 d6 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& S8 Y9 U3 ~& s2 X
  28.                 PROCESS_INFORMATION pi;
    7 t* p1 {6 x& o& C1 P1 v: Y
  29. " k! K$ d. X  _% O) D5 H8 v
  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
    % u- Z& b8 D" ~+ n" \/ y1 y
  31.                 DEBUG_EVENT dbge;
    8 `# Y  c5 [' r& b% @: m

  32. - W" j  v7 V9 c5 a8 ]2 h
  33.                 //Commandline that will used at CreateProcess% P# H* j; i& u; k# [1 v+ p5 ^
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
      R8 ~# n- p; m& g
  35. # [. V9 p  U0 }
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    - F2 w9 p  ^  A2 i! ]/ V! q' L
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)+ k- S5 R, T0 u& {2 S
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    3 c2 B, f: J8 m- O0 R
  39. " S) M4 I7 A" ]  R' f" x* D: ~
  40. 6 c5 P$ [5 i9 J/ ?0 O6 g+ I  N; N

  41. # u" j  r  M* {
  42.                 //Start DekaronServer.exe
    + B+ [: i' V' c# _5 ?
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx7 ~# }& F+ ^: Q* Y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)' f0 w( Z5 ?. Y+ z% j1 ?% f
  45.                         szCmdline,        // Command line# ~* f) ?( d# P) ~
  46.                         NULL,           // Process handle not inheritable
    ) {9 x. q0 [/ \+ h
  47.                         NULL,           // Thread handle not inheritable; B! C, z+ ~6 \4 {; ~
  48.                         FALSE,          // Set handle inheritance to FALSE1 [' Z& ~0 `% P7 b+ x) x( Q
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    - I2 I6 _4 ^/ S5 t5 Z
  50.                         NULL,           // Use parent's environment block* W4 N" m9 ~% e5 [2 X* I7 O
  51.                         NULL,           // Use parent's starting directory
    4 f1 ^3 U, P% U5 n
  52.                         &si,            // Pointer to STARTUPINFO structure
    2 V* j2 S* ~- c0 G4 Q, C. k
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ! l" f# ]. H$ O; L0 Q: h
  54.                 ) + f1 k! k8 |/ h) b# E
  55.                 {
    # y/ ~$ ]4 L6 L" \! X" K# ], `
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    6 ]/ d1 U: a2 \9 b9 v" t
  57.                         return 0;
    8 a9 z6 H  n. ]' l, Z" g6 R
  58.                 }
    1 q  t: A. E( }5 f8 R* \% a
  59.                 //Creating Process was sucessful
    " o+ j( Z. f  Z' ]* ~& I$ H
  60.                 else0 w2 g  r: J! ^$ {
  61.                 {. {+ B( G. \7 `8 v4 d  G3 O3 F0 @
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    2 E8 @2 j! X% e8 z3 M: v
  63. : B/ b5 Y2 r. J: c. M
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    " j. ?% y/ U& J$ B
  65.                         dbge.dwProcessId = pi.dwProcessId;
      U" h4 E* ~8 D5 U! X
  66.                         dbge.dwProcessId = pi.dwThreadId;
    ) Y/ R* ~+ z8 M( g4 T& @) ~

  67. 0 I" o8 a2 v* K
  68.                         while(true) //infinite loop ("Debugger")
    * i7 X$ D; i3 T# w1 H/ j6 Y4 O  U
  69.                         {' n0 V# N* t+ o" O! X2 @
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    + B3 n! Q0 A6 O
  71. ( Z  }! v) k: |0 [, D# W, Y" `
  72.                                 /*
    ) o! w; t" K( V& Y8 H  y8 N& L
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
* [4 X( s1 z& b8 F9 b

$ [) I8 A& X9 e: y" D% V+ O$ r$ t; Z# y" |/ j" E, S7 v5 m+ m, Z
商业服务端 登录器 网站 出售

13

主题

250

回帖

1199

积分

高级会员

积分
1199
金钱
765
贡献
166
注册时间
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

主题

250

回帖

1199

积分

高级会员

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

3

主题

97

回帖

4811

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-8 23:30 , Processed in 0.060087 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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