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

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

[复制链接]

153

主题

333

回帖

5695

积分

管理员

积分
5695
金钱
1795
贡献
3414
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 0 t# H( @! M# s* l! j# c

* k, S- ^1 l( J) _0 V# a虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。  N* S6 C8 ]8 d& ]8 m. X

- O- Z2 p! B1 X" _2 W
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    ( k0 a% S$ s' y
  2. //3 i% z( N  z+ p6 E5 l9 c

  3. 5 {) X& a  j( \* N4 u
  4. #include "stdafx.h"( F" ]6 a3 z2 ~0 L5 @
  5. #include <iostream>) r8 S" {/ O+ `4 ^
  6. #include <Windows.h>- M) |1 E. j( E
  7. #include <io.h>6 n3 D* q& E4 C8 D/ f7 g
  8. ) v$ j/ ]2 x! x4 C( j# o1 o

  9. 0 Z0 D2 P! V2 y2 V
  10. int _tmain(int argc, _TCHAR* argv[])
    / O% s) _* M8 w
  11. {
    2 `0 u2 m3 U* f6 s% A" S) {
  12.         printf("Dekaron-Server Launcher by Toasty\n");' p9 R  ~! {  H' ^

  13. $ `  ~# Q8 F& W1 r" ]1 l
  14.         //查看文件“DekaronServer.exe”是否存在
    ' b# H' X% T. @3 j, Z; `. H" F3 z
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ) L0 n! G+ z0 l
  16.         {- K6 d$ {1 F$ J2 L- J1 b
  17.                 printf("DekaronServer.exe not found!\n");: m" t# ^7 G# f1 B1 k+ Z
  18.                 printf("Program will close in 5seconds\n");
    + y  e0 d6 p% y
  19.                 Sleep(5000);& x% ^2 X& {/ r0 O; n
  20.         }
    4 \4 E3 Z# [6 _) l5 g  g
  21.         else
    % ]- @5 J1 |2 O, ?
  22.         {
    6 t( k4 U# F- S/ M+ Z
  23.                
    2 l" S# f+ d4 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  J0 _, E5 l: `. }
  25.                 STARTUPINFO si;9 N( n1 I# x# Q0 B$ }& Q

  26. + X- ~' L( X* R
  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: w2 ?; T, _  `& n
  28.                 PROCESS_INFORMATION pi;/ o0 j' q$ b  a- B% Y7 I

  29. & T4 [* Z& G6 \9 F: O
  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
    ) o; y' i. _8 I9 B8 L+ t! Q
  31.                 DEBUG_EVENT dbge;
    ) e0 c1 f4 h! i: p% S0 D! e
  32. * D7 m6 x7 @- E2 k4 q; L5 H
  33.                 //Commandline that will used at CreateProcess) c4 m2 ]! A+ d
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    9 g! ^  s( A/ V  ^
  35. : P9 n3 `6 o( `
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    " ]) u; M- D; @( b
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    " i, J' ?; z' n& K0 H
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made), q- |  L8 J! c1 l
  39. ' \8 v2 Y4 O" `/ D& v) m

  40. " B# k7 e3 E) N5 _
  41. , J' @! F' T% ?- W" c
  42.                 //Start DekaronServer.exe $ X6 Y- h: \* Q$ W
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    2 h; T' q6 G# u8 |4 H* q. X
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    # m# z7 B, Y* }$ u- _# a
  45.                         szCmdline,        // Command line& q  H  t2 U  c" e
  46.                         NULL,           // Process handle not inheritable; `2 W+ D8 I( b! B% Q
  47.                         NULL,           // Thread handle not inheritable( o9 h( B+ x/ n6 V+ a
  48.                         FALSE,          // Set handle inheritance to FALSE' M& t/ j1 y5 t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    - r& E& F% ?0 V
  50.                         NULL,           // Use parent's environment block) |7 l& H8 J& {8 d- `" N+ r
  51.                         NULL,           // Use parent's starting directory
    5 Q" ^: t( k- {: Z% S
  52.                         &si,            // Pointer to STARTUPINFO structure- K" v& [* q3 M& u
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    8 I/ g! s& P$ g0 [
  54.                 ) 8 y+ E/ ^7 H' K
  55.                 {
      m! V1 Z9 u4 w8 R" l0 l. B, S0 @; c
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );: G. s2 h3 {. E  `# ^1 C  w. @
  57.                         return 0;) _7 E! X& t# j: r
  58.                 }) R# N- Z2 h( G7 b
  59.                 //Creating Process was sucessful8 p; i* Q) @# ~7 C0 ]* u
  60.                 else0 i; K7 _/ F5 ~! W: p4 u
  61.                 {6 d; X2 p/ W. p
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ) U( w0 ?1 v/ I

  63. 9 }3 ^- p2 b' K& C! y4 C
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure5 q/ ~: p6 A/ h; B1 _6 p
  65.                         dbge.dwProcessId = pi.dwProcessId;- z! o1 I# t/ p
  66.                         dbge.dwProcessId = pi.dwThreadId;
    & |4 c- x  z" P

  67. , i( `" I5 N$ e' _, n# A+ Z$ x
  68.                         while(true) //infinite loop ("Debugger")( E  ]/ w! x, {& N3 s
  69.                         {
    + X7 J0 I8 s& }# J
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx; X+ p% d% `" n" d9 `# `

  71. 2 r' H& z$ v0 p$ ?8 `& P6 a* ]1 s
  72.                                 /*- M! u$ {" d, }/ ^0 ?5 M2 R5 O( l
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
2 D+ E' s! d# H9 j! o8 u4 c
) V3 P4 M+ F/ B" E6 a) w( _% l+ S
; {- P5 w3 s' N* V" @
商业服务端 登录器 网站 出售

13

主题

250

回帖

1214

积分

金牌会员

积分
1214
金钱
775
贡献
171
注册时间
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

回帖

1214

积分

金牌会员

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

3

主题

98

回帖

4971

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-20 05:32 , Processed in 0.064342 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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