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

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

[复制链接]

157

主题

363

回帖

6898

积分

管理员

积分
6898
金钱
1961
贡献
4417
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 1 R, J- T6 d% r& z
0 m9 t0 {- X& X/ ~2 o  [
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。4 X) l/ p! ]  w

( F8 [9 n5 t' U' S5 s, \
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。% {1 N& _9 S3 d& P
  2. //# \2 W" x' c! d- z8 Q4 `: R

  3. " t( _( O. n1 |0 a* E3 d
  4. #include "stdafx.h"+ l- b, k2 i$ W+ R+ k8 w
  5. #include <iostream>
    0 ]: {2 v! m" Y/ q3 {
  6. #include <Windows.h>4 v, O" i: Q7 {- x, p3 D7 s3 R: ]: i
  7. #include <io.h>, T  @2 z# S. ^  I0 s
  8. 0 I! W' b" W8 B2 R
  9. 9 }3 z% ]+ s- B7 c8 V6 q
  10. int _tmain(int argc, _TCHAR* argv[])
    . ^) u# \8 y2 g3 C+ d
  11. {
    * U, E$ _/ q) v) F8 F" H
  12.         printf("Dekaron-Server Launcher by Toasty\n");5 d8 u+ m) n! O' J- e- J

  13. 0 m# s) m' Y8 S! H0 P
  14.         //查看文件“DekaronServer.exe”是否存在
    * p7 c. j8 r7 ^
  15.         if(_access("DekaronServer.exe", 0) == -1)2 m/ q1 }0 d+ s0 o
  16.         {
    2 M* a  Q- j4 ^* O- l
  17.                 printf("DekaronServer.exe not found!\n");
    + h  a9 B( p& T; N; z
  18.                 printf("Program will close in 5seconds\n");4 ]( r4 _( M% p9 g8 l' a: R
  19.                 Sleep(5000);7 i# E2 ^4 @# V& H
  20.         }
    " t' g) e) J! f& B3 D8 O
  21.         else- ^+ I9 {" Y2 X- L" S& h# K* }
  22.         {  v" z; G$ r0 G9 S  D
  23.                
    % k: T! o% H7 v8 p! _2 z
  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! X! a) D) U( }: g3 i6 L
  25.                 STARTUPINFO si;
    / X+ g& j) D  `; j+ F  |. J
  26. ( c" q8 E2 L  {: k& r/ H+ f+ Z2 ?
  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
    / z" K( ^2 z2 L$ @" T* ~
  28.                 PROCESS_INFORMATION pi;7 d# A$ }5 x+ a( P/ Y- M/ f: p
  29. 7 L) t5 b! o. }5 i3 K  _+ 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
    : w( p9 w0 I- A* X! u
  31.                 DEBUG_EVENT dbge;
    & S9 |/ P7 w, u6 h; o% Q* ]) E
  32. 5 \$ o0 L/ N+ \
  33.                 //Commandline that will used at CreateProcess
    * B) p0 ^* o& |" B* a( L4 z" L  s
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    3 s' j/ t& p, Q  a
  35. ( C6 s* G' ^( M& K. t: P" n
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)! S" G+ Z5 f& R3 G
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    . H. F8 ~. e5 G! W2 K/ G2 e
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
      p: O2 A3 K* e. @/ z
  39. % y6 d! s8 y# o$ X4 }

  40. 5 H0 q0 d2 A( y" \
  41. ( k) ^0 Q- N9 a- E
  42.                 //Start DekaronServer.exe
    : w3 Z6 x  h3 {& b& r
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    1 X2 D% a( W7 S
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)! |0 N8 K' F7 z
  45.                         szCmdline,        // Command line
    & P" o6 p7 y- Q
  46.                         NULL,           // Process handle not inheritable" Q9 y, B' i3 s4 m# G; d# e/ G1 y( }
  47.                         NULL,           // Thread handle not inheritable
    . K  b$ ^- i0 X' ~6 |/ _/ x: z9 ?% o
  48.                         FALSE,          // Set handle inheritance to FALSE
      B; `, _- S+ P  W. t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx' e. J/ T# W/ J1 C: J
  50.                         NULL,           // Use parent's environment block% F3 _, ?9 Y/ q% W0 K: f! t
  51.                         NULL,           // Use parent's starting directory ! k2 i( B, u5 n6 ?. t
  52.                         &si,            // Pointer to STARTUPINFO structure
    3 C0 F/ c  _# p; d. a. N6 }
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    $ k! O8 |  \" H- l& T7 E, ~
  54.                 )
    . g7 Q& Q- H$ F- g
  55.                 {
    ' W. T, W7 h0 E# U' Z6 S+ l
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    ! P  G3 s+ Y" O6 e4 @- X! Z( T
  57.                         return 0;/ f! v* Q# n5 L4 }( V
  58.                 }
    / m/ _# N- L( |1 i( D  F& l3 e) W
  59.                 //Creating Process was sucessful
    ; H$ l3 J5 T, P0 ?* ~! k* G, @9 X
  60.                 else/ G9 V% `5 S! N1 p6 l
  61.                 {3 G! ]- V/ ~4 K6 _8 x2 r
  62.                         printf("Sucessfully launched DekaronServer.exe\n");) \3 I7 i& q/ P5 I* v: x: n
  63. ' T" z+ T1 N5 Z) K* |
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure( \) x% s. a, L& O6 h1 w. D
  65.                         dbge.dwProcessId = pi.dwProcessId;* `; V2 {; U5 _8 X
  66.                         dbge.dwProcessId = pi.dwThreadId;6 @' S7 e  a5 s+ g; w) }2 }; Y
  67. & I2 w7 g% t- i, v
  68.                         while(true) //infinite loop ("Debugger")
    5 U/ a) N6 \4 P
  69.                         {
    + P; [$ ^, d- v
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    % w0 h' ]5 t$ Y3 r' u( G
  71. 3 M5 _5 G$ c# T" a( H8 ~
  72.                                 /*# ]6 _( Z1 x1 M+ Q& d! b" r$ x
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
/ S7 V3 A2 ]# C# w. n
  v( ~$ }% q* c" {8 e  C& |1 V3 n
" {' C# c, f) w5 H
商业服务端 登录器 网站 出售

15

主题

257

回帖

1255

积分

金牌会员

积分
1255
金钱
884
贡献
94
注册时间
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

主题

257

回帖

1255

积分

金牌会员

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

3

主题

102

回帖

6679

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-25 17:21 , Processed in 0.071928 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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