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

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

[复制链接]

136

主题

189

回帖

3862

积分

管理员

积分
3862
金钱
1351
贡献
2186
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 0 K( T+ Y) k% V
9 Z" L9 E6 M+ [, _. X3 {2 }+ M# Y
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
$ p; j$ u, K" \+ c, U  F  o, V8 B
; c5 a5 A( m  i6 ^" W# h
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。* U8 j8 s, o+ a* ?/ X! @
  2. //; \7 U% ^% @# i) r% a+ X0 a
  3. 9 F5 {' |7 I6 E) u) w/ o3 \0 ^
  4. #include "stdafx.h"! I% ?  `, m, R( v) o  ?! u+ d
  5. #include <iostream>
    0 v; y( }! c8 p( F3 z* p# K3 N
  6. #include <Windows.h>) h4 O0 M  p: R
  7. #include <io.h>
    0 O9 ]- I' w( ?0 c2 o- q* Y' w

  8. & Q! `  I9 y- g8 g# Z
  9. - ~; p" }  e2 K  R" ?- j% [
  10. int _tmain(int argc, _TCHAR* argv[])6 X! U" a% O" j3 T3 }* l
  11. {2 m- j1 Z% c2 }+ o$ i# y/ E" u
  12.         printf("Dekaron-Server Launcher by Toasty\n");3 Z% U9 X7 \; x8 ]3 X: L
  13.   |' o% f/ G5 i: O) E2 X
  14.         //查看文件“DekaronServer.exe”是否存在
    / m) J  g* t$ e  T6 S9 H
  15.         if(_access("DekaronServer.exe", 0) == -1)
    $ ?3 J; e" _3 G9 J
  16.         {- T, E+ v* _, ?0 v0 m
  17.                 printf("DekaronServer.exe not found!\n");) Y2 @# X. D- I% X6 T
  18.                 printf("Program will close in 5seconds\n");5 z: W. Z4 }+ p9 Z" E  B1 h; V
  19.                 Sleep(5000);
    1 r9 F- ^  R3 g1 y7 s# j; H' Y; b
  20.         }8 n- R) k' R( c- m
  21.         else
    # A! O8 a$ r# t' M" @- U
  22.         {" [! f. E" m, f
  23.                 0 e# F1 ~8 s: s4 ]
  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).aspx7 J0 G* H: W  I( ]3 W% B/ Q( k
  25.                 STARTUPINFO si;
    7 {7 J( p2 v$ R, m# i9 W

  26. 8 m4 X5 I5 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
      [: R- J! P+ e2 S# n
  28.                 PROCESS_INFORMATION pi;
    7 T; J% K. B3 k; s1 q- t

  29. $ {8 a% M7 A& i
  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( m1 R1 s$ t" \; c4 r! x
  31.                 DEBUG_EVENT dbge;
    6 e9 a1 ~7 N# v0 @3 Q9 n7 o

  32. 8 A% k7 U1 P/ D: b1 ~
  33.                 //Commandline that will used at CreateProcess
    : R& a. \9 m# }* I: |
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));  |! `1 L. ^. F

  35. ! K' c2 d6 D! T- L! G. f- o
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)' ^& I6 U$ h9 g. S
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    % S4 p- S" o$ C2 G5 [% V) o) F& R( S
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    3 w; E3 |, Q  X* L" d+ W; t
  39. 4 [- I9 D; f. I  U) J7 x

  40. $ Y- O  Q3 i9 k9 }
  41. ; a/ U$ ]6 A8 B2 t8 P
  42.                 //Start DekaronServer.exe
    / {8 f( c4 Q$ o- Y
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx+ N: ~) J6 L$ Z" l. k! k* s; W- y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    3 ~1 W6 ]' `* w/ C2 [/ O
  45.                         szCmdline,        // Command line/ z8 g3 ?8 A7 K& l+ p7 E1 @) A
  46.                         NULL,           // Process handle not inheritable& E2 c  c  B5 O! N6 L# M; C/ L$ x
  47.                         NULL,           // Thread handle not inheritable! }: r! o1 o. _+ e
  48.                         FALSE,          // Set handle inheritance to FALSE
    - A5 N2 V; o0 E# h9 |
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    * p8 @& e2 G" g4 S4 M
  50.                         NULL,           // Use parent's environment block
    ( e& q( ^, M+ N5 C& A1 B; f  i
  51.                         NULL,           // Use parent's starting directory
    # N+ k4 a6 H+ t, r
  52.                         &si,            // Pointer to STARTUPINFO structure
    # Q7 z2 X. o2 y/ s8 f' d
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ) I8 P: Y4 ^& ~. F
  54.                 )
    ' r7 Q+ O5 A. Q8 A- @
  55.                 {
    % w. ]8 m* L; V! D4 ^
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    : [) w0 ]. o! v6 H- }3 s
  57.                         return 0;
    ( K- G! P5 S6 m" Y1 q
  58.                 }& w3 _: B6 ~+ g0 N
  59.                 //Creating Process was sucessful
    1 J$ j* K4 T$ L/ D. p6 @6 e% h/ H
  60.                 else0 ]; I3 B1 l$ J* f1 @6 b4 H" i5 B
  61.                 {
    # f& b/ k& F# T& n% z7 L& C' Z
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    2 M9 J9 F  G2 @& d
  63. / O* Q6 [# D2 U4 b, ?
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure0 ]- R# X8 A4 D' B
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ; Y/ l% k/ O7 f6 P& E
  66.                         dbge.dwProcessId = pi.dwThreadId;: z( l1 |. c) H7 w1 C  V5 W3 }

  67. : z* ^1 ~1 s0 @2 l; l
  68.                         while(true) //infinite loop ("Debugger")4 l" e7 _; J. `0 M/ a
  69.                         {; {/ p% E3 S/ V8 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  C7 I# X9 [6 P6 Q0 s5 _+ f* e

  71. 4 A  ~2 ~# G- ?# S7 W
  72.                                 /*9 d1 D4 j+ g8 f1 h
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

( a( H% T! L. X1 u5 m- t$ m' e+ s9 Q
: M6 [. q! ?' a6 e
0 q5 U# y2 y; u/ ~8 }- ^
商业服务端 登录器 网站 出售

9

主题

231

回帖

881

积分

高级会员

积分
881
金钱
534
贡献
102
注册时间
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

主题

189

回帖

298

积分

注册会员

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

9

主题

231

回帖

881

积分

高级会员

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

2

主题

83

回帖

1111

积分

高级会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2025-4-11 05:52 , Processed in 0.043551 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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