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

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

[复制链接]

167

主题

431

回帖

8221

积分

管理员

积分
8221
金钱
2407
贡献
5216
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
/ w! c8 C' j; x1 w3 u; e/ X+ \" n9 I& ~* Q2 Y
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
5 I% f4 E! _" `! R7 t5 E8 N
  J5 j5 q# w5 F& z# o- w- {
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。6 C, M8 y: B* c
  2. //: N( t5 y, L; z
  3. 1 N; h4 E" q. n" S' J" K/ k7 i
  4. #include "stdafx.h"
    # ~- n, W; I/ J9 E6 j" w
  5. #include <iostream>+ P! H. l9 t, E1 ?7 ~
  6. #include <Windows.h>( D, b6 A$ J8 Z7 ~# S( \) x) a% \
  7. #include <io.h>
    : p7 T  E% _" W/ r% r2 ]1 \+ n
  8. % ?9 P* K  [  F1 H

  9.   |9 h* y" |9 ?, q& P* [
  10. int _tmain(int argc, _TCHAR* argv[])' A+ O. e, ^0 U" u
  11. {
    ! z8 c3 ?8 [. u1 A: a* Q- s: Q; @
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    , H! Y1 W4 E8 e/ h& c
  13. ' u) `/ E0 Q3 M7 c
  14.         //查看文件“DekaronServer.exe”是否存在
      o, S/ H" x  q' r: |
  15.         if(_access("DekaronServer.exe", 0) == -1)
    4 H/ r3 _  ]0 w) N1 k. o
  16.         {
    * |" p7 N- w6 y
  17.                 printf("DekaronServer.exe not found!\n");
    : i: J1 ~0 E# A- y
  18.                 printf("Program will close in 5seconds\n");
      _, p* _- e+ ]$ {, M9 e
  19.                 Sleep(5000);6 }/ ~1 _/ J1 z# x) Y( ?
  20.         }' I$ u3 U( t" e3 c
  21.         else. b" L" d8 V; ^- v# E- R. X; n
  22.         {
    * v: [! L* Z( v6 o$ [. H
  23.                 ! s) ^7 x8 z* C9 D9 s
  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
    " m+ V+ Y( E- V! o
  25.                 STARTUPINFO si;2 }* G! C5 s; @: T: ~4 l) |
  26. : l6 L7 X! H6 K& g, k' X4 p
  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
    ( v/ B9 b, I5 K5 K( a' a
  28.                 PROCESS_INFORMATION pi;% x6 v: H! N$ V8 r# @

  29.   x+ {7 t- G8 I
  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).aspx7 @% L& h" v7 G% E9 D- q- z
  31.                 DEBUG_EVENT dbge;
    2 h5 u3 ]  x. B" S
  32. . v" q. N( I- L, T% ?3 s' \# Q7 V. U
  33.                 //Commandline that will used at CreateProcess
    ) b& E' T8 E. w1 Y8 T' C3 s. i
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));9 u: R. S- k0 a& g* g" |3 [

  35. 6 ]) g3 X& G( }% D
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    9 h) q8 p- Y. F1 a* C; w
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    3 I/ @$ \0 t# V: j
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made); \/ V8 K7 v! E5 Q
  39. : |) t* o8 @3 m- \' O

  40. $ H" B7 l! |6 O8 ~. I5 z
  41. 7 i( R* A; U  q/ K8 k  P
  42.                 //Start DekaronServer.exe ; a- q5 K/ v" J6 ?0 Q4 R: g- Q
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx, }) c2 P  y; G/ t$ c
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)% \+ H; D. K: l2 k5 s/ [
  45.                         szCmdline,        // Command line
    ( m4 {# H* ~' L$ ^3 h- P
  46.                         NULL,           // Process handle not inheritable  B2 Q9 J1 J" i$ L
  47.                         NULL,           // Thread handle not inheritable
    * O! c/ i# M* ?# q8 P, |
  48.                         FALSE,          // Set handle inheritance to FALSE
    % B7 k/ g1 S$ S
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx  }& U5 h' \$ }/ u; z- b
  50.                         NULL,           // Use parent's environment block& a. p$ m$ D0 y
  51.                         NULL,           // Use parent's starting directory # B  O0 p$ E: c% }9 f7 P3 ~8 H3 Z
  52.                         &si,            // Pointer to STARTUPINFO structure# h* a  G* Z# l  p  K5 D/ C8 @5 V) d
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure9 ~0 H( `& C$ _, b
  54.                 )
      Q3 U8 m- S' h0 r. s& ~- h
  55.                 {
    7 Y# L- n9 e. Y1 {# E4 ]& ?
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    2 L; i! ]. @% C' ^2 R4 N$ P7 V, n
  57.                         return 0;% Q( N% h! Y+ c: @# a6 v# u
  58.                 }
    ; c  c* q2 i8 P) e" r
  59.                 //Creating Process was sucessful
    ) o: e6 ?% V: w2 U: L: ?; J' A
  60.                 else
    ; h& ?2 i) f0 Q4 E! \( }- V6 s
  61.                 {7 p- Z7 P! I/ L2 o5 H& N
  62.                         printf("Sucessfully launched DekaronServer.exe\n");8 k" m# A( B5 O% `

  63. 4 R$ Y% v2 T( }  f
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure# [1 i) Y! W! B1 Z
  65.                         dbge.dwProcessId = pi.dwProcessId;
    / ]* p7 S2 ]5 W$ J8 a$ j
  66.                         dbge.dwProcessId = pi.dwThreadId;  ^: y" |3 O" H* _4 c) E5 c
  67. : J/ Y* s; \& O* V& M" v
  68.                         while(true) //infinite loop ("Debugger")" A$ a7 W4 E2 [
  69.                         {
    1 K+ D% j7 G: K1 A. O
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx! X  y9 r  O2 G2 \
  71. , L7 H; v  ]4 B6 F  y
  72.                                 /*( [% n% T7 M0 E* Y$ ~( T9 T$ {
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

  j. U  s% n! r
' d% Y& K* ]9 [3 \: ^
2 F# e* j0 Z* i4 M8 [
商业服务端 登录器 网站 出售

16

主题

268

回帖

1534

积分

金牌会员

积分
1534
金钱
1117
贡献
128
注册时间
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

主题

212

回帖

370

积分

中级会员

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

16

主题

268

回帖

1534

积分

金牌会员

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

3

主题

103

回帖

9383

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-10-22 09:53 , Processed in 0.100342 second(s), 29 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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