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

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

[复制链接]

157

主题

360

回帖

6649

积分

管理员

积分
6649
金钱
1926
贡献
4206
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
6 u2 R5 |# [: ]$ Y& c  |) Q, L
, U% G# z2 E, R5 F8 n# R虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
: q+ S. c* f$ G. o; F% Q% a; `8 P# O( H. `2 g6 a
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    / L5 d! b* S5 g4 l7 e* V
  2. //& K+ E. F: r- ^0 @) |) j% c

  3. ( P+ d# _( v% |3 ^% X
  4. #include "stdafx.h"
    # ^, k- [" q$ n/ u' o
  5. #include <iostream>$ |$ s, k& d4 G  O
  6. #include <Windows.h>1 v, a& `6 ^# D! x
  7. #include <io.h>5 _' A/ V2 M4 J
  8. ! z8 E- m7 U9 F/ Z, d1 C! E; r

  9. " ~; J) O1 V& J
  10. int _tmain(int argc, _TCHAR* argv[]): @/ P) p0 w" @- B, W( s
  11. {
    9 }2 X# F5 U9 ^0 R
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    * r4 C# x/ `& k8 G

  13. 0 z8 M  |' q3 B, `
  14.         //查看文件“DekaronServer.exe”是否存在* v& v2 X, D& N( L  I
  15.         if(_access("DekaronServer.exe", 0) == -1)5 `/ E+ M( A' O5 N' ~$ y
  16.         {
    5 _8 _7 |! \8 J0 P3 P2 N
  17.                 printf("DekaronServer.exe not found!\n");
    % ?7 y9 H. s2 O
  18.                 printf("Program will close in 5seconds\n");
    " B) o: v) A  L: I- V
  19.                 Sleep(5000);
    1 a4 D/ j2 G/ d5 r
  20.         }
    9 O% c6 q4 O2 s" S
  21.         else
    / P5 k; a8 S" ~, g. I' s
  22.         {. E" T8 p9 A, }+ \, k) T# k
  23.                
    3 N2 P$ ]( j6 v0 i% `. F
  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
    " d+ w( u9 x; |4 P
  25.                 STARTUPINFO si;
    # [# N) O5 D) ~
  26. $ K7 \+ ?. S" O* {: Y  y
  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' _6 ^2 {1 s9 H" e0 s. l1 m8 u, o2 D
  28.                 PROCESS_INFORMATION pi;- x2 y: R2 Z. V$ i4 _" R' P

  29. 6 u/ I, r  V% e, |5 ?! 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* m0 r5 o; s5 r. h% V
  31.                 DEBUG_EVENT dbge;
    * F% r! o/ ]; }# W# x/ f7 L
  32. 0 U% t: x7 u) u
  33.                 //Commandline that will used at CreateProcess  y; Y+ e/ j5 T+ H' ]* j' t
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));4 v6 ~: a8 w2 q- j' u6 H' C& s+ L( c

  35. % e" h2 C8 L* S2 _3 m% V7 g" q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    " m6 C  e* r; H1 Q9 `- O7 D8 a
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    % N4 H' b0 ]2 v! w0 j( ~5 H6 |& T
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    2 ^  n/ C( H6 p8 b( G5 B* Z
  39. 9 x3 C* O' T$ N8 e  _

  40. , F0 |4 g0 W1 E/ r6 U9 d4 V! Z1 @8 W

  41. 4 O" V( [! Q! C/ d" W. g
  42.                 //Start DekaronServer.exe
    8 Z8 P; f+ I) ~4 t
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    : F0 A0 s  }- Z$ V
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)+ L# J9 y' t/ V% P4 g/ q
  45.                         szCmdline,        // Command line. N, e& G. |9 c8 y$ G
  46.                         NULL,           // Process handle not inheritable
    . h3 Y" a' K8 J  t* |3 @! S
  47.                         NULL,           // Thread handle not inheritable6 l/ K' b+ X% |" A  `
  48.                         FALSE,          // Set handle inheritance to FALSE
    4 b. w3 \( g6 p) x
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    0 Q) h) |$ `7 D' s7 ]
  50.                         NULL,           // Use parent's environment block
    ' V6 l$ ~* T; U3 H' J& ^: \- ~/ W
  51.                         NULL,           // Use parent's starting directory ( j. M9 K  a( P/ F8 T8 G
  52.                         &si,            // Pointer to STARTUPINFO structure* w: J) i) J7 i" o8 c
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    7 n. \" N* A# a: a
  54.                 )
    3 r) Q2 ^4 T8 \# [6 R8 Z
  55.                 {& X% v* d1 k- s9 B" k- ~
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );. S$ u! p# n' J) @
  57.                         return 0;( L7 z6 g& |* _! A" o
  58.                 }
      a& K4 J' N( ?' F
  59.                 //Creating Process was sucessful+ ?* f% _, U7 \) a0 ~& o+ K1 P2 a
  60.                 else6 t1 b& k4 X/ C$ p" a- X
  61.                 {6 C+ q' ~, l3 j5 X9 |7 C
  62.                         printf("Sucessfully launched DekaronServer.exe\n");' B: h0 t' v& P1 Q

  63. 6 Q9 U  S. c$ Y! x% P, j
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure8 _' L- N0 j# A. K% k" H! ?
  65.                         dbge.dwProcessId = pi.dwProcessId;
    0 W6 u% k- g, h2 e0 |3 o
  66.                         dbge.dwProcessId = pi.dwThreadId;
    1 k% e0 {  B9 u# G7 B* T: F

  67. ' k+ u! e3 b& w& S; ~3 Y  d: j
  68.                         while(true) //infinite loop ("Debugger")( A% ^) b$ R" U: ~6 e8 L
  69.                         {
    ; G6 v9 o7 I$ ?' s+ `  c
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx! @' I, v  B, f

  71. 2 n* A& r( t8 Y: }, M
  72.                                 /*! |7 x5 ?0 j3 [2 d- B0 q9 Q! E6 K3 @
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
" w8 q& T0 ]' O; m! G

) \2 q' J. W! M' V0 ?! Q) {# t, }; i
商业服务端 登录器 网站 出售

15

主题

256

回帖

1253

积分

金牌会员

积分
1253
金钱
861
贡献
116
注册时间
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

回帖

1253

积分

金牌会员

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

3

主题

102

回帖

6281

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-3 11:21 , Processed in 0.073706 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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