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

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

[复制链接]

157

主题

364

回帖

6933

积分

管理员

积分
6933
金钱
1968
贡献
4444
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
5 X+ R) [1 |& ^& z2 B5 G# C( O& h2 X4 v: t# G
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。% M: q  R4 `# L  c9 I' O

; p% V9 v9 f$ y9 L1 s4 T, @, m
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。: W' g2 Y- a# B( c4 t3 k5 y5 F
  2. //
    3 r9 @. a2 v0 _+ M- {9 t! A1 \

  3. ' @& D7 s0 n8 @$ U
  4. #include "stdafx.h"% c* f* b' }6 q2 \0 I7 ^
  5. #include <iostream>
    ) ~8 i% x; \# V0 u
  6. #include <Windows.h>
    9 |7 y, i* l1 s, [" b* H
  7. #include <io.h>5 m* @7 T) g: \: S
  8. $ o, Y" o" j9 {, \

  9. . }, E+ |0 J' O' o% [, D
  10. int _tmain(int argc, _TCHAR* argv[])
    9 @2 |9 p( j. W% O
  11. {4 a8 Y: V0 D: `% O' _8 p
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    & Z$ U4 n; {! x2 B7 h$ @

  13. # L8 Y! _: _7 v; l, G% H
  14.         //查看文件“DekaronServer.exe”是否存在
    4 n, u! o( z4 p6 Z+ C9 a
  15.         if(_access("DekaronServer.exe", 0) == -1), u, {) ?# L$ D, G
  16.         {
    3 X* z. K0 E( C( f- C! S  z4 _2 H
  17.                 printf("DekaronServer.exe not found!\n");
    - P% J0 G' v$ F) b! V
  18.                 printf("Program will close in 5seconds\n");
    2 h5 q6 n7 J% |% Z# ~: S
  19.                 Sleep(5000);
    $ ~& r) q9 q$ a1 G# r
  20.         }
    . A- ^% ?" \4 X- G/ k* i8 u: t
  21.         else
      P: s1 t+ w1 [/ `6 W1 m* c
  22.         {) l- V( l% w5 O  C0 S- C. b  M/ G
  23.                
    4 s1 J' w- x( T5 a+ v
  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
    / _, w! S2 B+ f- A, V2 X! p9 Y
  25.                 STARTUPINFO si;# j0 Z) T( V& T

  26. ' D& K! S" S2 g  t
  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
    5 Z& t1 p1 p0 C
  28.                 PROCESS_INFORMATION pi;
    1 {- V3 i$ ^1 E

  29. . q  N* _# Z8 g: Z
  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
    ; [6 Z8 Z/ K4 C: m! F
  31.                 DEBUG_EVENT dbge;- G5 n: @, Y+ o! o0 m0 g
  32. ! z* z# w0 }, z% L$ B% P
  33.                 //Commandline that will used at CreateProcess9 \6 G% w5 q6 L1 C5 M
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    1 Q1 x" I& W# P! b/ T. K$ p. }$ }  i

  35. , k( v/ a" e' r6 V
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)7 P5 k3 u0 B7 r9 k
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    3 F# I; B+ {& L" }3 D  n: m4 C! h2 X
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made): X" J5 f5 ?) Y1 ?, R  F. ?

  39. : s( A; k+ k% J$ Z; ?) r7 c: `

  40. $ l7 A" a- ]. n  `

  41. # I& P5 Y2 l* U9 I  D0 V
  42.                 //Start DekaronServer.exe
    # n6 o, o3 y7 }6 {' f4 k. l
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx2 k8 ^# B7 W3 k: S8 t; G; O
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ) F- h5 }; a5 U
  45.                         szCmdline,        // Command line$ G- E1 j( V3 k. v+ l
  46.                         NULL,           // Process handle not inheritable" P) R* X6 _/ Q7 ]
  47.                         NULL,           // Thread handle not inheritable8 g# _5 n9 P- w' @, H( f4 x
  48.                         FALSE,          // Set handle inheritance to FALSE6 n/ R, n& }1 }
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    1 {4 c8 ]2 ~: g- d4 n6 c. L/ u
  50.                         NULL,           // Use parent's environment block
    8 ]+ r  I1 ]  l; D( C
  51.                         NULL,           // Use parent's starting directory
    " E* T, l$ v6 [$ y& ^
  52.                         &si,            // Pointer to STARTUPINFO structure2 S, ]% a; _4 u+ X
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure7 X( `$ r& l, i7 |9 u
  54.                 )
    1 @* R0 B$ N# A  E/ Z% q. o
  55.                 {
    ' J2 t4 q4 Q; q7 ?( L5 \$ V
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );" S" C* G. i' P
  57.                         return 0;
    2 h' G  j/ ^' b, T( B+ x6 v
  58.                 }! h' N+ I% v% f2 o/ I* ?, k
  59.                 //Creating Process was sucessful! x& F# L0 p! z7 ^
  60.                 else1 z- u: X  D: k5 U) K1 w
  61.                 {
    * u* f5 s! V2 l3 p7 b9 G
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    7 X- F  U! F8 ?" O

  63. 3 ~* a8 W  A$ h5 n* M
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure+ ]0 R! Y2 x: ]& X- }8 d4 m- e
  65.                         dbge.dwProcessId = pi.dwProcessId;: d0 \5 I$ ~) h1 W7 M+ O6 s
  66.                         dbge.dwProcessId = pi.dwThreadId;
    9 c, K3 e, p6 j$ D6 W
  67. 1 k6 R: h# p- L# g6 B! A
  68.                         while(true) //infinite loop ("Debugger")& Z5 b) s6 r* S) o
  69.                         {
    ( B" Z( s" J% L( h4 r1 N
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    ) E7 w- O; C& [6 G! R$ r3 Q
  71. 3 R1 ^3 K- J9 a1 T2 V
  72.                                 /*
    3 b9 `7 L& i5 r. P; r
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

/ o. ~7 ~( B* A/ {! R% T3 _" d  y  a8 [
* r* w5 i4 W4 s+ s8 ?: ~
商业服务端 登录器 网站 出售

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

回帖

6838

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-7 18:55 , Processed in 0.051041 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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