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

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

[复制链接]

155

主题

348

回帖

6179

积分

管理员

积分
6179
金钱
1868
贡献
3808
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) 3 c2 |" U$ q9 O* r/ |  ?' {# _

  h. a. g0 n0 Z, p5 h) B6 p虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。) [* N' E, C# U3 D5 w$ o
# E$ {2 s& v1 J
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    4 G+ v. w7 O0 C" l
  2. //
    9 c' Q1 e5 N3 F5 K* O+ P! I" g
  3. 6 f3 _' m7 ]% B; u6 `
  4. #include "stdafx.h"
    . E8 X  w+ K7 c0 ?- E$ Q
  5. #include <iostream>& k/ g) T3 b( Q! `/ A( V$ H- ]
  6. #include <Windows.h>) O5 U/ F& _. O/ ]4 `1 a# d
  7. #include <io.h>
    ) f1 f; b" i( d' [; z$ d& p

  8.   Y& q) z7 O' w) o+ G$ \/ H

  9. : d  g. j% l, h) \
  10. int _tmain(int argc, _TCHAR* argv[])
    / @; B7 ?1 K4 `( ?# k2 M% `
  11. {
    7 u( I: i, l8 G+ ]
  12.         printf("Dekaron-Server Launcher by Toasty\n");( i" N# o% h6 H6 ]6 E, o

  13.   c6 E+ G7 Y( I& E' p  s/ _
  14.         //查看文件“DekaronServer.exe”是否存在
    / X3 T! R# \2 F) u4 T/ _) a& `
  15.         if(_access("DekaronServer.exe", 0) == -1)
    % E' v/ T$ c% D5 G5 @) |
  16.         {
    4 P6 e9 q1 b- {4 J
  17.                 printf("DekaronServer.exe not found!\n");
    7 K% v6 q3 |0 w2 n  i' V
  18.                 printf("Program will close in 5seconds\n");
    0 v  e+ `$ R6 \' ]
  19.                 Sleep(5000);: i4 S: ^6 \/ W4 k; Z
  20.         }
    8 g+ E6 c2 y/ y8 f2 A9 G
  21.         else
    $ w3 r9 ^4 K, ^2 T' E+ D, A" N
  22.         {
    . i$ e9 [$ i- J1 p7 w) d% {
  23.                
    2 a1 [  g: g2 z# Z/ \: q
  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
    / U) D5 k. Y6 h% V1 ?
  25.                 STARTUPINFO si;* s$ ?- \2 G  O" w0 R  J9 ]% e2 n
  26. 4 l1 e" x, _4 ]7 ]4 E) [
  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
    1 V+ z( _5 k# Q2 L
  28.                 PROCESS_INFORMATION pi;
    8 K9 ~# y# M* O0 ^+ c( M; s

  29. 7 i+ f/ ~; G; b
  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" G* A+ G4 Q0 D  v" p3 {
  31.                 DEBUG_EVENT dbge;
    4 T% ]5 |. b5 \  g* e! ?  p
  32. . S  f" u# ]/ e% l3 `2 z
  33.                 //Commandline that will used at CreateProcess
    " {! l( M( n7 ?
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ( Z3 ]3 n! F9 }, \8 m7 M( d4 Q

  35. 5 I& T( c  z6 \5 a
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)( h* M- b" ?8 `6 D8 |) C  w
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    ! G: X( `6 i; g- o: Y0 F) K
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)7 e; g* E3 N& O3 `

  39. # |& l8 {* G; G; r

  40. ) q1 M2 u4 s$ W& [9 ]+ |  z

  41. . P4 G" ]; e5 z" n
  42.                 //Start DekaronServer.exe 3 q% {' b) ~5 T3 H7 M1 N# L
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx: z* m4 Z* ]) R' ~! t$ b
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    # P+ D( u3 K& v" `5 |
  45.                         szCmdline,        // Command line
    " D" H6 C) z6 c) y5 |+ J
  46.                         NULL,           // Process handle not inheritable! {; ^. i# E- L
  47.                         NULL,           // Thread handle not inheritable/ D) Z$ u; ~8 [7 P- h
  48.                         FALSE,          // Set handle inheritance to FALSE
    " c: i' s" \- E- U( u
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx0 b2 l" R" o/ x0 w1 Q
  50.                         NULL,           // Use parent's environment block
    4 z5 C. M9 k8 M( ?* q
  51.                         NULL,           // Use parent's starting directory * G7 I' v% f! x- e% A) i5 F9 Z
  52.                         &si,            // Pointer to STARTUPINFO structure3 B# {8 @7 u+ U! J' v
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
      ?& B2 r- p/ K1 N9 i1 b. s3 t
  54.                 )
    1 K  j. D; \8 F- j
  55.                 {! h- O. M5 G& i; ^6 m
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );/ v6 F7 u0 _  O: n. y, e4 R
  57.                         return 0;
    3 L$ ?7 y1 |: n: k7 N; t8 L
  58.                 }; @! }& c' b7 `' ^+ s+ B0 C* T
  59.                 //Creating Process was sucessful% u0 }( k$ M% f9 o4 b9 U) e) H; t: i
  60.                 else
    " C2 p$ t5 Y" v; I& J
  61.                 {0 z3 q( |# O; g9 u7 k2 k" G
  62.                         printf("Sucessfully launched DekaronServer.exe\n");5 F9 G  J1 J/ n- j

  63. 7 I' j0 G3 V2 S  K8 `2 T: ]) f
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ( M, j: H' {7 f# y! S$ P7 y5 t
  65.                         dbge.dwProcessId = pi.dwProcessId;2 y- u% [' u9 G% T( @4 N8 u
  66.                         dbge.dwProcessId = pi.dwThreadId;% ~( ?! F  S: X' F% h" q
  67. 4 c1 Y# D" r0 k" i& a. u0 t0 S" ~  Q
  68.                         while(true) //infinite loop ("Debugger")
    5 Y- R- K- }6 }' d8 d: B$ b
  69.                         {1 W0 `$ `! ^+ `' b0 q' W
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    , }! `- R7 B9 b% i
  71. & J" e' X$ C) e, @& a
  72.                                 /*; v4 ?$ B( W/ e# X9 |* U: B
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
9 m# z7 V' D' f0 X
+ Z0 Y- A! N0 {& g# f8 _

- ]1 g* E" h8 _" p
商业服务端 登录器 网站 出售

13

主题

251

回帖

1245

积分

金牌会员

积分
1245
金钱
816
贡献
160
注册时间
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

主题

205

回帖

345

积分

中级会员

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

13

主题

251

回帖

1245

积分

金牌会员

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

3

主题

100

回帖

5721

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-1-1 23:59 , Processed in 0.085110 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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