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

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

[复制链接]

153

主题

333

回帖

5695

积分

管理员

积分
5695
金钱
1795
贡献
3414
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) " O. R6 `2 m' H- @  l- N" l3 v2 B
% l, j- u3 i! @1 X4 z$ m! U* Y! |
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
3 s# @& o- X3 Z6 n3 h8 R. _/ S/ l. Q
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。- P. G; M3 o; m: }- M( G/ Y; X
  2. //
    3 L! Y8 e! W5 a. o% Z

  3. - W( u) r( W# P$ l
  4. #include "stdafx.h"9 ~, W) D2 `) p7 v
  5. #include <iostream>
    9 _! [' j$ Y$ e+ m4 t4 a5 y$ J
  6. #include <Windows.h>
    & n. }- v9 n- M/ `( x. d+ r
  7. #include <io.h>
    0 v3 L, o% ]8 Q- \8 E) u
  8. 3 q! x4 Q' g* m+ a: T- ?, p0 j

  9.   p* Z% A6 U9 n) M, R
  10. int _tmain(int argc, _TCHAR* argv[])
    ; v7 ?, J6 A$ w2 t+ ?$ O1 b) X
  11. {8 _0 p8 m0 d$ j% F% h. ~9 I# B, m
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    5 f' _0 z) P# P2 }* [
  13. 0 X# Y+ [) D/ Q7 n- v
  14.         //查看文件“DekaronServer.exe”是否存在! H+ R$ a0 u# e. |& w$ A) W
  15.         if(_access("DekaronServer.exe", 0) == -1)( `& F& N+ Q( }' @
  16.         {) m+ q6 @1 u# S3 P
  17.                 printf("DekaronServer.exe not found!\n");
    : m9 i! i* X  m5 n& g' Z2 i) V; k
  18.                 printf("Program will close in 5seconds\n");
    3 Q% G3 }% _- x$ r- q0 h5 H
  19.                 Sleep(5000);8 ]) @; X: v$ `' `
  20.         }
    & }  w; A# U- r1 Q, s7 ?
  21.         else
    3 W! s* g) A7 M. E( S) \
  22.         {
    1 P2 Q! _3 X! M5 l
  23.                 0 l4 F2 R: q# s
  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 O. r% w1 v, V+ W$ p, d" f
  25.                 STARTUPINFO si;
    & L3 ?$ F- d* U0 `9 x( Y+ \7 P1 M2 |
  26. / i. o9 U3 E- [% l4 b1 F# A/ E
  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. s0 W/ \+ i& ]9 u
  28.                 PROCESS_INFORMATION pi;, y: z: `- @  Y0 X$ o% X
  29. & c* e5 ^7 e* z: Y; I- p& y2 I
  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
    9 M& T. c: _# |- e9 y
  31.                 DEBUG_EVENT dbge;
      M) r9 h* g1 r

  32. 2 h3 a: L# t, p' l$ m
  33.                 //Commandline that will used at CreateProcess
    . `/ D, X8 B* v
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    1 W% I0 C7 u4 a& ^

  35. $ z9 r: P2 S) j" n$ j, [
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)) ~4 i( K5 r7 B0 F+ y6 {" \
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn): [4 u' ^, O# [& O5 H7 w9 A
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    3 ^# a3 E" m' T& n: h

  39. 7 B4 b$ j( H4 L* M! l
  40. 0 s7 ?/ g& T2 N* f; t
  41. 1 U# R& R3 t3 ?) Q0 N1 F
  42.                 //Start DekaronServer.exe / n2 ?+ a; L: f! P! H  Q
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx) \# W; w  u. i: d% f
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    * b& @: \. h1 k2 w  {
  45.                         szCmdline,        // Command line
    + k. p9 R* g; ~: Z
  46.                         NULL,           // Process handle not inheritable
    2 {1 E6 Q0 Y# {8 |6 I
  47.                         NULL,           // Thread handle not inheritable
    ; M' H* _8 l8 b, H; C, q% @
  48.                         FALSE,          // Set handle inheritance to FALSE
    2 V8 z0 U1 h2 v
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx( y( {) m- B' M" P5 b  `' X! \
  50.                         NULL,           // Use parent's environment block5 l" j7 S0 S1 Y* U4 C
  51.                         NULL,           // Use parent's starting directory $ j! ~% t/ Y4 ]
  52.                         &si,            // Pointer to STARTUPINFO structure% s$ U3 r, D* D( E! g9 T7 p) j
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure# N3 B1 r6 d3 |8 v
  54.                 ) + k. W0 ]2 k0 M! p7 \+ k
  55.                 {9 M0 ~. }$ {& x! P( g  [
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    + M. k9 W2 N) t, {$ E2 L" f* T
  57.                         return 0;
    1 J; U' w1 Y! w9 g5 S
  58.                 }4 l! Q7 O) g9 i9 V
  59.                 //Creating Process was sucessful
    0 V2 w' ~6 i3 |8 o, A
  60.                 else% ^" z1 _$ S! @  g& `! \- k
  61.                 {
    " ]" `0 D- c& C  M/ r% \9 Q
  62.                         printf("Sucessfully launched DekaronServer.exe\n");8 s6 ~0 ^8 n6 P8 \" c1 _6 F

  63.   R- D5 v2 {6 \- b% A) E
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure* f; c5 _; e7 h' l8 p9 h
  65.                         dbge.dwProcessId = pi.dwProcessId;! E' u" C& H3 J+ O
  66.                         dbge.dwProcessId = pi.dwThreadId;
    - l- z4 i0 ^; I8 T( w

  67. " u9 l' n; N1 J4 Y
  68.                         while(true) //infinite loop ("Debugger")
    ) V% r0 L& {! L7 A
  69.                         {6 d3 a+ W; F8 \. I! z
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    3 i2 A' W7 Y. e8 H5 T

  71. 0 j; r3 g. |' T$ \3 f! q
  72.                                 /*( V. G: Z8 }" j8 G- W! M' w
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

8 p9 ?' a* ~# i! p$ I, k9 U  f- f" b4 ~7 N/ ?. {
% V" v/ n8 v+ U& K/ W
商业服务端 登录器 网站 出售

13

主题

250

回帖

1214

积分

金牌会员

积分
1214
金钱
775
贡献
171
注册时间
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

主题

250

回帖

1214

积分

金牌会员

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

3

主题

98

回帖

4971

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-20 03:40 , Processed in 0.083299 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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