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

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

[复制链接]

154

主题

343

回帖

5846

积分

管理员

积分
5846
金钱
1835
贡献
3514
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 0 a5 }5 {' j% z+ b+ K9 W- }6 b
* ^7 E, o# i. Z- C% ]
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
- ]# ~3 U5 T( @0 v& I
1 O, ^% _# d$ d  e
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    8 k/ R; w9 M" m, `
  2. //9 [% x9 ?1 U& y
  3. , L3 p4 j5 R4 i* W/ V" j+ Q0 f# n
  4. #include "stdafx.h"! v  w3 B) ~8 T: R& `! b, f
  5. #include <iostream>/ J' O" c  q4 l
  6. #include <Windows.h>
    7 `9 p3 j  X: Y8 a" k6 V1 N( f
  7. #include <io.h>/ M* {. n+ u0 ]5 `" ~5 e! m

  8. " ?2 ]9 b+ s0 q) a, E- e
  9. 4 e, P9 I6 K3 @5 h
  10. int _tmain(int argc, _TCHAR* argv[])
    ; R0 x/ n! k7 B4 k' T. Y5 E
  11. {
      |7 Y5 Z' @$ [, p0 j5 g0 v* P* [
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ) J7 ~+ }4 Y. L7 S

  13. 4 ]3 M" Y( Y  V0 }0 P, M
  14.         //查看文件“DekaronServer.exe”是否存在0 P# N4 r8 h" W" ?! v* b
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ; L4 \, U4 L# G$ R" |+ P
  16.         {& K/ C6 n  Y+ U) W
  17.                 printf("DekaronServer.exe not found!\n");
    ; I* L5 y) D. a' n
  18.                 printf("Program will close in 5seconds\n");; P+ s  Z5 L; V4 O; S- f4 Y, d- P5 W
  19.                 Sleep(5000);
    2 ~; B% b8 f: Z
  20.         }
    # S4 N2 c# f* v* m
  21.         else& c1 T* n7 c* U% @, F' X
  22.         {
      S- {7 \" p% H3 c( u/ p
  23.                 ) K$ Y" W0 D1 M/ N
  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).aspx8 F$ k3 S* P) I+ X
  25.                 STARTUPINFO si;
    + m% f3 \& u8 A8 O- y
  26. 2 o# N: a+ C2 Z+ Z  x
  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
    : `: p7 `! |4 @6 p
  28.                 PROCESS_INFORMATION pi;3 {! S! l9 V7 M1 r( p0 e* |
  29. # u/ ^" |' p0 K0 q+ e' c
  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* G# j4 c% w6 j- C, Y' A- [. @
  31.                 DEBUG_EVENT dbge;
    0 s7 Q. X2 E  E9 A3 _
  32. 9 z- u3 P7 u: W) P) `5 r
  33.                 //Commandline that will used at CreateProcess! n3 X' q  {* }" l$ R
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));* K/ {2 |) f- ~3 r( Z3 A1 [

  35. / D$ S$ `. D) O* f; @
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ; S3 ?/ _# k4 [0 B5 `) ~( ~
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    , M: S3 p1 P; x. {! |3 Z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)- R/ {4 b6 [' {5 n) F  }1 d
  39. ; O. H+ S' K+ ?5 k1 V4 c. L, \8 v

  40. ( G4 b1 A0 Z( b" J# u+ w

  41. 9 }: j) D  l! R# ^, Q( ^$ ]
  42.                 //Start DekaronServer.exe 7 }; q0 _; M8 `4 @/ M1 W; k. K, ?
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx! ]# b: `% i3 V! n( Z; G. N. o
  44.                 if( !CreateProcess( NULL,   // No module name (use command line); Y# g/ N" S, |$ A8 p) y+ A- v8 J
  45.                         szCmdline,        // Command line
    + _( J! k' c: k$ P5 w
  46.                         NULL,           // Process handle not inheritable+ v  F8 Y2 W; Z0 b$ t6 g
  47.                         NULL,           // Thread handle not inheritable- [8 l4 W2 [) A
  48.                         FALSE,          // Set handle inheritance to FALSE
    0 K3 u. N4 S5 w# A- u/ a& `
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    9 u/ s7 Q  v9 H5 S  G1 y( n
  50.                         NULL,           // Use parent's environment block9 \) j' e# O4 @- p- @. _0 X0 Y- z
  51.                         NULL,           // Use parent's starting directory . x4 \, \, ~, M
  52.                         &si,            // Pointer to STARTUPINFO structure& k, Q$ P2 Q9 s% N1 r- s
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure$ O" ?- p- U3 F. q! k9 G
  54.                 ) - N( i* N9 F4 H" |4 e
  55.                 {# {" W9 p4 O7 G2 S
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    # S9 K) i' b9 w: n3 ]% H% b. u
  57.                         return 0;
    ; y! D# r5 n8 A' G# _  S$ e
  58.                 }4 M. Z$ P4 Z$ V- D# k1 ]6 w
  59.                 //Creating Process was sucessful
    % S  R' f; ~: [) h' l) @3 q6 p9 m& S
  60.                 else0 F- |* p& s: X% u6 x+ M* i% W
  61.                 {
    - K4 p% Q6 ]7 |
  62.                         printf("Sucessfully launched DekaronServer.exe\n");" x. a( |9 T& p
  63. & ~8 E' t2 J9 G' {  n
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    2 Y# X; K* _% Y! N7 L# ^9 `
  65.                         dbge.dwProcessId = pi.dwProcessId;$ E$ N( T+ h  R0 i+ k( x3 J! j( ?
  66.                         dbge.dwProcessId = pi.dwThreadId;0 G* X0 \) \% i* x8 t

  67. 2 r) e0 \3 K- ?- |5 u- a
  68.                         while(true) //infinite loop ("Debugger")+ z- F" Q& v- _- r6 u
  69.                         {
    - I0 t' e& P0 @, ~( f
  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% m) o3 r! j! _) S3 J

  71. - b- [5 W! k4 l( L% n
  72.                                 /*
    ) d4 t7 I  b& g8 M" S$ M
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
' ]' O! O$ R+ g

1 _! R0 G" A% }' `
5 ]5 h. K" g  [
商业服务端 登录器 网站 出售

13

主题

251

回帖

1249

积分

金牌会员

积分
1249
金钱
796
贡献
184
注册时间
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

回帖

1249

积分

金牌会员

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

3

主题

99

回帖

5373

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-10 11:53 , Processed in 0.067804 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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