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

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

[复制链接]

136

主题

168

回帖

3153

积分

管理员

积分
3153
金钱
1030
贡献
1819
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 7 `3 m4 ]/ z9 |1 K5 I  U

; f+ \" T& u9 y% b) `  E+ V虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
2 m5 O  X  z) p& V
3 r4 V4 S6 \0 m- f1 _- ^
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
      F, n/ d. E( [: `; B- U! q; i
  2. //
    ' T1 @, ]* `3 Z- w6 g; x/ x
  3. 6 O) h7 H( p- v( |! U
  4. #include "stdafx.h"
    / a# w( X1 Y$ i, x$ I) P2 _" s6 ^
  5. #include <iostream>
    4 _' V+ t7 g. |
  6. #include <Windows.h>
    : K  p( G, o/ M. b1 N4 p
  7. #include <io.h>
    " s, V* _3 G. `, K7 k0 W1 N
  8. ) }1 k) B3 X/ p
  9. # d2 ~/ s* Z* U. y8 G
  10. int _tmain(int argc, _TCHAR* argv[])
    6 u7 G: j( l% N& b& M: T+ K( ^
  11. {
    " P8 b$ h: H/ ~5 ?& M4 x
  12.         printf("Dekaron-Server Launcher by Toasty\n");7 L( t2 j* T: l! o5 @0 |& F

  13. ! n# c9 E' G# _5 ?
  14.         //查看文件“DekaronServer.exe”是否存在# n5 m- h# r6 D
  15.         if(_access("DekaronServer.exe", 0) == -1)+ I% Y! E2 i) T" _
  16.         {8 j- O: v0 R- h5 a1 ^" J
  17.                 printf("DekaronServer.exe not found!\n");9 p4 d* ^! d+ o
  18.                 printf("Program will close in 5seconds\n");
    4 ?4 U6 t/ T# O) s  k
  19.                 Sleep(5000);$ D/ [' g0 b! f9 @1 P! V, H
  20.         }) }6 n2 H5 f5 H9 P! I5 z, j
  21.         else+ i4 ^4 Z- k0 z, q+ t% |) y
  22.         {
    6 ]8 n. c2 n1 Q( Y* J* ~4 P6 V
  23.                
    # i. D- `3 Q5 ^7 R: k
  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" |' ^% [9 X% L$ o' @! x
  25.                 STARTUPINFO si;( u* e# D/ u- q8 @  P7 s5 _
  26. - Y/ m/ G/ M& w: @$ 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' P" J  j5 Z, n( n' f1 t  L
  28.                 PROCESS_INFORMATION pi;" D9 b* U/ m% ^! i  h
  29. " h( U- d0 ^0 _, s6 H: R
  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( v; v- u9 R. u5 ~0 o" O' G& {8 O6 Z
  31.                 DEBUG_EVENT dbge;) t2 I4 c. _+ W* Z# D% U
  32. 8 p0 f$ q$ h! N
  33.                 //Commandline that will used at CreateProcess
    . B. }( }$ c/ X( a" ^
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    & j4 [2 N/ \, c1 \2 O: `

  35. 0 s1 |7 H% k6 y* f
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)2 P# Z8 [6 F# ]8 z: j% |7 q
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)8 O) M' q9 q7 G! ^3 n) o
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)1 t1 d- z2 Z% w7 L5 g$ r+ D
  39. , E3 L$ B2 F, L3 O, I
  40. 5 Y6 T" g" }8 Y/ R3 l* `6 A

  41. 6 }  ]  r' b* Y/ ^" `( N) H" c1 ^
  42.                 //Start DekaronServer.exe
    2 \+ z* {7 T1 {  j/ Q% b! Q  a
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    3 l2 h6 V1 \0 B6 {0 K/ X# ]2 m+ Y/ ^
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    % ~+ ?9 @) r& E$ X/ F2 P' g, P
  45.                         szCmdline,        // Command line
    5 E8 B( X5 H& E+ y- X8 k
  46.                         NULL,           // Process handle not inheritable
    4 V, n- w+ _* z0 U
  47.                         NULL,           // Thread handle not inheritable% }$ ~, C% e  J; S6 w
  48.                         FALSE,          // Set handle inheritance to FALSE6 N9 @. d) @# u+ ^8 [% y- n
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    % s3 a& ~  F& `# s; Y& d
  50.                         NULL,           // Use parent's environment block
    # p' e) Q. g9 L& l# i- q$ J0 g, C
  51.                         NULL,           // Use parent's starting directory ! O4 J& i0 |8 o: i- r
  52.                         &si,            // Pointer to STARTUPINFO structure7 s! _" f/ b# o; u- l
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure+ Y6 ], f8 f! A8 F; m
  54.                 ) * B9 W% I; W- V. z/ p0 k; y
  55.                 {
    % @9 E/ E* N: ^0 H% m0 r; P
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    % v( X; [1 H& r$ R; b
  57.                         return 0;' [- B% a; U7 Z& q) {  t
  58.                 }
    - }, V( ^( t$ n- [
  59.                 //Creating Process was sucessful
    ' i( G7 k9 o7 q2 v9 u3 r( @# q
  60.                 else
    " z# m* F" |$ f: J: e& g
  61.                 {0 ~# g$ O5 T5 p$ _2 ?- }- S
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    , L5 [0 N6 B, |+ p  ^
  63. 4 J, h; {1 Z7 d3 M' v
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    6 Q  E# g) i6 L+ ~3 L- s
  65.                         dbge.dwProcessId = pi.dwProcessId;) |! [6 _( [& z, z) f/ k/ \
  66.                         dbge.dwProcessId = pi.dwThreadId;9 z/ @2 J# W! `/ R9 S

  67.   d0 t. [, [4 d8 t
  68.                         while(true) //infinite loop ("Debugger")% {2 O8 E: j5 f
  69.                         {
    % e$ ~% q1 Q$ ]. m8 ]
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    % \2 |3 z& Z5 C7 T$ W

  71. ) p; j$ u; I$ D; w4 p
  72.                                 /*
    ! |' [6 X5 c/ z& p( b2 |
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
3 n* ^3 b9 N2 h- h5 b* ?5 w

# V+ \" s% W) T, G8 I1 ]& Z! W9 m; H& v7 Y$ g
商业服务端 登录器 网站 出售

8

主题

230

回帖

816

积分

高级会员

积分
816
金钱
487
贡献
86
注册时间
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

主题

189

回帖

298

积分

注册会员

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

8

主题

230

回帖

816

积分

高级会员

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

2

主题

81

回帖

611

积分

高级会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2025-2-22 16:44 , Processed in 0.047722 second(s), 25 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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