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

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

[复制链接]

157

主题

361

回帖

6818

积分

管理员

积分
6818
金钱
1937
贡献
4363
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) , N' W# d9 s( b% n
9 R  Q0 F; E) R
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
" b/ K! g" }3 B( j; |. s2 q9 X2 |' x
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。; R% r3 j+ a9 S& J% K: ?8 t% x  Q
  2. //
    & I6 ?. K. E: c% @
  3. 2 ^3 m. y7 _# Q3 I: X
  4. #include "stdafx.h"
    . X( q  T/ O# |5 C, k+ f/ m; s! o
  5. #include <iostream>3 U' M) X- a) X
  6. #include <Windows.h>
    & I2 e- U  H. X! l. f0 ^
  7. #include <io.h>
    . _, }8 G3 N  z+ x
  8. $ x: ]1 u( p& d8 q5 T
  9.   B- V1 m, a; F% U9 l
  10. int _tmain(int argc, _TCHAR* argv[])
    ( l% _; J* W: [$ X; G3 {
  11. {
    5 ~: ]0 I2 f& q  ~9 Q! [' p
  12.         printf("Dekaron-Server Launcher by Toasty\n");) l4 Q- a+ I3 \; N7 ?

  13. 5 G" q- t( Q& `+ ]$ \3 {$ J
  14.         //查看文件“DekaronServer.exe”是否存在& Q8 Y: `% G; O; t1 M) v" b+ \% w6 u( i
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ( w3 Z3 |0 d: B9 }) j
  16.         {
    + u5 j5 ^0 u' b. _7 d
  17.                 printf("DekaronServer.exe not found!\n");: M, ^$ C4 t/ j; o* y9 J  E5 _2 h: j
  18.                 printf("Program will close in 5seconds\n");
    * O( c2 {3 T2 b6 D" @/ H3 x: ]
  19.                 Sleep(5000);* Z& T7 Q2 x8 d
  20.         }, ]7 q+ T# R% X1 w, ^
  21.         else& W! Y. i: r$ @/ M
  22.         {
    # f" H1 a; g4 N6 e! e. T
  23.                
    ! _4 r9 o& C, }" Z/ `
  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! M% U) Y* W: g
  25.                 STARTUPINFO si;
      O+ ]7 A7 q) b5 X1 M6 e

  26. 3 |4 L  I! {, y' {1 Y
  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
    , |) D  R  m0 T# _  e( F
  28.                 PROCESS_INFORMATION pi;  K! e8 c) L4 {6 B- Y: q; p/ a
  29. ) f8 [0 O$ ~9 {% m% {; A
  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" ]5 Z" t* |1 J$ M% w0 J
  31.                 DEBUG_EVENT dbge;; z6 ~0 _8 _- V

  32. + b, d9 B5 ]3 R4 ?0 d
  33.                 //Commandline that will used at CreateProcess
    : J8 b5 U2 D2 k+ w% W! B
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));5 r( A' }4 ^+ p$ U( ^; A, [
  35. % o1 f. x8 E) h7 b  i
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    - y- ~+ {1 H, @8 {
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)5 V4 Q! Q( ?! i4 d( g; ^4 h
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    " e9 r3 o$ d4 n. m
  39. 0 C/ G$ ]. L) H/ j6 Z' i; z

  40. / J5 I7 m; j% K; W

  41. , {) a9 Z& e4 T- b
  42.                 //Start DekaronServer.exe 8 c0 h2 T8 `4 Q
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx# ?( }! F4 r0 o. |
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)1 e! }& C8 f9 k: @
  45.                         szCmdline,        // Command line
    - L& O) r5 L6 w9 H: ?% u! N
  46.                         NULL,           // Process handle not inheritable
    , A- X. N5 M% e; V
  47.                         NULL,           // Thread handle not inheritable0 B# k& A" [9 [3 ^" A: Y, i
  48.                         FALSE,          // Set handle inheritance to FALSE* W' L9 C: Y" w1 ]% t
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx% ^/ S8 o& p0 U0 p0 J
  50.                         NULL,           // Use parent's environment block
    / |1 }% ?: l+ Y: m9 R! K4 l
  51.                         NULL,           // Use parent's starting directory
    7 r% n& H( r6 o3 j  c! F
  52.                         &si,            // Pointer to STARTUPINFO structure' f& q7 R) C% f
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    . V9 o. @& G7 X6 P
  54.                 )
    8 A0 ^: v$ U' {$ G8 s
  55.                 {1 S! b4 n7 k( [# {" l" O9 Y; J
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    $ f5 \' T4 K+ Z
  57.                         return 0;
    0 Q% h: T+ ~" u" p8 c: h9 U
  58.                 }' F& Q; Z; z% l6 \; B
  59.                 //Creating Process was sucessful
    1 B' p# a: g6 r8 I9 m+ Z* B7 }, ?
  60.                 else
    / s: J3 T: ]0 j3 S) E5 C
  61.                 {
    6 Q* h1 r/ q2 `& h5 T1 V  ]& p
  62.                         printf("Sucessfully launched DekaronServer.exe\n");$ w- P; S7 r. K3 ]* w
  63. 1 q" p0 I; [9 u, J$ Y( m4 a  I4 f
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure  a7 ^' K8 L$ p( N# }7 |: w* O' k
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ; a7 u5 g. R6 W  ]$ R% V. u- y
  66.                         dbge.dwProcessId = pi.dwThreadId;
    - s7 A; [1 O! F& ]- q' E, i
  67. 2 w2 t' i8 `# h
  68.                         while(true) //infinite loop ("Debugger")+ o. N; E5 ~& `  g; {6 X
  69.                         {
    ! K4 w6 ]5 O9 {. U9 R) P" C
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx- D# `# J( w8 o9 P5 h4 P5 v% y
  71. ; {0 E  Q) ^% ^' |3 E
  72.                                 /*) ]( J0 C/ \6 r9 u$ w
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

6 i" g. E8 _  c# o/ q! c
8 q) |; }# j  E/ U% L
0 j2 ~, D4 J5 o4 j1 [7 }
商业服务端 登录器 网站 出售

15

主题

256

回帖

1265

积分

金牌会员

积分
1265
金钱
869
贡献
120
注册时间
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

主题

256

回帖

1265

积分

金牌会员

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

3

主题

102

回帖

6441

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-11 11:06 , Processed in 0.066914 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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