*/ VOODOO_METHOD(DropEvent)(_In_ CONST Uuid event, _In_ Functions::CallbackFunc func) PURE; /** * Broadcasts an event to all registered handlers, passing the provided argument list. * * @param event The Uuid of the event to call. * @param count The number of variants passed, may be 0. * @param pArgs The list of variants passed as arguments, may be nullptr if @a count is 0. * * @warning This calls all registered callbacks for the given event. The order registered callbacks will be called * in is undefined. * @warning Callbacks can modify the arguments, but not change the count. * @warning If a callback returns a failure value, the loop will be aborted and remaining callbacks will not be * called. The failure will be returned by this method. If no callbacks fail, this will return generic success. */ VOODOO_METHOD(CallEvent)(_In_ CONST Uuid event, _In_ CONST uint32_t count, _In_reads_opt_(count) Variant * pArgs) PURE; /** * @} * @name Core Field Methods * Getters and setters for core fields. * @{ */ /** * Retrieve the Xml config document for this ICore. * * @return A reference to the config. */ VOODOO_METHOD_(XmlDocument, GetConfig)() CONST PURE; /** * Retrieves this core's IFileSystem implementation. *
// operator // //--------------------------------------------------------------------- HKEY CRegKey::GetHKEY() { return _keyHandle; } //--------------------------------------------------------------------- // // Create // //--------------------------------------------------------------------- LONG CRegKey::Create(_In_ HKEY hKeyPresent, _In_ LPCWSTR pwszKeyName, _In_reads_opt_(255) LPWSTR pwszClass, DWORD dwOptions, REGSAM samDesired, _Inout_ LPSECURITY_ATTRIBUTES lpSecAttr, _Out_opt_ LPDWORD lpdwDisposition) { DWORD disposition = 0; HKEY keyHandle = nullptr; LONG res = RegCreateKeyEx(hKeyPresent, pwszKeyName, 0, pwszClass, dwOptions, samDesired, lpSecAttr, &keyHandle, &disposition); if (lpdwDisposition != nullptr) { *lpdwDisposition = disposition; } if (res == ERROR_SUCCESS) { Close();
} // D3D11 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "d3d11/d3d11.h" namespace { // used to check for delegation within the D3D11 dll bool g_NeedD3D11Hooking = false; } GENERATE_INTERCEPT_HEADER(D3D11CreateDevice, HRESULT, WINAPI, _In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, _Out_opt_ ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, _Out_opt_ ID3D11DeviceContext** ppImmediateContext) { SDLOG(0, "DetouredD3D11CreateDevice ppDevice: %p (%p) ppImmediateContext: %p (%p)\n", ppDevice, ppDevice ? *ppDevice : NULL, ppImmediateContext, ppImmediateContext ? *ppImmediateContext : NULL); g_NeedD3D11Hooking = true; HRESULT ret = TrueD3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext); SDLOG(0, "-> ppDevice: %p (%p) ppImmediateContext: %p (%p)\n", ppDevice, ppDevice ? *ppDevice : NULL, ppImmediateContext, ppImmediateContext ? *ppImmediateContext : NULL); // Check for success and non-null ppDevice and context (can be set to null to check feature level) // also check if call was delegated to D3D11CreateDeviceAndSwapChain internally if(SUCCEEDED(ret) && g_NeedD3D11Hooking) { if(ppDevice != NULL) new hkID3D11Device(ppDevice);
_Requires_lock_held_(_Global_critical_region_) NTSTATUS FatPnpCancelRemove ( PIRP_CONTEXT IrpContext, PIRP Irp, PVCB Vcb ); IO_COMPLETION_ROUTINE FatPnpCompletionRoutine; NTSTATUS FatPnpCompletionRoutine ( _In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt ); #ifdef ALLOC_PRAGMA #pragma alloc_text(PAGE, FatCommonPnp) #pragma alloc_text(PAGE, FatFsdPnp) #pragma alloc_text(PAGE, FatPnpCancelRemove) #pragma alloc_text(PAGE, FatPnpQueryRemove) #pragma alloc_text(PAGE, FatPnpRemove) #pragma alloc_text(PAGE, FatPnpSurpriseRemove) #endif _Function_class_(IRP_MJ_PNP) _Function_class_(DRIVER_DISPATCH) NTSTATUS
{ return reinterpret_cast<HANDLE>(0x4000); } extern __declspec(dllexport) BOOL WINAPI ReportEventA( _In_ HANDLE hEventLog, _In_ WORD wType, _In_ WORD wCategory, _In_ DWORD dwEventID, _In_opt_ PSID lpUserSid, _In_ WORD wNumStrings, _In_ DWORD dwDataSize, _In_reads_opt_(wNumStrings) LPCSTR *lpStrings, _In_reads_bytes_opt_(dwDataSize) LPVOID lpRawData) { return TRUE; } extern __declspec(dllexport) BOOL WINAPI DeregisterEventSource( _In_ HANDLE hEventLog) { return TRUE; } extern __declspec(dllexport)
/* Call the worker function */ SepAdtPrivilegedServiceAuditAlarm(SubjectContext, &SeSubsystemName, ServiceName, SubjectContext->ClientToken, SubjectContext->PrimaryToken, PrivilegeSet, AccessGranted); } static NTSTATUS SeCaptureObjectTypeList( _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, _In_ ULONG ObjectTypeListLength, _In_ KPROCESSOR_MODE PreviousMode, _Out_ POBJECT_TYPE_LIST *CapturedObjectTypeList) { SIZE_T Size; if (PreviousMode == KernelMode) { return STATUS_NOT_IMPLEMENTED; } if (ObjectTypeListLength == 0) { *CapturedObjectTypeList = NULL; return STATUS_SUCCESS;
OnPostFrontendRender(); } #pragma comment(lib, "d3d11.lib") static IDXGISwapChain1* g_swapChain1; static DWORD g_swapChainFlags; static ID3D11DeviceContext* g_dc; static bool g_allowTearing; static bool g_disableRendering; void MakeDummyDevice(ID3D11Device** device, ID3D11DeviceContext** context, const DXGI_SWAP_CHAIN_DESC* desc, IDXGISwapChain** swapChain); static HRESULT CreateD3D11DeviceWrap(_In_opt_ IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, _In_opt_ CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, _Out_opt_ IDXGISwapChain** ppSwapChain, _Out_opt_ ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, _Out_opt_ ID3D11DeviceContext** ppImmediateContext) { if (g_disableRendering) { *pFeatureLevel = D3D_FEATURE_LEVEL_11_0; MakeDummyDevice(ppDevice, ppImmediateContext, pSwapChainDesc, ppSwapChain); return S_OK; } if (!IsWindows10OrGreater()) { return D3D11CreateDeviceAndSwapChain(/*pAdapter*/nullptr, /*DriverType*/ D3D_DRIVER_TYPE_HARDWARE, Software, Flags | D3D11_CREATE_DEVICE_BGRA_SUPPORT, pFeatureLevels, FeatureLevels/*nullptr, 0*/, SDKVersion, pSwapChainDesc, ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext); }
#ifdef _WIN32 typedef Gdiplus::GpStatus(WINGDIPAPI * FGdipGetImageEncoders)(_In_ UINT numEncoders, _In_ UINT size, _Out_writes_bytes_(size) Gdiplus::ImageCodecInfo *encoders); typedef Gdiplus::GpStatus(WINGDIPAPI * FGdipGetImageEncodersSize)(_Out_ UINT *numEncoders, _Out_ _Out_range_(>= , (*numEncoders) * sizeof(ImageCodecInfo)) UINT *size); typedef Gdiplus::Status(WINAPI * FGdiplusStartup)(OUT ULONG_PTR *token, const Gdiplus::GdiplusStartupInput *input, OUT Gdiplus::GdiplusStartupOutput *output); typedef VOID(WINAPI * FGdiplusShutdown)(ULONG_PTR token); typedef Gdiplus::Status(WINAPI * FGdiplusStartup)(OUT ULONG_PTR *token, const Gdiplus::GdiplusStartupInput *input, OUT Gdiplus::GdiplusStartupOutput *output); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipSaveImageToFile)(Gdiplus::GpImage *image, GDIPCONST WCHAR* filename, GDIPCONST CLSID* clsidEncoder, GDIPCONST Gdiplus::EncoderParameters* encoderParams); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipDisposeImage)(Gdiplus::GpImage *image); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipCreateBitmapFromHICON)(HICON hicon, Gdiplus::GpBitmap** bitmap); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipBitmapSetPixel)(Gdiplus::GpBitmap* bitmap, INT x, INT y, Gdiplus::ARGB color); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipBitmapGetPixel)(Gdiplus::GpBitmap* bitmap, INT x, INT y, Gdiplus::ARGB *color); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipCreateBitmapFromHBITMAP)(HBITMAP hbm, HPALETTE hpal, Gdiplus::GpBitmap** bitmap); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipLoadImageFromFile)(GDIPCONST WCHAR* filename, Gdiplus::GpBitmap** image); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipGetImagePixelFormat)(Gdiplus::GpImage *image, Gdiplus::PixelFormat *format); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipCreateBitmapFromScan0)(INT width, INT height, INT stride, Gdiplus::PixelFormat format, _In_reads_opt_(_Inexpressible_("height * stride")) BYTE* scan0, _Outptr_ Gdiplus::GpBitmap** bitmap); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipGetImageWidth)(Gdiplus::GpImage *image, UINT *width); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipGetImageHeight)(Gdiplus::GpImage *image, UINT *height); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipGetImageGraphicsContext)(Gdiplus::GpImage *image, Gdiplus::GpGraphics **graphics); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipDrawImageRect)(Gdiplus::GpGraphics *graphics, Gdiplus::GpImage *image, Gdiplus::REAL x, Gdiplus::REAL y, Gdiplus::REAL width, Gdiplus::REAL height); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipDeleteGraphics)(Gdiplus::GpGraphics *graphics); typedef Gdiplus::GpStatus(WINGDIPAPI* FGdipGraphicsClear)(Gdiplus::GpGraphics *graphics, Gdiplus::ARGB color); class GdiPlusFn { HMODULE m_hDll = nullptr; GdiPlusFn() { m_hDll = LoadLibraryA("Gdiplus.dll");
// We define EVNTAPI without the DECLSPEC_IMPORT specifier so that // we can implement these functions locally instead of using the import library, // and can therefore still run on Windows XP. #define EVNTAPI __stdcall // Include the event register/write/unregister macros compiled from the manifest file. // Note that this includes evntprov.h which requires a Vista+ Windows SDK. #include "ETWProvidersGenerated.h" #ifndef _In_reads_opt_ // Support building with the VS 2010 Windows SDK. #define _In_reads_opt_(x) #endif // Typedefs for use with GetProcAddress typedef ULONG (__stdcall *tEventRegister)( _In_ LPCGUID ProviderId, _In_opt_ PENABLECALLBACK EnableCallback, _In_opt_ PVOID CallbackContext, _Out_ PREGHANDLE RegHandle); typedef ULONG (__stdcall *tEventWrite)( _In_ REGHANDLE RegHandle, _In_ PCEVENT_DESCRIPTOR EventDescriptor, _In_ ULONG UserDataCount, _In_reads_opt_(UserDataCount) PEVENT_DATA_DESCRIPTOR UserData); typedef ULONG (__stdcall *tEventUnregister)( _In_ REGHANDLE RegHandle ); // Helper class to dynamically load Advapi32.dll, find the ETW functions, // register the providers if possible, and get the performance counter frequency. class CETWRegister { public: CETWRegister() { QueryPerformanceFrequency( &m_frequency ); // Find Advapi32.dll. This should always succeed. HMODULE pAdvapiDLL = LoadLibraryW( L"Advapi32.dll" ); if ( pAdvapiDLL ) {