?? dbg.c
字號:
/*++
Copyright (c) 2005-2006 E0 Technology,Inc.
Module Name:
dbg.c
Abstract:
Virtual Com Port Driver for USB to RS232 Converter of E0 Technology,Inc.
Environment:
Kernel mode
Notes:
Revision History:
2006/3/1 : Adapted from the BulkUsb DDK sample.
--*/
#if DBG
#include "usb2com.h"
// begin, data/code used only in DBG build
// may be overridden in registry in DBG buils only
// higher == more verbose, default is 1, 0 turns off all
int gDebugLevel = DBGLVL_MAXIMUM ;
// count outstanding allocations via ExAllocatePool
int gExAllocCount =0;
USB2COM_DBGDATA gDbgBuf = { 0, 0, 0, 0 };
// ptr to global debug data struct; txt buffer is only allocated in DBG builds
PUSB2COM_DBGDATA gpDbg = &gDbgBuf;
BOOLEAN
USB2COM_GetRegistryDword(
IN PWCHAR RegPath,
IN PWCHAR ValueName,
IN OUT PULONG Value
)
/*++
Routine Description:
Obtain a Dword value from the registry
Arguments:
RegPath -- supplies absolute registry path
ValueName - Supplies the Value Name.
Value - receives the REG_DWORD value.
Return Value:
TRUE if successfull, FALSE on fail.
--*/
{
UNICODE_STRING path;
RTL_QUERY_REGISTRY_TABLE paramTable[2]; //zero'd second table terminates parms
ULONG lDef = *Value; // default
NTSTATUS status;
BOOLEAN fres;
WCHAR wbuf[ MAXIMUM_FILENAME_LENGTH ];
USB2COM_KdPrint( DBGLVL_HIGH,("Enter USB2COM_GetRegistryDword() RegPath = %ws\n ValueName =%ws\n", RegPath, ValueName));
path.Length = 0;
path.MaximumLength = MAXIMUM_FILENAME_LENGTH * sizeof( WCHAR ); // MAXIMUM_FILENAME_LENGTH defined in wdm.h
path.Buffer = wbuf;
RtlZeroMemory(path.Buffer, path.MaximumLength);
RtlMoveMemory(path.Buffer, RegPath, wcslen( RegPath) * sizeof( WCHAR ));
USB2COM_KdPrint( DBGLVL_HIGH,("USB2COM_GetRegistryDword() path= %ws\n", path.Buffer ));
RtlZeroMemory(paramTable, sizeof(paramTable));
paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
paramTable[0].Name = ValueName;
paramTable[0].EntryContext = Value;
paramTable[0].DefaultType = REG_DWORD;
paramTable[0].DefaultData = &lDef;
paramTable[0].DefaultLength = sizeof(ULONG);
status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
path.Buffer, paramTable, NULL, NULL);
if (NT_SUCCESS(status)) {
USB2COM_KdPrint( DBGLVL_MEDIUM,("Exit USB2COM_GetRegistryDWord() SUCCESS, value = decimal %d 0x%x\n", *Value, *Value));
fres = TRUE;
} else {
USB2COM_KdPrintCond( DBGLVL_MEDIUM, (status == STATUS_INVALID_PARAMETER) ,("USB2COM_GetRegistryDWord() STATUS_INVALID_PARAMETER\n"));
USB2COM_KdPrintCond( DBGLVL_MEDIUM, (status == STATUS_OBJECT_NAME_NOT_FOUND) ,("USB2COM_GetRegistryDWord() STATUS_OBJECT_NAME_NOT_FOUND\n"));
fres = FALSE;
}
return fres;
}
PVOID
USB2COM_ExAllocatePool(
IN POOL_TYPE PoolType,
IN ULONG NumberOfBytes
)
{
PVOID p = NULL;
p = ExAllocatePool( PoolType, NumberOfBytes );
if(p)
{
gExAllocCount++;
}
USB2COM_KdPrint( DBGLVL_HIGH,("USB2COM_ExAllocatePool() gExAllocCount = dec %d\n", gExAllocCount ));
return p;
}
VOID
USB2COM_ExFreePool(
IN PVOID p
)
{
gExAllocCount--;
USB2COM_KdPrint( DBGLVL_HIGH,("USB2COM_ExFreePool() gExAllocCount = dec %d\n", gExAllocCount ));
ExFreePool( p );
}
#endif // end , if DBG
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -