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

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

[复制链接]

149

主题

294

回帖

5195

积分

管理员

积分
5195
金钱
1666
贡献
3086
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
+ a6 ]2 O" g  {+ Z2 Q+ H+ @, ]. T0 ]# |9 L
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。$ N4 B* D: n; s! O# ~

' q6 f9 D7 b. r9 a
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    * D1 I3 o; e: d) U
  2. //3 O$ [7 y! B/ S, c3 S: d

  3. 0 E% Z2 O: [! z$ U$ s( N2 ~: }
  4. #include "stdafx.h"2 p' p/ U' i* q1 q, _
  5. #include <iostream>* F$ V7 o1 j' B
  6. #include <Windows.h>) `  r/ B! N& q
  7. #include <io.h>' q4 e; a- h% ^0 c
  8. . e% d8 A! z; ~- {9 D
  9. 8 X' \$ J) |* ^
  10. int _tmain(int argc, _TCHAR* argv[])
    % ?& `- w% Z! E: R7 a- m! D0 B
  11. {4 ]$ x4 L, n, z( k& }: A
  12.         printf("Dekaron-Server Launcher by Toasty\n");9 Z5 ?# t2 V  L

  13. + c; \5 C' N; z+ n9 L
  14.         //查看文件“DekaronServer.exe”是否存在
    $ y3 c3 m. o2 U" D+ ]+ j2 n
  15.         if(_access("DekaronServer.exe", 0) == -1)
    * _# K. _+ i" U. X
  16.         {
    . J+ S: [) Z" z" I# ?! E4 ?
  17.                 printf("DekaronServer.exe not found!\n");
      l+ o) Y; ^8 Q& `1 H( M, i# m" E; o
  18.                 printf("Program will close in 5seconds\n");2 ?! k( {  t8 T! p. f5 w7 [
  19.                 Sleep(5000);# ^3 a- I) I  J* n. M4 |: g
  20.         }, L6 y& U, t. C/ b
  21.         else& C5 d6 J$ _0 e( [( H5 ^
  22.         {
    ) ?: U6 X2 X9 |1 ^) p
  23.                 ! J3 @  @. g/ W5 C" R3 r( 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! k  t! i/ D7 ?3 ~; A1 b" `
  25.                 STARTUPINFO si;
    ) L" e/ z) ]  x& T6 W6 Z+ Q  Y

  26. , ]# S) P( g/ E, B& ^  i
  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) E7 s* Q7 N. Y, t0 k
  28.                 PROCESS_INFORMATION pi;& E. n, T9 T/ X8 u% h$ Q4 U* v
  29. 2 }. _$ x+ @9 B3 y( g( X
  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).aspx7 G. l) R9 q3 c+ l3 T, Z3 t
  31.                 DEBUG_EVENT dbge;+ t0 A7 a. }& p. @. m2 {

  32. 0 m  b% T, a4 z) m
  33.                 //Commandline that will used at CreateProcess7 n# m  `0 f( _* X! R
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    . s- l# u: N5 h9 M- R6 U; Q
  35. ' f( f% [2 [2 A+ b! h: \, Q
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ; ~1 M4 k. ^& J* a5 K0 z6 d$ M6 ~' D
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)0 L: q/ U; Q5 p' Q3 r4 t6 o# x
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    6 w0 `1 _& q. \' |

  39. 1 Q! S7 v) @. {* |
  40. . b/ S9 k  M( A

  41. 1 U* K; G( j! g
  42.                 //Start DekaronServer.exe 0 I2 ^7 o$ V8 k& T
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx9 X8 V( ~' z! y5 e
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)3 ], |% O9 I% k) A8 P4 W
  45.                         szCmdline,        // Command line6 `$ V( w' R, v( x" d. Y0 l2 N
  46.                         NULL,           // Process handle not inheritable. {( |  b1 d2 r, ~7 V! U3 U- J
  47.                         NULL,           // Thread handle not inheritable
    ' B& E, \4 a6 h. \5 f
  48.                         FALSE,          // Set handle inheritance to FALSE
    * G7 A: H+ {( I" z7 O
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx3 Q8 ?& K: \" P
  50.                         NULL,           // Use parent's environment block# z- ?+ G3 I5 l0 u, I/ Y* _
  51.                         NULL,           // Use parent's starting directory 0 A8 F8 q( `* F8 t5 C
  52.                         &si,            // Pointer to STARTUPINFO structure
    , c2 |" p' d* K$ S, o& J
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure. E. e! u8 G: B3 P. M/ U
  54.                 ) - _$ ]0 m+ P5 Z! @4 `6 {* i0 f! j
  55.                 {) I+ f# R% [* k5 J# t
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );- _1 C  s' @$ g2 e7 K- k+ o. a! s& ~
  57.                         return 0;% U- k! o3 ]2 I; Q: q, V- @6 W
  58.                 }# k* N1 y# [: s3 K( c
  59.                 //Creating Process was sucessful, A9 w8 S4 G* O; d8 g/ p
  60.                 else6 W7 L) k+ ^# N' ^7 w; x3 g1 }
  61.                 {) Q7 G# O: P2 Y* s* {- t' S
  62.                         printf("Sucessfully launched DekaronServer.exe\n");3 m  t- J. B# z/ g

  63. 9 ~9 P; ?0 t& n/ o' d+ ]6 @, w& h6 @' B3 [
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure+ ^" D* t' _$ I9 G
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / t( x6 t& c; G# a0 a1 D
  66.                         dbge.dwProcessId = pi.dwThreadId;) v5 O! I# t" M' U
  67. : {- b: _0 k, R/ ~+ D
  68.                         while(true) //infinite loop ("Debugger"): w& A" F# Z2 @" T
  69.                         {9 D6 c; b" T8 o) l0 R4 G; n
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    9 w3 T; z: F4 L; [
  71. $ H& J2 }2 V9 b, D5 R
  72.                                 /*  W  p+ ?; B3 _( e
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
% y& z+ C8 j: F4 \! @, |: T
; T5 B$ k* d3 s$ I7 B; m+ g

! B8 J. D3 d  Y# _
商业服务端 登录器 网站 出售

11

主题

245

回帖

1124

积分

高级会员

积分
1124
金钱
712
贡献
151
注册时间
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

主题

204

回帖

340

积分

中级会员

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

11

主题

245

回帖

1124

积分

高级会员

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

3

主题

97

回帖

3919

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-9-20 00:11 , Processed in 0.048815 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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