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

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

[复制链接]

160

主题

382

回帖

7348

积分

管理员

积分
7348
金钱
2112
贡献
4694
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
" n9 V4 Y2 ?! s0 s& N7 J( _4 Z! T7 _3 J: P9 h, Q7 _
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
) T3 ]- r2 U7 C& e3 |
$ @. z; Y6 L" ?. R0 v4 p, i0 S
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。/ c% Q' e3 b) G
  2. //
    6 B, B* g- ^& ~/ e5 z

  3. 1 S( B+ ~2 b8 H- k7 Q
  4. #include "stdafx.h"' j! z7 b4 _- y. \* O& a! N5 l
  5. #include <iostream>
    " q0 b. f8 [8 U
  6. #include <Windows.h>+ R6 |$ j5 G/ z1 q; k% _
  7. #include <io.h>
    ) j3 j% |1 f+ y& Q% r

  8. 9 m& ?  Q2 I1 K- s, D5 N

  9. / a5 A+ A3 Y; `) c8 H
  10. int _tmain(int argc, _TCHAR* argv[])
    ; _' G. X) ~: ^, q% q
  11. {9 U% B* h% }  x
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ; Q, t- q# x7 _

  13. 1 {3 X0 d0 t- ]; t( X: N, H( z
  14.         //查看文件“DekaronServer.exe”是否存在
    4 m" m- N+ Q1 O8 F9 k3 g0 M
  15.         if(_access("DekaronServer.exe", 0) == -1)
    . h) s% ?4 \. O3 m& V- p# j/ A
  16.         {
    0 M4 k4 ~" ]- ?3 r7 e" X
  17.                 printf("DekaronServer.exe not found!\n");& `$ q% U8 F: |  Z& n
  18.                 printf("Program will close in 5seconds\n");2 N( `. P4 x% |" _: F- S
  19.                 Sleep(5000);
    2 r1 g) U1 ?# w; e  k% ^, W/ t
  20.         }4 @, O( y7 [$ r
  21.         else5 M- N% q3 w8 T  |( z6 L5 H  ~) K
  22.         {/ i+ j) N& A5 ]( K+ w" G: Q/ R7 z
  23.                
    / Q4 K$ }- T8 r! i2 B$ y4 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
    " K, U) K* u  ]3 x% K$ G' l; R6 _
  25.                 STARTUPINFO si;
    + p# H1 W3 _) K5 P. `; l0 ~  r* J

  26. 6 U: A+ G- I2 ?8 t3 V
  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
    8 e+ W: I" S2 t% M
  28.                 PROCESS_INFORMATION pi;
    % C  h2 f+ ^! G- Y

  29. 4 q1 F& o/ I8 p( k3 g
  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
    2 f  z0 m- v! V# h' o' `, S6 A
  31.                 DEBUG_EVENT dbge;
    1 D0 o5 O# g; s/ S* x

  32. 6 @* q3 B/ X6 [7 D
  33.                 //Commandline that will used at CreateProcess
    & o+ F7 a' `% ^
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));: N6 ?+ ?( |# t4 W8 n! E$ c0 D

  35. 0 r* ^6 \* y6 l
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made), ]7 G9 O" A6 P: d) `# S
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)' @- v) X" c( k1 ]- m: J6 t
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)) l6 i. v6 Y! @4 N

  39. ( Q6 N/ m! c) I4 @8 \3 P5 t+ q+ z

  40. 4 E* K) ^% g7 v

  41. / Q  ?3 O4 U0 \6 k/ }
  42.                 //Start DekaronServer.exe ' M9 o8 o" p$ \5 X8 t+ ~
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    4 x  L' Y1 R) M( e
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ) j2 m- @7 l0 v: k" w2 L
  45.                         szCmdline,        // Command line
    ; V: H- B3 c$ Z1 T  z' ^
  46.                         NULL,           // Process handle not inheritable
      ~2 ]% I3 K0 G3 Y
  47.                         NULL,           // Thread handle not inheritable
    # b+ D6 u; a7 A& u! {1 A
  48.                         FALSE,          // Set handle inheritance to FALSE
    & A, h; F4 g1 V, B  I
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx9 M5 R- V" |: S
  50.                         NULL,           // Use parent's environment block
      A, U9 t; y9 ]
  51.                         NULL,           // Use parent's starting directory
    + J. {# f! i, c9 @$ j' n
  52.                         &si,            // Pointer to STARTUPINFO structure
    + K+ S7 ^/ g$ D0 ?6 j5 e, O9 q6 j
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure3 {) x: t+ d& s( w4 N6 T  F2 y
  54.                 ) ; n; F7 ]5 p7 a
  55.                 {: X1 S  u! L, A% N0 I$ Y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );1 S6 u' x# e; ~+ c' T
  57.                         return 0;* H9 l* i2 D$ L
  58.                 }
    4 @; a9 U2 E6 B3 u
  59.                 //Creating Process was sucessful
    " U# _/ L( _  f* S
  60.                 else
    5 t. `8 D$ F/ H: d  E. W0 R, {
  61.                 {
    . V  e. s* e4 y" x% M( t6 S) Q
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    3 E1 ~  F; f" [8 Z

  63. + L+ e& S6 Z+ m
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    $ k) R' J0 n6 Q$ b5 k9 a
  65.                         dbge.dwProcessId = pi.dwProcessId;" H! J/ E: U4 Z0 a& K6 m" F7 j9 ^
  66.                         dbge.dwProcessId = pi.dwThreadId;2 Z9 l: X& `4 j" Q$ p( V4 C! X
  67. , V' {5 f# X, ]9 E0 h
  68.                         while(true) //infinite loop ("Debugger")& Y  d& X1 H' W+ x# @3 z3 u
  69.                         {
    ( ?# t2 f8 M* V: l. X: }
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    5 w& u7 W- Z3 C; c: F- E  v

  71.   p0 l( [% T& X
  72.                                 /*
    4 S% F6 p" k5 Y# b3 E
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

4 e4 C! z/ I) \( ^7 F0 }) i
# j9 k& ]+ T8 T& b7 _$ q( k, |& [" G
商业服务端 登录器 网站 出售

15

主题

258

回帖

1270

积分

金牌会员

积分
1270
金钱
917
贡献
75
注册时间
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

主题

258

回帖

1270

积分

金牌会员

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

3

主题

102

回帖

7737

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-4-22 14:13 , Processed in 0.038863 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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