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

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

[复制链接]

157

主题

366

回帖

7083

积分

管理员

积分
7083
金钱
2024
贡献
4536
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ! _! r- c  N: z  g" W. u$ K
' o/ |" f- @1 ?) i6 _, o# z
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。# l# {  f# w, m$ J( \

* P) H* O: r3 |8 f0 H" _3 q9 E7 h' p
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。' X8 V, b4 {2 I
  2. //5 w9 ^5 s2 c  k8 o/ t5 i4 D
  3. ! M/ j- j) ]6 C; M9 r& A
  4. #include "stdafx.h"4 K) w0 X4 F4 z4 K. d! `/ M
  5. #include <iostream>
      n- x/ N/ }/ j; {# W
  6. #include <Windows.h>7 W8 `6 f2 k. U# D, x
  7. #include <io.h>) ]5 V4 y, e8 |: S: G' z, K
  8. $ Y+ m/ M( s" K# k: T- ^( r6 T% G
  9. ' v! s  f' R* o( q
  10. int _tmain(int argc, _TCHAR* argv[])
    ' I/ e( L: S9 a& {  z: U- d
  11. {3 A- x1 O6 Q' e6 C. A
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    - p, H1 m5 D! t6 g' v3 F
  13. 9 a8 ]" Y" V8 C) o
  14.         //查看文件“DekaronServer.exe”是否存在
    6 X+ _! T5 a# u1 ^
  15.         if(_access("DekaronServer.exe", 0) == -1)
    ' Q0 w5 t( a2 |0 p" }' E
  16.         {! w- a* J0 r; I( c* l6 T; r: e
  17.                 printf("DekaronServer.exe not found!\n");/ v: j/ g% W0 I6 ]9 f
  18.                 printf("Program will close in 5seconds\n");
    1 h. k4 F$ p5 {, I- K; |! c* j
  19.                 Sleep(5000);
    2 m( B! R: S5 f. U$ d
  20.         }" k) Z5 a0 [; v' ?+ b  v
  21.         else- Y9 h- j+ i7 j, W3 B0 W
  22.         {# s, K  o! Q0 L: v: U
  23.                 ' p" e/ a$ @+ g) b
  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).aspx2 Y8 M' T, F( V3 M5 k5 N8 N) k
  25.                 STARTUPINFO si;
    . t: R' s+ m1 t  p
  26. 1 _8 U7 Q% V; m4 Q( n
  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 e7 }$ y# C8 f% R" e
  28.                 PROCESS_INFORMATION pi;
    ( K* K5 e0 K2 u. p& R

  29. 4 h% r" _; G# w" l6 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
    / y5 N' _0 Y3 V) s
  31.                 DEBUG_EVENT dbge;2 F6 P3 ?8 a$ @& o7 S: M
  32. * ?# g/ v! E) R, A/ W. Z8 R, X
  33.                 //Commandline that will used at CreateProcess' c2 x1 s' x' M* X+ a
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    : n6 M$ ~8 {* T4 m; [: r

  35. " `* s% V2 l0 h, p
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    * j: O- U% t" l: h, V$ L+ q$ h
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)9 ^9 c9 b, R) k( f4 q
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)+ |1 U' M9 f* m$ u7 d5 \% B
  39. " d$ C5 u5 u* W4 H# ^& S

  40. ! B0 e3 w. `0 |# u

  41. 4 o6 Z1 ~# |) q! \) i
  42.                 //Start DekaronServer.exe
    . O( Y1 Q, {# G  R0 y3 X3 w4 s
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
      G& @9 f0 i, U6 L0 V" k6 j, c
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)
    ' ?1 e* G+ ^7 K0 p1 i# b. p7 k- E
  45.                         szCmdline,        // Command line* S  S" w) G3 N  O( ^/ Z% i, N
  46.                         NULL,           // Process handle not inheritable
    - c* @- V7 H( B  \+ D
  47.                         NULL,           // Thread handle not inheritable1 [% |( Y& O' o
  48.                         FALSE,          // Set handle inheritance to FALSE. d  z6 S  y2 y/ @
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    + S& B# e: _. w
  50.                         NULL,           // Use parent's environment block/ |0 G  D$ L5 C: `
  51.                         NULL,           // Use parent's starting directory
    , ]! I5 V2 E: A/ y' {4 ~' K
  52.                         &si,            // Pointer to STARTUPINFO structure
    ' G( U# ~0 w- G- I4 [, g- F9 D
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure+ W' X+ T: C/ ^5 O! o" Q" o
  54.                 )
    8 G2 ^* L3 x$ S, v; b9 ~$ G
  55.                 {
    0 G: {6 Q8 ]8 J0 ?
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );* t8 P, x0 X, ~& D7 M* Z0 @
  57.                         return 0;
    ! v- |1 S6 \8 z& C7 q% b: U
  58.                 }
    ! {# c$ b# `' ?! ?' g1 i
  59.                 //Creating Process was sucessful# i: o5 N" g" x/ N! v, E, G" U
  60.                 else% q; k8 y+ m  ~% Y
  61.                 {& D! D% U# s9 ?' S5 F
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    * s% H9 p2 a/ f: c+ m

  63. ) K6 h: X( O+ j/ G! r$ b
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure% U# x3 G$ @' ^
  65.                         dbge.dwProcessId = pi.dwProcessId;
    ' P5 N1 I" N3 j
  66.                         dbge.dwProcessId = pi.dwThreadId;1 g% {: T) p( G) i

  67. - @7 b. U$ P- M, L) ~# y1 z2 I
  68.                         while(true) //infinite loop ("Debugger")
    9 H* M) Q/ ?" r+ E( j0 J# q: ~
  69.                         {
    6 \/ A( {1 K# c4 Q9 {$ {
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx7 v! }: G5 o9 ^, c
  71. 4 }" |% O  \; [" n
  72.                                 /*
    ! x  @& k5 W' W/ s& B5 r+ ?
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

/ ^6 j5 V& E, `' ?# k
3 \: J# l; D! H2 ]# _. U' r: Z8 V2 \; V0 m
商业服务端 登录器 网站 出售

15

主题

257

回帖

1234

积分

金牌会员

积分
1234
金钱
896
贡献
61
注册时间
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

回帖

1234

积分

金牌会员

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

3

主题

102

回帖

7237

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2026-3-28 11:13 , Processed in 0.040893 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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