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

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

[复制链接]

157

主题

364

回帖

6927

积分

管理员

积分
6927
金钱
1964
贡献
4442
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
  ]$ f) H% {; }# |. U: M$ r3 n+ v! n* p
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。& P' v, i$ m. q8 s7 v6 C* j
# Y2 M* V3 A, P+ Y4 G. V" F
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    6 {" N* Z0 E8 l' `& ^
  2. //2 k# Z* K( `3 u; H- f# R
  3. 5 Z: b( c" ]& e! [
  4. #include "stdafx.h"
    # C! Y# F3 Y6 H; P3 A
  5. #include <iostream>
    3 Y6 M1 B- P4 x$ P, l% H
  6. #include <Windows.h>6 V2 q0 u" x' [" T
  7. #include <io.h>
    1 p* e4 i, }3 }- q( [, Z" w

  8. 4 t, N: g( |/ E. n$ r0 D% V
  9. * B4 \( ^7 H5 L& ?" S
  10. int _tmain(int argc, _TCHAR* argv[])  v5 v3 s) ^, }
  11. {
    9 t0 t$ C0 e7 h( t& c  \! O
  12.         printf("Dekaron-Server Launcher by Toasty\n");" B8 |' L6 s. v2 i% B' u
  13. ; |1 ~- Z$ u7 p; m7 Y4 x" Y
  14.         //查看文件“DekaronServer.exe”是否存在/ `/ @; R" j; y5 A+ o4 F+ h
  15.         if(_access("DekaronServer.exe", 0) == -1)$ U; i' T3 O2 m2 Z- N/ e
  16.         {  b0 j# G/ h+ r4 c! o4 [& z# M5 P
  17.                 printf("DekaronServer.exe not found!\n");+ Q/ u) V5 e# M9 E7 s' s
  18.                 printf("Program will close in 5seconds\n");
    ' [% ?( a) N, A+ d6 Q
  19.                 Sleep(5000);5 N7 D1 G) \! e1 u! {
  20.         }
      ]* O$ d9 {! m& a
  21.         else' B% O1 Q4 }4 C3 Q6 a
  22.         {1 W7 Z; I" r+ C, P
  23.                
    , M( o: s; L# L1 H& a; I/ K
  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
    % I& ]$ L- g" L+ ?: O
  25.                 STARTUPINFO si;  r, p) \- C9 ~( x3 z  u

  26. 5 }1 c% T+ r9 |: {
  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).aspx7 F0 F- E* A* Y9 i8 c
  28.                 PROCESS_INFORMATION pi;9 p  i# s+ J: W# I  U% n1 M

  29. ! B8 p6 W- v5 c
  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- X1 t& Z' l) R+ o& r
  31.                 DEBUG_EVENT dbge;
    2 }& a2 I( Q; u( a6 x( C' y5 @
  32. 5 n5 j* L6 E0 q7 ~2 m
  33.                 //Commandline that will used at CreateProcess; K) N4 m" D! V
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));0 d. t( M: d) v' n( f2 @6 o" e

  35. 6 r1 E6 @# v4 o4 O' T5 g! b+ h8 K" }
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)4 t8 j7 [, ]2 ^9 U% Z6 H' V
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)- b3 M. }9 `, G# W: k3 G% ^
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    + y9 e( H! w4 k$ {% u% q

  39. ; f& l  G* M0 ^5 e4 m
  40. % Q/ [( z5 C4 o$ S  `( |8 X
  41. ( d  {2 @* h( ^- h# }3 I/ A
  42.                 //Start DekaronServer.exe
    ) g' c) N3 h6 A7 a
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    * d, w& z/ S5 h+ C
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)% W: p' r( J7 g
  45.                         szCmdline,        // Command line, |# h; P+ h% R- f
  46.                         NULL,           // Process handle not inheritable+ S+ n% L/ m) ]/ C/ s5 v
  47.                         NULL,           // Thread handle not inheritable2 T' g! f- N' x6 t: E5 R
  48.                         FALSE,          // Set handle inheritance to FALSE' ]$ A6 F7 A; R2 ^1 N
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx$ e* X3 }: k% x: [4 S. f8 n* J5 @' I
  50.                         NULL,           // Use parent's environment block+ s/ h4 V+ R# Y; i% a
  51.                         NULL,           // Use parent's starting directory
    ( p3 K% y. @6 H2 p
  52.                         &si,            // Pointer to STARTUPINFO structure! K2 ^7 Z% v/ |, I( \. y" [
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    6 f1 O7 R1 s4 W" c) J
  54.                 ) 3 i: `6 ^' b5 G6 T( E8 ]
  55.                 {* h+ o3 q9 {6 s( M; {
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );+ c( s7 }8 R% `' Z
  57.                         return 0;+ j7 @2 V# U: [/ y* z& j" D) e8 g3 ]
  58.                 }9 L) ^2 j' ~. D& s
  59.                 //Creating Process was sucessful0 p/ Q- g$ \% u$ i
  60.                 else
    8 d5 Y/ e6 P$ e* B+ U/ X5 L
  61.                 {
      u+ F! a* o1 n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    3 [6 ^) o' o; o9 T

  63. " @9 L( Q/ c& }7 ^
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure2 h; i5 ^2 E/ [' D; _3 _
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ( ~0 y% o# W) `0 H; H
  66.                         dbge.dwProcessId = pi.dwThreadId;+ f2 q0 F$ Y: L- H- M0 L/ I
  67. 4 \- r. d$ q" ^& o8 j( J6 f1 }
  68.                         while(true) //infinite loop ("Debugger")8 N  u; B9 p" W9 C2 n% S& r$ ?
  69.                         {+ y, V+ n, a0 I  h
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ! V) t5 H/ `' b( s  m
  71. . D- t, F+ p/ ?6 j+ r7 Q
  72.                                 /*3 e3 T0 q0 C& l2 r
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

6 C1 O1 q: N- q+ H, m; C
+ u( J$ ?; p' x7 c" S  R
1 L2 K. K& g+ I5 V
商业服务端 登录器 网站 出售

15

主题

257

回帖

1226

积分

金牌会员

积分
1226
金钱
886
贡献
63
注册时间
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

回帖

1226

积分

金牌会员

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

3

主题

102

回帖

6779

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-3 00:45 , Processed in 0.063652 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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