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

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

[复制链接]

153

主题

334

回帖

5706

积分

管理员

积分
5706
金钱
1802
贡献
3417
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
( `. P! r7 M/ y  }$ A8 e$ r# o% z5 D+ y( d
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
9 w! L$ e! ?$ l5 ?# @* W3 T" F6 u, d9 A, g( R( u
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    2 n3 x" ?) D% z, v$ d6 ^* V( c1 C
  2. //9 _2 [: `$ o- M7 f& m

  3. # A0 g! ^4 u8 e$ x$ u
  4. #include "stdafx.h"
    ; i8 \, l: w; q0 D) ?3 K
  5. #include <iostream>( o. h# @6 a! _/ Z
  6. #include <Windows.h>
    ! e* `0 N. g+ K, c" ~
  7. #include <io.h>
    / p. o; v  K: S1 k. r& {
  8. # g3 n3 q1 S2 y1 U( k' Z' i) C

  9. 1 W* l5 x5 K5 [' L- r7 e! X4 J; W
  10. int _tmain(int argc, _TCHAR* argv[])
    4 w4 U) Y2 _7 f* {7 \5 t
  11. {9 Z) i+ g" c5 U3 Y& r# V/ ]
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    5 b# j$ T. ~0 @1 N' e3 n4 h- k& g
  13. 3 x! X2 ^+ i, T( ]! g4 v
  14.         //查看文件“DekaronServer.exe”是否存在* J: m$ H) P, o& y2 j7 [% W: l
  15.         if(_access("DekaronServer.exe", 0) == -1)
    8 S9 h' v( n0 i0 a8 ]) @4 W- `2 \& h
  16.         {5 l) `4 n9 c7 g6 w
  17.                 printf("DekaronServer.exe not found!\n");
    ' z) R: q' s* G2 l( U4 ?
  18.                 printf("Program will close in 5seconds\n");
      r( O+ p- Z* X9 L
  19.                 Sleep(5000);! ~7 S5 x+ h9 j  n8 I( x4 `
  20.         }
    4 @- y  |" }7 k9 z' N9 O
  21.         else
    & y8 b0 a" d! |5 U) R5 Z
  22.         {
    5 r; ^( w$ W% G) @" s# G
  23.                
    , f; v! f/ V0 v$ L2 R5 k2 Q$ ?' j
  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
    & y  I% n# g7 z2 I
  25.                 STARTUPINFO si;( ~3 o" P& n; }  h  s
  26. " _7 T! p! L. z
  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$ x( {$ j5 k# R2 }3 z  a3 k  m
  28.                 PROCESS_INFORMATION pi;
    / o. I. E' ^# N$ s

  29. # D8 S% v; }7 T/ U3 G( Y8 E2 P& P# a; E+ J
  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
    7 \8 w4 \0 C7 h  f+ q
  31.                 DEBUG_EVENT dbge;
    ) s$ w( G& p9 a4 j. j0 X, q

  32. ; |( j, w- @0 F5 Q0 Y
  33.                 //Commandline that will used at CreateProcess3 I) x3 i8 M, z+ n7 a+ y3 w( K
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));# S3 u( A* a% d( k! E% y

  35. * p) W2 w( s% f9 E: b
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    / B+ `: N9 y! B
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    # ~2 c  L1 h& a0 e9 T# P8 P
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    & o' l3 D7 O3 \
  39. 5 R" A3 r9 Y  l/ ^3 U& e

  40. 2 f7 d3 u$ q0 _/ \1 }

  41. 7 [- u" ~' C8 C6 S: \4 C
  42.                 //Start DekaronServer.exe 6 T% p0 I4 h8 I) ]& Q8 j
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx% h7 a* u$ w9 s. S% S8 J
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)8 t* V' E2 ?  }- ~; R
  45.                         szCmdline,        // Command line
    - d5 c' ^# r% N3 K& q: v- v0 A/ _
  46.                         NULL,           // Process handle not inheritable
    " j3 y6 U  V% o9 J& ?* b
  47.                         NULL,           // Thread handle not inheritable
    8 z5 I( J1 M3 a% T% ~5 U
  48.                         FALSE,          // Set handle inheritance to FALSE
    9 R# `% D) T# \# z0 |
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx' o8 A1 N) k% v5 [- U( g* p
  50.                         NULL,           // Use parent's environment block, J4 Q+ p) z" W% C
  51.                         NULL,           // Use parent's starting directory ' q! Q- [/ n6 g9 d5 S  W! B4 \4 b4 W
  52.                         &si,            // Pointer to STARTUPINFO structure
    $ S* n" h6 ]. k# E$ J$ c8 r  \
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure" n0 f' h$ n3 G5 w
  54.                 ) 5 R0 R; k, b7 v  D: u
  55.                 {9 T7 N% B. b$ U4 P" K( f
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    + i; b6 |7 @: D" @0 W1 J. g
  57.                         return 0;/ m1 C# v" R) L1 c: N: D
  58.                 }. R' F6 q. g) I! x* t6 n
  59.                 //Creating Process was sucessful2 L% l! ]" o- D9 x7 v
  60.                 else8 m6 z9 ^8 d/ o
  61.                 {
    8 |" H9 r  G* g4 z( `) k; b/ R
  62.                         printf("Sucessfully launched DekaronServer.exe\n");  y* l& q2 ]1 D* a, P
  63. * e2 |1 F$ u- n0 T
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure7 p0 S1 m6 p3 k2 J: i; h+ ]
  65.                         dbge.dwProcessId = pi.dwProcessId;) k0 I5 o& ^8 b, V( L
  66.                         dbge.dwProcessId = pi.dwThreadId;6 r3 b9 M8 x' }* E7 Q
  67. 1 L( W0 b* o0 k! P
  68.                         while(true) //infinite loop ("Debugger")
    + g( D" H! R/ x0 Z$ ?6 w# X- S
  69.                         {
    % p. _/ x& h, Z. g
  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 S  E4 X. W  ~  {7 f

  71. 9 S7 C: t" {4 {$ L2 Q/ b- Z
  72.                                 /*% x. @1 g. C- H3 v2 R% Y
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
2 q* F5 |8 W& `8 S; s4 S

( h% q1 K0 i3 ]* p4 c: W0 n& z6 o4 T* M
8 d7 G4 b3 M0 E2 y; ]
商业服务端 登录器 网站 出售

13

主题

250

回帖

1220

积分

金牌会员

积分
1220
金钱
779
贡献
173
注册时间
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

主题

250

回帖

1220

积分

金牌会员

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

3

主题

98

回帖

5091

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-11-26 05:27 , Processed in 0.064659 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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