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

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

[复制链接]

149

主题

291

回帖

5186

积分

管理员

积分
5186
金钱
1661
贡献
3085
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) / K6 J/ E: ?. U% X: G

! y8 B  @) K+ `% z8 j# A虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。  \& w1 Z8 p% o7 m

) T! G/ f8 D+ z2 |% E- k
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    & q# o/ I  ~$ L6 k' j$ p
  2. //
    ( B& k! a, e# x" V5 t" a; ]+ i
  3. . H; }5 R+ i% @* H2 Y! s/ l6 X0 l
  4. #include "stdafx.h"2 v& [* [9 o- s) p" [1 v% G( G
  5. #include <iostream>1 Z1 H) z& `! g! V% w
  6. #include <Windows.h>
    5 {7 H+ V2 S- E/ L/ A$ w
  7. #include <io.h>7 j. o! t- F7 ?4 _
  8. 5 v, B6 r5 H+ f3 C0 [8 c
  9. 6 D* f0 V8 F7 r2 Z, k0 m! s
  10. int _tmain(int argc, _TCHAR* argv[])8 B, y, T6 h" z  q3 p
  11. {8 D( i) Z& E+ h5 t% R! u& X* u
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    0 U8 R% Z* ?6 g$ K/ o- z
  13. ; I7 `3 D4 R, r+ _7 T
  14.         //查看文件“DekaronServer.exe”是否存在& m- p) m' D5 S- f6 [& t8 X  [. |
  15.         if(_access("DekaronServer.exe", 0) == -1)) N$ r6 D7 B) t1 |" @& I, Q
  16.         {  ]& `8 l7 f2 j
  17.                 printf("DekaronServer.exe not found!\n");
    3 B- e7 S, Y* B* S& z3 A
  18.                 printf("Program will close in 5seconds\n");
    : e3 g% A' h( c, a) S6 X
  19.                 Sleep(5000);1 |6 N" s/ v- T9 u
  20.         }
    * j0 m2 ]- e% v9 r1 N4 ^- V
  21.         else
    , H7 H# X' S6 [0 Y' P
  22.         {$ H2 n8 K8 {2 i. r6 f) y: p8 ?
  23.                 # ?: i! c% E8 w0 k, j
  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).aspx4 O5 ^$ x$ f% B- H) h$ }
  25.                 STARTUPINFO si;) @8 Q0 h: @, e# `

  26. 2 ~# ?" Q; q# R, N5 s( W# r
  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
    5 q3 T2 O# j, H' A$ l' |( o
  28.                 PROCESS_INFORMATION pi;) M. M8 q8 e, _, b$ u
  29. : w' s) X# s+ q6 f; D  ~+ K* S
  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# ^3 t0 [$ j3 T6 B. p
  31.                 DEBUG_EVENT dbge;
    + i7 ?% t, ~) N3 O$ ]

  32. - q- [3 ]4 j( X' |0 p
  33.                 //Commandline that will used at CreateProcess
    5 e2 M' h2 v7 I% F+ d6 L
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ' G/ U+ f! |; l+ H3 u; K7 x& }1 ]% ?2 y
  35. + N, I% [/ Y8 g! @2 p7 S' i
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)- _- g3 t/ E% j; z
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    ' S2 V3 s$ Y6 z3 X0 X* \& O
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    5 A$ N9 G9 X/ n6 u9 [
  39. 7 C. N' d- X, |6 J7 o: U8 t

  40. . s6 x6 U# o- z/ a( B
  41. 9 l( b  e; ?; f4 q5 n
  42.                 //Start DekaronServer.exe 6 _9 f! ]: |9 o  u6 }% `( _
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    : K5 i' D; f# q
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    . M5 {$ i, z4 n* F9 p) [
  45.                         szCmdline,        // Command line6 f6 q+ e" H! R
  46.                         NULL,           // Process handle not inheritable
    3 _& x4 P" }( ^, @# D, @
  47.                         NULL,           // Thread handle not inheritable8 v5 ?* c  w: Q2 A+ \  t/ Z+ N" j) n
  48.                         FALSE,          // Set handle inheritance to FALSE- c+ h4 F; \. S- o1 p+ `$ {
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx, |$ T0 J4 V% ~% s4 u2 F( T
  50.                         NULL,           // Use parent's environment block6 @; Q1 E3 j' p
  51.                         NULL,           // Use parent's starting directory
      ]! E; v3 t6 j* `6 x
  52.                         &si,            // Pointer to STARTUPINFO structure
    + H6 ~+ C: `" t( v- _
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    " b# k0 ?0 _5 i: C6 G& \  C
  54.                 )
    7 ~# Z; \" ]3 g+ ?. p. d; G' o% w
  55.                 {9 ~2 j& N5 u# ^9 J- G, P
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );2 o" x+ e9 |1 M0 B' F, z! D3 e
  57.                         return 0;
    ' ?# \* \( j. W
  58.                 }0 J4 A0 g. R  X- z( f: T
  59.                 //Creating Process was sucessful! p6 M2 {! U9 M+ h
  60.                 else
    3 ]( i1 Y8 d" H
  61.                 {! o- J2 _  E$ N3 b8 J9 F
  62.                         printf("Sucessfully launched DekaronServer.exe\n");% a& p$ D0 F& o" j* b9 \9 n
  63. * M1 F* A# f. p3 c: @! C
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    $ l/ y$ M  h, X9 i% a3 D/ A' o, e- I
  65.                         dbge.dwProcessId = pi.dwProcessId;2 ~" r, \# n2 `
  66.                         dbge.dwProcessId = pi.dwThreadId;# g( I4 [) M2 y* `9 K
  67. % u6 V5 c* e3 V% e  q5 E' ?
  68.                         while(true) //infinite loop ("Debugger")
    ) B1 q5 `$ \8 g- T5 O; w
  69.                         {; ?, J; z( t3 i9 e& W; 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. F  R5 a4 K% H) y+ j" Y3 L( ~

  71. 8 Q5 ?- N' B3 k8 E) e# n( n) Q
  72.                                 /*
    ' r4 X, u' g; r1 Z
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

. k2 c7 g2 g8 {! V
3 T6 n4 F, Q( l5 [3 r9 y! a4 K1 I8 }- x* X+ `: k/ H
商业服务端 登录器 网站 出售

11

主题

245

回帖

1124

积分

高级会员

积分
1124
金钱
712
贡献
151
注册时间
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

主题

204

回帖

340

积分

中级会员

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

11

主题

245

回帖

1124

积分

高级会员

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

3

主题

97

回帖

3919

积分

金牌会员

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-9-19 14:58 , Processed in 0.043861 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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