1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2008-2014 |
---|
3 | // Created by Roman Ryltsov roman@alax.info, http://alax.info |
---|
4 | // |
---|
5 | // This source code is published to complement DirectShowSpy developer powertoy |
---|
6 | // and demonstrate the internal use of APIs and tricks powering the tool. It is |
---|
7 | // allowed to freely re-use the portions of the code in other projects, commercial |
---|
8 | // or otherwise (provided that you dont pretend that you wrote the original tool). |
---|
9 | // |
---|
10 | // Please keep in mind that DirectShowSpy is a developer tool, it is strongly recommended |
---|
11 | // that it is not shipped with release grade software. It is allowed to distribute |
---|
12 | // DirectShowSpy if only it is not registered with Windows by default and either |
---|
13 | // used privately, or registered on specific throubleshooting request. The advice applies |
---|
14 | // to hooking methods used by DirectShowSpy in general as well. |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | //////////////////////////////////////////////////////////// |
---|
19 | // CDirectShowSpyModule |
---|
20 | |
---|
21 | class CDirectShowSpyModule : |
---|
22 | public CAtlDllModuleT<CDirectShowSpyModule> |
---|
23 | { |
---|
24 | public: |
---|
25 | |
---|
26 | DECLARE_LIBID(LIBID_AlaxInfoDirectShowSpy) |
---|
27 | |
---|
28 | DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MODULE, "{DC64B11B-10DC-4F58-9485-17655B8A393E}") |
---|
29 | |
---|
30 | public: |
---|
31 | // CDirectShowSpyModule |
---|
32 | CDirectShowSpyModule() throw() |
---|
33 | { |
---|
34 | AtlTraceSetDefaultSettings(); |
---|
35 | TraceModuleVersion(); |
---|
36 | _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this); |
---|
37 | _W(CExceptionFilter::Initialize()); |
---|
38 | } |
---|
39 | ~CDirectShowSpyModule() throw() |
---|
40 | { |
---|
41 | _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this); |
---|
42 | CExceptionFilter::Terminate(); |
---|
43 | } |
---|
44 | |
---|
45 | // CAtlModule |
---|
46 | HRESULT AddCommonRGSReplacements(IRegistrarBase* pRegistrar) throw() |
---|
47 | { |
---|
48 | _A(pRegistrar); |
---|
49 | _ATLTRY |
---|
50 | { |
---|
51 | __C(__super::AddCommonRGSReplacements(pRegistrar)); |
---|
52 | _A(!IsEqualGUID(m_libid, GUID_NULL)); |
---|
53 | __C(pRegistrar->AddReplacement(L"LIBID", _PersistHelper::StringFromIdentifier(m_libid))); |
---|
54 | TCHAR pszPath[MAX_PATH] = { 0 }; |
---|
55 | _W(GetModuleFileName(_AtlBaseModule.GetModuleInstance(), pszPath, DIM(pszPath))); |
---|
56 | __C(pRegistrar->AddReplacement(L"FILENAME", CStringW(PathFindFileName(pszPath)))); |
---|
57 | __C(pRegistrar->AddReplacement(L"DESCRIPTION", CStringW(AtlLoadString(IDS_PROJNAME)))); |
---|
58 | } |
---|
59 | _ATLCATCH(Exception) |
---|
60 | { |
---|
61 | _C(Exception); |
---|
62 | } |
---|
63 | return S_OK; |
---|
64 | } |
---|
65 | BOOL WINAPI DllMain(DWORD nReason, VOID* pvReserved) throw() |
---|
66 | { |
---|
67 | return __super::DllMain(nReason, pvReserved); |
---|
68 | } |
---|
69 | }; |
---|
70 | |
---|
71 | extern class CDirectShowSpyModule _AtlModule; |
---|
72 | |
---|