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

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

[复制链接]

157

主题

360

回帖

6652

积分

管理员

积分
6652
金钱
1928
贡献
4207
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
" M9 L, c  Q  d- [3 }2 I8 H6 U1 e
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
- H* E3 o$ O7 T* j% r! A' A4 \* ], d: z* m, N4 A0 x/ `- Z+ s6 @
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。! S# Y& y( Q% c) \& ~
  2. //' |  ^+ I% m7 w/ p( p
  3.   i/ ]7 b( E. @( k) P& p
  4. #include "stdafx.h"* E1 B% I4 j( Q- Q
  5. #include <iostream>' e! G. h9 f  g
  6. #include <Windows.h>
    ) A& F: m% Z# S
  7. #include <io.h>
    0 Y4 d) G0 i* {' N

  8. 2 \2 I0 P6 e4 d
  9. , e; Q: ^0 p) ]  q7 Y' U. G
  10. int _tmain(int argc, _TCHAR* argv[]). z2 R! p9 B. W% Y
  11. {# K% q6 ~+ f* E" ?
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    $ {- n2 ?% v7 s" `5 |

  13. . }' `1 b+ \* y# Q( V( w
  14.         //查看文件“DekaronServer.exe”是否存在/ X6 d0 H: @3 X3 V$ w3 M
  15.         if(_access("DekaronServer.exe", 0) == -1)
    * A) A( x& [; n3 N; D8 q2 `
  16.         {
    6 F8 d% I- }' X& B" c
  17.                 printf("DekaronServer.exe not found!\n");
    ' c6 l+ w/ z9 I1 i
  18.                 printf("Program will close in 5seconds\n");) Z9 K& y" Q& o
  19.                 Sleep(5000);
    / `) N4 Q! q- k' H# d2 J2 c
  20.         }
      A+ n0 x* L% y- g# U* ^
  21.         else
    $ m5 O7 C; J+ x! |
  22.         {3 ]# o! T) @4 |
  23.                 % Y1 a3 I" O6 g+ ~( U
  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  W) i  v, W, j+ O/ T& V
  25.                 STARTUPINFO si;
    " w, Y9 D* z7 x3 |+ x' |0 h" |7 W

  26. ' E2 y- i, {5 O/ l& G4 X& 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).aspx. Q$ E9 ^  l0 j$ O# V7 {
  28.                 PROCESS_INFORMATION pi;
    ( `6 s; Q' ^( n$ A4 [6 @

  29. 2 z5 W9 W. S" ^
  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
    3 J: l; ]7 M0 O% L5 P. V$ c9 C
  31.                 DEBUG_EVENT dbge;: M' O* \+ e+ \* i  k0 }. t/ t

  32. , y- k" v% }0 a! t. ^/ V! c
  33.                 //Commandline that will used at CreateProcess
      r5 C6 Y+ y2 @+ z0 O
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    " p- ~4 s8 q; t& b6 ?
  35. 9 V( h% E9 O8 f4 Q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    # r" T! F3 ?9 a( z% ]- n
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    # V$ H7 P! g, n% f$ c4 b/ h
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ; [* S  H0 ^# ^' p' m% s8 L! t

  39. 8 D9 j) \# `+ U% h7 `5 b

  40. 8 ?/ u4 I- l5 v) s  i1 _! Z
  41. 4 N0 X3 U- y7 o, N
  42.                 //Start DekaronServer.exe / E8 E. e) K. `( h5 V. z8 X6 Z
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx6 i+ b/ I3 K5 }  s. T% t# a) c
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). q, s. t, t5 F6 {+ J+ b3 y
  45.                         szCmdline,        // Command line
    % F3 h; s0 J3 s/ m! A: V
  46.                         NULL,           // Process handle not inheritable
    ( J% W( m( M1 D. F& @% O0 L
  47.                         NULL,           // Thread handle not inheritable
    - \% r6 A9 x/ Q/ V+ ]
  48.                         FALSE,          // Set handle inheritance to FALSE
    1 ~# g( _0 r# Y6 X7 e8 \6 }3 x
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    $ b! J, d6 ?) y# `% g
  50.                         NULL,           // Use parent's environment block7 t2 u# h! K: ?9 @8 f* R' L
  51.                         NULL,           // Use parent's starting directory
    * P. B; S4 G9 V: ~# c
  52.                         &si,            // Pointer to STARTUPINFO structure% Y% @( h8 w1 D
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure' V6 [+ e+ ~  j3 e$ o& x$ Y; J
  54.                 ) * r( Z0 Q2 J* ~. M, G$ s6 i
  55.                 {! r6 |! Q# i" C  L9 s) a
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    9 l3 N; }$ Y7 w
  57.                         return 0;
    6 [# X4 @) `$ S  |0 b  T
  58.                 }
    ! H3 u# X$ {6 r- h, G
  59.                 //Creating Process was sucessful
    / n6 G) v( w' I% B/ ~, f; F& H6 E
  60.                 else
    + |9 h( c- ]. I9 b$ p
  61.                 {
    - ?* a& m* n2 x4 A/ T
  62.                         printf("Sucessfully launched DekaronServer.exe\n");2 V  L) K5 z+ {
  63. ! I0 y; M4 W! h/ a" f% K
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure+ U! n' V" P% `3 [+ \& F; ?4 B
  65.                         dbge.dwProcessId = pi.dwProcessId;3 o% M7 }$ W" @, h
  66.                         dbge.dwProcessId = pi.dwThreadId;# f9 Q2 c. ]: X1 d

  67. 9 z+ @0 F" e3 `" g
  68.                         while(true) //infinite loop ("Debugger")
    5 }& e0 |* u. x9 ~
  69.                         {
    5 j0 {/ F  H0 L5 c8 E: s9 I
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    % e& r0 A0 O1 Y) B; X" a' ^# H
  71. & r3 M: R/ N1 i9 y
  72.                                 /*
    3 l1 E4 m% a: Y( |. q
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

) X: Y; L+ X$ U3 R
' @1 `$ J0 n% p: J, S5 @8 K0 T
- A$ \) s2 l7 z8 ~# m$ r) V) C
商业服务端 登录器 网站 出售

15

主题

256

回帖

1256

积分

金牌会员

积分
1256
金钱
863
贡献
117
注册时间
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

主题

256

回帖

1256

积分

金牌会员

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

3

主题

102

回帖

6301

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-4 08:15 , Processed in 0.069136 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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