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

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

[复制链接]

155

主题

352

回帖

6233

积分

管理员

积分
6233
金钱
1878
贡献
3848
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
- J8 d" d- C  o. _+ v3 r
6 Y; q" k* f& G" l# {4 f虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
0 k7 v. D! k7 P5 O- p
* F" J7 G% ]( l) @) R6 T
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。& R$ N! T  V3 `) X
  2. //
    : ?" e  `% {8 Z: ~

  3. 9 h1 F! g; m) X( c) z
  4. #include "stdafx.h"
      x6 g4 w0 \( N
  5. #include <iostream>1 f: w0 K+ v+ T1 X; j
  6. #include <Windows.h>' D- q( L' O3 O* n* E
  7. #include <io.h>
    3 f, P  A9 d1 c: N/ \/ O
  8. 0 O& V* Z1 o3 t6 J8 e! j
  9. " _) {, P& U/ j# U
  10. int _tmain(int argc, _TCHAR* argv[])
    5 d; D% I' m0 B+ c( v" @* A
  11. {
    ! {2 _9 K% Q/ B- O5 C
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    2 F' z! x) _7 R) f' W2 u

  13. # ?7 Z6 o' Z- F3 h0 T
  14.         //查看文件“DekaronServer.exe”是否存在
    ) W1 h! ]5 i  t
  15.         if(_access("DekaronServer.exe", 0) == -1)
    3 {# X( c' A# b% _
  16.         {) [  J" ?* c+ p7 x9 E% Y! ~
  17.                 printf("DekaronServer.exe not found!\n");
      t+ E/ O$ m$ H0 s! X" B
  18.                 printf("Program will close in 5seconds\n");
    2 J/ b! ]$ t9 J4 z) K
  19.                 Sleep(5000);! G! Y+ U1 g; j7 b/ Y. I5 {$ d
  20.         }
    $ s9 Z8 m' C+ B7 ?+ C7 N4 M4 t; l
  21.         else
    2 j: Z( W2 P+ n( B
  22.         {( W9 Z/ c: Q, o) r& g
  23.                
    + O3 G# k( ?6 }: d1 ~( h. x  i
  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).aspx4 a  k$ N4 O. P2 \
  25.                 STARTUPINFO si;' t8 N; \6 ]; f
  26. ; c  q0 D! s8 X' ]
  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).aspx3 I- _1 ~' w3 r( e/ A* S3 k
  28.                 PROCESS_INFORMATION pi;) R' _  R% @9 s: E8 V
  29. 4 x+ Q, D6 W4 [7 ~
  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
    " S& M1 \+ O+ b- B1 Y
  31.                 DEBUG_EVENT dbge;9 ^" }3 ~4 {* U  Y! z, j

  32. 3 \3 `. _9 \( Y& Z
  33.                 //Commandline that will used at CreateProcess
    ( p/ y" H, J' v3 G5 j
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));4 {( ?- g+ `. ^7 Q* p

  35. ' j/ i7 |8 `2 b+ o8 X
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ; A) Z- \5 K6 p2 ?
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    . ~! O; X& V8 t* l
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    1 F0 a3 Y. R9 Y  E& a  y/ I

  39. 0 q5 k8 b. t- S4 b* j# Z! Z

  40. ! ~4 Q3 r: v3 z0 d: `9 y& N+ z

  41. % e0 p: d5 N2 I4 }8 U
  42.                 //Start DekaronServer.exe 4 h6 R9 y! t5 a6 K5 I% f4 F
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    8 x6 U2 _: O) t% y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)3 G" K; g5 q- S/ ], p" k
  45.                         szCmdline,        // Command line
    . b' R% R3 a; F5 t% H9 A4 Q
  46.                         NULL,           // Process handle not inheritable
    7 j$ n( O# U7 R% n( C
  47.                         NULL,           // Thread handle not inheritable
    2 h" |; H: w% u6 _6 ^7 S' `3 F; @
  48.                         FALSE,          // Set handle inheritance to FALSE/ s  r0 l8 `) M: G6 B2 `# a4 O7 z
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx2 R2 i3 F2 K  B! C* P9 Y, f9 R
  50.                         NULL,           // Use parent's environment block
    9 k6 @4 O% A" Z& j, r8 W
  51.                         NULL,           // Use parent's starting directory
    ( ]" P% e/ B7 Q( k: ?, f: k
  52.                         &si,            // Pointer to STARTUPINFO structure. q) @9 H: B  f3 d8 M
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    & W+ U0 h5 W3 D- d
  54.                 )
    6 m5 [/ ]$ N: w' E  s7 T8 T
  55.                 {- i5 y; L% l" r$ p$ d
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    5 n) c4 V0 V) L) q, E% [7 I
  57.                         return 0;/ k: x3 f6 z! Z6 G- @' L
  58.                 }
    - F( ?; L& `% {2 _! E+ \
  59.                 //Creating Process was sucessful# k' a2 M+ e* ^( r: q
  60.                 else
    ) D  [; v; ]1 W4 {4 R& }3 B
  61.                 {
    ( H; T) d1 N+ `) N* L
  62.                         printf("Sucessfully launched DekaronServer.exe\n");: c( u5 [3 ]$ W( o, ]- w

  63. / u+ l. v5 `- v
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure& h/ b9 ?: {0 I1 Z1 L* |
  65.                         dbge.dwProcessId = pi.dwProcessId;
    - U" ~# L4 [  _) o" r6 b
  66.                         dbge.dwProcessId = pi.dwThreadId;
    / I9 E# H: H* A+ w2 D1 f5 g# `8 s
  67. & d# Z1 l# U: H' B  {; ], g2 T& {
  68.                         while(true) //infinite loop ("Debugger")
    % `) J1 y+ v  {4 J
  69.                         {
    $ Q/ M; U0 }+ `6 B% B
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    * `5 w, C& O% s( P' d' }: B; [

  71. 4 O7 t/ m+ Q/ H) m8 p% e- J. y. N
  72.                                 /*
    / g& \, i% R3 i% V
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

7 G2 B2 o9 u* V# _2 n* }6 V  i$ l6 k3 a( L6 n
$ @. g- H4 y# B2 V" |5 |
商业服务端 登录器 网站 出售

13

主题

251

回帖

1250

积分

金牌会员

积分
1250
金钱
826
贡献
155
注册时间
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

回帖

1250

积分

金牌会员

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

3

主题

102

回帖

5903

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-12 04:23 , Processed in 0.071451 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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