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

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

[复制链接]

160

主题

385

回帖

7418

积分

管理员

积分
7418
金钱
2127
贡献
4746
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 4 b! o; ]% D$ S) m5 i
4 _; Q$ H2 C5 r  L" x8 S& v0 O
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
5 W/ K9 ~; o/ [. C# Z& h9 {: P, l5 t+ O& S( E. d$ n% n
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    9 }- F2 ^& j9 Q% t2 `: G' a& W9 }
  2. //
    4 S3 p# n- j) Q4 t' o

  3. ) T# {3 d) U% z% |
  4. #include "stdafx.h": r9 k2 Y4 V0 v$ A
  5. #include <iostream>  E1 Q2 g2 H% d" J0 ^6 |  J$ z
  6. #include <Windows.h>
    # }8 [( V9 s3 J1 D
  7. #include <io.h>* p5 v# ]9 F" a- [
  8. / M6 d0 l7 H0 U
  9. % T7 a, j: S2 h
  10. int _tmain(int argc, _TCHAR* argv[])5 }+ L/ w. z% _% F- Y
  11. {) d6 b6 |4 ]0 c( T) Z! @
  12.         printf("Dekaron-Server Launcher by Toasty\n");+ ]8 }" V" F% o

  13. ( @6 p$ s" P: J' ~4 @
  14.         //查看文件“DekaronServer.exe”是否存在
    % g! h1 F5 n2 @. V
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ; J1 K( v: L  w
  16.         {0 p7 ^3 G/ u& R, R7 v
  17.                 printf("DekaronServer.exe not found!\n");6 W' @; \9 X5 D9 ?8 f4 o
  18.                 printf("Program will close in 5seconds\n");/ ], I, J3 d5 D  e2 ^% ?+ B
  19.                 Sleep(5000);, [1 D" `- G; x1 u- |
  20.         }) ~8 J% U5 f' y9 G# m
  21.         else
    4 e# F3 p$ N: G2 k% X: D4 H
  22.         {# E6 {9 X( x) h3 z
  23.                 ( `. e% s, Q  ?; ?8 Q- j6 C
  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$ r8 @" y4 s1 J% f* Q- ]$ i8 f
  25.                 STARTUPINFO si;
    8 k1 Z; w' D; Y9 ?
  26. ' Y6 _9 i2 J  N) 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).aspx6 p/ f* v5 x) T1 S$ R+ s/ F
  28.                 PROCESS_INFORMATION pi;  {3 K2 j. x1 C
  29.   c0 s6 F4 `- Y- a
  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
    0 G4 @0 I& d. h' w0 o
  31.                 DEBUG_EVENT dbge;9 Q% @" F' ~6 F8 E

  32. - ?, [3 W" ^* G0 P9 F
  33.                 //Commandline that will used at CreateProcess
    6 W# |) u! n* A# v
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));& R( d* d9 c% A8 J, E( L

  35. . K/ Q: g  m- @: C# F, g- b  C3 U
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)( Y* T- V% `# z* R3 D1 ?. \
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    5 c) a7 l: d" @
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    8 G. l2 V* j0 a' {& z* a- G! |% C

  39. 6 n% M6 M4 }8 z

  40. 6 Q# i% p' C' G9 x1 r

  41. ( L; e  M7 g" D
  42.                 //Start DekaronServer.exe
    2 L3 B* ?2 u. t1 ?( r
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
      {7 R& s9 I$ k  h; q$ E
  44.                 if( !CreateProcess( NULL,   // No module name (use command line): _4 w) J1 T: e. e3 v
  45.                         szCmdline,        // Command line! G, P0 e. l7 ]$ }9 u
  46.                         NULL,           // Process handle not inheritable( ~* i/ f4 O# L7 G( F
  47.                         NULL,           // Thread handle not inheritable
    - I( I# x8 t4 V" K: g$ r
  48.                         FALSE,          // Set handle inheritance to FALSE! {* U3 m: G1 t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    6 G9 W/ R: Y* D9 N4 L
  50.                         NULL,           // Use parent's environment block5 M* f" v9 s( F+ D. q1 M
  51.                         NULL,           // Use parent's starting directory 1 `. G4 d9 K6 B; ^6 g
  52.                         &si,            // Pointer to STARTUPINFO structure
    % o9 y/ u: D) J* X- N
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ! _; G! r, g0 U" z+ E
  54.                 ) - B8 f2 n" `. A
  55.                 {
    8 p8 {: ?  ^# p4 m# ^- J4 C( h
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );% f% L* X, f0 \8 l& I  i
  57.                         return 0;1 P, P  ]# E$ k
  58.                 }' @7 X, w/ D" _2 R1 d( f9 Z
  59.                 //Creating Process was sucessful
    ' b0 ~5 M# T- l* o8 f
  60.                 else  x7 c8 P6 [  L
  61.                 {* L' `' k  S, S" z+ \8 D
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    , i$ \) G" b( M5 y! D5 k5 P

  63. 8 K) j5 B$ X6 P' K$ `+ s
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    # E# Q3 H; J# J, S
  65.                         dbge.dwProcessId = pi.dwProcessId;8 y) q9 L2 P: A5 F
  66.                         dbge.dwProcessId = pi.dwThreadId;! L& x) U7 i3 n8 {* `% Y" e  ]
  67. 6 q. F* H8 n" u
  68.                         while(true) //infinite loop ("Debugger")* D% |7 b3 M1 J8 M& n+ j. I
  69.                         {6 s  J/ T3 L! ?6 g! x. P5 c0 p
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx# v% _+ T5 N7 i: [* ]

  71. 7 k/ z" L1 [& _9 p' B
  72.                                 /*
    ; H/ ~' s  F, O/ Y, N$ O2 ^
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
9 j$ N& y: L7 L' l

  N2 X4 e8 r2 h  b& C2 G; R% F! O9 W* `, L6 ?) \' D
商业服务端 登录器 网站 出售

15

主题

260

回帖

1286

积分

金牌会员

积分
1286
金钱
927
贡献
79
注册时间
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

回帖

355

积分

中级会员

积分
355
金钱
142
贡献
6
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

15

主题

260

回帖

1286

积分

金牌会员

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

3

主题

102

回帖

7877

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-29 16:54 , Processed in 0.035449 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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