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

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

[复制链接]

157

主题

366

回帖

7083

积分

管理员

积分
7083
金钱
2024
贡献
4536
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 1 ?  P) M7 X4 G4 k; D3 j
7 U$ c/ z! Q! `7 x
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
' u1 E% ?! c+ W3 ^- B$ @% k" S
0 W, B9 C( _: `; l4 P
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。# M4 X' t4 d9 [; z
  2. //
    ; K# W7 j) S; i6 j) P- |

  3. 7 K7 j6 U" g/ f7 j, |4 D* \  D
  4. #include "stdafx.h"4 e& q* B0 Y2 |! {6 p) M8 N
  5. #include <iostream>
    . I' H+ I# h: l' g, c
  6. #include <Windows.h>
    , Z" T( M: S& F
  7. #include <io.h>9 U; p% A5 \  M

  8. ! _* T7 O$ z  Y7 U& [
  9. 8 V9 I6 V* D( Z9 E; Q
  10. int _tmain(int argc, _TCHAR* argv[])
    4 {/ \( x* ~, R
  11. {
    5 U0 K6 ?0 N. w8 |; h
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    7 }0 c% K% D: Q! e& K' R

  13. 9 R8 D  F3 J1 R1 j; `+ j
  14.         //查看文件“DekaronServer.exe”是否存在
    ' G0 \' U# A* X$ k
  15.         if(_access("DekaronServer.exe", 0) == -1)
    # k, f' i+ L1 ]! S5 m! F
  16.         {
    1 N* a' q- N' d% y0 d
  17.                 printf("DekaronServer.exe not found!\n");
    . J" \* S' U- N
  18.                 printf("Program will close in 5seconds\n");% ?3 R9 x# m1 Z" R
  19.                 Sleep(5000);
    4 p' \8 V3 m* T, a/ Q& Q
  20.         }
    6 I/ l# }" b! \7 c' J& Y  a7 S
  21.         else
    2 S! }% E5 b5 F( W  ^5 H) f7 d
  22.         {
    $ M2 s( z- Q- y3 f
  23.                
      k3 s8 ^0 \9 a4 o. O. 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).aspx
    6 \# Q  \1 ~; i' p6 m3 B
  25.                 STARTUPINFO si;
    ) U! y' v& ]' C# F- [! G

  26. * \" R' Z* ?$ z7 r$ 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).aspx6 P9 n" @4 [2 P% k2 `# k& o- ^
  28.                 PROCESS_INFORMATION pi;
    5 V6 P6 K* C' T
  29. . f, @. b7 Q+ L; T) s$ j% 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
    + r* h5 S6 M' U8 i( g8 H1 Z/ k4 f# Y
  31.                 DEBUG_EVENT dbge;
    5 Q4 M1 K8 Y, G4 S6 V

  32. : u4 ^, `5 ~' h1 ~+ B4 y
  33.                 //Commandline that will used at CreateProcess
    ' D* `' o$ [# y
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));* {- }+ f( K2 c

  35. 1 b- ~# w2 a! W2 _$ |3 c. E5 a
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    ' s- e. s% n! U
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    + a" @, ]7 k9 S* W
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    3 I5 T2 B2 N9 S- v' ^8 s& Q- X
  39. - ~1 u8 J. n, y% g* @; K* Y
  40. + M9 |+ j# K3 L$ H. o$ o
  41. 9 x9 R( p) e/ E. d9 J9 C) `
  42.                 //Start DekaronServer.exe + w! Y. O2 u4 x) {
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx9 c# `  G8 w# h5 `
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    " \. k7 T# [9 g/ l$ |' y; ]0 M. W
  45.                         szCmdline,        // Command line8 ~6 n0 M1 ?& h9 |9 o
  46.                         NULL,           // Process handle not inheritable
    & r: u) g7 R1 r  T5 E$ U, u* P6 b9 m
  47.                         NULL,           // Thread handle not inheritable
    4 o* `- N3 G: ^4 C' O% Z" W3 U
  48.                         FALSE,          // Set handle inheritance to FALSE/ y( W6 ?5 {  v0 ~2 h
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    7 H) {) u& J. R8 ~3 G2 a: ?
  50.                         NULL,           // Use parent's environment block: k; S9 T# q) P
  51.                         NULL,           // Use parent's starting directory
    # j$ |+ S$ c$ Y$ r: C! v# Q3 b
  52.                         &si,            // Pointer to STARTUPINFO structure
    . J3 S: G% s) w  H& J' N) N
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ; W1 T# i$ a) j4 c. _9 P
  54.                 ) % S/ p" u' j" ]$ P
  55.                 {
    , }/ r% k  ~+ V+ e/ g1 ?6 v
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );8 `: H. R* x( f8 x8 c' `6 k3 e# ~! {" A
  57.                         return 0;
    9 J) A& I4 V4 Y( {$ ?/ {4 `
  58.                 }
    ' z9 S# u2 W7 R# S- L0 O
  59.                 //Creating Process was sucessful
    & E' T! h( B1 o0 F* t
  60.                 else  `: j1 X9 k# w  O8 U! f+ D
  61.                 {$ t1 S* N, H7 [; n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");3 t# P" A  z& j4 z3 ]  t

  63. . S: {3 i5 D" E/ B
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure; W: M4 ?/ n- N' ?
  65.                         dbge.dwProcessId = pi.dwProcessId;
    & w7 }" Y  b+ n- ~) t: G. a
  66.                         dbge.dwProcessId = pi.dwThreadId;7 r6 A7 W9 P* b9 p
  67. * L) z" D# a# j8 V7 x9 s
  68.                         while(true) //infinite loop ("Debugger")
    5 H7 g. K) X! i# Z
  69.                         {2 h+ F7 u: h* g' B$ K4 p5 p
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    % D2 d9 ^% Q4 o3 {

  71. " U/ U: D) S! g
  72.                                 /*
    0 O* w+ ?" h# i5 V; v6 u% \
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

) n) l' [+ N9 C$ n# q
* B3 l+ ?* |/ {0 X3 j! n: t8 L# K5 L1 N% c7 l+ C
商业服务端 登录器 网站 出售

15

主题

257

回帖

1234

积分

金牌会员

积分
1234
金钱
896
贡献
61
注册时间
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

回帖

1234

积分

金牌会员

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

3

主题

102

回帖

7257

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-29 11:17 , Processed in 0.041753 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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