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

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

[复制链接]

136

主题

201

回帖

3936

积分

管理员

积分
3936
金钱
1387
贡献
2212
注册时间
2023-11-3
QQ
发表于 2023-12-9 17:54:37 | 显示全部楼层 |阅读模式
SourceCode_Win7DKLauncher.txt (3.77 KB, 下载次数: 0, 售价: 5 贡献) , s7 |# n/ g% P5 o. @2 n1 M% K& {# C
+ ?% h$ x" S/ }) L1 F
虽然很多朋友有了成品的工具,但是我发的是源代码。。。需要的可以拿去研究研究。。
6 L" }" v8 m0 o: E# E9 g, |  {# m5 I  a8 ]
  1. // Win7_DKLauncher_v1.0 : 定义控制台应用程序的入口点。
    8 M/ }2 a' }8 j. C3 j' t  h
  2. //# t: f' G9 Z+ ?. K0 f) {: c

  3. . Y2 ]2 E; N/ T. S! z. q3 s
  4. #include "stdafx.h"
    2 y/ M( s, g; V+ ^' _
  5. #include <iostream>
    % k' o' s; d- U4 _* u& I0 s
  6. #include <Windows.h>
    . [0 }! U+ o) V' @  l1 w7 \: i
  7. #include <io.h>
    3 o' o5 T1 r! V+ O$ Z: _

  8. 7 u+ ]* d4 d2 C0 P. i
  9. " M9 t# L! y' T4 e% M# F
  10. int _tmain(int argc, _TCHAR* argv[])
    % ^- N: O3 ?; |' G, H# ~$ m7 D
  11. {
    ( Q( D" s: E- j: U: W
  12.         printf("Dekaron-Server Launcher by Toasty\n");
    . l; c# S5 U2 t' y& Q

  13. 3 g) \8 Q* z1 i# Z% X
  14.         //查看文件“DekaronServer.exe”是否存在+ s3 D+ f& C& M
  15.         if(_access("DekaronServer.exe", 0) == -1)! q" A; k  y7 d* h) x
  16.         {7 E- \, i  j- H, g% m3 G! f
  17.                 printf("DekaronServer.exe not found!\n");8 @* ~: g4 ?2 ]5 z$ Z
  18.                 printf("Program will close in 5seconds\n");
    3 `9 i7 ^& F4 W0 X/ D* d- [7 ~
  19.                 Sleep(5000);9 U: Z+ c% I* T
  20.         }: Z4 J1 H1 m8 }- q- f
  21.         else) F; Y' G: B) l9 I9 K( K
  22.         {
    0 I3 T% O8 _6 ?' j
  23.                
    8 O7 B- M: c& @* u2 L2 |! c
  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* s: f$ H4 a7 E, t9 G; x
  25.                 STARTUPINFO si;
    + v; C* }+ A- X" s
  26. ' T% E( E3 i4 h$ e& z5 ~
  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
    - N8 d/ F6 u, S5 S3 h
  28.                 PROCESS_INFORMATION pi;! @2 W5 G% U5 c6 z$ `: g
  29. ; R* o$ q& X/ p! d
  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* ~) s& a$ X3 a8 I
  31.                 DEBUG_EVENT dbge;9 R% b* U* O$ W
  32. & `7 U  P. a8 q! o5 l8 R
  33.                 //Commandline that will used at CreateProcess
    . e) X  \5 U" w
  34.                 LPTSTR szCmdline = _tcsdup(TEXT("DekaronServer.exe"));
    2 L) N/ Y2 p4 Y( N* V1 G

  35. . {1 b7 N8 S5 s% G# s6 P- i
  36.                 ZeroMemory( &si, sizeof(si) ); //Set memory of the startupinfo structure to Zero (because no initialization was made), O( @% |9 f+ t& r2 m) N
  37.                 si.cb = sizeof(si); //Size of the Structure (see msdn)
    $ t9 ]- I# S2 t* x( }4 q/ C& f
  38.                 ZeroMemory( &pi, sizeof(pi) ); //Set memory of the process_information structure to Zero (because no initialization was made)
    & Q) f* {. i0 v: J& t& k8 A- F
  39. % V* l+ n: s* r1 f5 P
  40. ( R+ C, i" M3 c/ y$ j& z/ |

  41. 9 j8 A) ~1 D6 X* c& F
  42.                 //Start DekaronServer.exe
    7 C7 Q% X' j8 _) r
  43.                 //More info fore CreateProcess function at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
    8 D- D! O: F$ ~9 Z$ S
  44.                 if( !CreateProcess( NULL,   // No module name (use command line)* |) [5 w/ q* o; p# ?! u
  45.                         szCmdline,        // Command line
    * K- o7 h4 D% R* ?$ |. j! c3 C! c" s
  46.                         NULL,           // Process handle not inheritable$ R1 r+ w5 ^, s  E4 X
  47.                         NULL,           // Thread handle not inheritable
    - n, R- B( h% D& E. [* p! b
  48.                         FALSE,          // Set handle inheritance to FALSE; O9 D/ o9 q2 p, s. W
  49.                         DEBUG_PROCESS,  // Enables Debugging for the started Process http://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
    5 d! K/ m3 l" b1 T  }% u
  50.                         NULL,           // Use parent's environment block
    6 k) w7 s  D* \1 {9 i1 t
  51.                         NULL,           // Use parent's starting directory
    / q9 z: J$ q. d- R
  52.                         &si,            // Pointer to STARTUPINFO structure
    # q" u1 ~# d: i  X/ l1 [
  53.                         &pi )           // Pointer to PROCESS_INFORMATION structure; W2 C8 H( b4 B* n: A0 x5 b
  54.                 ) " A$ m- }) [: n- q, j" s: [  @+ l& a+ u
  55.                 {! X+ i; `' v  S' n
  56.                         printf( "CreateProcess failed (%d).\n", GetLastError() );
    + g) t/ `% P; G/ y' a% r4 c: H/ [
  57.                         return 0;
    # g% n9 X7 r+ I) k. c
  58.                 }1 W& {9 o% j- e
  59.                 //Creating Process was sucessful
    3 F* ^: x4 A4 O6 W$ t7 d" s5 ]7 i- C
  60.                 else2 @% A# B: X$ l  c2 k( W( |: g" i
  61.                 {
    - ]" S! z6 ^, T7 n- i  \
  62.                         printf("Sucessfully launched DekaronServer.exe\n");) v9 e8 ~6 @7 W; K% {. _
  63. % d; T; I* a+ e6 J* m6 h7 b' |# y
  64.                         //Write ProcessId and ThreadId to the DEBUG_EVENT structure
    ( ]; t) f; W' q2 G1 `* C6 [# p. F
  65.                         dbge.dwProcessId = pi.dwProcessId;0 D' V6 y* V$ q/ P; t
  66.                         dbge.dwProcessId = pi.dwThreadId;
    % f$ X& J* U4 [) K0 F
  67. " r5 w- K0 I- `+ Q. Y
  68.                         while(true) //infinite loop ("Debugger")
    6 k9 t, ?. Q+ F# r
  69.                         {
    # `) `, r! `" |; w. U+ k8 v1 W. e
  70.                                 WaitForDebugEvent(&dbge, INFINITE); //Wait for an debugevent to occur http://msdn.microsoft.com/en-us/library/windows/desktop/ms681423(v=vs.85).aspx# a6 @% L; @" w/ ^6 J% G

  71. ! s) q! B- a/ J
  72.                                 /*
    3 |7 `1 `: _+ R# F7 V; g# ]: R
  73. <blockquote>通常,您必须在此处处理不同的调试事件(这些事件被写入dbge.dwDebugEventCode),
复制代码
& b& {3 r7 _0 f% ~" I

6 {8 L' j% I! G
" }" A) V: M" t1 H
商业服务端 登录器 网站 出售

9

主题

233

回帖

935

积分

高级会员

积分
935
金钱
550
贡献
138
注册时间
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

主题

193

回帖

312

积分

中级会员

积分
312
金钱
114
贡献
5
注册时间
2024-5-14
发表于 2024-5-14 15:56:57 | 显示全部楼层
学习学习赞赞赞

9

主题

233

回帖

935

积分

高级会员

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

3

主题

88

回帖

1375

积分

金牌会员

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

本版积分规则

Archiver|手机版|小黑屋|EGameol

GMT+8, 2025-4-27 15:54 , Processed in 0.160608 second(s), 25 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

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