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

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

[复制链接]

161

主题

389

回帖

7509

积分

管理员

积分
7509
金钱
2167
贡献
4792
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) * l" k+ k1 ^7 |
7 R) C1 V% H' O. U8 t
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
% l3 A1 T, \: l1 T4 L, Z: n  q5 |: _6 ~# `5 ~' ?) g9 C
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。% N# M1 i% Q" k: J1 Q1 [
  2. //: |7 N5 [. {; `8 h: z
  3. & T- ~4 ]9 ]- u' \
  4. #include "stdafx.h"/ r2 z0 W5 _6 w$ M
  5. #include <iostream>! U0 s. X$ R0 f0 W
  6. #include <Windows.h>
    + N* p. x( }& _! r
  7. #include <io.h>
    9 y) e. x) `' |. ~5 @2 W, a

  8. # ]1 L' z, D+ A: a5 S
  9. ( s; i& d. @! U% Q. C" q
  10. int _tmain(int argc, _TCHAR* argv[])$ D( E1 x7 l' ~
  11. {0 \  f; f# P9 K# ?# V  P
  12.         printf("Dekaron-Server Launcher by Toasty\n");9 z3 ^4 s5 _8 F: w

  13. $ N0 |: o) c" D8 r( r
  14.         //查看文件“DekaronServer.exe”是否存在  u" c* L( X& F. p
  15.         if(_access("DekaronServer.exe", 0) == -1)
    " y6 @. u. `6 R/ @# d
  16.         {
    # r9 {; B) X) \3 v) e; |
  17.                 printf("DekaronServer.exe not found!\n");( ^: P0 i7 O/ Q
  18.                 printf("Program will close in 5seconds\n");
    ' H9 ]. s+ v) R' ~5 `3 V
  19.                 Sleep(5000);
    , ], }/ N% o8 u
  20.         }
      n9 K0 j. A8 t
  21.         else% B+ N9 K3 @1 m7 u& }& ?
  22.         {( V, x+ V3 y- W, C' L3 {3 l2 E* a
  23.                 2 O- h2 l# D% y: d1 j& f- ?" c
  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
    ) j* L. Y/ l0 ?$ w
  25.                 STARTUPINFO si;
    8 \7 c6 U  u9 _' [  j5 a! b
  26. % V% G% O" t# t2 M8 {
  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- Q* t6 \2 ~- R) V
  28.                 PROCESS_INFORMATION pi;
    " `4 x# q- ~- s1 j1 ?) m

  29. 0 O3 W/ k' g3 ~; i, Q
  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
    + x3 f# v  p9 N
  31.                 DEBUG_EVENT dbge;. X9 p! ?5 z2 B* f# e" Z0 t5 s
  32. : N1 a9 D; v. n0 Q- _
  33.                 //Commandline that will used at CreateProcess
    6 i: \! B# @9 ^$ D3 f/ W
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));) Q. T+ ?* m  f& o8 h, v3 \1 B

  35. 0 @) G- J) o6 C
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    $ v% o% a7 _5 l) A# J. S4 \; H% Z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)" {0 T4 z  j& r/ u
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    * W" ], c: S& H, N; Y0 I
  39. & |" ^9 x2 ~. W% g- b6 [( F
  40. ! T. `: R# }' y/ q$ C& N! ~0 j
  41.   v" g" q1 w/ n4 }1 N2 o
  42.                 //Start DekaronServer.exe
    ) V4 i" b- w4 T$ N
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    * x$ b. m% X6 A- ~4 S
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)( Y  h6 o% v3 s9 a) w
  45.                         szCmdline,        // Command line
    " A  s; f  `7 g0 t* G; e/ ~$ B# O
  46.                         NULL,           // Process handle not inheritable8 L. Z3 |9 T  {/ \, V; Y
  47.                         NULL,           // Thread handle not inheritable
    & {( w3 [' ~- s& @) j) B( w
  48.                         FALSE,          // Set handle inheritance to FALSE4 O3 b& o2 G3 A5 r
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    4 d0 X3 U# Q4 G! g* t" L
  50.                         NULL,           // Use parent's environment block: B7 Q" L' q! j9 N6 |+ v" O  h
  51.                         NULL,           // Use parent's starting directory
    * e$ x, P2 q/ F2 A- m
  52.                         &si,            // Pointer to STARTUPINFO structure
    6 R# \3 m$ v) o: L3 d
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure* y* }) s8 [# E" i5 x( s5 \3 A: ~
  54.                 ) ) K* a4 H  u# ~3 T# l
  55.                 {
    6 D+ G  W5 @8 w% O
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );4 ~1 E( c6 N- m) G+ x
  57.                         return 0;; C/ v7 _; ~* `3 s
  58.                 }; X3 C" M$ k- ^+ f* n
  59.                 //Creating Process was sucessful
    9 \0 U6 @. W: P$ n* a2 `
  60.                 else- K% i* [% v6 v
  61.                 {
    - V; S- w, |( z0 p- h  n% o
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    ; G5 z0 N3 n9 ]" t, }9 j7 I

  63. ) ~( U) `* g2 U# u7 z
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    # _8 ]$ w( v# a7 L8 u1 _
  65.                         dbge.dwProcessId = pi.dwProcessId;: ~! a4 E4 ]5 B. Y' b& W5 }- m4 t
  66.                         dbge.dwProcessId = pi.dwThreadId;
    : }: K' e% M- L$ u
  67. $ b2 Y7 h! U; Z( A/ H0 ]1 [
  68.                         while(true) //infinite loop ("Debugger"), A) \5 ~: i" A7 d. x% Z. I" B% _# H
  69.                         {
    9 i$ g6 t6 F7 @8 ]1 l" g: 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" P% R1 e: }! c

  71. 2 @1 r5 U: [. ?- c9 T8 u6 j5 A
  72.                                 /*& V5 g2 K, j5 x
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

! z  q5 N/ }4 C; L0 @1 P
$ g/ C6 A5 Z) h# C! d! |# `; T. _" C( B. |3 m
商业服务端 登录器 网站 出售

15

主题

260

回帖

1313

积分

金牌会员

积分
1313
金钱
945
贡献
88
注册时间
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

回帖

355

积分

中级会员

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

15

主题

260

回帖

1313

积分

金牌会员

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

3

主题

102

回帖

8257

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-5-18 13:44 , Processed in 0.034527 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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