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

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

[复制链接]

157

主题

364

回帖

6927

积分

管理员

积分
6927
金钱
1964
贡献
4442
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 2 H) @% [" g( Y  m( K! V

7 w0 W3 S, ?. J4 t% b- d  {6 x1 W: l6 n虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
) r. K. A7 w- t& `' V- F5 r3 X
: [  `  o+ O) M5 z
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。% o- [5 `6 G0 z# W/ e
  2. //, W1 c1 z' l1 r3 E& v
  3. ) z; w2 F; v- Z
  4. #include "stdafx.h"; J2 B% D/ q2 U/ w. w; T& f
  5. #include <iostream>
    * u( M, c( L' v7 K' a# ]$ i! z
  6. #include <Windows.h>6 x1 T% }* c$ ?! D
  7. #include <io.h>
    : |+ w+ r% C' d
  8. ' ?  }3 T# T9 P$ C
  9. 5 z# y2 P& F& \( y) ]0 h1 n
  10. int _tmain(int argc, _TCHAR* argv[])
    9 v/ B" z7 G+ e. I6 J  I  h
  11. {* `; e) _* X' g  Y% P
  12.         printf("Dekaron-Server Launcher by Toasty\n");0 e3 Y: D" w/ l  ^$ |$ D- V, h: F

  13. 5 b7 P; {5 u( \* {( G% l
  14.         //查看文件“DekaronServer.exe”是否存在
    5 `3 z/ p/ C4 ]( J
  15.         if(_access("DekaronServer.exe", 0) == -1)0 D4 h& ], Z9 s$ [% B; k( H
  16.         {, N/ z+ J8 d5 A* Q. U4 ^& e
  17.                 printf("DekaronServer.exe not found!\n");
    6 d* P7 P/ n6 s( L3 {
  18.                 printf("Program will close in 5seconds\n");9 C4 a9 F' ?) y
  19.                 Sleep(5000);4 `6 R0 T2 N: }
  20.         }
    7 E4 @: h( x! ]$ X, ^- E, H  U! Z
  21.         else/ U% V) n/ O4 D2 D
  22.         {
    $ ~, v- b9 j+ {: f& v
  23.                 . F, E3 r9 s! w. {, B
  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  q+ Q/ F; P3 g/ p& q( w7 k
  25.                 STARTUPINFO si;; l. W& p0 k* W" w' r  {

  26. 4 L+ {- ]* ?& a3 ~
  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
    . ^' O8 x5 S, {% F/ t6 _' p3 [) R
  28.                 PROCESS_INFORMATION pi;
    # C8 J1 H' N2 Y* h% q$ r. p

  29. 5 H3 s( ^3 e, S* _7 f5 U2 ?9 Y$ A! @! F: q& D
  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. j0 u0 l2 H# }% X
  31.                 DEBUG_EVENT dbge;9 `1 S8 w% V( z0 N8 V

  32. 5 }9 Q& y" O/ r. o/ h
  33.                 //Commandline that will used at CreateProcess% y( d. _0 s5 R
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));! b) d! F3 q( n% f% x1 b

  35.   U( V5 V/ P, ~
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)6 B: `: w! d, R* m
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    9 N2 A! b1 C* f# u" O  l
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)- k2 s& B; k7 D( [$ X3 @
  39. ' V  B( Q6 h4 ~7 n# W" O4 f
  40. , B0 n) S; m3 @0 V( T) \7 l" Q

  41. # k- @( d$ n; R3 U6 F
  42.                 //Start DekaronServer.exe
    3 ~, }6 c) w3 C. l" i! G: O3 a
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx9 [9 I) M7 z  q+ o6 N& _
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    / U1 v/ v4 p2 e
  45.                         szCmdline,        // Command line
    9 ~3 _; N+ a6 u3 f, @
  46.                         NULL,           // Process handle not inheritable
      h0 |" ]: @) d6 U4 p1 S6 ^
  47.                         NULL,           // Thread handle not inheritable
    ! L. O) o/ x8 C( j+ l2 G" T& t9 V; o" t; L
  48.                         FALSE,          // Set handle inheritance to FALSE
    2 [8 L  P) A1 c6 t& b
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ! `3 U4 A& L; m8 Y3 k2 p6 P( U" H
  50.                         NULL,           // Use parent's environment block
    - ^4 N$ v6 M6 c& n7 ^
  51.                         NULL,           // Use parent's starting directory ! C+ Z$ {+ s. x
  52.                         &si,            // Pointer to STARTUPINFO structure5 Z: d8 S7 ]3 q) p. W$ i4 m
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    4 E# I) k( ~/ h9 Z7 e
  54.                 )
    " k: d4 n+ h' x; W% D
  55.                 {$ r+ [2 r3 R8 |3 F
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );) U( p& Z- i+ \$ A% c
  57.                         return 0;
    - A9 H, s( F2 P& ]6 Y2 }( B: c
  58.                 }; K+ ?& f- w, q6 U" _( y9 s6 w
  59.                 //Creating Process was sucessful
    + u% A5 \  e1 P  I! }0 v
  60.                 else
    , m$ D! C- _& R% C: R- j- b: f5 b8 [
  61.                 {% d9 {! x2 n3 h4 ]6 `
  62.                         printf("Sucessfully launched DekaronServer.exe\n");! F6 S# A3 v2 ?3 `( j- Y  }! z
  63. , C3 Z1 T, x0 v1 D0 [
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure$ I: j( T& s$ H+ {1 B8 L
  65.                         dbge.dwProcessId = pi.dwProcessId;3 `' K4 c' U$ [9 ^; m' v' [
  66.                         dbge.dwProcessId = pi.dwThreadId;/ l* K' F6 @2 p0 ]. \  }9 ?

  67.   o/ Y" w9 m! ?" g/ ~& S
  68.                         while(true) //infinite loop ("Debugger")
    1 L! x) o1 n% y. `( _
  69.                         {
      H% j- |* C9 E  d: \
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx4 z6 ^( @7 g. Y2 ]( X/ z3 P  ^
  71. ) q5 y( L4 t% D( T
  72.                                 /*
    ' B& l! O3 a1 t3 o; w0 `! P
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. K2 w' }% g) _- c4 v" S
! {0 O; B) Q* i) Y; T$ b. b6 U. O6 b' V

* ~' n7 z$ Z! o0 r, t
商业服务端 登录器 网站 出售

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

回帖

6699

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-26 18:18 , Processed in 0.062972 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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