找回密码
 立即注册
查看: 5594|回复: 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 贡献)
! Q$ _/ {# ~1 `2 i2 D( l' u
9 k1 [3 u4 u" m- [, M* `3 y7 M4 R虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
% @4 [- O# k2 B7 C
4 b8 S% x3 |, |0 {6 Q$ T( d, G
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。- l* w  r8 F* Q% K0 X  F# z
  2. //
    , r6 D1 S' s( f

  3. 2 P/ x  \( l4 |
  4. #include "stdafx.h") ~# T& U9 x6 v& C: w
  5. #include <iostream>/ I( Y- C# [) h9 `5 S
  6. #include <Windows.h>
    2 T2 k: K! v  y. j
  7. #include <io.h>  |1 n6 q. O$ [
  8. 2 i( r7 e: \& p- q9 G/ a
  9. ) X/ n$ k5 N9 U' F
  10. int _tmain(int argc, _TCHAR* argv[])7 u6 l$ d+ I" V4 R- S
  11. {
    : H0 h+ P7 R* ~& s( H1 o
  12.         printf("Dekaron-Server Launcher by Toasty\n");' Q  Z7 [: H3 i- \+ K) _5 O

  13. / u! h& A/ ]0 b0 G3 K( R
  14.         //查看文件“DekaronServer.exe”是否存在
    : T) O* e# @8 e9 M' |" a
  15.         if(_access("DekaronServer.exe", 0) == -1)
    8 v; M3 C' b2 D- O
  16.         {
    + }( p! d$ O$ j5 N$ H, {
  17.                 printf("DekaronServer.exe not found!\n");! C8 r$ Z: u: B7 l8 R7 s
  18.                 printf("Program will close in 5seconds\n");' v+ W9 I# s9 v0 i5 J) L! }4 V; u
  19.                 Sleep(5000);
    * K* f/ B  ^- M5 L( o; s
  20.         }
    ( D2 `2 E! F* ^
  21.         else
    , ]$ e( H' U- t) l% z/ E
  22.         {+ Z8 }' L2 \( \9 ?/ h! U; h, @. C
  23.                
    . D  L( H; z3 V, o, X' Y- [
  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/ ^* u2 G. Q- k' z
  25.                 STARTUPINFO si;
    * |- d" X9 b5 x- }+ w1 a7 v* L" \# |

  26. , [: p6 |9 }0 U5 s
  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! j: w* y$ n5 x. P( v0 u1 @2 j6 l
  28.                 PROCESS_INFORMATION pi;
    1 B3 v  j: V" {- y' S4 r: P

  29. ( m3 W1 @. d9 c
  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  R/ R9 u0 b4 B& e
  31.                 DEBUG_EVENT dbge;
    2 S- d5 k( w0 D9 U6 z
  32. 8 {* \# \+ g, u2 y2 K8 u# |4 P
  33.                 //Commandline that will used at CreateProcess- h  \1 @( U( H# ^) Y0 H
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    2 c$ Z6 T# x3 Z  ^* G8 ?9 L

  35. $ V; `) ]8 _9 N1 J" F1 u) T
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made): G, U9 d2 a* P2 J3 c+ U
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)9 P' c3 v9 Q( h# i! ~7 t0 Q# Q" X
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)+ u$ v# S4 {- E$ l/ F
  39. ' i- |! G2 o, A$ @9 Z! r
  40. 6 v) `0 g4 r( M3 d+ s
  41. ( y1 ]# B! f8 D. E( h" D! k
  42.                 //Start DekaronServer.exe
    1 p9 J0 m$ Y. N0 G- L
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx4 L, n: ]- ^: P4 i! I8 {4 q$ f
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    0 o. ?1 O  z7 L8 y/ _
  45.                         szCmdline,        // Command line8 G; G9 b" B9 D
  46.                         NULL,           // Process handle not inheritable
    1 f- n3 V, n3 b
  47.                         NULL,           // Thread handle not inheritable" v3 Z# C; l: I- {& L9 B( a4 Y
  48.                         FALSE,          // Set handle inheritance to FALSE
    * h) \% O3 T$ [# x& |3 K& E
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    ) w; m1 }1 K) x* r
  50.                         NULL,           // Use parent's environment block
    " P& s4 m& M; h3 h5 s! m* v
  51.                         NULL,           // Use parent's starting directory
    ' c! N/ Q* C- T3 M: w* @4 {
  52.                         &si,            // Pointer to STARTUPINFO structure* |% J: F  t! W% p# ]
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    / `9 G/ R3 I, ]" y# V
  54.                 ) 2 G6 J8 f' X$ t7 F
  55.                 {. c% t' D( e% Y6 G$ K7 W( |
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );& E, c0 u& `2 m: y
  57.                         return 0;
    9 Q$ [" L! t  o; H  c% T3 f
  58.                 }
    ! k/ r1 g9 S, U- v# a0 k' r! R
  59.                 //Creating Process was sucessful: j3 X" q/ W6 @6 |8 P
  60.                 else
    9 T/ O4 y4 s: s
  61.                 {
    ) t' d) C) t! e- l7 [1 O' ~
  62.                         printf("Sucessfully launched DekaronServer.exe\n");1 ~  J7 R- o! [8 {
  63. 4 s( c" a2 b" Q, o5 P( m0 @2 `- |
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure& G! ]4 i% \8 e, W
  65.                         dbge.dwProcessId = pi.dwProcessId;
    7 v4 L0 N( P1 G0 L
  66.                         dbge.dwProcessId = pi.dwThreadId;) U7 c* X, D+ T- T4 C* f, _
  67. 5 q4 Y, Z# G9 E3 R1 B7 y! s$ k7 [
  68.                         while(true) //infinite loop ("Debugger")( g. O3 O- K$ y2 H8 m
  69.                         {, Q( k( G+ u- p" s
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    9 C0 ]2 Q, L/ l! `& m+ V

  71. / S3 y, Q" z' P" I6 D
  72.                                 /*. d3 q5 y4 f! W* Z; Y" @. F
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

2 _6 G8 t  q; {; y9 ~" D& e
+ q: E  y! v) A' k5 X+ h3 }2 {! [: n" j( p- {, L
商业服务端 登录器 网站 出售

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

回帖

6739

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-1 13:42 , Processed in 0.072788 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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