// determine the directory for a given pathname // (wstring only for now; feel free to make this a template if needed) /*static*/ wstring File::DirectoryPathOf(wstring path) { #ifdef _WIN32 // Win32 accepts forward slashes, but it seems that PathRemoveFileSpec() does not // TODO: // "PathCchCanonicalize does the / to \ conversion as a part of the canonicalization, it's // probably a good idea to do that anyway since I suspect that the '..' characters might // confuse the other PathCch functions" [Larry Osterman] // "Consider GetFullPathName both for canonicalization and last element finding." [Jay Krell] path = msra::strfun::ReplaceAll<wstring>(path, L"/", L"\\"); HRESULT hr; if (IsWindows8OrGreater()) // PathCchRemoveFileSpec() only available on Windows 8+ { typedef HRESULT(*PathCchRemoveFileSpecProc)(_Inout_updates_(_Inexpressible_(cchPath)) PWSTR, _In_ size_t); HINSTANCE hinstLib = LoadLibrary(TEXT("api-ms-win-core-path-l1-1-0.dll")); if (hinstLib == nullptr) RuntimeError("DirectoryPathOf: LoadLibrary() unexpectedly failed."); PathCchRemoveFileSpecProc PathCchRemoveFileSpec = reinterpret_cast<PathCchRemoveFileSpecProc>(GetProcAddress(hinstLib, "PathCchRemoveFileSpec")); if (!PathCchRemoveFileSpec) RuntimeError("DirectoryPathOf: GetProcAddress() unexpectedly failed."); // this is the actual function call we care about hr = PathCchRemoveFileSpec(&path[0], path.size()); FreeLibrary(hinstLib); } else // on Windows 7-, use older PathRemoveFileSpec() instead hr = PathRemoveFileSpec(&path[0]) ? S_OK : S_FALSE; if (hr == S_OK) // done path.resize(wcslen(&path[0])); else if (hr == S_FALSE) // nothing to remove: use . path = L"."; else RuntimeError("DirectoryPathOf: Path(Cch)RemoveFileSpec() unexpectedly failed with 0x%08x.", (unsigned int)hr); #else auto pos = path.find_last_of(L"/"); if (pos != path.npos) path.erase(pos); else // if no directory path at all, use current directory return L"."; #endif return path; }
#include "stdafx.h" #include <cstdio> #ifdef __cplusplus extern "C" { #endif SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier, _Out_writes_opt_(_Inexpressible_(BufferLength)) SQLPOINTER DiagInfo, SQLSMALLINT BufferLength, _Out_opt_ SQLSMALLINT *StringLength) { AQ_ODBC_LOG("%s called\n", __FUNCTION__); switch ( DiagIdentifier ) { case SQL_DIAG_CLASS_ORIGIN: AQ_ODBC_LOG("SQL_DIAG_CLASS_ORIGIN\n"); break; case SQL_DIAG_COLUMN_NUMBER: AQ_ODBC_LOG("SQL_DIAG_COLUMN_NUMBER\n"); break; case SQL_DIAG_CONNECTION_NAME: AQ_ODBC_LOG("SQL_DIAG_CONNECTION_NAME\n"); break; case SQL_DIAG_MESSAGE_TEXT:
#include "stdafx.h" #ifdef __cplusplus extern "C" { #endif SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV EnvironmentHandle, SQLINTEGER Attribute, _Out_writes_(_Inexpressible_(BufferLength)) SQLPOINTER Value, SQLINTEGER BufferLength, _Out_opt_ SQLINTEGER *StringLength) { AQ_ODBC_LOG("%s called\n", __FUNCTION__); return SQL_SUCCESS; } SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT StatementHandle, SQLINTEGER Attribute, _Out_writes_opt_(_Inexpressible_(BufferLength)) SQLPOINTER Value, SQLINTEGER BufferLength, _Out_opt_ SQLINTEGER *StringLength) { AQ_ODBC_LOG("%s called\n", __FUNCTION__); AqHandleStmt * hstmt = (AqHandleStmt *)StatementHandle; AQ_ODBC_LOG("hstmt id: [%d]\n", hstmt->Stmt); switch ( Attribute ) { case SQL_ATTR_APP_PARAM_DESC: AQ_ODBC_LOG("SQL_ATTR_APP_PARAM_DESC\n"); *((SQLINTEGER*)Value) = (SQLINTEGER)&(((AqHandleStmt *)StatementHandle)->apd); break;
_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
_com_error ce (ret); dll_log.Log ( L" > FAILURE %s - (%s)", TZF_DescribeHRESULT (ret), ce.ErrorMessage () ); } return ret; } typedef HRESULT (STDAPICALLTYPE *CoCreateInstance_t)( _In_ REFCLSID rclsid, _In_opt_ LPUNKNOWN pUnkOuter, _In_ DWORD dwClsContext, _In_ REFIID riid, _COM_Outptr_ _At_(*ppv, _Post_readable_size_(_Inexpressible_(varies))) LPVOID FAR* ppv); CoCreateInstance_t CoCreateInstance_Original = nullptr; IMMDevice* g_pAudioDev; typedef HRESULT (STDMETHODCALLTYPE *IAudioClient_GetMixFormat_t) (IAudioClient *This, _Out_ WAVEFORMATEX **ppDeviceFormat); IAudioClient_GetMixFormat_t IAudioClient_GetMixFormat_Original = nullptr; HRESULT
LcmSplInSem(); while (pIniEntry && lstrcmpi(pName, pIniEntry->pName)) pIniEntry = pIniEntry->pNext; return pIniEntry; } LPBYTE LcmPackStrings( _In_ DWORD dwElementsCount, _In_reads_(dwElementsCount) LPCWSTR *pSource, _Out_writes_bytes_(pDest-pEnd) LPBYTE pDest, _In_reads_(dwElementsCount) DWORD *DestOffsets, _Inout_updates_(_Inexpressible_("Involves negative offsets.")) LPBYTE pEnd ) { DWORD dwCount = 0; for (dwCount = 0; dwCount < dwElementsCount; dwCount++) { if (*pSource) { #pragma prefast(suppress:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED, "Just getting the length of current string, index of psource is correctly limited") size_t cbString = wcslen(*pSource)*sizeof(WCHAR) + sizeof(WCHAR); pEnd-= cbString; (VOID) StringCbCopy ((LPWSTR) pEnd, cbString, *pSource); *(LPWSTR UNALIGNED *)(pDest+*DestOffsets)= (LPWSTR) pEnd; }
#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");