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

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

[复制链接]

157

主题

367

回帖

7122

积分

管理员

积分
7122
金钱
2045
贡献
4553
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
3 j+ z" g0 j; \; I4 W; B) `. w8 e3 f+ c; j; @9 e
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
" y: f8 _* o: K& ]) A! z! y4 G0 t7 s4 w; {4 {( _! }2 w- e5 \% n
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。9 |. J7 y$ c# b) \8 N
  2. //
    4 u" O, E0 K% d* f( k

  3. ' L# D, q) W" a4 Q
  4. #include "stdafx.h"
    9 o+ L+ p; k/ p' G* v4 [$ L0 E
  5. #include <iostream>) y% B, Y( a( O# V. R0 V8 ?7 |, ]
  6. #include <Windows.h>
    6 P! P, L) l9 L
  7. #include <io.h>' x; I. n- `) F( W

  8. 4 h! Q; D. @! {5 F. Q

  9. 6 A. P, }$ i: ^! b5 o3 D
  10. int _tmain(int argc, _TCHAR* argv[])
    8 O" |! q) j  l8 \) O* b% O& q0 Z: [
  11. {6 b8 Y( C/ h+ Y: \
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ; v% w6 u4 E2 f8 ]' F+ ?

  13. 7 D: E4 o% _( g. U! b7 E) p( R9 [
  14.         //查看文件“DekaronServer.exe”是否存在
    * K% |* E" S6 s5 Q4 B& f' B$ P
  15.         if(_access("DekaronServer.exe", 0) == -1)
    5 V, |- ?& M) A( S( w
  16.         {
    6 x* |$ b6 t+ L4 v& D0 Z
  17.                 printf("DekaronServer.exe not found!\n");6 A0 V/ C' c2 C: [
  18.                 printf("Program will close in 5seconds\n");
    9 I* D0 A& d, I
  19.                 Sleep(5000);; x0 r9 z# @6 C8 T4 t' _5 p3 k. l
  20.         }
    7 q/ p! q3 y8 N% g
  21.         else
    $ T: a! P  R" T, h) b0 @1 @
  22.         {: O: G( W6 K6 _6 ^
  23.                
    0 v+ c. C" J6 `% o3 u
  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: f1 ?8 h& n. }, _4 k2 v
  25.                 STARTUPINFO si;* g; K2 ~* e. F8 ^
  26. , c- W+ }5 {: a* E% ~
  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
    7 [8 C  Z  f& H$ H
  28.                 PROCESS_INFORMATION pi;
    ( v( s( ~* D+ j  j4 W. r6 X
  29. : A# b5 G% Z. J) w2 m( d; b/ x. e
  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
    ; S( i: x) S  K2 x" }
  31.                 DEBUG_EVENT dbge;* X4 i" B, O1 D2 y  W

  32.   P1 S3 ]- r& N1 h: [" D
  33.                 //Commandline that will used at CreateProcess9 \9 q) s& E. X7 T
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));; ]# H6 ^7 V% g7 Y1 C" s
  35. / L7 g1 o0 O3 B- m
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
      q0 w: p! n/ s$ Y, Z( M/ n
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)) N5 `' {5 F+ h( \
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)( j  q; p- l' v# l% F: b9 Q# a

  39. * U. V: Y$ a6 @

  40. : X. r0 }+ t) E" s' d& Q

  41. * b$ \  l# X. U0 R
  42.                 //Start DekaronServer.exe 9 J; y5 x6 g" u1 h5 l
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx, \3 @9 O$ H8 j4 t" q
  44.                 if( !CreateProcess( NULL,   // No module name (use command line); T$ {( {) H+ _5 f! p6 y9 b5 F
  45.                         szCmdline,        // Command line
    , b) a) M, ?' Y
  46.                         NULL,           // Process handle not inheritable' e+ U3 Q) T6 H; V7 a+ i
  47.                         NULL,           // Thread handle not inheritable
    ; `0 x2 {) N# ]$ A2 G
  48.                         FALSE,          // Set handle inheritance to FALSE
    % _4 k! |; X& L- v2 t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    8 b! E1 s: A1 h; I
  50.                         NULL,           // Use parent's environment block" v; u) ?6 F3 D6 E4 h$ @4 F7 b0 l
  51.                         NULL,           // Use parent's starting directory ' u6 s3 v" D& g5 d% a
  52.                         &si,            // Pointer to STARTUPINFO structure' s  ]" b# Q4 T* `$ `
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    2 @% j$ t5 A, u
  54.                 ) : Y* @: r7 _& L" j* u5 z) {& v
  55.                 {( }& u" u& V% f
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    2 p0 ~+ y' ^/ `; L' \
  57.                         return 0;3 l% j% Z+ a- @, u+ p& x- Q
  58.                 }2 X" E+ J: j$ a8 H8 Q- }0 V
  59.                 //Creating Process was sucessful1 N9 R  Z, j& L
  60.                 else8 L+ W4 l, _+ E' C' `3 k! o" ^
  61.                 {  n/ l: |4 e" t
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    $ V0 n3 b  B" B* S: D5 L/ k, [

  63. % s! D/ ]) x# K. J9 i
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure: V; q& j/ b$ S, F4 ~
  65.                         dbge.dwProcessId = pi.dwProcessId;, {: O2 M- a# Y# S: W$ D
  66.                         dbge.dwProcessId = pi.dwThreadId;
    & I5 n( h- M( G, b7 S1 S+ y! }+ l

  67. * n, S4 N) f0 x' h) E
  68.                         while(true) //infinite loop ("Debugger")/ b+ I( n7 u7 C9 v: U
  69.                         {
      T& n; E$ i6 z* I" t
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx" `  W. r+ e  x8 p
  71. 9 u/ J0 W4 T% L  n" n1 O* m
  72.                                 /*
    3 E( @) ^/ `; {+ P% |
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
) l' c: {% h. h) C& v; y  W

+ v9 T" o- e1 ]' r. b- E8 |% N; |: X8 ~; V$ @
商业服务端 登录器 网站 出售

15

主题

258

回帖

1245

积分

金牌会员

积分
1245
金钱
903
贡献
64
注册时间
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

主题

258

回帖

1245

积分

金牌会员

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

3

主题

102

回帖

7357

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-3 14:40 , Processed in 0.049700 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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