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

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

[复制链接]

154

主题

340

回帖

5829

积分

管理员

积分
5829
金钱
1830
贡献
3505
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
. M( e- k0 z( r# r) {" t. x3 T' d& ~0 a3 X/ R! m; h
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。! }. m# C/ s2 H" t, D* v! ~

/ ~8 Z. O; i, H& O4 R; \1 R3 T
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    7 y( O0 a4 V9 D  A: W& x0 S
  2. //
    ) h( o; }3 `, C

  3. . P6 @9 n4 c3 U" N8 M
  4. #include "stdafx.h"
    ' G  v3 ?. X/ k, A* k. {  w& e
  5. #include <iostream>
    % y1 E* ?: }4 z* u- I
  6. #include <Windows.h>- \& s( ~  F1 q0 g
  7. #include <io.h>0 D; h9 ^1 l* A
  8. ! P! A/ g) l' z9 W% ?8 h: h( y1 \
  9. . @- H" e; _& u' v& m
  10. int _tmain(int argc, _TCHAR* argv[])
    . t6 _& P+ q( ~
  11. {
    % ?6 K1 W6 H- C9 X4 C
  12.         printf("Dekaron-Server Launcher by Toasty\n");! u0 t+ g' G# l3 E- ]

  13. 5 Z0 X  u: z, N! h
  14.         //查看文件“DekaronServer.exe”是否存在
    . f  D: E. e! {0 E
  15.         if(_access("DekaronServer.exe", 0) == -1), w  q% O8 P) I: a  h# J
  16.         {
    8 C0 ^0 @9 }& |; W0 L
  17.                 printf("DekaronServer.exe not found!\n");
    ) J/ h3 j2 V- \0 m" W3 G* P7 j. _
  18.                 printf("Program will close in 5seconds\n");; V8 d5 d* o. \' r
  19.                 Sleep(5000);8 K4 E; z8 [9 L+ y- G! I
  20.         }( M& u+ r- {7 ?/ t
  21.         else0 A. P3 h( m; @: d" s
  22.         {8 s+ J1 C9 s  u+ V6 G  E
  23.                
    # q* ]* p1 y  X/ D
  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
    4 I, N$ g- i# K  A1 O
  25.                 STARTUPINFO si;- ^3 ?: i1 t5 [+ l

  26. . o) e! |4 R) \2 \9 @
  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).aspx2 X9 o% ^7 Y9 O* K* K
  28.                 PROCESS_INFORMATION pi;, H4 _" N$ h7 W7 e2 x$ @' y

  29. ! P. r/ C2 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
    ( p0 p8 X1 N% L
  31.                 DEBUG_EVENT dbge;# @4 E# R" O4 w: a# _
  32. & P# L( h1 M/ n$ w
  33.                 //Commandline that will used at CreateProcess
    8 M' U1 K' R1 l0 [, T
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));8 u9 W( y  t7 V) Z
  35. + R1 O9 }! E7 f1 s
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)8 Z! q; a2 @: k' Q* I
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn), @' b: D1 Q' X
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    ' d8 l3 |2 o( k9 S5 ^- A% u
  39. 1 P7 Q7 H) e+ Z
  40. & {4 V$ ]0 k6 h/ r5 r# p8 d" V$ k

  41. 6 w$ d- x( P* V( W0 C- t
  42.                 //Start DekaronServer.exe . F& e' J0 x3 H) f% s/ ]- \: _
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    * t6 ~" f$ ]$ I* Y
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    . [" H2 X2 V: a; @& U) q
  45.                         szCmdline,        // Command line
    - F5 X: D7 R0 C% Y) p# l
  46.                         NULL,           // Process handle not inheritable
      E% v, a! B% k# c  R/ C
  47.                         NULL,           // Thread handle not inheritable6 Q+ x+ X" D* p) E' ?7 t4 F
  48.                         FALSE,          // Set handle inheritance to FALSE
    4 N: H* s+ K0 O5 e
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx! |9 q1 b- Q* p6 R6 T& a. V
  50.                         NULL,           // Use parent's environment block
    * U$ B2 K& _4 `* N6 i# b% b: {
  51.                         NULL,           // Use parent's starting directory & j( c* m: [* W) H9 f$ A
  52.                         &si,            // Pointer to STARTUPINFO structure3 f! K5 R; _) ^2 r' u
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure# d9 M( L6 t! y3 B! M
  54.                 )
    6 Z7 w5 s; K$ A2 E. a6 K0 v; I) c
  55.                 {  ]9 p3 n5 H4 c5 o& S4 U% l
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );6 K, |+ h! T# T0 I! q0 [. a6 O
  57.                         return 0;
    " a% a6 h  E$ d2 U  D
  58.                 }/ E# g% `# Q3 n
  59.                 //Creating Process was sucessful
    ( b$ \# `5 o6 G' R+ w3 l% i! U0 m
  60.                 else
    - r% d/ G( m+ u6 c6 s
  61.                 {
    6 |: W1 j6 z8 M2 W3 l5 _/ N
  62.                         printf("Sucessfully launched DekaronServer.exe\n");: X5 O. d% p( N' J
  63. 7 k, e' ^1 d4 M3 n
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    / `: V4 p! W, y9 K# w* q
  65.                         dbge.dwProcessId = pi.dwProcessId;1 f) Z( U) `4 h9 K" h0 B7 I2 m
  66.                         dbge.dwProcessId = pi.dwThreadId;
    % V, W- m- X. n6 b) C$ l8 e
  67. + _6 a, Y: @& V# w8 I3 R, o. Q
  68.                         while(true) //infinite loop ("Debugger")
    2 M9 w, i/ W* x! m" p3 }
  69.                         {
    - d( z" h1 o4 F. G2 t' R4 A5 V6 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
    " `4 L- V( O( a" D9 y9 U
  71. 0 x9 M1 Q$ p) L8 q8 N- b! a
  72.                                 /*
    0 d/ ~6 Q" p$ I" i" t( O% M4 U
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

1 K! _$ F8 w$ q5 Y+ v! V
' I7 |: [5 ^3 J$ A  ]7 s# W+ _0 ]9 q7 d9 r+ Q/ F6 R" [2 r! `
商业服务端 登录器 网站 出售

13

主题

251

回帖

1249

积分

金牌会员

积分
1249
金钱
796
贡献
184
注册时间
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

主题

205

回帖

345

积分

中级会员

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

13

主题

251

回帖

1249

积分

金牌会员

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

3

主题

99

回帖

5353

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-9 10:52 , Processed in 0.073633 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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