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

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

[复制链接]

155

主题

348

回帖

6179

积分

管理员

积分
6179
金钱
1868
贡献
3808
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
3 `0 Z0 [% @! m0 ~. \  i" j6 \3 g) f5 S4 S
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
+ K; n- Z+ I9 Y7 y& ^/ R
3 R) M6 l" O* M8 g3 L
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    8 A9 @! r# D  j0 v) C( {4 i
  2. //
    ! p( U0 w% i& v# u' V8 ?

  3. ! s  U$ `" E0 x+ C4 ~) F) b
  4. #include "stdafx.h"
    5 D5 z! v  |: s
  5. #include <iostream>! x  c  p4 D+ @% ~$ B; ]
  6. #include <Windows.h>
    7 r, c9 `8 D, S1 l0 t
  7. #include <io.h>6 W1 J* n& [( l; p. _8 v' M( @# e+ ]

  8.   t( |0 v* ~0 ]/ o0 c% x
  9. " V! r/ z* k5 `8 j6 w# O$ y) W* V/ I% _
  10. int _tmain(int argc, _TCHAR* argv[])+ U- E4 W0 A' C' G4 e
  11. {
    , j* P7 {& K7 _
  12.         printf("Dekaron-Server Launcher by Toasty\n");; z) H# x: s6 l! {( b$ U

  13. , ~9 k) t5 t6 l5 \0 t" H1 j
  14.         //查看文件“DekaronServer.exe”是否存在
    + z: t0 @  ^; p7 V4 e" e$ W
  15.         if(_access("DekaronServer.exe", 0) == -1)
    5 o1 _% d* i: M+ x' B. N! y. ?8 l
  16.         {
    ; C) W: G# ?9 d
  17.                 printf("DekaronServer.exe not found!\n");
    6 t4 v$ q: f$ l9 i9 R
  18.                 printf("Program will close in 5seconds\n");; p+ U8 j0 v* w$ a
  19.                 Sleep(5000);) q& ?! Q7 E5 X) ^: j+ V" ?
  20.         }
    " N; n& y" W3 Z  q
  21.         else2 j2 g% C7 s/ q& W. ~6 W
  22.         {
    & c7 }6 h8 o* W0 R7 F- ^4 `
  23.                 8 l; ]0 t- R0 Q7 k
  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 w* E) h3 S/ ^3 b0 N9 `
  25.                 STARTUPINFO si;+ b! S9 B. p7 _2 y; u

  26. + x; Q, E8 A. V6 k6 r; ^
  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).aspx0 ?/ Y: r+ i1 e
  28.                 PROCESS_INFORMATION pi;
    / c2 r7 p; a7 a: r4 D- O$ F
  29. " e) X8 T- m& w: b
  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
    4 i8 X, g$ ], k7 z
  31.                 DEBUG_EVENT dbge;
    $ z, N: g+ N& e1 N. Y) R' E% ~

  32. , D# Z$ n, d" T3 i
  33.                 //Commandline that will used at CreateProcess  A: |$ {3 D6 I& `/ Z; p) Y; e1 B
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));1 n3 Z0 c6 \; t! @

  35. ' H1 [8 m% M  e0 V  ^
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    - s- E7 s, f6 Y5 l  e7 Y, z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    3 ?! D1 c& C+ D! w- A: C
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)' s1 D+ i7 D" h- x& U8 d; g' T
  39. " i9 u, ~) {: J- I5 z1 M
  40. ) O0 y/ k" h" Z! s
  41. * m4 s* i5 D4 P: J$ a3 q; R% E
  42.                 //Start DekaronServer.exe
    * b' V" m( \( [4 Z2 p3 Z
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    # Y' J. b1 X" t1 T' P8 K. D' _6 ?
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)' ^8 Y" ]4 n  d% H/ T$ ^1 \; l
  45.                         szCmdline,        // Command line
    0 ~' ]4 G! X5 z4 D% L
  46.                         NULL,           // Process handle not inheritable4 D/ Q) B1 e( K7 y% a1 [* _2 A
  47.                         NULL,           // Thread handle not inheritable
    % x/ U$ B% U$ n0 u0 x
  48.                         FALSE,          // Set handle inheritance to FALSE
    - D$ D: m* N) {1 @/ a
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    / ?& D  I7 u) I) J3 t
  50.                         NULL,           // Use parent's environment block8 P" f( S$ @4 w, q+ v5 ^8 c
  51.                         NULL,           // Use parent's starting directory ! b8 i2 c' s, @/ L, y; x
  52.                         &si,            // Pointer to STARTUPINFO structure
    : t# r. z, ^: j! j8 S; y
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    6 M8 d  E1 y; Q
  54.                 ) # P0 O/ Q1 u! W6 N9 E
  55.                 {
    ' g, \, k" X, P- J& S/ t
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );& z1 c! b  B! w( {0 L3 a6 M+ g
  57.                         return 0;3 F) j5 W- a0 D! {$ ~# Y5 w; v5 p
  58.                 }
    # S0 S" W7 n) y$ E2 K
  59.                 //Creating Process was sucessful' ~5 z2 ~& g& y/ H# G! R
  60.                 else3 I* ]7 Z' L; v6 d- v
  61.                 {
    7 z2 u* n/ l! |( q; a
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ' q" v# I: ~; B
  63. + s4 O* S/ d6 E: ]' t( G9 {$ q
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure* R; Y1 g# ^2 F! k1 m
  65.                         dbge.dwProcessId = pi.dwProcessId;
    4 S, I+ {3 G, ~8 z) ~
  66.                         dbge.dwProcessId = pi.dwThreadId;; @6 i$ H  F! D

  67. + ^( O( v$ s. x
  68.                         while(true) //infinite loop ("Debugger")
    ; V" X3 D( ~+ j
  69.                         {4 Q8 ?* e8 W" {% J' s) P7 V
  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 \+ z) E) N9 ^+ v$ d" }
  71. ) j$ M4 x( q( U  t7 X+ Z6 Y
  72.                                 /*
    , s/ N/ P; ~% P
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

. O7 u8 x8 \$ @8 c( {0 w9 j
. P2 R9 I: d5 |, }% Q6 k  S; d' ?' V) c
商业服务端 登录器 网站 出售

13

主题

251

回帖

1245

积分

金牌会员

积分
1245
金钱
816
贡献
160
注册时间
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

回帖

1245

积分

金牌会员

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

3

主题

100

回帖

5721

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-1 15:06 , Processed in 0.164229 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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