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

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

[复制链接]

154

主题

343

回帖

5849

积分

管理员

积分
5849
金钱
1837
贡献
3515
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
+ V5 g5 q1 K4 I- M: d
5 s0 z4 h7 c7 [. \; B$ |  }2 [虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
/ Q& D; q. [1 Y7 m9 ?2 N0 \3 h- T
/ v$ R2 N8 U* j. U, D3 @
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。( v! H# ]8 D4 z5 p/ `4 d
  2. //! m. r. g; \, ?5 g3 n
  3. 1 W( D( Q0 {" ?3 K: N/ t
  4. #include "stdafx.h"
    5 Y) P: Z7 M7 A2 m/ @- d) Q
  5. #include <iostream>
    " ~$ R* T3 A& `" X
  6. #include <Windows.h>
    1 x1 |7 {/ o( ]- b* h- w" b4 r  v
  7. #include <io.h>& Q& k; K: k! `. s

  8.   ?0 Q$ ~% A+ u# G4 N

  9. 7 K' x# f2 }( Y* J
  10. int _tmain(int argc, _TCHAR* argv[])
    ) J$ k+ j. f6 i  X
  11. {- Y8 S+ ?: {, w
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    , W) P3 D+ `/ Y) Y
  13. 1 b  B1 u2 o$ c: Q
  14.         //查看文件“DekaronServer.exe”是否存在
    ' m# @+ O; m0 }
  15.         if(_access("DekaronServer.exe", 0) == -1)
    / y' L" }3 F$ U) m5 s) C
  16.         {
    ) e- @1 q, [, @: [3 S
  17.                 printf("DekaronServer.exe not found!\n");1 P* I( e2 |% u7 G
  18.                 printf("Program will close in 5seconds\n");" U6 C6 ?' l# d- c; ]' N- M5 V
  19.                 Sleep(5000);, u3 g1 \$ K: T' f1 M4 j% _8 W6 p
  20.         }
    ; J9 F+ A  H  I% ]
  21.         else$ q5 j$ y' l  |) u9 t0 q
  22.         {1 {$ A8 V3 z- a0 y/ P
  23.                 / |& d6 w, ^- U; z* L& K. N7 n
  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; ]2 {1 ^; `  g: @! l, a$ H
  25.                 STARTUPINFO si;2 Q: m0 x' w+ e

  26. ' `1 G% x) u3 O$ V
  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
    - U. Z+ T! w" n" F1 c) q  ^
  28.                 PROCESS_INFORMATION pi;( a8 p4 a( l$ b0 D# w

  29. 4 }) k: d1 ^9 a, o( s
  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).aspx4 X( k. n4 M0 `. }
  31.                 DEBUG_EVENT dbge;
    $ C4 R" F0 ^' e# K0 @: C/ ]0 F# f

  32.   T2 _7 Y1 K0 O+ b( \
  33.                 //Commandline that will used at CreateProcess4 D, k' |: l4 ~+ v( f3 G" n8 ]
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    1 g1 F, R6 I; m# y4 \0 h5 \

  35. ( h  v1 _0 M1 l4 R) R
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ' z2 H  u% w. T+ S2 W( E6 g
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)8 i" z! V& `2 s: ?' w
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    # A& E( M1 r: _- d  {* ?' ^
  39. % T) H5 R  ^3 Z% P$ P% o5 K

  40. 5 O7 B6 @: r' l; w' T+ F
  41. / H# |' P# b1 Z0 T9 l. i: |$ l
  42.                 //Start DekaronServer.exe
    ( h, C( h+ T4 h: ?$ g" ~
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx! g# O8 `& [5 J; {
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)& ?& J! @8 W( X' h2 r' q
  45.                         szCmdline,        // Command line( f2 f& V$ z  X! q; Z5 X: m0 h
  46.                         NULL,           // Process handle not inheritable& g1 G( j3 b. [# L9 q6 S' h+ B
  47.                         NULL,           // Thread handle not inheritable5 _: d# w9 A. R
  48.                         FALSE,          // Set handle inheritance to FALSE" Q% ~& b- @2 k' Z
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    / P) a5 b) @+ B4 }
  50.                         NULL,           // Use parent's environment block
    ! i( G; c+ Q6 \. C
  51.                         NULL,           // Use parent's starting directory
    $ X' Z$ C5 p( |: t+ U* I
  52.                         &si,            // Pointer to STARTUPINFO structure
    1 v0 P9 M* ?. F. I& \  u: I
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ; Y: B/ s; _* R1 n( Q' h5 C
  54.                 ) / J% P+ w# j. U, l  M% A1 `9 b* B/ x
  55.                 {6 W% M2 Q5 G! v
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    5 q5 h8 L) m, H7 ~7 k6 R
  57.                         return 0;
    $ j& E. e6 T6 H2 ]1 ^0 M! q
  58.                 }
    & r" Q. k4 p, d% K. n* u
  59.                 //Creating Process was sucessful0 B, A* l. }/ q! ]+ `9 m  S/ }  J
  60.                 else
    9 n; F: I) t. M$ |
  61.                 {
    , V0 N# _5 g5 p9 W- a
  62.                         printf("Sucessfully launched DekaronServer.exe\n");% D* V8 J9 M  p& @) `
  63. 8 D9 o, P, v7 A. L% p; e6 ]
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    3 t  j: l+ L  y( ?* e/ j% Z$ o
  65.                         dbge.dwProcessId = pi.dwProcessId;7 f. _1 I% s: U% r8 q
  66.                         dbge.dwProcessId = pi.dwThreadId;# \5 g' [) F% g, w
  67. : ~* h5 j7 O  v0 Q# F
  68.                         while(true) //infinite loop ("Debugger")1 A8 P% v! j1 X
  69.                         {* a$ c4 k2 x' p# V
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx; R" u4 p# J  q6 Z

  71. ) h. B' h! J+ g- i8 q3 N$ q5 ^$ ]
  72.                                 /*
    4 w6 a3 W8 p) o1 i( n4 V
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
# P0 \+ T" q4 s2 I) q" S8 G! R) Y

/ m/ ]0 Y9 `( Y
1 o# c3 s* h; O% @% V* ^+ @* g6 }; T
商业服务端 登录器 网站 出售

13

主题

251

回帖

1252

积分

金牌会员

积分
1252
金钱
798
贡献
185
注册时间
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

回帖

1252

积分

金牌会员

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

3

主题

99

回帖

5393

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-11 07:22 , Processed in 0.064359 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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