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

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

[复制链接]

106

主题

128

回帖

1472

积分

管理员

积分
1472
金钱
633
贡献
605
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
& n" ?! i1 b$ A: H# g

) ?: S3 E1 f* T虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
& I# l! S4 u# k6 S, Q# K* ~; P4 x8 y2 j
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    ' H' D2 g( U' ?+ f
  2. //
    ; S( W  i* l# A& s- @

  3.   Q/ g1 j  J' f2 I$ s- g) {; l
  4. #include "stdafx.h": V( l1 f+ l4 F9 J( z& r" s
  5. #include <iostream>% U7 A1 s& D( @; y2 U, ~
  6. #include <Windows.h>2 F, J6 `3 S# `6 `5 f
  7. #include <io.h>
    . o4 \' W1 o0 b4 f9 R; t& q6 q
  8. 6 x6 `% X2 K% }& }. X( @
  9. " C4 @: h3 Y$ W' r+ c" s
  10. int _tmain(int argc, _TCHAR* argv[])# d# g9 ~' ^7 `9 y6 _/ f2 x4 B
  11. {9 j: }( n5 a& @
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    9 w4 o! M9 o6 `8 M+ X3 |$ p

  13. # Z% O- ~& D+ p5 s7 ?/ r
  14.         //查看文件“DekaronServer.exe”是否存在+ v% j2 {' V/ N. V3 E0 ^
  15.         if(_access("DekaronServer.exe", 0) == -1)+ [6 ?; y, l, h4 N9 V& s1 \
  16.         {
    2 C( X# C8 s3 m
  17.                 printf("DekaronServer.exe not found!\n");! _  P) @- P# w5 }" @( B6 V. i
  18.                 printf("Program will close in 5seconds\n");$ p( V6 y6 {# U7 _; g; `: ^% a
  19.                 Sleep(5000);
    9 q! C) J! @( L5 _5 \3 Y# K
  20.         }7 `2 p" v7 `) w4 e2 A( x
  21.         else
    4 I, t! R& g' o0 B2 ~6 E( `
  22.         {
    / y! H4 L3 S: W: k) o7 T
  23.                 ; ^( d$ U  }8 @
  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
    + s7 J( j2 C, R! |1 q- ~
  25.                 STARTUPINFO si;4 x& m: ?1 x! H! l$ I

  26. 5 \5 M. X" s' f. S+ j
  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  w# P% |2 t$ [) c8 p
  28.                 PROCESS_INFORMATION pi;
    % M6 h  l1 X+ U) k9 j9 ^

  29. & j; x7 n# k% D- \; W) ?
  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
    : g1 b* `; {6 m- X1 j( d
  31.                 DEBUG_EVENT dbge;% f) E7 F% {# }: A
  32. 6 ]+ F; O* S, F4 x  i1 ^
  33.                 //Commandline that will used at CreateProcess+ z# D" V! v! T: T7 \
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( K2 F8 L5 B0 g. g
  35. 4 |2 x2 o5 N& L! y5 q, ^
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)# n9 X) w# ?2 E. R( K7 N  j& Y
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)* X% A+ z* I( d) Q$ }! V; E/ [
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ; K9 @" `9 X- L3 U% i

  39. 3 b2 b! J- ?5 s. m4 y- z
  40. + d( O- D" ]8 _% a0 O5 q

  41. ; W* q6 }5 \! H* ?1 ?* |" w
  42.                 //Start DekaronServer.exe ( D+ [+ o9 D! E' L% _2 L* {" _
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    / f+ q. T6 y2 k" Q/ w: l
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    8 v0 I. R' W- T+ y& w' _; ~
  45.                         szCmdline,        // Command line+ T2 ~. L& w* H1 r/ V
  46.                         NULL,           // Process handle not inheritable! W+ l1 B  v0 q6 D
  47.                         NULL,           // Thread handle not inheritable
    7 g# ?% ~, I  Q  v. G4 ]9 j
  48.                         FALSE,          // Set handle inheritance to FALSE8 Z) G' j4 Q5 ~4 y& D8 E
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx, [2 w) z) \' `* o& U
  50.                         NULL,           // Use parent's environment block+ V3 w3 |7 h2 w0 e1 t! x% w
  51.                         NULL,           // Use parent's starting directory
    0 _0 c2 u5 u. h( H# h: g
  52.                         &si,            // Pointer to STARTUPINFO structure
    7 }6 O, @  T* p# i4 v* @4 q4 `' _
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure% |( E6 K6 i3 J3 `4 {, i" ?7 @
  54.                 )
    " u* b0 ?6 f. F- ?% [9 _
  55.                 {: j- x$ p) h! ~7 K
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );2 S6 p8 \/ }* ]) \7 A- t
  57.                         return 0;
    3 t1 `9 |1 I: p! ?
  58.                 }
    5 {3 f$ T$ d  ?. C. ]6 [5 a
  59.                 //Creating Process was sucessful/ }- Y9 T/ A+ w2 s& s& x6 ?* P
  60.                 else
    6 Y) V6 D+ F& O4 j7 l& U5 |3 u
  61.                 {
    / U, H& l0 W" j
  62.                         printf("Sucessfully launched DekaronServer.exe\n");# Q$ ~& S1 g- z* p) Y8 U) {/ ]
  63. 3 ?) i  y) P5 r: c/ |- n* Y
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; h3 @6 v+ P  }
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / k, b( z( [: p) b* f2 Y* i) ]1 f; D
  66.                         dbge.dwProcessId = pi.dwThreadId;
    7 P# W" f* I  F7 ]
  67.   Q5 `6 v. h" I2 ^0 H
  68.                         while(true) //infinite loop ("Debugger")
    " D! [) ?( C1 p7 p
  69.                         {, A. h5 _) l4 D8 G5 c  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
    . u" C! P5 G( E% j" }, _9 x
  71. * w6 b& `* M4 u4 Y6 r. J
  72.                                 /*
    , s. r" g( F" Q% \7 K, g# V0 L( A* P
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

; i- c8 x. @1 k0 ~
# |; ^; c8 F, p' ?# }# u" q
6 [4 |/ z8 \  q3 ~& d

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

764

积分

高级会员

积分
764
金钱
280
贡献
88
注册时间
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
发表于 2024-6-5 17:06:28 | 显示全部楼层
学些大神分享,受用了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-14 01:39 , Processed in 0.091814 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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