[310] | 1 | //////////////////////////////////////////////////////////// |
---|
[376] | 2 | // Copyright (C) Roman Ryltsov, 2008-2015 |
---|
[310] | 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 | #include "stdafx.h" |
---|
| 17 | #include "resource.h" |
---|
| 18 | #include "Module_i.h" |
---|
| 19 | #include "dllmain.h" |
---|
| 20 | |
---|
| 21 | #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) |
---|
| 22 | #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms." |
---|
| 23 | #endif |
---|
| 24 | |
---|
| 25 | //////////////////////////////////////////////////////////// |
---|
| 26 | // DLL Exports |
---|
| 27 | |
---|
| 28 | STDAPI DllCanUnloadNow() throw() |
---|
| 29 | { |
---|
| 30 | return _AtlModule.DllCanUnloadNow(); |
---|
| 31 | } |
---|
| 32 | STDAPI DllGetClassObject(REFCLSID ClassIdentifier, REFIID InterfaceIdentifier, LPVOID* ppvObject) throw() |
---|
| 33 | { |
---|
| 34 | return _AtlModule.DllGetClassObject(ClassIdentifier, InterfaceIdentifier, ppvObject); |
---|
| 35 | } |
---|
| 36 | STDAPI DllRegisterServer() throw() |
---|
| 37 | { |
---|
| 38 | HRESULT nResult; |
---|
| 39 | _ATLTRY |
---|
| 40 | { |
---|
| 41 | nResult = _AtlModule.DllRegisterServer(); |
---|
| 42 | __C(nResult); |
---|
| 43 | } |
---|
| 44 | _ATLCATCH(Exception) |
---|
| 45 | { |
---|
| 46 | _C(Exception); |
---|
| 47 | } |
---|
| 48 | return nResult; |
---|
| 49 | } |
---|
| 50 | STDAPI DllUnregisterServer() throw() |
---|
| 51 | { |
---|
| 52 | HRESULT nResult; |
---|
| 53 | _ATLTRY |
---|
| 54 | { |
---|
| 55 | nResult = _AtlModule.DllUnregisterServer(); |
---|
| 56 | __C(nResult); |
---|
| 57 | } |
---|
| 58 | _ATLCATCH(Exception) |
---|
| 59 | { |
---|
| 60 | _C(Exception); |
---|
| 61 | } |
---|
| 62 | return nResult; |
---|
| 63 | } |
---|
| 64 | STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCommandLine) throw() |
---|
| 65 | { |
---|
| 66 | HRESULT nResult; |
---|
| 67 | _ATLTRY |
---|
| 68 | { |
---|
| 69 | static const WCHAR g_pszUser[] = _T("user"); |
---|
| 70 | if(pszCommandLine) |
---|
| 71 | { |
---|
| 72 | if(_wcsnicmp(pszCommandLine, g_pszUser, DIM(g_pszUser)) == 0) |
---|
| 73 | AtlSetPerUserRegistration(TRUE); |
---|
| 74 | } |
---|
| 75 | if(bInstall) |
---|
| 76 | { |
---|
| 77 | nResult = DllRegisterServer(); |
---|
| 78 | if(FAILED(nResult)) |
---|
| 79 | DllUnregisterServer(); |
---|
| 80 | } else |
---|
| 81 | nResult = DllUnregisterServer(); |
---|
| 82 | } |
---|
| 83 | _ATLCATCH(Exception) |
---|
| 84 | { |
---|
| 85 | _C(Exception); |
---|
| 86 | } |
---|
| 87 | return nResult; |
---|
| 88 | } |
---|
[831] | 89 | |
---|
| 90 | #if defined(AVAILABILITY_INTERNALWRITEMINIDUMP) |
---|
| 91 | #if defined(_WIN64) |
---|
| 92 | #pragma comment(linker, "/EXPORT:WriteMiniDump,PRIVATE") |
---|
| 93 | #else |
---|
| 94 | #pragma comment(linker, "/EXPORT:WriteMiniDump=_WriteMiniDump@16,PRIVATE") |
---|
| 95 | extern "C" // __declspec(dllexport) |
---|
| 96 | #endif |
---|
| 97 | extern "C" STDAPI WriteMiniDump(HWND hParentWindow, HINSTANCE hInstance, LPSTR pszCommandLine, INT nShowCommand) |
---|
| 98 | { |
---|
| 99 | return InternalWriteMiniDump(hParentWindow, hInstance, pszCommandLine, nShowCommand); |
---|
| 100 | } |
---|
| 101 | #endif // defined(AVAILABILITY_INTERNALWRITEMINIDUMP) |
---|