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

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

[复制链接]

155

主题

352

回帖

6236

积分

管理员

积分
6236
金钱
1880
贡献
3849
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) . ~8 U) F5 C* ~2 z% }+ S7 N  {3 c
, v, p% K5 A) i- }$ D
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。! I; C, `( Z9 W9 a" X4 c) k+ f

" e. B4 H' f/ W; _
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    8 T3 I- V, Z- D/ V) `
  2. //3 x# }  }9 f) z; V6 n! r! @
  3. : r; Q! j6 s* R: r
  4. #include "stdafx.h"
    0 B. ~7 V& Z1 e" `$ E$ o
  5. #include <iostream>8 L+ M/ ]% m+ p* _: U  p& W$ ]
  6. #include <Windows.h>4 n& a: k6 A) Z) E
  7. #include <io.h>
    $ ^/ c# g; s% @/ f$ n! c6 I

  8. - P8 E  e2 C6 Y; }0 M( \- V3 J
  9. ) e: S8 d0 H: ^
  10. int _tmain(int argc, _TCHAR* argv[])
    0 B% C( e3 [4 u# ?
  11. {
    & O+ H; j4 Y/ u: P% V
  12.         printf("Dekaron-Server Launcher by Toasty\n");" b2 ^% D: Z: Y$ `+ [5 i
  13. 8 `; d$ q) D/ j$ [0 y
  14.         //查看文件“DekaronServer.exe”是否存在
    ; @8 h1 ]0 ^; Z" W6 R
  15.         if(_access("DekaronServer.exe", 0) == -1)
    : M. J9 d  @5 m. G* P0 E& W( g
  16.         {
    1 J" F6 J3 ?9 W, \
  17.                 printf("DekaronServer.exe not found!\n");$ Y$ `+ g* j. E1 S
  18.                 printf("Program will close in 5seconds\n");
    5 s1 Q: M$ P8 H2 B: b
  19.                 Sleep(5000);& H) V4 o4 y5 i! r3 h( e
  20.         }  C% X( S0 h6 I8 W" [
  21.         else' R; v9 |8 ?0 F" B
  22.         {
    2 D4 d# B' M5 }" M
  23.                
    - ?- D) Q! P) c
  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
    ( J7 e5 U2 X) B' G
  25.                 STARTUPINFO si;* k, W* w1 k% O2 a. O2 V$ T  o

  26. 4 q* F, `4 P# _  F! F
  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! y  H/ W/ b$ I& f+ C
  28.                 PROCESS_INFORMATION pi;+ ?% J  S: I  Z7 h6 P8 X( {. b* D& q

  29. 6 a$ T' N+ r4 D9 s8 M: T  B
  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
    ; c$ C" @$ `8 H, N
  31.                 DEBUG_EVENT dbge;! c, K' m; k, I; X* E: T- C
  32. 2 i+ X9 I  G# P. Y* D0 s& m
  33.                 //Commandline that will used at CreateProcess4 s- E# ^% G& \5 S
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    $ r1 M% x0 B7 A# T/ H. n) L. ~5 `6 `
  35. , t1 j& P$ d5 ?3 b
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ' M. y: Y7 p! F  e* D  m
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)1 U5 U3 S3 i4 ?& `
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    2 K: `) \) I& D: u' F+ [4 u: t

  39. 9 R8 `* p' E5 B8 E) F" m* J* B

  40. 1 r$ d! Z1 p+ R! Z

  41. ; o9 o- ^$ I7 A( I, @
  42.                 //Start DekaronServer.exe
    ; S, X, v) I  Z( o6 R' S' _$ q) W
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx, J2 E/ c" K8 u, ?( B: K( L' }
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    3 @6 h; e  p4 v, E" l% N, Y5 X
  45.                         szCmdline,        // Command line
    6 L% N) k) O6 W+ L8 _1 n; I1 t0 G
  46.                         NULL,           // Process handle not inheritable
    , z$ G2 N# g0 y/ A- O
  47.                         NULL,           // Thread handle not inheritable7 ]9 R2 t) f; B8 M) b4 Y
  48.                         FALSE,          // Set handle inheritance to FALSE( x  l4 t. `  w
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx* I. `/ a( G) h
  50.                         NULL,           // Use parent's environment block
    . p# c# \* U/ [# z7 v
  51.                         NULL,           // Use parent's starting directory
    ( m& A' q/ D  `1 f
  52.                         &si,            // Pointer to STARTUPINFO structure
    ! m& ~" B6 G. `& }
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    . A3 w+ C3 e& @  R! U
  54.                 ) $ Y# V! x5 [3 Q9 z1 @
  55.                 {
    - o* f  V% I$ \) R2 |9 u0 B
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    & K5 V0 t% ~- m% N( D' E
  57.                         return 0;, P# \, \8 {# P: H7 O, Z
  58.                 }
    + n1 X- f: w2 Z1 E8 I
  59.                 //Creating Process was sucessful
    : f9 o, R" g  M* m9 n3 @6 ?! \
  60.                 else  u% R) P6 s0 k" i
  61.                 {
    6 k% Z: l8 Y9 `) @4 U0 E0 P
  62.                         printf("Sucessfully launched DekaronServer.exe\n");. j  y) x4 f- y
  63. % Z- C5 U. j2 ?4 m* n8 p
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ( I3 u1 t3 c" ]) C) s" w5 V
  65.                         dbge.dwProcessId = pi.dwProcessId;4 O; U" X5 A1 L1 R
  66.                         dbge.dwProcessId = pi.dwThreadId;
    / D, b  ]8 {6 b4 H

  67. : Q/ y7 ^3 |4 @5 V$ {- r$ B: u& b7 Q
  68.                         while(true) //infinite loop ("Debugger")/ V% U9 I$ C+ t6 B
  69.                         {
    " `' O% Z( N$ |* I" W
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx; Q* A% z' z# a" I. |9 H

  71. ) I" A5 M: c% h7 u- |# O
  72.                                 /*5 U/ V+ N1 \+ d3 x5 M
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

) J" x" ^( f. b$ B) r$ p$ P
8 K. g8 \5 X- B" i5 C
+ c- U& t& e" w! J
商业服务端 登录器 网站 出售

13

主题

251

回帖

1253

积分

金牌会员

积分
1253
金钱
828
贡献
156
注册时间
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

主题

251

回帖

1253

积分

金牌会员

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

3

主题

102

回帖

5923

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-13 00:26 , Processed in 0.075902 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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