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

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

[复制链接]

164

主题

407

回帖

7723

积分

管理员

积分
7723
金钱
2247
贡献
4905
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
/ B3 j4 _6 V. f: F  U" z$ [* I) b5 Y0 j) G$ O
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。0 d% F7 b2 c& X& |# v6 t3 E6 b

6 z% o$ I% H. C) Q( F
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。6 [" u1 ?) q6 c0 y, }
  2. //
    6 z/ ]7 c; H1 n* j! |: }9 g$ F3 o4 H$ m
  3. ; u1 p) L6 D! g: T* t
  4. #include "stdafx.h". `# T7 }" @) z* e9 P. \; q9 o* w
  5. #include <iostream>1 V4 f3 h- |6 X0 M6 F2 V1 |0 }4 ]: ?
  6. #include <Windows.h>+ w1 B  V: J) g$ R& f% S) D" \
  7. #include <io.h>" f7 r1 D) Y9 j
  8. 6 k" }$ [* N6 r1 [! _" }' G
  9. : k5 X! [- K2 I! @, P
  10. int _tmain(int argc, _TCHAR* argv[])
    9 @. \+ N6 J3 B! }: U
  11. {
    5 h! ^( J+ }8 F5 W6 i' O0 U$ Q  `
  12.         printf("Dekaron-Server Launcher by Toasty\n");# e* Z; g4 e, u$ U
  13. : e$ x3 M, i2 l. y* ^
  14.         //查看文件“DekaronServer.exe”是否存在6 X: P1 Z% {  P5 o1 u1 B
  15.         if(_access("DekaronServer.exe", 0) == -1)
    2 ^  u2 X: Z4 J! Q3 I& q# F# m
  16.         {
    " v) u0 ?2 g. o6 D& S; c" j
  17.                 printf("DekaronServer.exe not found!\n");
    # C. M  R% a8 m" \  R  [+ u
  18.                 printf("Program will close in 5seconds\n");1 c" E0 C! P* \4 g! }0 W7 t7 K& Y; E
  19.                 Sleep(5000);
    , Z: i7 H" q( j0 M2 F+ g
  20.         }0 c% p/ h5 D5 Y: q' V) F
  21.         else0 _9 [# e" ~* s. h
  22.         {
    - k5 R- p- b8 @5 \  m( q
  23.                 # n- z3 Z2 k9 M6 s" `% c
  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* t; ~% }4 z' z( I, F$ p
  25.                 STARTUPINFO si;
    # Z' C$ B4 K' n% ~/ z  R% `3 k

  26. 1 _. \0 |3 c1 C* z5 n/ L8 @
  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
    1 d, t+ V1 A! t' f/ q
  28.                 PROCESS_INFORMATION pi;% \# u- E$ F4 {& b' a% H

  29. 0 w7 R' L4 m- x) j0 o/ g
  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  l  h& B* Q9 N/ ~+ X0 N
  31.                 DEBUG_EVENT dbge;
    + @8 V2 ~! e2 @
  32. 0 a) u6 o+ l7 D# y5 T& F
  33.                 //Commandline that will used at CreateProcess) V1 }7 ~: c/ j  P7 _& T# Y
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    9 r" h& d0 [1 Y. i0 l5 h+ _

  35. , r$ @4 y+ A) V: a1 Q  L( ?
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    0 [5 f' U6 n! g! U$ X" |) q. l
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn), U; l1 r# S3 M+ Y6 v/ w
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)9 Z& B6 B/ r& Z4 U/ G: u/ D- M

  39. 5 k  S/ s2 S% V9 H# u9 z
  40. % f3 `' [- ~, b! b! E) E
  41. 0 g8 a( G- P! j  Q) M/ Y; [! z8 j
  42.                 //Start DekaronServer.exe - l1 E2 j1 }2 g+ O: ]2 S% n/ p
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    ! g, {  ^) A/ ]. g
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)& V8 B. B( o/ d0 U4 A- N" j% @1 W# f4 \
  45.                         szCmdline,        // Command line% s0 I7 s) A5 i; d1 B! n
  46.                         NULL,           // Process handle not inheritable
    " f. a" [! g1 Y) T) E* U
  47.                         NULL,           // Thread handle not inheritable: C" h6 F* B" U3 g8 R' _
  48.                         FALSE,          // Set handle inheritance to FALSE
    , l4 k2 u& O; m% A- b- c: f( o
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx- @2 Q( r  ?! |6 e+ R: C' i* S" n. p
  50.                         NULL,           // Use parent's environment block
    9 e7 F6 m5 Z! D0 c+ y
  51.                         NULL,           // Use parent's starting directory 6 {. b+ a! i* R2 F+ a
  52.                         &si,            // Pointer to STARTUPINFO structure
    ; g0 d- a6 E& g
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ) {- j, P8 Z* g! l
  54.                 ) ) e4 E4 u+ L( E; d  N
  55.                 {3 F6 Z7 C0 w* |9 g
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
      N; Z7 l) `& y' T
  57.                         return 0;
    ! L7 P& [- v. Q; J- @
  58.                 }/ p2 A! ~0 W+ g; ?! j+ W6 N
  59.                 //Creating Process was sucessful0 k! i  |" X5 K7 r! `) d7 R+ {7 R
  60.                 else
    + v3 k' O: C7 m! d$ z
  61.                 {- D; Y5 w, x1 B/ ?2 i. H' `+ \9 `
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
      t  v2 L5 _- L

  63. 3 \5 I6 X+ c! |% @7 ?1 ?7 s
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    & I1 K- K6 w* c1 p, F+ K# N
  65.                         dbge.dwProcessId = pi.dwProcessId;% E8 A, N2 U$ e7 \( N( }: G
  66.                         dbge.dwProcessId = pi.dwThreadId;
    & a% u, h) U* @& h. s( E  i
  67. * e+ d" H* h0 [2 W4 k, ~
  68.                         while(true) //infinite loop ("Debugger")9 b4 A( R' r& h! ]) K0 m6 }
  69.                         {
    , a2 k, ~8 ]" V$ ^' ^
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx6 z& D. B* P8 M8 z- P0 k1 b

  71. $ A8 m. m7 A, K, N, w! d
  72.                                 /*
    * v/ I. s* r. Z; e7 a
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
' O; ?  ^* X1 ~3 z/ t

( j9 N, f+ P3 W4 X
# J( {* P2 [6 W* b
商业服务端 登录器 网站 出售

15

主题

260

回帖

1347

积分

金牌会员

积分
1347
金钱
979
贡献
88
注册时间
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

回帖

355

积分

中级会员

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

15

主题

260

回帖

1347

积分

金牌会员

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

3

主题

102

回帖

8957

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-6-23 06:31 , Processed in 0.074968 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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