/* We do, query its name */
Status = ObQueryNameString(LogEntry->DeviceObject,
ObjectNameInfo,
- sizeof(OBJECT_NAME_INFORMATION) +
- 100 -
- DriverNameLength,
+ sizeof(Buffer),
&ReturnedLength);
- if ((!NT_SUCCESS(Status)) || !(ObjectNameInfo->Name.Length))
+ if (!NT_SUCCESS(Status) || (ObjectNameInfo->Name.Length == 0))
{
/* Setup an empty name */
ObjectNameInfo->Name.Length = 0;
DeviceNameLength += sizeof(WCHAR);
/* Free the buffer if we had one */
- if (PoolObjectNameInfo) ExFreePool(PoolObjectNameInfo);
+ if (PoolObjectNameInfo)
+ {
+ ExFreePool(PoolObjectNameInfo);
+ PoolObjectNameInfo = NULL;
+ ObjectNameInfo = (POBJECT_NAME_INFORMATION)&Buffer;
+ }
/* Go to the next string buffer position */
ErrorMessage->EntryData.NumberOfStrings++;
break;
}
- /* Derefernece the device object */
+ /* Dereference the device object */
if (LogEntry->DeviceObject) ObDereferenceObject(LogEntry->DeviceObject);
if (DriverObject) ObDereferenceObject(LogEntry->DriverObject);
{
PERROR_LOG_ENTRY LogEntry;
ULONG LogEntrySize;
- PDRIVER_OBJECT DriverObject;
PDEVICE_OBJECT DeviceObject;
+ PDRIVER_OBJECT DriverObject;
/* Make sure we have an object */
if (!IoObject) return NULL;
/* Check if we're past our buffer */
if (IopTotalLogSize > PAGE_SIZE) return NULL;
- /* Calculate the total size and allocate it */
- LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize;
- LogEntry = ExAllocatePoolWithTag(NonPagedPool,
- LogEntrySize,
- TAG_ERROR_LOG);
- if (!LogEntry) return NULL;
-
/* Check if this is a device object or driver object */
if (((PDEVICE_OBJECT)IoObject)->Type == IO_TYPE_DEVICE)
{
}
else if (((PDEVICE_OBJECT)IoObject)->Type == IO_TYPE_DRIVER)
{
- /* It's a driver, so we don' thave a device */
+ /* It's a driver, so we don't have a device */
DeviceObject = NULL;
- DriverObject = IoObject;
+ DriverObject = (PDRIVER_OBJECT)IoObject;
}
else
{
return NULL;
}
+ /* Calculate the total size and allocate it */
+ LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize;
+ LogEntry = ExAllocatePoolWithTag(NonPagedPool,
+ LogEntrySize,
+ TAG_ERROR_LOG);
+ if (!LogEntry) return NULL;
+
/* Reference the Objects */
if (DeviceObject) ObReferenceObject(DeviceObject);
if (DriverObject) ObReferenceObject(DriverObject);