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

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

[复制链接]

140

主题

247

回帖

4319

积分

管理员

积分
4319
金钱
1517
贡献
2415
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ) |* W: L' p. r; Q) U  G

9 }3 [2 P* G9 y, }$ v1 e虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
4 [4 P( x( J9 P3 d8 o  y
% J3 d0 ~2 F( P4 k
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。8 w- u0 }/ W. H' D0 T( C
  2. //
    , i' J/ v/ ]4 _. U

  3. . G9 ~. v2 [& i& A8 B6 _) B! h
  4. #include "stdafx.h"
    ! s8 l- Y" b0 f
  5. #include <iostream>  H4 Q% g! a5 ~& ?7 S+ [
  6. #include <Windows.h>2 N/ s* J0 f+ d9 |
  7. #include <io.h>: r1 r4 r7 G6 c" ^5 M' X

  8. + C4 g! d, ~/ g) g
  9. 5 U: _' p9 V, Q+ ^9 V7 U! H
  10. int _tmain(int argc, _TCHAR* argv[])( U7 K  e8 c1 S' J+ F
  11. {
    % ~( g3 R* g- V; c
  12.         printf("Dekaron-Server Launcher by Toasty\n");. A' t! W  ~1 z# r
  13. 4 B0 r  F! r5 m( k( t4 B
  14.         //查看文件“DekaronServer.exe”是否存在
    3 J- b  z' Y) Z5 N
  15.         if(_access("DekaronServer.exe", 0) == -1)! u, @1 g4 A& u
  16.         {0 g8 J. S, c; u9 z. h( R
  17.                 printf("DekaronServer.exe not found!\n");
    5 O" E% z- K. z
  18.                 printf("Program will close in 5seconds\n");
    : l8 V5 c# `( m9 o
  19.                 Sleep(5000);
    ) t4 S  e2 _; E
  20.         }, }5 D7 [( w: h
  21.         else. c0 B3 N0 l  q! y8 |6 @6 d
  22.         {
    9 B7 i. A2 _+ i4 q# n" `
  23.                 / l& x( s& c2 F) J' ^
  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( k6 I4 p  z* q9 j3 p; }2 y
  25.                 STARTUPINFO si;
    " ^& R8 @1 k4 J) S' g$ s* v
  26. 5 @7 P$ M0 v& O0 U7 C5 u2 \
  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) l. y# n; i" a! s) S9 A
  28.                 PROCESS_INFORMATION pi;
    + v; r' A5 y& d2 d% E
  29. 5 A7 L6 ^+ w2 F  v
  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).aspx7 ^* Q$ O) G& @; p
  31.                 DEBUG_EVENT dbge;7 @; P6 C$ l8 t* A! `% [% h

  32. 0 }2 z5 E& t, h7 L
  33.                 //Commandline that will used at CreateProcess0 G" U# B3 `5 I# z: S
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));) i/ A8 D, x7 f$ C; N

  35. % p9 C2 M* b% U0 A+ p4 B! \; z0 Q7 i
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)4 s" V0 |& n% m4 f; L4 a
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    4 C; m! |: V, P* y
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    2 l1 D* @/ Q: P$ E0 i7 z5 S' \
  39. & b1 o* U# l4 F3 P: p* A1 p
  40. * b& ^4 R; I" x* m. u+ M
  41. 3 W7 D/ |, i! B/ H2 e
  42.                 //Start DekaronServer.exe
    & ^" e, r, d- v* B0 L% g/ x6 X: n6 N
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx' q" b( w& \5 V
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ; s0 a& C% ^  u. l2 p7 I- P5 f
  45.                         szCmdline,        // Command line: G/ L( E, S0 B+ n% _
  46.                         NULL,           // Process handle not inheritable
    " O% D7 T2 v' o9 Z+ B+ [
  47.                         NULL,           // Thread handle not inheritable' j+ G5 r! T& y9 ?1 n6 G
  48.                         FALSE,          // Set handle inheritance to FALSE
    " D. w) y/ S" _( E; x0 N
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    0 E/ j$ o5 R7 P0 |" @& {% [+ f
  50.                         NULL,           // Use parent's environment block: L" f8 n& h! P4 P" i/ ]3 G+ c& \
  51.                         NULL,           // Use parent's starting directory
    ( e% z! S. w% U% v" m5 {! M  y6 i
  52.                         &si,            // Pointer to STARTUPINFO structure
    * ~  w8 D# W. _$ h
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure; [7 x3 x, m0 E* M/ s; O
  54.                 )
    1 a- m) j9 m% I( c
  55.                 {
      H  O3 g6 J) C" |8 p* Q
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    7 p: [# p. H! g( k
  57.                         return 0;
    7 K. c4 h- `6 w$ z# v; Q& [+ {" b+ X
  58.                 }
    & M. i. y( T1 O' k( ^; o
  59.                 //Creating Process was sucessful1 t* k, A  }, \1 N  N3 s4 R
  60.                 else
    - ?/ ]$ _; c1 |6 U/ [1 e4 D
  61.                 {  V, T0 r7 {* K/ F5 y
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    6 f' D; @8 W+ h

  63. 7 u; l3 _  s, k9 T+ G3 m" t' L1 }
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    . f; D1 c2 B' [
  65.                         dbge.dwProcessId = pi.dwProcessId;
    , U  Z7 B  M. h+ k
  66.                         dbge.dwProcessId = pi.dwThreadId;
    - o9 p) P" x& x6 V( v
  67. ; N' S. S9 F0 |# j& D/ w" }3 G
  68.                         while(true) //infinite loop ("Debugger")
    $ m+ B4 w) t* m: k. C4 \
  69.                         {
    3 `2 N( K  Y& D; 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) g1 N+ N4 K' D8 _3 A. ]
  71. 9 l: u2 Z% {. b( n  F" q
  72.                                 /*4 U: Z! }) d1 x7 ~
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
" `! y) Y8 b( Y* @( Q0 x& |
: E7 e: d$ y4 ]2 e; E

0 I7 G6 p( }8 j& o- p( o
商业服务端 登录器 网站 出售

9

主题

236

回帖

982

积分

高级会员

积分
982
金钱
601
贡献
131
注册时间
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

主题

204

回帖

340

积分

中级会员

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

9

主题

236

回帖

982

积分

高级会员

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

3

主题

95

回帖

2389

积分

金牌会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2025-6-27 13:30 , Processed in 0.061855 second(s), 25 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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