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

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

[复制链接]

160

主题

385

回帖

7415

积分

管理员

积分
7415
金钱
2125
贡献
4745
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
/ m6 @4 H+ e6 F- `7 ?1 g. b/ m" @& D7 j" ~# c1 _
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。  ?& s" V6 M9 p4 K8 ?7 b

9 j4 G2 `' `9 E3 M9 L
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。# a" _5 k" Y& G' Q& n# O1 F
  2. //
      I8 q" p8 Y, y/ o: y! J

  3. * ?3 G0 Q8 D# ], n9 K/ _- k
  4. #include "stdafx.h"3 C: u/ e; J4 y8 j0 z
  5. #include <iostream>1 V" k8 F& K) P, Z* U
  6. #include <Windows.h>
      E: q0 k* M6 A: G* C: k' `
  7. #include <io.h>/ R% d+ l" \6 z

  8. * X- H! l8 v, [% f8 d

  9. ( l7 q3 b0 ^% O! E2 o, s; M
  10. int _tmain(int argc, _TCHAR* argv[])0 p6 U. G1 v6 V; o- p0 j, S5 S( X
  11. {
    ( H% u. C: I" |! Z* d( J
  12.         printf("Dekaron-Server Launcher by Toasty\n");/ ~  k% d& k  w

  13. # b1 q* o+ e' N9 j4 `4 S& A
  14.         //查看文件“DekaronServer.exe”是否存在
    $ B' `3 W$ Z8 k
  15.         if(_access("DekaronServer.exe", 0) == -1)5 {% `+ j% s, U9 D: r
  16.         {! r, m7 w% G' f9 a" ]5 u( [
  17.                 printf("DekaronServer.exe not found!\n");
    : J" t& B! e+ r! Y6 l0 I' }; o! L9 }
  18.                 printf("Program will close in 5seconds\n");; Z6 D) B' o) x/ C/ {
  19.                 Sleep(5000);
    # \# `, M# A( ]7 i4 L1 T2 i
  20.         }
    3 d7 T% k/ n% U3 N# [9 f
  21.         else
    * A+ [' P, p+ A7 K7 k5 r# e* Z3 S4 |
  22.         {5 H9 e* |0 ?6 p; V
  23.                
    9 x' C+ K$ ^* N
  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).aspx8 ]7 Z4 S! {4 d7 v8 I8 Y0 g
  25.                 STARTUPINFO si;8 Q' ?4 ^4 V9 Y5 v& c# J

  26. , [4 @) |. p3 n3 d8 t1 t: A
  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).aspx3 W1 R: {$ [, |( x, Z
  28.                 PROCESS_INFORMATION pi;6 ~2 k* o4 ^6 K( G9 O0 f; j

  29. 1 K0 t) g0 u! o/ o1 B
  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
    2 ]4 y0 S- g+ P; a$ y5 H
  31.                 DEBUG_EVENT dbge;
    / Y' A9 |, F* O; F* e' K
  32. 6 g$ V) |9 p# n% y6 m# b
  33.                 //Commandline that will used at CreateProcess$ y, d- A: K' v! y( E
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));  e( {4 X8 g1 O

  35. 8 q1 w7 m% t' h1 |
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)* k6 M( w$ B2 Z, K3 Y: d
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)! b9 R7 B; h* Z! X$ c( y, ~
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)8 b3 K+ g+ G( m! @/ ?6 r

  39. " P  m1 S  f/ B# U

  40. - E4 N6 p$ c# d" X/ {3 W5 b& l7 M1 a1 O* ]
  41. " N; I. w' \0 i0 }
  42.                 //Start DekaronServer.exe
    8 P  J* H8 a6 x. k8 ?; b- }
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
      H+ @& Y+ ^: h* a
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    1 r; j& M* r  W7 d6 e
  45.                         szCmdline,        // Command line$ L3 Q" P. S$ l; T( K
  46.                         NULL,           // Process handle not inheritable& |% V) Y2 n5 Z+ x9 K6 D
  47.                         NULL,           // Thread handle not inheritable3 q* d7 `+ I6 ^) L
  48.                         FALSE,          // Set handle inheritance to FALSE
    $ r% C& l9 y2 J$ T, i! D
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    , b8 |" o6 |1 s3 n, y) G
  50.                         NULL,           // Use parent's environment block# S4 ?0 a* R, }
  51.                         NULL,           // Use parent's starting directory % Q' J- R8 j2 Q2 S
  52.                         &si,            // Pointer to STARTUPINFO structure  |% n! [$ M  w6 Y$ y% H& Z
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    & J  F: a; a0 W
  54.                 )
    ' D8 U, N% ~. x" k$ p
  55.                 {: p+ f/ A! `, M5 f9 u% [) o
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );3 V2 \: B/ |& I9 B) [) f$ \) i
  57.                         return 0;# T9 M$ U+ I# C
  58.                 }, i. \! Z* {6 G( D, h
  59.                 //Creating Process was sucessful% j8 j/ J" A$ ?: R
  60.                 else9 H7 X$ n3 [4 R( X% `
  61.                 {
    ( S  e, t! Q: Q" V1 Q9 z
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    * t4 |) G  }/ {' R! S3 |

  63. # l) D' ^% |, S2 S) }1 r, w
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure: z: ?& Z; l  A/ b
  65.                         dbge.dwProcessId = pi.dwProcessId;8 _) M# C' A; A. t9 t1 _  ~
  66.                         dbge.dwProcessId = pi.dwThreadId;
    . M6 h' X2 L& u  l9 C9 f7 i7 I

  67. " W* i# K) @% o# o  d) M: ~
  68.                         while(true) //infinite loop ("Debugger")* X' W! L# j: z  m
  69.                         {
    # e- ?7 b* T) e; o, H) o4 V
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    4 v: m- y: ~  r" B+ w$ U& ~
  71. 1 K6 X% u* x/ {! `- t
  72.                                 /*
    * r6 _6 _  J- v: c. w
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

: ?1 h  N! r/ h! }
: v) g  }5 p) G  K- g: s' W1 [
$ A4 U9 F8 _- v/ @2 p# P  K6 P0 ?
商业服务端 登录器 网站 出售

15

主题

259

回帖

1281

积分

金牌会员

积分
1281
金钱
924
贡献
78
注册时间
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

主题

259

回帖

1281

积分

金牌会员

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

3

主题

102

回帖

7837

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-28 15:25 , Processed in 0.034778 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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