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

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

[复制链接]

157

主题

372

回帖

7186

积分

管理员

积分
7186
金钱
2070
贡献
4587
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ; ?) k( G  F( m1 @) ~0 s
( l2 c+ ~8 `  S. P* C6 c+ f
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
- D* V; \" U" t8 T
* Q, j* a2 C: Z  N
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    ; A# p+ Q! X# f# N. M, q: l
  2. //
    7 j$ Y6 S! ^' g! v7 a4 G& q! }

  3. 7 x+ c$ Z7 z$ k! @" I' N0 f
  4. #include "stdafx.h"5 }6 ^5 R4 w* V% O; A
  5. #include <iostream>& \; \( K# `; l4 e# {
  6. #include <Windows.h>
    ( O& r, f4 A/ Y! U, \+ P4 R
  7. #include <io.h>. s5 }5 f' |: m/ K
  8.   Z! @6 L3 e* x' }
  9. + \0 E, j' S0 ~
  10. int _tmain(int argc, _TCHAR* argv[])
    ) R' B( x. G8 J8 C- B
  11. {$ \4 }6 x5 Q& ^
  12.         printf("Dekaron-Server Launcher by Toasty\n");) N3 j% Z5 V9 i3 F9 D( @
  13. * C: _: X3 n$ f: F
  14.         //查看文件“DekaronServer.exe”是否存在. w. ~: q6 U2 n) `5 J
  15.         if(_access("DekaronServer.exe", 0) == -1)
    0 b8 V$ v  u' o- t& |! t
  16.         {0 Z0 x3 o' s- i$ m  i
  17.                 printf("DekaronServer.exe not found!\n");
    % f: ^/ p+ _9 }
  18.                 printf("Program will close in 5seconds\n");
    7 o# W" |+ ^! f' U' p! w% N
  19.                 Sleep(5000);
    4 |" E% q3 d4 n% t
  20.         }& |. O! x  b( ~5 j" c7 `5 P6 g
  21.         else
    ' J7 K0 ^) ^, f) S: r$ D% i. f
  22.         {- D  m4 m- s7 W* @. C8 H0 Y
  23.                
    ) D+ L" g6 H+ 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
    8 U* W' U" p6 {* k2 m+ S5 X* H
  25.                 STARTUPINFO si;
    " A  ^8 N: ]6 b/ ?, k3 W5 C
  26. & A% N7 g8 W: h0 q9 c7 G. n
  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).aspx4 C( u" j) [3 ~7 q
  28.                 PROCESS_INFORMATION pi;
    $ @4 V5 a8 K; U& F5 ~' n4 i
  29. / x$ Y) _/ p  e9 d5 ~5 m0 t! v
  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  ]( J9 X3 r$ f/ j4 W3 t8 A- x
  31.                 DEBUG_EVENT dbge;
      _, d8 |! q% N4 R$ w9 m

  32. . k0 f2 h" d! E( [) x
  33.                 //Commandline that will used at CreateProcess
    1 t1 Z( Q. ^) F
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));, y8 f7 r: X2 j# g) E1 ~9 w. @

  35. 5 A! Y6 |/ S4 L' J& @: Q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    3 l' W( Z+ N" P
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    - A0 Q  r/ m' i$ G
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    & Q$ h2 R! s  B! O& _, S
  39. / Y9 X# m2 h% S$ {4 E/ M2 ]; D

  40. ) d" V( c2 P- d
  41. ( L0 ]* @" K, }/ ]" c" S$ U1 K4 R# N
  42.                 //Start DekaronServer.exe   H5 m4 H$ v! f. s: ]" h
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    # }- ~8 T  \( t5 d
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    " d% O1 ]' x$ x+ T: L
  45.                         szCmdline,        // Command line" X4 f+ X( R/ `, u% D
  46.                         NULL,           // Process handle not inheritable
    8 ^8 U' }2 _! B# w, I3 p0 f# _! d
  47.                         NULL,           // Thread handle not inheritable
    $ i6 i- u9 H5 `; v" `  [
  48.                         FALSE,          // Set handle inheritance to FALSE
    8 C: o( w0 `) b2 [
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    1 \3 P) Q, l- }- @' E) E
  50.                         NULL,           // Use parent's environment block# ?4 m' V+ c: p8 v" P
  51.                         NULL,           // Use parent's starting directory 0 V- q: c5 B' C( W7 s9 y  K) U
  52.                         &si,            // Pointer to STARTUPINFO structure
    ) x$ m: A" E% w5 k
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure; M8 B+ [8 H9 z  I1 F$ T4 M: f- Y
  54.                 ) * r' ?6 V$ N( ^1 O  I# _% Z4 v
  55.                 {
    # |3 y/ W; b4 \# N( ^5 z
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    - D2 F% F/ P: T1 s7 h
  57.                         return 0;2 L  N  k8 y' L) ]
  58.                 }
    / z" n' R. S) N; H
  59.                 //Creating Process was sucessful0 v- d0 _. q' Z5 o% f$ I
  60.                 else/ i1 e" i- k( P; ^  l# G" Z# ~
  61.                 {9 K. k& k' w8 K  w7 ?, P
  62.                         printf("Sucessfully launched DekaronServer.exe\n");2 I& ?- j+ c+ v2 P6 \2 z9 y

  63. + n1 i+ d$ T' f5 N4 w* ~: W/ j. }3 i
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure% L* n5 I% Y, s* Y8 _
  65.                         dbge.dwProcessId = pi.dwProcessId;! x- p& w. I) k) q+ g4 M
  66.                         dbge.dwProcessId = pi.dwThreadId;% q1 _4 e& M0 ?; M! \: Y
  67. 9 k$ e, S( j( J9 F/ `% ]: W
  68.                         while(true) //infinite loop ("Debugger")
    # O7 f4 z* A1 p1 d& [
  69.                         {7 |0 D) @5 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# [$ R( R5 \5 o$ E& J0 H% }
  71. % i, L* r$ ?. I
  72.                                 /** {% ^2 M8 e2 n+ ~
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
; ^5 K) {/ m+ @9 r

' B! p( ^% @, q3 [5 }1 K( L' \" c  O# e
商业服务端 登录器 网站 出售

15

主题

258

回帖

1251

积分

金牌会员

积分
1251
金钱
907
贡献
66
注册时间
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

主题

258

回帖

1251

积分

金牌会员

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

3

主题

102

回帖

7517

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-11 14:50 , Processed in 0.038402 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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