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

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

[复制链接]

136

主题

168

回帖

3159

积分

管理员

积分
3159
金钱
1034
贡献
1821
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) - \  t8 s8 ]% x
/ ~& [0 f8 h( N9 c+ \+ A/ ?' Q" r0 K
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。1 d* M" \+ Y. l1 J8 X4 w* W

9 t- y* `: q0 z; N; I
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。- ]& f0 I5 t' `1 X: t+ y
  2. //5 M; O9 `' V- i  z: v9 P
  3. 2 [/ a( U1 h7 O* e- w- @( O, g$ {) J, \7 j
  4. #include "stdafx.h"9 Q+ f- T* e( s% Y- ?; ?4 y8 F6 M
  5. #include <iostream>
    ( g1 m: S3 C/ `
  6. #include <Windows.h>: Z4 v* b9 w4 \8 G) B
  7. #include <io.h>+ u) J  P+ m9 l8 q

  8. 9 ?% ~+ k; U1 S
  9. , |; b. e& `6 Z
  10. int _tmain(int argc, _TCHAR* argv[]), a9 `% T% q( U" X) h; C1 z
  11. {
    % X1 a! ?1 i! S0 y* }
  12.         printf("Dekaron-Server Launcher by Toasty\n");! p5 f/ l* N- m) U! i# l6 P( l, ~
  13. 3 x* H' X9 B5 A, T. J
  14.         //查看文件“DekaronServer.exe”是否存在6 _1 ?: a  a4 ^  e0 T4 r0 ?
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ; }( G- d! B5 G5 M. I
  16.         {7 u; [3 d- j" o  w/ T9 D* s+ u
  17.                 printf("DekaronServer.exe not found!\n");
    # X, y2 W: @+ J; x: q" C; l7 V
  18.                 printf("Program will close in 5seconds\n");; a, E# L  H+ ~! g# l4 c/ p
  19.                 Sleep(5000);  g; }; E6 P1 n* z" p8 `
  20.         }. P$ g$ H( C5 I' y- V& |
  21.         else
    & N  v! \! u2 E& [5 ~9 C
  22.         {* D# H9 J& q$ G- D
  23.                 4 O1 y; n# k  Y& H* {
  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! C: g( a5 @) ^( n9 F
  25.                 STARTUPINFO si;
    . Y3 J1 v- z. I6 {' q. S
  26. + B4 t7 H: p9 x- k: G) n9 r) P/ H8 |& L
  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
    ( ]( ]+ z7 |) r6 {; |9 {/ u
  28.                 PROCESS_INFORMATION pi;% E2 o3 C. r1 A; e! G
  29. . ?, w2 ]6 `8 T+ M9 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).aspx7 s* g* s' X" @4 C( r2 j
  31.                 DEBUG_EVENT dbge;
    1 W& [$ m5 s( a2 T# G) p4 g; Z
  32. * O3 ]; c  O0 z9 P# B
  33.                 //Commandline that will used at CreateProcess
    0 F! F# N$ M$ a, v1 ~: D8 x
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));) S! g9 q" N& Y, p

  35. 7 H$ V# o- A& G8 K4 B
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)- R( y( w- Y$ y
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)) c4 K) {5 ~4 F6 O
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)+ T3 W5 R5 b; v

  39. " K1 @* W1 ?, l  Q! L

  40. ; T: `7 l+ V8 o; d$ g% c/ j& Q
  41. ' ~2 j. V0 x( h5 \- U4 K6 F9 k
  42.                 //Start DekaronServer.exe 5 _7 R; X: Z# X1 Y$ u% A# t3 D' y
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx% t! n5 E) o+ g9 I
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)/ T* y3 G  S9 g- Q
  45.                         szCmdline,        // Command line0 h' X/ Q7 y; q3 C/ c' h
  46.                         NULL,           // Process handle not inheritable
    2 b3 ~, G. q# l3 f
  47.                         NULL,           // Thread handle not inheritable
    % A" R; Q# d* R% b. r( q
  48.                         FALSE,          // Set handle inheritance to FALSE% E5 l/ ]4 J, {4 V
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    0 W1 Z6 s0 h" j1 s# B4 I8 I
  50.                         NULL,           // Use parent's environment block  K; s  D# }& {6 U4 Q4 k2 L" i
  51.                         NULL,           // Use parent's starting directory $ v! \/ L1 ]8 k" U3 e
  52.                         &si,            // Pointer to STARTUPINFO structure( D# S- O* }9 d  z* e
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    6 R3 {& i# d7 m& R0 X
  54.                 ) 4 y& @+ T9 W$ K/ h( X% ^0 ^9 O
  55.                 {9 C& d0 q- e, A/ X' }1 A1 V
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    # x2 ?7 s. C0 c* D
  57.                         return 0;
    ( Y9 {" h- u) u# O# j' C  s4 _: J
  58.                 }
    2 x0 K9 q3 r; Y0 d' v: \
  59.                 //Creating Process was sucessful# v5 P6 P9 a) r( w) }4 h
  60.                 else, A5 m$ l  i2 _9 E0 Q1 q
  61.                 {
    8 w& r6 I+ k+ U3 ]  q' o
  62.                         printf("Sucessfully launched DekaronServer.exe\n");- `' t) `- e+ N5 U$ i* j

  63. $ h; M' ~" ~1 b4 S6 i
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    & i% i/ ^( I( _2 K: v: D# ~4 R
  65.                         dbge.dwProcessId = pi.dwProcessId;+ K% _8 ~4 y/ I6 {! k
  66.                         dbge.dwProcessId = pi.dwThreadId;
    + U9 Z$ `) t8 A8 ?& d" H+ A1 y6 ^8 J
  67. 2 {% b0 ^& P1 ~( F9 G" I
  68.                         while(true) //infinite loop ("Debugger")4 L0 _  l  p, Z" ^8 {. w
  69.                         {
    9 e' m3 l( `+ T, P0 d2 M
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx7 Y8 p. K% ^4 ]0 B5 k$ \. z/ l

  71. ' d" x  w% c5 d8 X2 m2 `
  72.                                 /*
    ; E" d+ {& r2 S2 g. L/ W4 z4 w
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
. o! R  H9 r" u( h5 L

" s  J0 }9 R$ K! \# I: ^1 {) d2 k) G2 Z7 I' c$ {0 i% a( H" K
商业服务端 登录器 网站 出售

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

回帖

614

积分

高级会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2025-2-23 23:24 , Processed in 0.051319 second(s), 26 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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