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

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

[复制链接]

156

主题

353

回帖

6350

积分

管理员

积分
6350
金钱
1891
贡献
3950
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) " t# Y) d2 g6 a! Z: A+ g) o
' ^  Q' T6 w6 U, C8 A% W
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。; }: J' t5 y5 m+ [1 u/ B& z
* m; o) ~5 }" r% N  M- b# M+ h
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    0 y+ W% l+ V% ]" }
  2. //1 }& `) _8 W) k7 _
  3. 7 n0 p3 k3 T3 a* h  n. q
  4. #include "stdafx.h"
    - p# F& V: K" W7 o% `9 X8 S4 j6 V5 _! J
  5. #include <iostream>* K6 |2 i, C" E9 B; ^* P( D
  6. #include <Windows.h>/ T0 _$ R& X7 t# H+ D
  7. #include <io.h>
    2 P/ k1 N2 I; Y. z1 X% t% X
  8. 0 [$ n  p0 h9 L& m2 @, [
  9. , Q- N5 a+ O8 ?; D5 A2 H
  10. int _tmain(int argc, _TCHAR* argv[])4 ~' ^  q( C2 D, H. ^/ K5 r. u
  11. {* z- S6 q3 W& e! s2 q# x
  12.         printf("Dekaron-Server Launcher by Toasty\n");1 r9 s9 M( w. i) c7 k4 a# y
  13. " q6 \3 b/ k6 s8 z1 r
  14.         //查看文件“DekaronServer.exe”是否存在
    2 t& d- h  F  V# n) u$ T
  15.         if(_access("DekaronServer.exe", 0) == -1)8 a6 s7 k1 i8 K7 W. V$ U, ?  g& m
  16.         {1 b+ B" {, r9 \$ C8 _
  17.                 printf("DekaronServer.exe not found!\n");
    3 H. |( |' r8 X. ]# f- T  W  Z
  18.                 printf("Program will close in 5seconds\n");
    + `& X1 r4 L* G# X' S  J5 M) f; C/ {
  19.                 Sleep(5000);
    ' }9 \% u1 j# k
  20.         }
    ( V2 c, a) |1 J( Y; y' P" J/ N4 Q* N
  21.         else8 m2 O/ @8 @3 C4 o% L
  22.         {# {5 @5 n$ a) ~  K0 S- T% X+ B7 w
  23.                
    ; m  U* [* O7 _
  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 b! L  D# F2 E; i
  25.                 STARTUPINFO si;) t; \- {/ r  R. t/ y# f! i

  26. + c1 L$ [2 G/ C$ l/ c8 Q8 k9 r
  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% N  ?9 a' q8 u* R+ c
  28.                 PROCESS_INFORMATION pi;
    - w# a' `. ^1 ~" q% `# Y

  29. - W, D6 ?0 x6 R( o
  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).aspx0 A: t' u+ {' y
  31.                 DEBUG_EVENT dbge;. E) U( w9 T8 D

  32. . [, Z$ }4 c# n7 W
  33.                 //Commandline that will used at CreateProcess! ?; s$ m7 p; [- h& D$ `
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( z$ {! F4 p0 C0 F$ P

  35. ) u# C8 Q3 `8 ~! l: R/ E8 {
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)3 J& T" F; q, O0 Q1 }
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    7 A/ V% w2 e3 C2 J4 z
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    5 K6 L6 N. n/ A

  39. 0 D+ p9 \" S9 M
  40. / A- r) N- [7 E) g+ m
  41. ' R0 d1 F& C5 r  B( R/ |+ N
  42.                 //Start DekaronServer.exe
    0 g5 q' [1 s8 x" H! i
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    % k) J& r; g; }  k
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)  y1 \% a4 d9 {- B; p0 e2 l
  45.                         szCmdline,        // Command line
    . n4 e9 X" ]4 f
  46.                         NULL,           // Process handle not inheritable$ d2 ?' `- B! c- @
  47.                         NULL,           // Thread handle not inheritable( J2 |* o* k3 f" R1 D3 }
  48.                         FALSE,          // Set handle inheritance to FALSE. X3 c! @0 R+ y* A7 p
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx. |' \; n: y+ y& j3 {
  50.                         NULL,           // Use parent's environment block/ A4 r" N+ M8 d8 l' }% P
  51.                         NULL,           // Use parent's starting directory - p+ Q2 J* z: c
  52.                         &si,            // Pointer to STARTUPINFO structure
    1 ~: o# O+ L2 d
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure  a2 ^5 U+ v4 p
  54.                 ) , h; v" `" ?. G0 U1 f8 _1 U6 \8 O
  55.                 {
    7 w# p2 k$ H& @
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    $ R9 t3 t7 V' G  c& v  o
  57.                         return 0;2 C# f6 o+ m9 z
  58.                 }
    9 l9 J2 V% Y8 r7 T6 j
  59.                 //Creating Process was sucessful2 B1 z: v$ z& S( Z$ {
  60.                 else
    ; h9 i, Z5 R# N  X+ b5 k
  61.                 {. d3 |+ I3 g% Y7 r; w0 K& U
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    , P0 |1 _5 x, j
  63. & `5 ?, e6 P- ?. q, M
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    4 r( ]: Y% [8 _0 s* S5 B9 L7 Y8 M* `
  65.                         dbge.dwProcessId = pi.dwProcessId;) \3 p8 G2 O: C$ b
  66.                         dbge.dwProcessId = pi.dwThreadId;: h' u  Y% E  B7 E& M6 Z7 i+ o) c9 y
  67. 3 @( C+ x* O( w1 o, k
  68.                         while(true) //infinite loop ("Debugger")/ k! Z% s; A* y, T; }
  69.                         {
    . i9 b/ A" C+ r; n
  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 K' L4 ?0 w2 M* r' H, J+ P, l

  71. # D+ \; J5 \* Z/ l; a. K" B3 M( B' Y
  72.                                 /*
    % J; ]8 O3 A$ @5 `# D. R% @5 |
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
/ J& P1 }; P9 I, h1 J

. |  ^9 q* _) y
8 E; p' l$ T' b- B' ~) \
商业服务端 登录器 网站 出售

15

主题

256

回帖

1231

积分

金牌会员

积分
1231
金钱
849
贡献
106
注册时间
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 | 显示全部楼层
学习学习赞赞赞

15

主题

256

回帖

1231

积分

金牌会员

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

3

主题

102

回帖

6029

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-20 02:31 , Processed in 0.078123 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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