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

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

[复制链接]

106

主题

128

回帖

1472

积分

管理员

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

6 Z6 r. |; ?4 ?$ S3 ]! c# b' l
' Z& x. U+ b9 S6 E' M. f' B6 S% @虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。! c% r2 \8 L4 f  R+ J$ V

. u" i5 Q& s* I
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。5 n) Z4 c' ~& d6 a" W
  2. //
    ' B+ E; h8 t# m; {* B
  3. + I# X2 O" ?; b* B0 B% O, I) c
  4. #include "stdafx.h"  W# u9 o2 D# F6 c* s
  5. #include <iostream>
    - A/ H2 i+ X2 W/ ?$ u: l) K! z- C
  6. #include <Windows.h>
    9 W& f' C7 N5 I4 ]7 T/ [' V
  7. #include <io.h>1 i. R6 O& V* e# C' b

  8. ; U( p4 `! M. h! X# |8 [; ]3 x+ X
  9. 9 D1 Q0 ~' ^3 l4 K/ }
  10. int _tmain(int argc, _TCHAR* argv[])' s5 V) T: c# @/ w
  11. {- a1 @' d" T3 q: v5 p
  12.         printf("Dekaron-Server Launcher by Toasty\n");4 p. r  |9 p  q0 [5 E$ Y( H$ Z8 g

  13. / W1 o7 R' r7 J) l3 A
  14.         //查看文件“DekaronServer.exe”是否存在
    $ Z. J0 l2 z8 b. \2 y  W
  15.         if(_access("DekaronServer.exe", 0) == -1)3 y  A7 T: W' R. m2 R( S. F; \
  16.         {4 Z5 }+ y' o1 q/ l* F3 f5 O; Y
  17.                 printf("DekaronServer.exe not found!\n");
    2 Z% J. K& K9 ?! D
  18.                 printf("Program will close in 5seconds\n");
    % S0 K! o1 U, ?
  19.                 Sleep(5000);, H! x- d5 q* C1 R! Y* |& H
  20.         }
    / A% U/ h: @0 z& q
  21.         else
    1 A3 x+ w6 j/ w$ T- G1 @  P8 d
  22.         {
    0 K( c: e- r" `+ ?+ v: L
  23.                
    & ?1 Y3 \$ Q% r5 h9 }
  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
    / J1 t+ `& S8 F- `
  25.                 STARTUPINFO si;4 A% D7 T; o  F6 B
  26. , D; w2 y2 l7 Y' k! C& [
  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
    7 n* O4 T3 R! B/ K$ J9 S
  28.                 PROCESS_INFORMATION pi;
    6 N2 A5 D- f: ^% b7 D0 K( t/ F) [

  29. ) F% Z. [2 d, v' d+ k& @' A% g# Q, ?6 `
  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
    8 W5 j5 a! ~( w6 e6 u5 Z
  31.                 DEBUG_EVENT dbge;, c; t8 c6 }( i9 l' V: E
  32. , s3 z) t- I  |, |1 H; _8 c
  33.                 //Commandline that will used at CreateProcess: G+ O& r, e4 o0 k- u! n+ y
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    - G, v; Y" c  `  `% s
  35.   m" ?4 w6 V7 _+ T* c0 @
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ) s  @1 L3 q8 \; W% I3 E0 H2 I. e
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    - U+ \( P* P( a/ i
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)# \: {- D0 z' U5 K. f

  39. # u7 x6 V1 [" p! @  l: v# B

  40. ; s$ Y# G# T* q0 b: W$ ~
  41. ' b0 z' @8 Y6 w5 Q& L- s1 K# k
  42.                 //Start DekaronServer.exe ) l# |) H' W* l- c! p
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx) ~3 Q' l% V' [
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)4 S# t! r* V% x( Z; N: t+ G
  45.                         szCmdline,        // Command line% [- l" k7 l& r( G1 K
  46.                         NULL,           // Process handle not inheritable
    ) ?& U; G" M/ c) @* H# N
  47.                         NULL,           // Thread handle not inheritable
    : }9 ?8 G* U  S4 [3 B7 f4 U/ @
  48.                         FALSE,          // Set handle inheritance to FALSE
    ! q2 f8 {3 b8 n5 o8 ?
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ; i/ U1 U7 v7 m' |: D
  50.                         NULL,           // Use parent's environment block7 \: B9 T, h; I) G; H
  51.                         NULL,           // Use parent's starting directory
    + L) Q5 {% J# D* d( c
  52.                         &si,            // Pointer to STARTUPINFO structure" n( ^% V) c* [' n
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    6 R4 B6 w- h4 B* }
  54.                 )   J- z& _0 q% E9 c
  55.                 {
      |: L* n0 C/ e. J+ u2 P
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    3 T. j. K1 Q. A& c7 J/ C  d
  57.                         return 0;: Z' o; e8 I- F+ e2 Q( F
  58.                 }0 K) h" ~2 D7 C4 L1 Y
  59.                 //Creating Process was sucessful' ^8 }6 ?- n3 G/ T; ?/ e" C
  60.                 else. m, w+ c3 W3 c6 s  a0 [
  61.                 {
    ! K% g4 V& e5 }0 u& _( a8 O4 i
  62.                         printf("Sucessfully launched DekaronServer.exe\n");  \, Z/ q$ R/ Q# H! i

  63. ; z: F7 P, T" Z
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    " g5 m  E1 Q, d2 A% u; N
  65.                         dbge.dwProcessId = pi.dwProcessId;# J* e, q, |% C$ p7 k
  66.                         dbge.dwProcessId = pi.dwThreadId;6 J$ x& t( q, X0 s+ b& l9 s4 g

  67. . c4 w8 [& t$ _% s& @5 `
  68.                         while(true) //infinite loop ("Debugger")8 `5 F/ L2 G4 U# N/ r; o
  69.                         {
    5 X" X! P# P% ]$ z. {% N% K/ K# z
  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 S% s) v; P" p& t" y

  71. 7 A+ g: u, |: Z4 r' ^
  72.                                 /*
    , Y9 e0 |" S5 n/ ]* L0 r
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
5 P0 W' X* ^0 k

  }% |* ]7 r2 Q5 |3 n/ E
9 _8 c( Y' Q2 g+ H

本帖子中包含更多资源

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

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

8

主题

188

回帖

454

积分

中级会员

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

21

主题

375

回帖

767

积分

高级会员

积分
767
金钱
282
贡献
89
注册时间
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 13:34 , Processed in 0.084644 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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