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

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

[复制链接]

160

主题

385

回帖

7427

积分

管理员

积分
7427
金钱
2133
贡献
4749
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ) \2 s4 f, l% _. P- v
6 @6 }# R  ^( {: B1 p: m
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。* W" J- R, K+ g- x; i

# N3 Y4 N0 o3 w1 j
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    / B, d! G) _" T, @3 z
  2. /// G5 @+ _: Z5 h; k; v9 \* s% ^5 S

  3. . F9 H- W& y: B: g  p( z
  4. #include "stdafx.h"3 i4 f8 t7 G6 F# Q0 f$ Y
  5. #include <iostream>
    8 ?' e  A- D0 N& K/ l. f7 \
  6. #include <Windows.h>  j- S; A8 V1 S$ l
  7. #include <io.h>
    0 K2 n) I1 Q5 z+ I9 z% b: ?
  8. 2 n0 R4 n0 L* v5 d" W, j

  9. ' b# j+ ]7 i( G7 m
  10. int _tmain(int argc, _TCHAR* argv[])
    + Q3 v' h: q" i
  11. {
    4 k5 `/ h$ L2 U  `
  12.         printf("Dekaron-Server Launcher by Toasty\n");# y5 R* Q3 z. ]8 o' I1 c

  13.   P$ o  s" C; Y0 N: Q2 V9 y# m* V
  14.         //查看文件“DekaronServer.exe”是否存在. S/ G5 E+ _+ D& c' w& ]+ i8 I" w. Z# ]
  15.         if(_access("DekaronServer.exe", 0) == -1)
    $ e! p7 H$ D7 _  F
  16.         {
    ' l$ X1 r2 H/ L+ b" H! y
  17.                 printf("DekaronServer.exe not found!\n");4 H/ _& H7 e. m6 y4 R" @% ^/ t2 a
  18.                 printf("Program will close in 5seconds\n");. y1 c$ g- f1 \# b$ N5 h& u  s  [6 \+ o
  19.                 Sleep(5000);8 u- ?" f) i  T
  20.         }
    " f( `' ]( p: p
  21.         else
    4 `6 @. `3 `0 Q7 K) B1 l
  22.         {
    . A) \$ a3 d' x, D" a
  23.                 4 `, _$ u6 `  r+ }, P8 c' Z3 i
  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
    # g6 e$ t: B6 d& y# u5 a
  25.                 STARTUPINFO si;( X! Y+ V1 x$ t7 X* {' C9 h2 }" A

  26. ! j2 }; {: r, `9 G, ~
  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).aspx1 B' j! A1 O+ I. Q) V' C! {. c3 p5 Z4 @
  28.                 PROCESS_INFORMATION pi;
      q3 ]6 ?: _% N0 k2 I' L. g; Z& u/ I$ ~6 O

  29. . X" p7 i2 y# C- O+ B+ E
  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$ n( p& v2 A! Z
  31.                 DEBUG_EVENT dbge;  U! }' I* v: h6 v- L
  32. ; A7 z) S; ]% o) b
  33.                 //Commandline that will used at CreateProcess
    " B9 A7 d8 |! J
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    % X0 t4 n$ e6 M: V6 W
  35. / W' q  D* J8 ^: I+ f) I
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    7 L6 F9 z* Z% N* a+ G3 ?
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    6 w# j& }- k* T7 O: u
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    8 P% P5 E( `  R, M5 }
  39. - ]- m0 f) v5 D2 p9 s7 h
  40. & r1 G. y9 `5 E. w# Z& }4 J3 V; C3 W5 ~; u
  41. , W* _& E. C9 R
  42.                 //Start DekaronServer.exe
    3 p7 L! W' B1 e( L% U6 g" C
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx# k1 r% y# l1 H) A: N  b
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)3 L( `/ [% E/ c& ?
  45.                         szCmdline,        // Command line
    5 k, d+ S& M- {9 x" ~
  46.                         NULL,           // Process handle not inheritable0 X5 `8 w% ^1 h
  47.                         NULL,           // Thread handle not inheritable; v) @! C( z  D8 K" k" B
  48.                         FALSE,          // Set handle inheritance to FALSE; R0 s+ ]3 z8 @" d7 J$ @
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx2 W" F! ]' ]# @; x& a- D. o* w
  50.                         NULL,           // Use parent's environment block
    . q+ R3 [8 M) ~: I
  51.                         NULL,           // Use parent's starting directory / P  C: l% @% Q9 Z& ~
  52.                         &si,            // Pointer to STARTUPINFO structure
    ! f) T9 ^' N  K/ J, P
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure& r' X$ F8 w8 G" ~
  54.                 ) 1 Z" W3 @8 l& K% O6 L
  55.                 {% w, k5 B6 [  h% T4 `! z% z( [
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );0 I+ L1 W: o$ r0 K$ C: b
  57.                         return 0;
    3 N. K" o6 |* C, F
  58.                 }( q8 V) e( b# n: {* P2 ~
  59.                 //Creating Process was sucessful6 M$ M8 d9 Q- a
  60.                 else
    + E6 C/ I, H' X
  61.                 {
    3 C  e  _& {6 f* V' o
  62.                         printf("Sucessfully launched DekaronServer.exe\n");/ F$ w; C3 ^, A' J' [

  63. $ O/ ?& O: @/ Q* A
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; C; W1 V) J7 k( n* g
  65.                         dbge.dwProcessId = pi.dwProcessId;4 E; M* t2 t6 m8 t% q
  66.                         dbge.dwProcessId = pi.dwThreadId;8 J  [0 M% a: {2 d

  67. , L7 L. K0 N2 K& A" f
  68.                         while(true) //infinite loop ("Debugger"): ]6 J! D9 g% y; u/ {# Z
  69.                         {( v  P, Q: k# ]; F7 C
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    8 x* ?6 ?, V, Q7 P
  71. $ e: f; W) L1 e$ H, ]7 ~
  72.                                 /*! U. m0 D8 l2 H" e& |+ m
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
- |% I- |# o2 w+ X4 {9 n
7 A( v5 J8 z  b: g' h4 N

2 u0 T8 B; Q9 e4 T3 R: t& Y
商业服务端 登录器 网站 出售

15

主题

260

回帖

1292

积分

金牌会员

积分
1292
金钱
931
贡献
81
注册时间
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

回帖

1292

积分

金牌会员

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

3

主题

102

回帖

7937

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-2 20:51 , Processed in 0.034063 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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