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

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

[复制链接]

106

主题

128

回帖

1455

积分

管理员

积分
1455
金钱
629
贡献
592
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式

7 }/ A9 ~; D. M: W4 r8 Y# ~- y8 A3 ^" u# G$ W" O
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。- y; \' Z  L4 r8 h) \

( w& F0 e: s& o, |) l8 D, j% [6 l
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    7 N5 r1 N9 Q: p  M( y
  2. //
    5 S7 `. b/ G. i8 ^

  3.   v2 V+ e/ S9 i' v6 S& S
  4. #include "stdafx.h"& |7 {0 `& o8 v" ?4 e, w+ K
  5. #include <iostream>- @1 Z6 D% ~' O+ l0 v& F5 u" h6 d
  6. #include <Windows.h>
    # ?- a6 F3 @( S6 }
  7. #include <io.h>9 d* K* I* d0 b- M" n
  8. ' a: |* J) S" l* N2 q

  9. ) w, L. o! R& Q7 n5 H
  10. int _tmain(int argc, _TCHAR* argv[])$ Q9 Q& p  u: G' r7 f& d
  11. {- i& w5 z# }: x
  12.         printf("Dekaron-Server Launcher by Toasty\n");; ?7 r+ ~* X8 {# O' U: d( o
  13. 8 b! n# v. G8 F/ o; e
  14.         //查看文件“DekaronServer.exe”是否存在6 D: x9 O: `% }4 I; _
  15.         if(_access("DekaronServer.exe", 0) == -1)
    . @0 s& b3 j7 |& W
  16.         {  W" w3 _" [7 Z; h; y9 t, e+ h
  17.                 printf("DekaronServer.exe not found!\n");) ?' X  N1 O9 |6 k
  18.                 printf("Program will close in 5seconds\n");" V' S+ x6 v, n# d* `7 {& L$ p
  19.                 Sleep(5000);
    ( ]# L* p* r( [6 i8 `8 e7 _
  20.         }8 j2 n& N/ Q$ P5 I; J/ R9 G0 R
  21.         else' `$ j4 }- f  t. d
  22.         {
    , X" e# \9 S1 v4 I) u- n
  23.                
    7 {* C, \& @) @; X# Z& \
  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
    " V# [' U5 U3 `/ w! P# j
  25.                 STARTUPINFO si;0 g1 J( R5 R* t) D/ o

  26. 4 G. z8 _2 J5 b2 e3 {7 A
  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& @2 U. e- |: R  s1 W5 w
  28.                 PROCESS_INFORMATION pi;8 C4 u2 c/ N& g. e" U' I

  29. # V6 L4 ~- i5 X; u2 C- ]# z  h: Y
  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
    " V: A2 V# {9 O, d) P
  31.                 DEBUG_EVENT dbge;
    ; a  M7 n4 Y  n( q
  32. 3 [$ W! M% i+ S6 V4 h# `
  33.                 //Commandline that will used at CreateProcess
    0 \4 F! z. C, @& u) b# B
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));4 @: Q0 t  `2 b
  35. 6 Y( x) p. P9 P1 l# Z
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    + k: \& v0 t9 q2 O0 T1 p) \# }
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn); m% ^$ F& J# H* O# J
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    4 E* X. Q( F) W; C

  39. - }5 Q" K  `! V" u

  40. 7 q! {5 B1 i$ C+ H0 k/ `: K
  41. " ^3 L" w# ^: Y: l7 g7 x4 S
  42.                 //Start DekaronServer.exe
    5 V/ g( |4 Y6 ?' Z  ?" b5 `
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx! @3 G/ R# U& l
  44.                 if( !CreateProcess( NULL,   // No module name (use command line). A! [4 k6 |( ~. P6 {
  45.                         szCmdline,        // Command line1 n$ t. h& Y6 d5 P$ j! A
  46.                         NULL,           // Process handle not inheritable
      I! R) l0 c: ^6 M# f
  47.                         NULL,           // Thread handle not inheritable3 s7 X7 D, w7 }. _" o
  48.                         FALSE,          // Set handle inheritance to FALSE5 v5 R- f% N- B$ {- Q
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx& ?1 P' d4 b8 j+ l. O6 m+ A
  50.                         NULL,           // Use parent's environment block
    1 G- p/ k3 ?5 I( r; Y
  51.                         NULL,           // Use parent's starting directory
    3 e# V" L( N) T; t! e
  52.                         &si,            // Pointer to STARTUPINFO structure
    + {* T% K" z: m& l" G8 F* J
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    9 j, R+ f4 K$ U4 K' k
  54.                 )
    6 w4 i" T% R5 I% |  y% v$ }: N
  55.                 {, O0 b- l" g1 V9 u9 C
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    ; u- o; C9 s* [, P% n  S
  57.                         return 0;; m) [+ ], d: L" z- [
  58.                 }
    6 N: R2 ^' R7 r+ X
  59.                 //Creating Process was sucessful0 V/ B  V% B7 c7 w
  60.                 else
    ) p9 F# B' z# c+ V- C' z! I
  61.                 {% B8 M. V  s% M
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    9 l( t5 p- z; l# W) x

  63. : ?( R! z% `0 |6 j' H
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure5 t! U  t' y1 M8 _2 v6 H6 X
  65.                         dbge.dwProcessId = pi.dwProcessId;
    - Q: P' T4 ]) ~/ _5 W) A1 e# t
  66.                         dbge.dwProcessId = pi.dwThreadId;
    $ i2 E6 l7 d9 U% }! Q& P/ s
  67. 5 ~  E5 Z2 s; r7 G$ u
  68.                         while(true) //infinite loop ("Debugger")
    0 [6 ?9 D$ e! \
  69.                         {
    7 v# m& g' _. A
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ; K6 X! q8 M" b1 T8 w3 l

  71. , b, a% n" M' A5 x3 g' l
  72.                                 /*
    ' c2 `3 [2 b' \' ~8 x
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
$ P: Z  k# _' s' M8 m

0 E1 [. p0 S! W8 Z9 A* F  b) |+ \& R  x, g

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
商业服务端 登录器 网站 出售

8

主题

188

回帖

454

积分

中级会员

积分
454
金钱
247
贡献
6
注册时间
2023-11-10
发表于 2023-12-18 20:34:07 | 显示全部楼层
我是来学习的!

21

主题

375

回帖

752

积分

高级会员

积分
752
金钱
272
贡献
84
注册时间
2024-1-20
发表于 2024-1-21 13:37:44 | 显示全部楼层
感谢楼主分享,我是来学习的

0

主题

42

回帖

105

积分

注册会员

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

8

主题

188

回帖

454

积分

中级会员

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

2

主题

51

回帖

156

积分

注册会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-7 09:53 , Processed in 0.177329 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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