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

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

[复制链接]

156

主题

354

回帖

6531

积分

管理员

积分
6531
金钱
1908
贡献
4113
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 8 ?4 S; i% {% I* X: v" z+ y) z7 }

6 g9 T/ {! ]3 j5 C4 {0 m3 }虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
1 k# w) ^# t: M6 \0 s2 x) A' M$ f; V8 A2 b
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。( t" p, I' n, |: Y2 p: L9 I
  2. //
    8 F9 T0 q4 N8 M- W. P; A
  3. % @: z5 B( [3 M/ O4 y
  4. #include "stdafx.h"5 q/ z" F; L: e3 l6 K# E, l* P
  5. #include <iostream>
      c1 ]% O) f$ o* `. p, j' _
  6. #include <Windows.h>4 o/ ^! j( V# I+ \; \, w4 i
  7. #include <io.h>
    ) [1 V9 |( e7 n9 Z% Q
  8. / S  p. L5 K' Y: g
  9. $ j: l5 A6 q! z# c8 K/ d7 o2 G7 ^; ?
  10. int _tmain(int argc, _TCHAR* argv[])
    # S) p! l. r) b9 g$ E; j
  11. {
    # d1 k7 y' b- Q+ C- o
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    9 N7 |8 j8 f& }
  13. 9 ^+ R* Q: |, y9 C1 _
  14.         //查看文件“DekaronServer.exe”是否存在+ s" m3 H4 o$ W, V+ [4 t
  15.         if(_access("DekaronServer.exe", 0) == -1)) x- O+ P8 a) W5 {
  16.         {8 G0 ?. z* |1 W
  17.                 printf("DekaronServer.exe not found!\n");
    8 _- p5 c# N' d4 D6 U
  18.                 printf("Program will close in 5seconds\n");
    " l9 y" R" s2 v$ m
  19.                 Sleep(5000);
      c5 U  ^- k, c; \' C
  20.         }8 p' G; n' |  ?0 \( H+ v% A7 e$ X
  21.         else
    : f+ d; c9 b* I* q! E
  22.         {- q8 k, i2 `* p( B3 W3 @. E+ n
  23.                
    ! N9 _! m, p- c% H/ l
  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
    - o- O7 J" w, ]: P9 \( J
  25.                 STARTUPINFO si;
    * F+ h2 Q0 I7 u* U1 d; y  U" C& a

  26. $ g+ m  M, H& D! M
  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
    6 s% Y8 W/ |$ C( N: v
  28.                 PROCESS_INFORMATION pi;
    4 n5 U  E& S' {% Z7 i$ I; E8 ~

  29. 3 @1 t6 r! K* 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
    - _0 n1 Z# V" X1 p2 p
  31.                 DEBUG_EVENT dbge;
    ! s% n# X$ P6 e

  32. ' ?! G( [) V' R! }0 z. q+ c
  33.                 //Commandline that will used at CreateProcess4 x& K* d( {6 T# J  n/ G2 v
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));+ t; ?2 a% Y4 f! K% X3 Y

  35. 8 B5 r0 V1 r, G) J- x! v3 ]
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)# q' B- I( \, j5 U
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    # e6 p- f& s% t5 x
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    9 S3 o, r, o6 I/ M9 I8 l1 Q$ t# P

  39. - q6 \4 c% z  l6 d6 F

  40. 2 T; F( _( M) j; Y2 _" D( p3 w( U

  41. + W0 g/ O3 Y  c/ p
  42.                 //Start DekaronServer.exe
    0 f2 C0 E% `! c
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    6 N2 s( J/ s. ?* ?3 J% o! @
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    # Y4 P5 A3 v0 Z
  45.                         szCmdline,        // Command line: s  N, [  X$ M# z7 Y  ~+ |. P
  46.                         NULL,           // Process handle not inheritable
    ; o' a: h! ~& [; B# r* T
  47.                         NULL,           // Thread handle not inheritable
    0 \% x0 c8 i, C4 B
  48.                         FALSE,          // Set handle inheritance to FALSE
    ) s# }- |# h1 q% S- n
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx7 w. W3 A! S  m7 T& A# t
  50.                         NULL,           // Use parent's environment block- x$ \- P7 a% `2 v: j2 c3 Z% n
  51.                         NULL,           // Use parent's starting directory 1 d& k7 c% b1 v1 C) S7 ?
  52.                         &si,            // Pointer to STARTUPINFO structure8 l( b+ x# x7 _. \' k" P, a- A
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure( i8 Q6 N& U6 R& U0 y7 a, z4 M
  54.                 ) 6 V' S4 R9 B* }. x% B
  55.                 {) V/ \' x2 C# I3 ^
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );) t6 q- o* k4 }
  57.                         return 0;
    / {- b2 Y" v& o' F, V
  58.                 }$ l8 [: c) J+ m8 w  N& P+ M
  59.                 //Creating Process was sucessful: B6 J# F: y% P2 g9 R5 z" I
  60.                 else
    ) Y- z* Y: x% X1 |4 s2 t
  61.                 {# j1 B1 o9 |  K2 \) ^  B; w
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    4 N: O( C" ]+ T
  63. 6 p7 M% U3 t. S+ X1 ?( n9 d
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    7 C  P& `* y/ A
  65.                         dbge.dwProcessId = pi.dwProcessId;. E- m$ M' o& `
  66.                         dbge.dwProcessId = pi.dwThreadId;
    4 G+ O. V# {' W* X0 S1 C5 i
  67. 1 L, ^1 R9 o$ V' ^; M
  68.                         while(true) //infinite loop ("Debugger")% n  O# l3 B2 M/ A* u1 H) b
  69.                         {
    9 |" Y9 A3 ~# Y$ N1 u+ D: o' g
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx; ?1 W0 k2 ]+ T8 m7 y1 b6 a

  71. 7 c0 h7 U3 L8 P! P/ j# Y
  72.                                 /*
    9 i7 m3 K! K& B1 o& t/ I
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

& `/ I0 z! N  V( T& Z6 Z' U' ~, c! D8 h" S8 L+ b3 _0 m

% f1 E8 b$ E- s2 ~
商业服务端 登录器 网站 出售

15

主题

256

回帖

1241

积分

金牌会员

积分
1241
金钱
853
贡献
112
注册时间
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

主题

256

回帖

1241

积分

金牌会员

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

3

主题

102

回帖

6121

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-25 17:02 , Processed in 0.072462 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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