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

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

[复制链接]

154

主题

335

回帖

5769

积分

管理员

积分
5769
金钱
1815
贡献
3465
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 3 R( z; [4 {( N9 o: b8 _  y

6 j7 q& v# x" R虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
$ E: ?, |9 w2 V7 d
  }# j0 L3 G* v6 \' g
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。9 x' X+ J5 {3 x/ F% p
  2. /// R) j, K" @; \- O9 e
  3. 0 S( s; J* }9 l7 Z/ u4 ^! c% A
  4. #include "stdafx.h"
    9 w5 B8 w" O2 \2 P6 t
  5. #include <iostream>; d; F$ C" a9 \
  6. #include <Windows.h>
    ' f; z" K8 Q8 p% g+ V
  7. #include <io.h>! x9 ^$ d0 S6 Z1 b' t: a+ Z% u. w
  8. * ?, N) J: ?/ a% y# G5 N

  9.   ?" P- {; C9 g1 h
  10. int _tmain(int argc, _TCHAR* argv[])
    + L- P. s, P# j5 o) ^
  11. {
    # ]' J2 o" z9 M" H! x$ L
  12.         printf("Dekaron-Server Launcher by Toasty\n");# H/ l' h9 v% ^. z' l9 J

  13.   _) H  h$ a0 w( j; b$ [: h
  14.         //查看文件“DekaronServer.exe”是否存在0 Z5 A" ^/ x) W6 v# c; a& m
  15.         if(_access("DekaronServer.exe", 0) == -1)
    9 ~( r& M. V; F- c% j
  16.         {* F0 e* k4 m* v' h/ s
  17.                 printf("DekaronServer.exe not found!\n");6 B( U5 t  a/ [9 t5 y8 }
  18.                 printf("Program will close in 5seconds\n");
    . n$ ^6 ~2 @% L/ P
  19.                 Sleep(5000);0 O% q, p: t( G2 j/ q2 \) t' a
  20.         }
    7 M* N5 Y$ W* Q0 H
  21.         else4 D7 m$ \$ T3 R) `, I* E
  22.         {' a8 m7 v: t  U8 m$ ^0 G
  23.                 ) q( E+ P7 L7 \& f! r
  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).aspx1 o# V0 J) H8 y/ }# }' U
  25.                 STARTUPINFO si;1 ^6 B; C: H. D' w, {4 r* u! H

  26. 7 u) _% J5 J; R5 ^6 _1 @$ Y
  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
    & M' G; H  W- e4 T" |& m9 C
  28.                 PROCESS_INFORMATION pi;2 a  V9 H+ S& m4 x1 O" p

  29. ( [8 q6 A$ l, a# _' A; a3 U# k! u4 j9 h  G
  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! ~! L. _4 F, s$ z0 }: ]9 a7 G0 R
  31.                 DEBUG_EVENT dbge;
    6 M/ a' V; j1 O9 v4 h( D

  32. 0 X6 x. \. \5 j7 f  d" b
  33.                 //Commandline that will used at CreateProcess
    . X# X  Z$ M/ U6 G2 u$ M* D3 y
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));' q3 F9 |1 d, m# o! l

  35. % G. q+ f* h% I: N4 c: X% t& @
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)# @+ P# P8 Z# B6 m1 w$ P
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    5 F+ c% o; d' G. e: U/ E
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)5 r2 V* I% g. d$ r$ T/ j+ H

  39. + z8 D& h9 w. Q, K; r; x5 ~! J+ B, {
  40. " O6 d; P$ C( O# o% {5 C1 b
  41. 0 S, ]! z$ K3 f0 e, s
  42.                 //Start DekaronServer.exe
    4 M' |, d$ \( R3 b
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    3 T0 y" {% k6 v# c3 G# }0 _+ A
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)- X5 a. s  i( D7 \) p2 x" k
  45.                         szCmdline,        // Command line, r4 @( p5 l6 y
  46.                         NULL,           // Process handle not inheritable  V# |9 |% V" o
  47.                         NULL,           // Thread handle not inheritable
    % a6 Z0 m4 w1 g9 r/ ?1 r
  48.                         FALSE,          // Set handle inheritance to FALSE
    $ L: t9 m& ]7 ]8 Y3 Q
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx# }7 X4 J( l; F. ?
  50.                         NULL,           // Use parent's environment block
    # U6 G* U! @' r& q1 K# W: `
  51.                         NULL,           // Use parent's starting directory . R8 R/ T& I) n, ?2 X3 b# x: G
  52.                         &si,            // Pointer to STARTUPINFO structure) d$ {- R+ w' w6 s, j$ u
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure/ ?9 a% ^* }2 E* T. H5 f2 U/ @
  54.                 ) % W4 I" S; m5 H2 @2 @1 s( i! V+ p6 h
  55.                 {% c9 G: V/ b7 L+ k$ {/ m
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );3 O" d" j4 C3 |' y% O
  57.                         return 0;
    $ l  g6 E. {2 O! J4 J
  58.                 }
    5 B3 l8 N8 }& c6 z7 ^, d
  59.                 //Creating Process was sucessful
    ' C+ o4 v7 e/ ^6 |4 U8 E) j
  60.                 else
    $ D: ]8 A3 Q" I
  61.                 {- Y9 O+ d8 C; h1 Q% F
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    4 ~/ z# I- J$ b* r
  63. : L- v# a; n7 g# v6 |; k2 m+ P
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    , \9 m  B5 Q5 t; z
  65.                         dbge.dwProcessId = pi.dwProcessId;  R# t# x4 ^# g6 h! z! V' F
  66.                         dbge.dwProcessId = pi.dwThreadId;; X; N4 ^# _5 C

  67. 2 _3 ~# y4 ^* e
  68.                         while(true) //infinite loop ("Debugger")
    : V- x, ^) p* k; {0 f0 }
  69.                         {
    9 S. t0 a2 D* B- b7 k
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    5 o2 o; r* u* ?; ?# O0 `
  71. - u! T$ h- `% o0 S  T# s1 p% U0 X
  72.                                 /*
    3 {3 e: {( U1 W" w$ E& z6 ~) d, j# R5 L
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
4 H8 t& i- U6 P3 F3 Z
* E( C: c8 N8 T: J) N
: r1 K' B+ ~' g4 p5 n8 W* a
商业服务端 登录器 网站 出售

13

主题

250

回帖

1232

积分

金牌会员

积分
1232
金钱
787
贡献
177
注册时间
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

主题

250

回帖

1232

积分

金牌会员

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

3

主题

99

回帖

5213

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-2 01:49 , Processed in 0.075612 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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