📄 locplugin.hpp
字号:
InitProvider(pRegPlugin, keyName);
}
#ifdef LOC_WHITEBOX_TESTING
// For white box tests, allow provider_t objects to be created directly
// (without calling into the registry to get config options)
// The implementation for this constructor is in the WB tests themselves, not LF.
provider_t(pluginSettings_t *pPluginSettings) : plugin_t(pPluginSettings) { ; }
#endif
virtual ~provider_t();
DWORD ScheduleWorkerIfNeeded(void);
void StopPlugin(void);
void ReportsUnavailable(void);
void ReportsAvailable(void);
void StartingUp(void);
void RequestReportGeneration(const GUID *pReportType);
void CancelReportGeneration(const GUID *pReportType);
void GetProviderInfo(PROVIDER_INFORMATION *pProvInfo);
void GetProviderLocation(void);
void SetFatalError();
virtual DWORD CallIoctlOpen(void) {
return CallProvIoctlOpen();
}
virtual DWORD CallIoctlCall(HANDLE h, DWORD dwCode, BYTE *pBufIn, DWORD cbIn, BYTE *pBufOut, DWORD *pcbOut) {
return CallProvIoctlCall(h, dwCode, pBufIn, cbIn, pBufOut, pcbOut);
}
virtual DWORD CallIoctlClose(HANDLE h) {
return CallProvIoctlClose(h);
}
PLUGIN_STATE GetReportTypeState(const GUID *pReportType);
};
//
// Implements resolver specific functionality. Resolvers require reports
// generated by a provider in order to function. For instance a Web Services
// resolver could be able to determine country/city/address based on current
// lat/long, but first a provider must give the resolver the lat/long to resolve.
//
// Function types for resolver DLL callback functions
typedef DWORD (WINAPI *PFN_RESINITIALIZE)(RESOLVER_INFORMATION *pResInfo);
typedef DWORD (WINAPI *PFN_RESGETLOCATION)(RESOLVER_CONTROL_BLOCK *pResControlBlock);
typedef DWORD (WINAPI *PFN_RESSTOP)(void);
typedef DWORD (WINAPI *PFN_RESUNINITIALIZE)(void);
typedef DWORD (WINAPI *PFN_RESOPEN)(void);
typedef DWORD (WINAPI *PFN_RESIOCTL)(HANDLE h, DWORD dwCode, BYTE *pBufIn, DWORD cbIn, BYTE *pBufOut, DWORD *pcbOut);
typedef DWORD (WINAPI *PFN_RESCLOSE)(HANDLE h);
// Forward declaration of reports collector class
class reportCol_t;
class resolver_t : public plugin_t {
protected:
// Minimum period (in ms) with which to requery.
DWORD m_minRequery;
// Provider specific settings
DWORD m_resolverFlags;
// GUID report types that this resolver can support - i.e. reports
// it is capable of resolving. For instance, a resolver may be able to
// process lat/long reports (LOCATION_LATLONG_GUID).
GUID m_supportedReportTypes[MAX_PLUGIN_REPORT_TYPES];
// Number of m_supportedReportTypes
DWORD m_numSupportedReportTypes;
// Last time (GetCurrentFT()) the resolver thread ran (regardless of success)
__int64 m_lastResolution;
// Which report types has this been requested to do lookups for.
// Maps with m_generatedReportTypes ordered entries. A resolver
// (unlike a provider) can have some report states be active while
// others are unavailable or not even requested to be on.
PLUGIN_STATE m_reportStates[MAX_PLUGIN_REPORT_TYPES];
// Are there providers (in theory) capable of generating a report this
// resolver supports. Only mark as FALSE AFTER we try all providers
// that could help this resolver and they all fail.
BOOL m_providersAvailable;
// Has the GetResolverReport thread been called at least once? This
// determines for how long we delay on lookup for 1st time and whether
// we need a stop call or not.
BOOL m_getRepThrdCalledFirstTime;
// Current provider that is generating reports for this resolver. This
// is used in case multiple provider generate a supported report type,
// the plugin knows which one to use based on highest priority.
provider_t *m_providerGenerator;
// Associated reports collector with current report to be resolved.
reportCol_t *m_reportCollector;
// Resolver DLL exported function pointers
PFN_RESINITIALIZE m_pfnInitialize;
PFN_RESGETLOCATION m_pfnGetLocation;
PFN_RESSTOP m_pfnStop;
PFN_RESUNINITIALIZE m_pfnUnInitialize;
PFN_RESOPEN m_pfnIoctlOpen;
PFN_RESIOCTL m_pfnIoctlCall;
PFN_RESCLOSE m_pfnIoctlClose;
void SetAllReportStates(PLUGIN_STATE newState);
void InitResolver(CReg *pRegPlugin, const WCHAR *keyName);
void FillRCB(RESOLVER_CONTROL_BLOCK *pRcb, RESOLVER_INFORMATION *pResInfo, reportSmartPtr_t &pProvReport);
DWORD DetermineDelayUntilNextResolution(void);
void SetState(const GUID *pReportType, PLUGIN_STATE newState);
// Wrappers for calling the resolver DLL itself
// In practice the CallResXXX functions will never over-ridden.
// White box tests do do this to make testing easier so make these virtual.
virtual DWORD CallResInit(RESOLVER_INFORMATION *pResInfo);
virtual DWORD CallResGetLocation(RESOLVER_CONTROL_BLOCK *pResControlBlock);
virtual DWORD CallResStop(void);
virtual DWORD CallResUnInit(void);
virtual DWORD CallResIoctlOpen(void);
virtual DWORD CallResIoctlCall(HANDLE h, DWORD dwCode, BYTE *pBufIn, DWORD cbIn, BYTE *pBufOut, DWORD *pcbOut);
virtual DWORD CallResIoctlClose(HANDLE h);
public:
resolver_t(CReg *pRegPlugin, const WCHAR *keyName) : plugin_t(pRegPlugin,keyName) {
if (PLUGIN_STATE_ERROR == m_pluginState) // Verify plugin_t constructor was successful
return;
m_isAProvider = false;
m_pluginState = PLUGIN_STATE_ERROR;
InitResolver(pRegPlugin, keyName);
}
// Returns which reportTypes the plugin can possibly generate
void GetSupportedReportInfo(GUID *pReportTypes, DWORD *numReportTypes);
#ifdef LOC_WHITEBOX_TESTING
// For white box tests, allow resolver_t objects to be created directly
// (without calling into the registry to get config options)
// The implementation for this constructor is in the WB tests themselves, not LF.
resolver_t(pluginSettings_t *pPluginSettings) : plugin_t(pPluginSettings) { ; }
#endif
virtual ~resolver_t();
void GetResolverLocation(void);
void GetResolverInfo(RESOLVER_INFORMATION *pResInfo);
BOOL CanSupportReportType(const GUID *pReportType);
PLUGIN_STATE GetReportTypeState(const GUID *pReportType);
void SetFatalError();
void ReportTypeUnavailable(const GUID *pReportType);
void ReportTypeAvailable(const GUID *pReportType);
void RequestReportGeneration(const GUID *pReportType);
void CancelReportGeneration(const GUID *pReportType);
void NewReportFromProvider(provider_t *pProv, reportCol_t *pRC);
void NoProvidersAvailable(void);
BOOL HasProvidersAvailable(void) { return m_providersAvailable; }
void ScheduleNextResolution(void);
void StopPlugin(void);
virtual DWORD CallIoctlOpen(void) {
return CallResIoctlOpen();
}
virtual DWORD CallIoctlCall(HANDLE h, DWORD dwCode, BYTE *pBufIn, DWORD cbIn, BYTE *pBufOut, DWORD *pcbOut) {
return CallResIoctlCall(h, dwCode, pBufIn, cbIn, pBufOut, pcbOut);
}
virtual DWORD CallIoctlClose(HANDLE h) {
return CallResIoctlClose(h);
}
};
#ifdef DEBUG
// Make sure that plugin is in a "workable" state
inline void DbgChkPluginStateValid(PLUGIN_STATE pluginState) {
switch (pluginState) {
case PLUGIN_STATE_ON:
case PLUGIN_STATE_STARTING_UP:
case PLUGIN_STATE_SHUTTING_DOWN:
case PLUGIN_STATE_UNAVAILABLE:
case PLUGIN_STATE_OFF:
break;
default:
// PLUGIN_STATE_ERROR & PLUGIN_STATE_NOT_SUPPORTED are
// not acceptable states under most conditions.
DEBUGCHK(0);
}
}
#else
inline void DbgChkPluginStateValid(plugin_t *pPlugin) {
;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -