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

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

[复制链接]

157

主题

367

回帖

7122

积分

管理员

积分
7122
金钱
2045
贡献
4553
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
2 U# q# u/ v& d& }" s0 O4 G; N
0 j# }( g: S$ \7 r- l9 Q% g/ V虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。) c2 r- B5 i* g
9 h0 Y$ d: @& [* ~* s
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。9 L; x& L0 {0 f; t+ a' b6 Y
  2. //# ~& ?: a2 I  @% r) @& K0 p; v
  3.   |8 p: w# H! E6 Q4 m6 X4 D; v
  4. #include "stdafx.h"2 y' V3 i. e5 C1 P- {
  5. #include <iostream>3 z" o1 _) W5 x
  6. #include <Windows.h>9 L2 R+ ^1 n  R! L) g, B
  7. #include <io.h>
    6 ~  d' f- j, M: u' A3 H* j( a

  8. $ Q  r, i) p/ j3 t& `

  9. / D0 T) z; j- x( h" g1 {
  10. int _tmain(int argc, _TCHAR* argv[])
    4 Y2 c1 L9 J+ ]+ L
  11. {6 S& @1 ~" N# L$ x& H9 X4 ?
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    6 j6 A6 r  |+ K+ X5 H* n) O3 q* M" }

  13.   H! B& u+ A, [3 b
  14.         //查看文件“DekaronServer.exe”是否存在
    & L! L( d, k; e+ s: @
  15.         if(_access("DekaronServer.exe", 0) == -1)4 v0 t, b- W2 u5 @7 i
  16.         {
    4 f1 N! ]9 x/ ?  q3 D# F& a
  17.                 printf("DekaronServer.exe not found!\n");
    # S/ ?% `. t5 F+ j
  18.                 printf("Program will close in 5seconds\n");
    ( _; ?5 r% D; c' |4 Q
  19.                 Sleep(5000);4 T4 n/ X; [% {2 ]# {
  20.         }, @- w% F3 t$ W# K
  21.         else
    1 {* N# [: D. m" a/ l+ [& o. x
  22.         {
    $ g- y/ h  U; N) ^
  23.                 4 l2 S$ M# I  [' M- l- ?* L
  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
    # T6 T% l" \3 i+ \0 ?
  25.                 STARTUPINFO si;, V* n) `. Z/ K6 g& `' C

  26. ) }' R$ Q( v7 D$ T7 _, t+ 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).aspx; X6 R2 k9 A$ L, ~
  28.                 PROCESS_INFORMATION pi;
    # o( C$ k. q4 O1 {4 A1 Z

  29. + L7 a9 G  o% H! W+ @
  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
    ; T, Z0 S/ k. l$ Z" d0 ?
  31.                 DEBUG_EVENT dbge;3 z% G4 H. E) q* `
  32. 5 R* N; _. ]3 `
  33.                 //Commandline that will used at CreateProcess
    & w, s$ J4 `# W% t
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));- i" O4 T6 }3 H7 I3 G9 @8 p
  35. ; J, J& y' X! F/ A6 @: O& S  b
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
      y5 F  T7 v) R9 {8 I
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    1 b0 f9 \( J$ i+ N/ |: H3 V  F
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)6 g5 `9 q5 @; n+ F) z
  39. 8 E$ f& Z8 L4 t: f6 [% O$ }5 l
  40. ) i# b# ~& G7 y+ r! m
  41. 7 X% a( H& m( T. D% Q
  42.                 //Start DekaronServer.exe . j# w0 V" _# G9 G/ v( ^
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx1 _6 j4 }: b9 Q8 S) J8 h
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)# ?; f3 {5 \1 U' B6 U6 l! i2 h
  45.                         szCmdline,        // Command line0 e4 E7 P$ O% @) J( {( g! v
  46.                         NULL,           // Process handle not inheritable
    - S: W# a. i# f% u
  47.                         NULL,           // Thread handle not inheritable- ?8 h5 _3 k, S. g' E1 a4 [3 D; l
  48.                         FALSE,          // Set handle inheritance to FALSE/ b9 q3 X( w$ |
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx$ t  Z- T( a2 x, _
  50.                         NULL,           // Use parent's environment block
    8 r; N4 x% R) w. ?
  51.                         NULL,           // Use parent's starting directory
    9 \: A- M7 y' ?. t- {
  52.                         &si,            // Pointer to STARTUPINFO structure
    ) y7 f. o+ w& \1 g
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure7 p& J: b4 _, g, A
  54.                 )
    * v6 I: I' |" l$ m2 O3 d
  55.                 {7 Z/ C: X2 |$ |. M& G6 n9 @, x
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    6 e( g+ n" a7 C. C& n
  57.                         return 0;1 H$ q/ d$ e) ^7 E
  58.                 }
    " X9 v3 ~8 b8 p. H! b
  59.                 //Creating Process was sucessful
    ! H0 m, h  \5 s/ E7 v
  60.                 else* w$ A+ ]' S  m0 p9 {/ S) D
  61.                 {
    / G# Q& W2 D: |- M
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    $ s8 q+ v6 W6 b8 O0 S

  63. 8 U8 Y0 @' R- D/ |  m1 `
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    2 Z( i. ], a7 k  \3 C  a
  65.                         dbge.dwProcessId = pi.dwProcessId;4 n, q+ i& k0 R% A
  66.                         dbge.dwProcessId = pi.dwThreadId;6 k% n& a2 E) t3 _$ V
  67. 9 z, Q0 z6 Z3 M7 O
  68.                         while(true) //infinite loop ("Debugger"), j3 h7 g8 t  N$ L7 B, ^0 ]2 A; d
  69.                         {
    4 r0 d# g. L* S
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx0 r" T# r) @! ], X
  71. ; w; M" p) F5 F  U1 ]! Y
  72.                                 /*$ X3 w5 Q: c6 o+ u( E
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
8 f) H/ |, h, q; x% M; r' k

4 b8 O$ m( d+ m7 |* M1 j
. {; D& G6 Q6 t, r/ @$ y2 l" O
商业服务端 登录器 网站 出售

15

主题

258

回帖

1245

积分

金牌会员

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

回帖

1245

积分

金牌会员

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

3

主题

102

回帖

7377

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-5 06:38 , Processed in 0.054015 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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