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

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

[复制链接]

161

主题

385

回帖

7436

积分

管理员

积分
7436
金钱
2141
贡献
4749
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
! Z) j  }" ^7 {( E" ~
, \, J7 v- h. p3 v/ |虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
! |4 b/ M" f" ^! a
$ M' C& _7 j% g: Q: l; i
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    ( _  s4 s$ d1 L4 s& J
  2. //3 ^: ?9 `( d: {4 c1 J4 h
  3. . `5 M  q2 F/ S5 o1 `( \
  4. #include "stdafx.h"
    $ j/ g. b5 T) N* X
  5. #include <iostream>
    0 K0 s6 _; b1 {3 L+ O* Q0 t) J
  6. #include <Windows.h>
      R; W1 f- }" f. J1 A/ \! j
  7. #include <io.h>: d/ y* N0 H) Z9 @* H3 e

  8. & {) I: r5 z0 b' e% a9 R" _9 O
  9. , u) a' U* h) B  R9 p4 c4 K
  10. int _tmain(int argc, _TCHAR* argv[])
    0 V( V7 I( C9 E6 {/ f3 Y6 D
  11. {) {) F. h3 L% t
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    8 V; s2 A9 B5 x5 k9 g  F

  13. & F3 K* Q  P8 [/ v/ P
  14.         //查看文件“DekaronServer.exe”是否存在
    . F& c5 Z& N) O) ?2 A9 q* ?
  15.         if(_access("DekaronServer.exe", 0) == -1), U/ Q) g* g* A- X* H5 p
  16.         {
    $ G" X) i$ o5 Q' u3 d8 J: d
  17.                 printf("DekaronServer.exe not found!\n");
    ( m/ Z4 _' c" ]7 h3 l0 z4 H
  18.                 printf("Program will close in 5seconds\n");" V# H0 D# D1 g, m& D
  19.                 Sleep(5000);- c- Q5 [' W: {/ u$ k7 d6 j2 O* P
  20.         }; P9 C+ F' Z5 a$ p$ E  W) P9 c9 ]
  21.         else' s: n' X$ n6 p2 r4 f
  22.         {8 ~' P4 Q$ T8 j) v& \+ ]
  23.                 8 r1 S! F$ P: r  N/ p  S5 t5 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).aspx2 l) K6 r" ~4 e
  25.                 STARTUPINFO si;7 J' z& c  C5 k

  26. + d' f+ n7 [6 a2 W; 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+ s  `" L7 L# F5 @* l& F- Z( N
  28.                 PROCESS_INFORMATION pi;
    0 V! o/ B" y0 w  h4 G. n

  29. % Y2 E" N' E$ h; b& n
  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
    ! o+ q* L! V9 o* Z! o( E# l
  31.                 DEBUG_EVENT dbge;6 z' K/ a3 o  |3 O

  32. 6 |# ], i5 K6 P
  33.                 //Commandline that will used at CreateProcess
    1 c: Z( s9 V  f; ^
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    / b( y2 Q6 P* }: c; G* O

  35. ! p& t( Z% J& P. ^2 Y: `0 Z( n) l
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)+ b% d2 Y0 p- L  ~2 r# s
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    . R% g" q5 k. }3 q
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)" x5 v4 B3 Y1 |" f
  39. 3 Y1 p9 o8 i- _$ H: a# I; R

  40. 9 Q. k5 g8 Q! r# L  \; T) H( D
  41. 6 V4 H4 R- t. O2 [: @# X
  42.                 //Start DekaronServer.exe
    9 w9 u3 [+ \% z+ u0 P% L) ]
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    + a. |" F0 X0 c9 ?, T/ f* F
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)5 [5 }; r; `9 |; ]! w
  45.                         szCmdline,        // Command line: l+ P  J# {- ^* y; ~
  46.                         NULL,           // Process handle not inheritable" R, ]! m. G* [3 K- c' J  F, T/ f
  47.                         NULL,           // Thread handle not inheritable; L3 L+ s4 E2 l. r2 J$ e; e
  48.                         FALSE,          // Set handle inheritance to FALSE
    6 y0 |( y2 K! i! q! F9 f" y) @( A; N
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx5 s+ @. F) s; Z
  50.                         NULL,           // Use parent's environment block
    , d: u: m% m3 [! J
  51.                         NULL,           // Use parent's starting directory ' R: _4 C2 @# H; v1 P8 B& x3 ^
  52.                         &si,            // Pointer to STARTUPINFO structure+ I, b0 E! k7 I# `+ {2 k  v" G3 ?6 p
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    0 y7 N) J* @$ j0 r
  54.                 ) ' A0 E( `+ ?' D( i
  55.                 {
    ! ~- l8 {  U5 S$ Q  G
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    $ j- j, p( j$ {4 F8 Y+ B
  57.                         return 0;6 W8 _! E% Z4 i+ }
  58.                 }& X5 v! U" a; ~" b
  59.                 //Creating Process was sucessful
    3 j  e4 E/ }: n/ n0 O& B5 Y  e7 w
  60.                 else
    * T/ r8 L' D/ t4 P* o) [
  61.                 {) a$ j/ B" i4 O6 m% h* B
  62.                         printf("Sucessfully launched DekaronServer.exe\n");  G) R1 I8 [* a4 i
  63. 5 \' _4 p' K% O9 ^
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure/ O% e# _; Z. S& S( h
  65.                         dbge.dwProcessId = pi.dwProcessId;
    6 l$ W; T2 c5 d. s  D6 I6 t6 @
  66.                         dbge.dwProcessId = pi.dwThreadId;2 o9 W# p' _3 Q1 ^1 I* b. j

  67. 1 C9 [. e! v; J8 |9 R
  68.                         while(true) //infinite loop ("Debugger"), Z1 @6 f: l9 q
  69.                         {0 Z3 [$ J% ^- s' l
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
      [4 l5 T& K/ h1 ?: [
  71. 2 N# K- ]2 V% r* W1 |% C% O' A
  72.                                 /*7 b5 k2 C; o: T2 b$ R8 I# f# k
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
$ v4 A: a; ]/ g! ]

& E* U# v2 `' V  V/ T) w
% m3 r2 u& }6 Q5 ]1 Y
商业服务端 登录器 网站 出售

15

主题

260

回帖

1298

积分

金牌会员

积分
1298
金钱
935
贡献
83
注册时间
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

回帖

1298

积分

金牌会员

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

3

主题

102

回帖

8017

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-6 06:17 , Processed in 0.038057 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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