-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
132 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,120 @@ | ||
#pragma once | ||
|
||
#include <dia2.h> // IDia* interfaces | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// PDBCallback | ||
// | ||
|
||
class PDBCallback : public IDiaLoadCallback2 | ||
class PDBCallback | ||
: public IDiaLoadCallback2 | ||
{ | ||
volatile unsigned long m_RefCount = 0; | ||
|
||
public: | ||
|
||
//IUnknown | ||
ULONG STDMETHODCALLTYPE AddRef() override | ||
{ | ||
return m_RefCount++; | ||
} | ||
ULONG STDMETHODCALLTYPE Release() override | ||
{ | ||
if ((--m_RefCount) == 0) | ||
public: | ||
// | ||
// IUnknown | ||
// | ||
|
||
ULONG STDMETHODCALLTYPE AddRef() override | ||
{ | ||
delete this; | ||
return m_RefCount++; | ||
} | ||
|
||
return m_RefCount; | ||
} | ||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID Rid, void **Interface) override | ||
{ | ||
if (Interface == nullptr) | ||
ULONG STDMETHODCALLTYPE Release() override | ||
{ | ||
return E_INVALIDARG; | ||
if ((--m_RefCount) == 0) | ||
{ | ||
delete this; | ||
} | ||
|
||
return m_RefCount; | ||
} | ||
|
||
if (Rid == __uuidof(IDiaLoadCallback2)) | ||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID Rid, void **Interface) override | ||
{ | ||
*Interface = (IDiaLoadCallback2 *)this; | ||
if (Interface == nullptr) | ||
{ | ||
return E_INVALIDARG; | ||
} | ||
|
||
if (Rid == __uuidof(IDiaLoadCallback2)) | ||
{ | ||
*Interface = (IDiaLoadCallback2 *)this; | ||
} | ||
else if (Rid == __uuidof(IDiaLoadCallback)) | ||
{ | ||
*Interface = (IDiaLoadCallback *)this; | ||
} | ||
else if (Rid == __uuidof(IUnknown)) | ||
{ | ||
*Interface = (IUnknown *)this; | ||
} | ||
else | ||
{ | ||
*Interface = nullptr; | ||
} | ||
|
||
if (*Interface != nullptr) | ||
{ | ||
AddRef(); | ||
return S_OK; | ||
} | ||
|
||
return E_NOINTERFACE; | ||
} | ||
else if (Rid == __uuidof(IDiaLoadCallback)) | ||
|
||
HRESULT STDMETHODCALLTYPE NotifyDebugDir( | ||
BOOL fExecutable, | ||
DWORD cbData, | ||
BYTE data[]) override // really a const struct _IMAGE_DEBUG_DIRECTORY * | ||
{ | ||
*Interface = (IDiaLoadCallback *)this; | ||
return S_OK; | ||
} | ||
else if (Rid == __uuidof(IUnknown)) | ||
|
||
HRESULT STDMETHODCALLTYPE NotifyOpenDBG( | ||
LPCOLESTR dbgPath, | ||
HRESULT resultCode) override | ||
{ | ||
// wprintf(L"opening %s...\n", dbgPath); | ||
return S_OK; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE NotifyOpenPDB( | ||
LPCOLESTR pdbPath, | ||
HRESULT resultCode) override | ||
{ | ||
*Interface = (IUnknown *)this; | ||
// wprintf(L"opening %s...\n", pdbPath); | ||
return S_OK; | ||
} | ||
else | ||
|
||
HRESULT STDMETHODCALLTYPE RestrictRegistryAccess() override | ||
{ | ||
*Interface = nullptr; | ||
// return hr != S_OK to prevent querying the registry for symbol search paths | ||
return S_OK; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE RestrictSymbolServerAccess() override | ||
{ | ||
// return hr != S_OK to prevent accessing a symbol server | ||
return S_OK; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE RestrictOriginalPathAccess() override | ||
{ | ||
// return hr != S_OK to prevent querying the registry for symbol search paths | ||
return S_OK; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE RestrictReferencePathAccess() override | ||
{ | ||
// return hr != S_OK to prevent accessing a symbol server | ||
return S_OK; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE RestrictDBGAccess() override | ||
{ | ||
return S_OK; | ||
} | ||
|
||
if (*Interface != nullptr) | ||
HRESULT STDMETHODCALLTYPE RestrictSystemRootAccess() override | ||
{ | ||
AddRef(); | ||
return S_OK; | ||
} | ||
|
||
return E_NOINTERFACE; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE NotifyDebugDir( | ||
BOOL fExecutable, | ||
DWORD cbData, | ||
BYTE data[]) override // really a const struct _IMAGE_DEBUG_DIRECTORY * | ||
{ | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE NotifyOpenDBG( | ||
LPCOLESTR dbgPath, | ||
HRESULT resultCode) override | ||
{ | ||
// wprintf(L"opening %s...\n", dbgPath); | ||
return S_OK; | ||
} | ||
|
||
HRESULT STDMETHODCALLTYPE NotifyOpenPDB( | ||
LPCOLESTR pdbPath, | ||
HRESULT resultCode) override | ||
{ | ||
// wprintf(L"opening %s...\n", pdbPath); | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE RestrictRegistryAccess() override | ||
{ | ||
// return hr != S_OK to prevent querying the registry for symbol search paths | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE RestrictSymbolServerAccess() override | ||
{ | ||
// return hr != S_OK to prevent accessing a symbol server | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE RestrictOriginalPathAccess() override | ||
{ | ||
// return hr != S_OK to prevent querying the registry for symbol search paths | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE RestrictReferencePathAccess() override | ||
{ | ||
// return hr != S_OK to prevent accessing a symbol server | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE RestrictDBGAccess() override | ||
{ | ||
return S_OK; | ||
} | ||
HRESULT STDMETHODCALLTYPE RestrictSystemRootAccess() override | ||
{ | ||
return S_OK; | ||
} | ||
}; | ||
private: | ||
volatile unsigned long m_RefCount = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters