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

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

[复制链接]

157

主题

364

回帖

6946

积分

管理员

积分
6946
金钱
1980
贡献
4445
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) $ C) Y5 o0 C4 }1 G

2 a. o) e2 }7 h5 A$ R0 s; }虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
8 S" o# m. L0 d, e" i
( ^* S) x' K" f& ?! K( ?& m
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。3 B9 z; ?8 k7 H2 K- K; z: P
  2. //1 K- T, b0 M& f: C

  3. - |8 [5 P( k, h$ e
  4. #include "stdafx.h"8 `8 ~" n9 G8 B, P2 K
  5. #include <iostream>
    ( W# B3 R0 N6 l, i; I+ d7 j, u3 E  U
  6. #include <Windows.h>* @( a* B1 S( q/ ~6 l% N4 S
  7. #include <io.h>. t6 k$ N* v0 H( W* i, u. H6 ^
  8. 9 h. G5 y9 l( W+ t: d  u- H8 ]
  9. - w- w) @7 H1 j6 K; m
  10. int _tmain(int argc, _TCHAR* argv[])/ b  V% L* \! K, z3 T9 k
  11. {$ g5 U. U; `1 f/ ~
  12.         printf("Dekaron-Server Launcher by Toasty\n");8 F; ~/ w3 k* m9 ]! C4 i% t

  13. : C5 j# O* g, }. i; j; v; L$ \
  14.         //查看文件“DekaronServer.exe”是否存在
    , |% J2 W# g& q5 x* |; {
  15.         if(_access("DekaronServer.exe", 0) == -1)  U) f) N1 P5 R8 c& ?. c/ }
  16.         {
    8 _: E' B! H! t! n7 k/ i$ f
  17.                 printf("DekaronServer.exe not found!\n");! I' i4 P  I  w" N0 g2 J. P2 d- t
  18.                 printf("Program will close in 5seconds\n");* c( X) U) B  _
  19.                 Sleep(5000);" d3 y$ N- A1 p* Z: f7 I* q' [
  20.         }
    ( q& u- Z- b5 V% W6 {5 [
  21.         else( m+ I' g/ o3 t$ k6 O8 v( f8 t: }
  22.         {
    5 [. m8 p; ]* h
  23.                
    ( D) T+ m9 [' h. ~) ^
  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
    + o3 T0 Z8 T: ?  i" s
  25.                 STARTUPINFO si;2 _* R2 H2 B7 B

  26. % ], J( a# _+ x/ O2 g
  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).aspx1 e$ B7 v+ m4 [3 J0 y
  28.                 PROCESS_INFORMATION pi;
    % B" [& u  V3 ^; p7 O/ `. T0 A0 b

  29.   J- V2 n% L6 L: m' J2 a) P
  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
    / _& [4 j4 p/ H
  31.                 DEBUG_EVENT dbge;
    3 u# V6 F2 T- `& x
  32. 8 j5 A8 m/ T$ U. c8 @; ~; B
  33.                 //Commandline that will used at CreateProcess- J3 i! w0 G3 ?; I
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));. n* t! H/ z* @3 T( m& j- m' X- _

  35. 1 E6 S) ?, W6 e2 b9 _- T$ |, |
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made); L. a4 T  T3 t$ {" A2 y4 J
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn): i  T0 T. @. B' g. F0 H( Y
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)$ U  Y# T- S2 S  G  L3 i: Q
  39. ; Y. ?0 O& x" u7 G2 g" r- y1 m

  40. / h, r0 m; V7 q+ v" W
  41. ! P7 A3 w) M5 q7 p8 F" Z9 u
  42.                 //Start DekaronServer.exe
    2 ^5 ]$ B6 C5 i: T! B& Z
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    + A* X5 x! G1 |# N0 N6 f
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)2 d  W; M3 p" `
  45.                         szCmdline,        // Command line$ k) h6 G  V& n/ _( d
  46.                         NULL,           // Process handle not inheritable
    * F. R8 N# I: U8 ]4 o# A+ v, |) d
  47.                         NULL,           // Thread handle not inheritable' S( q& ~" f# y0 `+ \  Y$ N
  48.                         FALSE,          // Set handle inheritance to FALSE+ E% X8 t. [5 x# L+ [5 [
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx' Z/ r) V/ w/ o+ X9 K
  50.                         NULL,           // Use parent's environment block1 E4 W$ ]* ]/ c  C+ r8 ~, y1 M
  51.                         NULL,           // Use parent's starting directory ( M8 m- Z, X% n% e5 x6 |2 j; d' a4 V& z
  52.                         &si,            // Pointer to STARTUPINFO structure
    / d8 K# |6 k5 M
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    2 G: D8 g# T/ [$ B9 q  q! v
  54.                 )
    8 ^8 _# o$ ^& j# I
  55.                 {6 X) L4 e. M2 ^8 i+ r$ K
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );9 ?4 i4 W( l$ F% `! C. i
  57.                         return 0;0 W8 @5 L# W$ @1 f' T- ~- n+ P7 p8 s
  58.                 }5 r, A! r1 b) n, o
  59.                 //Creating Process was sucessful. z: C* L1 C% i/ Y. N
  60.                 else5 C  `# e# K9 S0 S1 |# S/ L, D
  61.                 {
    ) T/ g: I7 m3 Y/ s: p
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ; S1 ~/ Z+ H- o* k! w1 B# K
  63. ' d8 U8 s; ~8 S: E
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    , ~  {2 a/ I* H- G3 j  d- B
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ; U: c  y/ O* w
  66.                         dbge.dwProcessId = pi.dwThreadId;# @1 p( J# P; T7 E: k$ u

  67. ( ?7 R' m8 U3 H$ f! A) Y+ T7 {
  68.                         while(true) //infinite loop ("Debugger")
    3 A0 y9 T( G9 a3 e: b' F
  69.                         {
    / k4 L7 a% T- f1 z8 ^
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    $ ]: P$ |' |5 ?% G

  71. , e2 R0 Z% z+ B" I
  72.                                 /*# b  L. o: _. Q  d
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

, R3 r# W8 P! x' i& ?/ h9 ?: p. J1 S% v' k1 O9 y3 Q
' n/ s4 G( f+ _* y1 O
商业服务端 登录器 网站 出售

15

主题

257

回帖

1226

积分

金牌会员

积分
1226
金钱
886
贡献
63
注册时间
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

主题

207

回帖

352

积分

中级会员

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

15

主题

257

回帖

1226

积分

金牌会员

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

3

主题

102

回帖

6838

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-8 08:30 , Processed in 0.053343 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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