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

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

[复制链接]

154

主题

343

回帖

5872

积分

管理员

积分
5872
金钱
1839
贡献
3536
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) ; f- m( b/ S2 R, [! p# j
. x% N* E! `! P" D. q6 x
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。/ C& H+ _- r5 A. f" H6 ~6 L

& [) P( r4 s8 g- r. C. H
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    3 S! p4 z6 A' _* ?/ m0 u9 d" M% |
  2. //
    ' w* ^& Q' R/ B
  3. # x: w7 S( a4 D% p' t/ K+ ~- A
  4. #include "stdafx.h"
    ( g5 @/ ]; C' }2 O1 N- y
  5. #include <iostream>
    4 ~( M. _+ S$ A4 H
  6. #include <Windows.h>
    9 o* C* g/ {4 s& W% A. g
  7. #include <io.h>9 e/ z; }4 G: R$ U4 i
  8. + N1 H9 J2 G6 A6 t
  9. " ?$ j; b, f5 W" D2 ^' a% h5 F5 {
  10. int _tmain(int argc, _TCHAR* argv[])6 P) L; J% l6 v' g5 _6 m
  11. {
    + L+ c; K" e) ?9 W
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    . s4 f3 I' Q/ Y1 y5 g

  13. 9 i6 g" T  f2 \' C+ L
  14.         //查看文件“DekaronServer.exe”是否存在
    ' _8 q+ d: ?) H: g; Z( ]6 z5 e1 m
  15.         if(_access("DekaronServer.exe", 0) == -1)3 r" A9 c" E# K& B! y- v
  16.         {
    ; a3 D* V* J# \0 C
  17.                 printf("DekaronServer.exe not found!\n");
    ; k3 b% q, Z6 t' A( Q
  18.                 printf("Program will close in 5seconds\n");5 C) ^% \0 X$ A/ U3 S
  19.                 Sleep(5000);
    7 O! {0 d  c' L; {* P5 T  Q* L0 m/ n
  20.         }
    & y9 G* ]4 P3 |1 M6 i1 H
  21.         else
    ' C6 g+ h  q) d1 }' c7 `: W
  22.         {
    ' d2 K" R# G$ m8 F% k
  23.                
    . t6 |5 v3 U/ Y# m6 W7 |: r
  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
    1 y4 s% A% [7 w. @; V0 r6 C* v
  25.                 STARTUPINFO si;
    ( H9 M* r# O) Y, ^* u4 H7 [
  26. . T) k% [/ l# {5 G
  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).aspx7 e8 s) t( I9 R9 v: I- e' W4 F. e
  28.                 PROCESS_INFORMATION pi;
    2 k8 D/ q) Z7 K; u( t% Z5 T
  29. . [; ~/ \& O5 P2 o1 W7 q
  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
    ; X6 W+ j4 ]7 O2 n& C) u& H
  31.                 DEBUG_EVENT dbge;4 n2 s" q9 o3 i4 H/ S* m  I+ d
  32. 3 G: D/ e" ?# }9 h; E' W7 W
  33.                 //Commandline that will used at CreateProcess0 {! Z  Z& A5 f7 K4 d
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));% p% v5 y1 G$ M4 a* F; p8 t7 w- O' N

  35. + \8 ]( S  Y1 j: r6 F% x1 O& Q* c
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made)
    : t* E& b. g- c* l
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    , f. W) B% K( f; k7 h1 ]
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    " d* N- x3 I* [

  39. ' X; \8 u) v0 O' Z6 e# G# I. A$ M
  40. 1 Y3 r  g* @8 o% F" W" h
  41. . Y2 |6 ]( k9 f* w+ s$ p
  42.                 //Start DekaronServer.exe ' X, Y% o# d2 @- u, p& }
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx; F4 |* G: x5 x4 ?) [( t
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)6 L0 Z8 Q+ }# M" u4 b5 y: j
  45.                         szCmdline,        // Command line- V1 l! _4 x% L% Q& M+ W
  46.                         NULL,           // Process handle not inheritable
    ! a! G. E  D$ Q, z+ _# Q; }
  47.                         NULL,           // Thread handle not inheritable
    8 }' k6 v; F! ^3 A4 b$ _
  48.                         FALSE,          // Set handle inheritance to FALSE& E. V7 `+ S5 o& Y9 r5 ~+ E
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    9 Z- z/ j! [; [4 ^
  50.                         NULL,           // Use parent's environment block
    0 S, V: s# h+ x9 r7 Z
  51.                         NULL,           // Use parent's starting directory ( k' s, W) T$ M6 M. l& a
  52.                         &si,            // Pointer to STARTUPINFO structure; N$ ]/ Z: x- Z: \" C+ c+ o! B
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure
    ' _8 K; B, z  \$ M9 }$ I1 ~0 T
  54.                 )
      J, ^" G+ i9 j2 j! B9 J& }
  55.                 {4 J7 e1 C9 J2 J6 E. F. Y
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );; L  V3 W, ^# b+ }6 o8 W, |" R
  57.                         return 0;6 ^+ ^# X0 y# L( f5 a; J1 x
  58.                 }
    4 s' g6 D2 [3 N# S9 y+ x
  59.                 //Creating Process was sucessful
    4 o" ~4 D% L9 ?+ u+ a0 N: @4 C3 m
  60.                 else
    ! s; @3 B" h- U# U5 h' N* l3 N  [
  61.                 {' u8 x" S, u, q3 G4 X2 n
  62.                         printf("Sucessfully launched DekaronServer.exe\n");
    3 d/ c- B1 e& m- y& Z

  63. , }8 r2 N6 ~/ [; U4 f% o) f  a
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    6 {8 K8 s* F" c% C% `
  65.                         dbge.dwProcessId = pi.dwProcessId;1 b, _2 ?, f0 ]7 w* @. N- b( p
  66.                         dbge.dwProcessId = pi.dwThreadId;
    * _. S( E3 z2 z& A3 V& x

  67. 9 Y1 b' a! ~( a+ E( w" G0 X) \& Q, W
  68.                         while(true) //infinite loop ("Debugger")
    3 Q/ v& k6 e) ]2 @+ P0 U" Z- r+ N
  69.                         {9 [( n9 O9 q( |  Q
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx
    & T) K; a' a( j- Q4 \( X9 _' T
  71. ; ]) h* _4 ^4 Z1 Q' E1 H
  72.                                 /*& R! N- x0 a- H( f  F4 R
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码

3 d# R; r/ U- k
; z7 r* g) `3 {. u* j; n. z$ B+ m- V0 ~1 _& C: o2 p( e
商业服务端 登录器 网站 出售

13

主题

251

回帖

1258

积分

金牌会员

积分
1258
金钱
802
贡献
187
注册时间
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

主题

251

回帖

1258

积分

金牌会员

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

3

主题

99

回帖

5533

积分

论坛元老

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

本版积分规则


Archiver|小黑屋|EGameol

GMT+8, 2025-12-17 17:26 , Processed in 0.071386 second(s), 27 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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