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

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

[复制链接]

160

主题

384

回帖

7379

积分

管理员

积分
7379
金钱
2116
贡献
4719
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) : I3 b! K8 u3 B! I" c, S% _

" H5 N7 X( C9 n虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。: G9 k5 j' z8 U8 ]" s
% c! h* C/ \2 s! |0 N6 _
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。/ C- U9 d0 ]% X2 X6 @
  2. //
    5 e5 ^& c4 c# g. Z2 r# ?
  3. 9 c7 S% G! d. U" m: Z. y
  4. #include "stdafx.h"3 J, B6 a, n! @3 z( w
  5. #include <iostream>
    - I' k8 }3 ~4 G$ j* D5 a: v" `
  6. #include <Windows.h>
    2 U0 i& Y& S! o5 A# A( b8 z! b: P
  7. #include <io.h>
    6 |3 ^% y' P6 L6 ^. ?1 |7 J

  8. 0 G* e' q  ]! ~' x5 W5 d# Z
  9. 0 z/ r3 R4 Y+ y. {8 O8 k2 A! L/ i
  10. int _tmain(int argc, _TCHAR* argv[])
    . u! h$ C( X. @0 n" h
  11. {
    . \% F1 p; u/ j) U
  12.         printf("Dekaron-Server Launcher by Toasty\n");' j* w# m" q% [
  13. 9 T$ q1 L  S5 ?7 h
  14.         //查看文件“DekaronServer.exe”是否存在& O+ X) Q0 A) i) M4 l( {2 T* c
  15.         if(_access("DekaronServer.exe", 0) == -1)' e* a$ J& T+ W4 w( @! P; v
  16.         {
    ! f* f; e9 H2 h& O" m5 b: H
  17.                 printf("DekaronServer.exe not found!\n");
    ! n: k7 {0 V5 r% ?3 O8 |7 X' X
  18.                 printf("Program will close in 5seconds\n");
    5 ?8 Y5 T, k9 f% t- n0 N
  19.                 Sleep(5000);
    # S) B) N* W) b
  20.         }; I( y9 e- @  g/ ?$ a" N( W. k
  21.         else3 E# d# ]( O4 ]
  22.         {
    5 B- ^2 \: U% K. L: {( Q! ]
  23.                
    - j6 L( ]" t0 W7 A+ p2 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
    * M  }: m3 c- K4 q4 }2 V
  25.                 STARTUPINFO si;( s& n* s+ G! Y3 t) Y$ v
  26. . n) |: i: C# J
  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
    7 d8 g# o9 [' A
  28.                 PROCESS_INFORMATION pi;# ?* x: c! E$ j, H1 r
  29. . c$ y' r- o$ t0 o) I7 L
  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( y  E) y9 j+ v: {
  31.                 DEBUG_EVENT dbge;) W- [, o: E, w! H2 X
  32. % l8 K3 C4 S3 h" U3 Y
  33.                 //Commandline that will used at CreateProcess( ?8 F5 Q! a1 H& i! A; w7 E. q# A
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));1 j) p; a7 ]' m0 G# E/ E

  35. ! o6 Z6 l! w) r
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    1 B( E3 O9 H. f2 H  y2 u
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)/ n; E9 @# p7 }( m% x- U# d6 A: I
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    5 w& M/ ^: \# {. K9 O' O

  39. + {; m+ o+ L) K- ~, F
  40. 6 G9 c  Q: Q' B/ J

  41. * l! ]- k/ {; W) Z! Q& R
  42.                 //Start DekaronServer.exe
    ) l2 O/ g6 |( w
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    5 ^- x+ I, j! q# B" {
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    9 A( \) \- j8 D9 P& E
  45.                         szCmdline,        // Command line
    : t3 l7 A4 w- n; f" M. E& h! R( O- t
  46.                         NULL,           // Process handle not inheritable
    : ^: F: I6 x+ `. G: r* [2 Q3 C
  47.                         NULL,           // Thread handle not inheritable
    ( w& e/ k: T; f
  48.                         FALSE,          // Set handle inheritance to FALSE* O5 P7 E5 b5 |3 i
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    . Y/ b5 P/ j7 b; c/ M
  50.                         NULL,           // Use parent's environment block
    1 A3 i6 Z9 g' F, E' q' K9 I- v
  51.                         NULL,           // Use parent's starting directory
    . L8 R3 O8 T1 [3 N
  52.                         &si,            // Pointer to STARTUPINFO structure/ B6 t' y+ p6 s, ~* I& J7 h& r
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    , X# t' W. y" o
  54.                 ) ) x1 _. Z( m, ]/ ~5 @/ l
  55.                 {
    1 v6 }3 j1 N7 V* J
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );$ w" w: O( d5 Z$ \8 k7 }
  57.                         return 0;3 v2 K! [. S1 u! n( B
  58.                 }
    ; F/ N/ v4 F8 m3 Z5 U: `' {! u
  59.                 //Creating Process was sucessful
    0 b& S( R; Y' c, ]- J( Q, v
  60.                 else0 m# i) o. ]7 w2 l2 I4 L
  61.                 {  {* J& u6 X% Q
  62.                         printf("Sucessfully launched DekaronServer.exe\n");, g0 g4 m/ h) J( {# `# p0 e

  63. 0 ^. K$ n( J8 Q% c/ E5 }: v
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure: ~) m1 _* k# d6 w) c
  65.                         dbge.dwProcessId = pi.dwProcessId;- ~( X2 K$ N& f
  66.                         dbge.dwProcessId = pi.dwThreadId;
      T8 p4 _9 R0 d; ]

  67. " N( ^; H* X) i8 y7 z3 w' Y
  68.                         while(true) //infinite loop ("Debugger")# o7 W! F9 S* b# j
  69.                         {5 [( z; m4 K3 u7 C" k
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx& n5 n& ^6 T5 T) P& t
  71. ' x6 S+ f6 S( ~/ @
  72.                                 /*
    0 E9 {. Q7 x- Z7 [% R$ C7 S/ ^- l$ v
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
7 U1 d1 R" V6 h3 [2 K
% B  u; U- f5 n& d+ }& d9 }9 G
# q' Q. E  F  c! F
商业服务端 登录器 网站 出售

15

主题

259

回帖

1275

积分

金牌会员

积分
1275
金钱
920
贡献
76
注册时间
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

主题

259

回帖

1275

积分

金牌会员

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

3

主题

102

回帖

7757

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-23 23:22 , Processed in 0.033333 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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