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

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

[复制链接]

157

主题

360

回帖

6663

积分

管理员

积分
6663
金钱
1930
贡献
4216
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献)
% L: {- D: ]& A4 {; ]2 V+ Q5 i
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。6 l" A: v4 b$ b0 s/ l

/ _  x9 p, e4 V% [5 p( B5 W: E
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。9 U. [# u0 m/ x# v! F$ c! [  @
  2. //
    2 ~) p- ]9 P) u" n. `

  3. + D! M& T. J& v4 c/ y3 h
  4. #include "stdafx.h"4 \2 C0 X6 [. _/ f4 W9 J
  5. #include <iostream>
    : g) y; D; }# V% O" E
  6. #include <Windows.h>1 T+ H6 W( |  V# e( @, Y( J2 C
  7. #include <io.h>
    ; ?1 @$ q3 U, R2 S

  8. " w1 i$ B+ J9 Y" H& @

  9. / s& g" C9 `) D% y1 c$ Y' A
  10. int _tmain(int argc, _TCHAR* argv[])' A; b8 u3 o/ F" R' f
  11. {
    4 F( U# b% j! M- Y) U5 b
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    ! t: m4 b$ c( M9 h; _- m, r

  13. * Q3 s' }+ I2 p+ o9 z8 E
  14.         //查看文件“DekaronServer.exe”是否存在
    2 h2 Z6 f% e- s& x+ R
  15.         if(_access("DekaronServer.exe", 0) == -1)
    2 M8 h4 f0 ^* K0 e5 @) ~
  16.         {
    + }* N2 J6 S3 G: N
  17.                 printf("DekaronServer.exe not found!\n");" |5 n7 A* W  u* C3 G
  18.                 printf("Program will close in 5seconds\n");9 s$ N% Y6 m. C; r+ O
  19.                 Sleep(5000);
      h1 d% W+ A6 ?
  20.         }- _$ A8 C8 ?+ m9 |8 A& \
  21.         else
    & V* I) c  I8 [# v. ~
  22.         {
    % p( I+ X) A4 o8 Z/ @" x
  23.                
    " }+ }/ r, q# H1 `
  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
    + v/ n: _( B1 t5 e0 x
  25.                 STARTUPINFO si;
    ; C' |0 r' n# m8 Q8 b8 V: d
  26. 8 e) }* d  |  |- l/ K0 {
  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
      J* Y, |' j, f5 F
  28.                 PROCESS_INFORMATION pi;
    / r" a* u0 F# z. X  k" u" J

  29. 5 z) p+ F9 g. a; d% a2 C) R
  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
    : }9 F9 J$ h: Q1 D7 k
  31.                 DEBUG_EVENT dbge;: A8 U& d2 \" [$ X

  32. + D5 s$ x1 V0 ]& t  p5 d
  33.                 //Commandline that will used at CreateProcess  c/ M8 h, M) U
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    ; N; M7 Y( Y7 A! u# u' X

  35. 3 `+ L3 Z3 A" h. i
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)7 \: o, W- N' g$ B3 h
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)( k, V* M! g/ G' {- @9 m
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)5 O- {5 s" B% l/ H& ~0 P  D

  39. # B; u4 N& \7 t% I6 ^
  40. : m  D, L2 w- r8 a& R4 ~

  41. 6 ?$ E7 w# Q4 h+ t
  42.                 //Start DekaronServer.exe
    ; Q( n! D5 [- Q
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx3 U5 a& \9 }6 L
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)2 Y4 P( _: |9 Z
  45.                         szCmdline,        // Command line: b4 L( @: K  Z% L* i! J& J- j
  46.                         NULL,           // Process handle not inheritable2 n" p2 {# {9 e3 t7 O3 D
  47.                         NULL,           // Thread handle not inheritable
    - W1 d/ s9 T' F, P- o
  48.                         FALSE,          // Set handle inheritance to FALSE% q* g3 j3 a7 F& E+ J7 G; o4 z
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx  b+ f* }$ V) _( i
  50.                         NULL,           // Use parent's environment block
    + C  I! r6 B* D  e/ [
  51.                         NULL,           // Use parent's starting directory
    7 |$ k2 h5 F! U
  52.                         &si,            // Pointer to STARTUPINFO structure
    / x5 n" t/ C% d' ~7 Q
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ; w% m4 d; m: X+ F! z
  54.                 )
    5 X7 g! G8 x) i" I/ M
  55.                 {
    ; N" ]* k8 W( o1 L
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );1 I, Q$ ]6 G) f& a$ T# c, `3 `
  57.                         return 0;. p( P& C: K, `0 o
  58.                 }' `/ K) ~$ x+ L
  59.                 //Creating Process was sucessful# g$ |% g* [  D4 |. M
  60.                 else* `, d5 i- N1 M+ H; m, F  W  T
  61.                 {2 J- X7 |: o9 U2 o+ h) E' }
  62.                         printf("Sucessfully launched DekaronServer.exe\n");5 I3 S: ~: X* o- |0 {
  63. & l" X  ^4 ^7 C' E% q8 O$ i
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    8 j% ~" e  d' \' c
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ) A4 j: J( ]' |
  66.                         dbge.dwProcessId = pi.dwThreadId;
    . M+ Z7 }+ [. k

  67.   w: N1 ]9 W2 b5 C9 c
  68.                         while(true) //infinite loop ("Debugger")
    / r1 Z4 t2 v5 @% j: R/ k7 e" D
  69.                         {0 j; Z: Z; k$ l( {. U
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    + ]7 W' N4 O! M1 @& ^7 O' P
  71. 3 E  q2 \+ T, O' p) `
  72.                                 /*/ z1 E6 `# }4 p1 a
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

1 T" G& B$ W4 k4 y. n9 g! {9 M* ^0 @7 |" H1 Q& z
) u9 y; r/ F9 c* W
商业服务端 登录器 网站 出售

15

主题

256

回帖

1259

积分

金牌会员

积分
1259
金钱
865
贡献
118
注册时间
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

回帖

1259

积分

金牌会员

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

3

主题

102

回帖

6341

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-2-5 23:18 , Processed in 0.068344 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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