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

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

[复制链接]

106

主题

128

回帖

1497

积分

管理员

积分
1497
金钱
637
贡献
626
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式

* C! K( E% Z( z+ _# t* l5 y/ a4 o4 ?% `8 v4 T& d# p$ F
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。' p! q* W8 r4 y' `" F

: b9 S0 Q/ v& I) c! t
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    8 E/ B- s! M8 z) }2 \  w
  2. //; d" ^6 X' K5 t& x" a9 L) I/ c
  3.   j/ D5 J$ E( O; u# Z
  4. #include "stdafx.h"- q1 E8 w9 G8 `  q
  5. #include <iostream>9 O  d( Y8 i; q3 t1 u
  6. #include <Windows.h>
    * G  A. y& j7 e
  7. #include <io.h>
    ' r4 j- Y7 ?2 j4 E

  8. / l/ C0 a9 G( I& l. f; b
  9. 0 J/ t5 f7 k) i* b0 Q
  10. int _tmain(int argc, _TCHAR* argv[]), v4 {  a( U  z
  11. {
    " X3 i7 l' K$ j5 |2 d% A% q
  12.         printf("Dekaron-Server Launcher by Toasty\n");* x" O3 z, l4 C$ o' \3 h. g8 X' e
  13. , Z/ k) h8 h) D' b. v$ j
  14.         //查看文件“DekaronServer.exe”是否存在) d" f) J9 o, T0 P% a
  15.         if(_access("DekaronServer.exe", 0) == -1)% E+ \0 z, r( z: c* r
  16.         {% B2 d' l4 j2 Y3 v4 T- p
  17.                 printf("DekaronServer.exe not found!\n");
    4 f& a4 d9 w& S5 [. c  U3 V
  18.                 printf("Program will close in 5seconds\n");2 v& i) p5 G2 t$ w
  19.                 Sleep(5000);
    ) O# c6 m8 g* {# m
  20.         }) M2 s/ J# Y# ?$ Q* ~. M9 D+ I
  21.         else* h. Y7 h6 @0 r; j% Q& m; t! r6 o7 B
  22.         {3 I: I! X6 a0 u$ a! e7 J0 K& J* S
  23.                 $ V5 H+ k7 {8 P) T) P9 f+ }* \
  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+ @0 u$ g; U3 [* s$ o
  25.                 STARTUPINFO si;+ l2 Q8 H& B1 N0 i1 H9 N8 _' J

  26. ) p+ x) u# @' G
  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
    * V; ?7 }# r5 r5 V9 X" \! X
  28.                 PROCESS_INFORMATION pi;
    ( X5 u" [9 q% L' L) W

  29. . D. }/ w) L& u  d: P
  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: H+ G, l" F2 t! M( ]
  31.                 DEBUG_EVENT dbge;/ ^" T: p- Q/ _8 d# E
  32. - ~) k+ |+ M# C9 p0 w: m
  33.                 //Commandline that will used at CreateProcess- V+ m# f3 u2 m$ j* w
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    8 V: n8 s8 F2 d
  35. + g4 p5 ?# `2 J, \: Y- b1 U
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    + p0 A) C2 e2 S; k
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
      T+ Q  c, D7 f& z7 e
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)0 `3 w8 t% ^$ q# a3 a8 B. Y

  39. 4 G5 W7 K4 S/ h8 p

  40. 9 {5 o( i) ?5 r& R$ V
  41. 9 w2 Q2 d3 M+ C" e- S7 d0 S9 s
  42.                 //Start DekaronServer.exe - Q* i; w" |5 G2 R  W
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx/ ?5 E& k5 m5 |: U4 ]5 F: V# x
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)3 C0 X* J( i" c6 H8 d3 X* O; W5 L& h1 f
  45.                         szCmdline,        // Command line
    6 F0 L* y1 L  y6 I3 r# P9 L' k
  46.                         NULL,           // Process handle not inheritable
    ' o5 f1 z# L' v! v; `
  47.                         NULL,           // Thread handle not inheritable
    2 _; V! X# Q9 L/ ?" H  A) m
  48.                         FALSE,          // Set handle inheritance to FALSE
    % E  C' ~+ ?+ D) e' s! P
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx# C3 Z, t$ ^( `7 n8 F2 T
  50.                         NULL,           // Use parent's environment block0 \+ A8 o" V/ ?; {& p9 S) K
  51.                         NULL,           // Use parent's starting directory 3 Y2 _5 z0 ~; T' {& T
  52.                         &si,            // Pointer to STARTUPINFO structure" X8 [" p8 b4 Z: E  o% v0 ~
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    # H8 Y9 H, A0 P: Z& P2 X
  54.                 )
    ) Q3 q6 |/ V$ Q% J* ^5 z2 j
  55.                 {
    2 z2 V& f# l" t& G
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    2 `% ~/ u' v, r0 T$ q7 _
  57.                         return 0;
    ) E8 i0 ?+ }- |& Y5 N: Y+ u$ [
  58.                 }- @* A8 r/ i2 N5 d" @
  59.                 //Creating Process was sucessful
    ; J: I, z8 j" h7 f4 F% y
  60.                 else
    ' J1 ?" ?1 ^8 g( d: f  M
  61.                 {
    & C' `9 V1 q" r% q3 ~7 s& V$ d# x
  62.                         printf("Sucessfully launched DekaronServer.exe\n");- X5 }! q& i2 {1 S4 p

  63. 3 d! B/ P% `% s1 Z, {( j
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    : b) d8 o2 ]" E! [
  65.                         dbge.dwProcessId = pi.dwProcessId;- [6 f' F8 t' I5 L' x) }. q. Y
  66.                         dbge.dwProcessId = pi.dwThreadId;
    ; u5 w5 w4 a( Y
  67. 9 J* B0 _0 \" b
  68.                         while(true) //infinite loop ("Debugger")
    # w" B" y4 W! M
  69.                         {) q  E% B: f# a! I5 ^
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx/ o" g8 S5 _/ X1 M6 N1 W0 i
  71. & `0 {7 v. q$ V% K6 n. j. |
  72.                                 /*
    $ m9 w7 N/ s) D, s; u% P" S+ N
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

& @- H- B& h3 C
* u! w3 [) v; c+ {+ Q0 j9 H
5 f2 O& y7 p4 }: I4 o

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
商业服务端 登录器 网站 出售

8

主题

189

回帖

459

积分

中级会员

积分
459
金钱
250
贡献
7
注册时间
2023-11-10
发表于 2023-12-18 20:34:07 | 显示全部楼层
我是来学习的!

21

主题

375

回帖

776

积分

高级会员

积分
776
金钱
288
贡献
92
注册时间
2024-1-20
发表于 2024-1-21 13:37:44 | 显示全部楼层
感谢楼主分享,我是来学习的

0

主题

42

回帖

105

积分

注册会员

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

8

主题

189

回帖

459

积分

中级会员

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

2

主题

51

回帖

156

积分

注册会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2024-6-18 21:13 , Processed in 0.070578 second(s), 33 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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