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

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

[复制链接]

154

主题

335

回帖

5769

积分

管理员

积分
5769
金钱
1815
贡献
3465
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
6 i# \2 F  y. E( d( z0 t: r1 L$ E; a4 F! z' f: {
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。* _5 v" Y0 ?6 c4 G

& O, h/ ]' v! k
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    8 M, C! M( [- p/ t/ ]/ t0 g$ c
  2. //
    . n/ p3 U6 I1 X) B
  3. ' b( [$ m. }6 B& E' ]+ ]2 |
  4. #include "stdafx.h"+ r9 M7 G+ K; {' ]9 C
  5. #include <iostream>" {; @; |/ p1 F% ~% S% t. H
  6. #include <Windows.h>
    : `% j1 g, B4 a, W2 x$ D
  7. #include <io.h>" k' T- d" F" ^5 H( \6 u
  8. & ?! g5 U" d8 ?$ L7 h

  9. ; B" `9 ~: y8 R& P  ~" p
  10. int _tmain(int argc, _TCHAR* argv[])
    , A2 d- T* f+ W/ S
  11. {
    / r, R& }, n& Y: P; O2 A
  12.         printf("Dekaron-Server Launcher by Toasty\n");7 d# O0 A" J$ m9 e

  13. # b' B0 E3 l1 m2 }3 o% y' Q
  14.         //查看文件“DekaronServer.exe”是否存在
    4 L$ g" K5 Z' g$ N$ e8 g
  15.         if(_access("DekaronServer.exe", 0) == -1)
    & a  \: y2 b3 x2 a/ A6 ^& f. U9 E
  16.         {$ U1 g9 M5 }/ O# k; S
  17.                 printf("DekaronServer.exe not found!\n");. ~3 ^( ^' a  W3 z& Y" K3 _
  18.                 printf("Program will close in 5seconds\n");. Z, z4 ~# J6 }% ~- R
  19.                 Sleep(5000);
    7 O% i8 B* ^% Q0 P: ], o+ L/ q
  20.         }* x, m- K% V4 I
  21.         else
    6 y3 S/ C" U- J, P6 q$ u& j( B! U
  22.         {
    * g0 Y6 F% \8 F* I+ R. X( h" A
  23.                
    & ?6 I" c- B9 G/ m
  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
    2 @( M. S( G* ~, D9 k3 K: V
  25.                 STARTUPINFO si;$ p4 v5 N$ {( G" Z3 f) w2 A1 s
  26. 3 a1 }. K& }- m$ t
  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).aspx9 S( }/ ~. ^( [
  28.                 PROCESS_INFORMATION pi;/ s7 k* P! R: a

  29. * A% M$ Q$ {; _+ P/ H0 m
  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
    * W8 g* T5 D8 c9 T, t2 S( V# N
  31.                 DEBUG_EVENT dbge;$ I- m( R1 h5 m/ N3 o7 C. z5 R
  32. # L5 e+ P2 q. t6 F5 [& Z, S; K
  33.                 //Commandline that will used at CreateProcess+ u/ p+ r- b) t1 ]3 E) j
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));- @* `, }( v$ Z5 }& |- ]
  35. : @% {; L- Z" y9 A: ~" G
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)7 b* z, k0 Y# M' e* z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    . }: F# ?/ z" {" q/ ^- ]: w  Q  T
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    / M8 |1 E* e4 x2 [$ P- ~2 z' k
  39. : R1 I5 x9 |9 v$ [% M6 P0 P
  40. * i& L3 m- l. U% U

  41. 2 x% X: @1 j6 n- Q, J. T" }+ Y& ^
  42.                 //Start DekaronServer.exe * K. Q+ I5 U7 e  x: b1 J; n; X
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
      J( d' B9 Y* a
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)7 X* J3 N' ?7 W% p' m0 c
  45.                         szCmdline,        // Command line+ F; J' O, t8 Q4 D
  46.                         NULL,           // Process handle not inheritable7 k( T4 o# S6 d/ n; Y, O
  47.                         NULL,           // Thread handle not inheritable3 n( E. y3 X$ s9 ?+ e
  48.                         FALSE,          // Set handle inheritance to FALSE
    / D; K  m0 i  [( a* f& G
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx8 S- P) L; n* s$ q0 v. A  H7 i
  50.                         NULL,           // Use parent's environment block
    9 b4 b+ M$ S& i
  51.                         NULL,           // Use parent's starting directory # p, b* X; v# K" z" x% m
  52.                         &si,            // Pointer to STARTUPINFO structure: F7 G4 u& q8 L
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure9 y, n8 C$ h9 C: Z
  54.                 )
    9 m( K/ z% u+ T3 q% c* O
  55.                 {
    6 N" c3 n; [, C- I  @# f
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    3 Q5 x- U4 b- U5 n+ E
  57.                         return 0;
    1 S; t+ \0 y9 ?. E! \; i, m
  58.                 }9 I/ W& s* O' Q- I
  59.                 //Creating Process was sucessful7 a" U9 V0 V" _3 v( R; A
  60.                 else
    0 k6 s% g8 d4 O; j! |
  61.                 {
    3 A# l$ V% l! e1 m" {+ E
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    * b) }. G# s: |8 s7 I( ^
  63. 7 ]3 M" Q4 W/ ?9 O7 l
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure8 K" K5 a9 F' b0 ?- Z8 c0 {) v+ l
  65.                         dbge.dwProcessId = pi.dwProcessId;
      ]+ \3 U. ~% p1 a' L# ~0 b) f) z
  66.                         dbge.dwProcessId = pi.dwThreadId;6 Z" n8 w9 Y) l
  67. , Y6 K, {% e, H/ Z) Y
  68.                         while(true) //infinite loop ("Debugger")
    " {9 }, Q! a7 j5 c! t
  69.                         {) @7 t5 _. _9 T
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    : a, R. z* \' W3 \$ `9 A- w
  71. # l3 F. n0 B3 _1 l8 r/ n" A/ T
  72.                                 /*  l, `' U1 \' \
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

8 [; A! y0 Y; u
% b5 X, [' k& Z1 q' p
; a4 k) Q9 j/ M: G
商业服务端 登录器 网站 出售

13

主题

250

回帖

1232

积分

金牌会员

积分
1232
金钱
787
贡献
177
注册时间
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

回帖

1232

积分

金牌会员

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

3

主题

99

回帖

5233

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-2 09:17 , Processed in 0.079664 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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