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

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

[复制链接]

157

主题

366

回帖

7107

积分

管理员

积分
7107
金钱
2038
贡献
4546
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) , ]1 O; Q" t: K& U: ^
' }% g; ~" X4 m5 r9 h& Y9 [; V
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
3 Y- E4 F9 E. j
3 _/ q- \/ D# M; ]  \: p
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。5 N- h; ?% ?9 Y. V: i, C
  2. //
    : B: K" E  t# R/ [- b$ M
  3. ) z' t$ |# M, {
  4. #include "stdafx.h"
    ; ~, C& {: |, I, g) r
  5. #include <iostream>
    9 P& t+ H% d* ~5 [2 x4 e
  6. #include <Windows.h>* C8 f- t/ u( Z% t- Q9 d
  7. #include <io.h>9 j' O% O9 t; `! S5 Y

  8. . }; L# P# I  ?; N
  9. ( {  D" Q6 j0 c. f
  10. int _tmain(int argc, _TCHAR* argv[])& }( }  f- p9 L7 p7 H% S
  11. {
    8 ~6 G) {. V: j
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ( p# N5 i. K+ F# M' G6 m

  13. ; c: {2 O8 e7 s+ W# ]0 K2 W. M
  14.         //查看文件“DekaronServer.exe”是否存在
    " d+ d" Y7 u- V
  15.         if(_access("DekaronServer.exe", 0) == -1)+ D2 G) z4 P, M
  16.         {
    3 r9 Q' z4 j* q1 v. _
  17.                 printf("DekaronServer.exe not found!\n");
    - \7 r5 O2 _4 c* t( n
  18.                 printf("Program will close in 5seconds\n");* H$ J9 ~: u! N
  19.                 Sleep(5000);
    ! T2 |8 o# h( c! Y/ x* f
  20.         }
    ( F2 c# v9 H$ ~6 Q" G0 ?
  21.         else& {! C) I! t6 E+ S. L- ?$ z  a
  22.         {. K1 ~( I+ K: |$ z: g
  23.                
    & {3 s% |; Z; H# g
  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: L+ ?2 e' r/ z# P0 L
  25.                 STARTUPINFO si;. l' }" \; f( G7 t
  26. 5 F5 w/ H* I7 p5 z
  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
    ' N) W8 n9 |, x+ a
  28.                 PROCESS_INFORMATION pi;
    ! o) g$ R: H5 z

  29. 3 G. D, ^" R1 i0 r1 g3 ~- m
  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
    & R9 X( p4 J/ c$ s9 C2 e* Y) Z
  31.                 DEBUG_EVENT dbge;
    9 Y( e( s1 Q+ C! ~1 \) Y

  32. , D3 E+ o8 I5 b0 q- ]* D
  33.                 //Commandline that will used at CreateProcess8 N7 b# Z8 L8 D: W% k, N
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ) W$ Q2 o7 _/ Y  t( p9 y5 N; u
  35. ; ]7 `% F7 @: p) V5 c
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    5 g0 Q+ l( M* Y( }4 S6 ~
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    4 P' t( K! Y8 I4 g" {3 E( r, T; }
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ) s& ?7 s/ c0 i9 e% a3 K
  39. 1 Y2 k  j- g) i+ F9 Y0 z
  40. " t6 X6 @/ B5 B% X8 ?
  41. 6 @% k9 R. C3 {5 y
  42.                 //Start DekaronServer.exe
    7 j9 R( @( r0 Q8 l7 h- p2 ]% i
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    # \6 `. c; O/ N5 m( f
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    " r' y* w, j* `% t; a; ]
  45.                         szCmdline,        // Command line! A: Z- O* [, q
  46.                         NULL,           // Process handle not inheritable( f8 W- S# z4 {+ S* _' x& e- a
  47.                         NULL,           // Thread handle not inheritable& b; ^% _. ?9 B2 D) I, O$ R
  48.                         FALSE,          // Set handle inheritance to FALSE
    9 k2 z9 ^& h( Q& s
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    5 @, }# @& U+ e( m
  50.                         NULL,           // Use parent's environment block
    , y5 u$ b0 \2 u2 [7 C& i% o
  51.                         NULL,           // Use parent's starting directory
    6 g: u3 {# ?5 s
  52.                         &si,            // Pointer to STARTUPINFO structure7 p, K% e5 e+ W. ^5 y+ V& f- ]: B( ~3 u
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    & L* e; X- ^" V5 h
  54.                 )
    . i4 [3 g9 t7 ~( k- O! B
  55.                 {
    8 V6 \  U, j. v& w4 p
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );3 i7 @4 \5 d5 y& b4 S0 o; s  [, T) X
  57.                         return 0;
    ' a( V! m* {; Y) v/ i7 \& U
  58.                 }
    2 s9 M2 r. N2 Y$ k
  59.                 //Creating Process was sucessful
    % s' \0 B8 L- n
  60.                 else# u0 \  s' b" ^3 o6 a% a
  61.                 {
    / N1 \: u! k$ C% M: f* W
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    & e8 R! E1 [% p

  63. ) T1 c, p& p1 X. {4 ]! _3 G
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    3 J7 \, j' E7 r
  65.                         dbge.dwProcessId = pi.dwProcessId;6 [. \. e% g1 N
  66.                         dbge.dwProcessId = pi.dwThreadId;
    ) k8 ~% j  `% _: E
  67. : k) j  j. m9 Q7 b
  68.                         while(true) //infinite loop ("Debugger")
    : r) j# d: `* d+ k
  69.                         {5 j* n0 i1 D  R$ T2 U  n& S
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    6 C: @/ l2 ~5 x/ B: K; c$ K9 L

  71. ' y/ \( k; F. o( W) i  Y
  72.                                 /*
    / n9 R5 l' l9 ~8 D2 T* Y
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
/ i! K! L6 [/ P8 S0 [

  A4 k+ X9 G$ n; Y! y7 l: |0 K
% k# B1 r8 U  N
商业服务端 登录器 网站 出售

15

主题

257

回帖

1240

积分

金牌会员

积分
1240
金钱
900
贡献
63
注册时间
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

主题

257

回帖

1240

积分

金牌会员

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

3

主题

102

回帖

7297

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-31 19:54 , Processed in 0.045103 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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