ULONG AlignedDeviceExtensionSize;
ULONG TotalSize;
HANDLE TempHandle;
+ PACL Dacl;
+ SECURITY_DESCRIPTOR SecurityDescriptor, *ReturnedSD;
PAGED_CODE();
/* Check if we have to generate a name */
DeviceName = &AutoName;
}
+ /* Get the security descriptor */
+ ReturnedSD = IopCreateDefaultDeviceSecurityDescriptor(DeviceType,
+ DeviceCharacteristics,
+ DeviceName != NULL,
+ &SecurityDescriptor,
+ &Dacl,
+ NULL);
+
/* Initialize the Object Attributes */
InitializeObjectAttributes(&ObjectAttributes,
DeviceName,
OBJ_KERNEL_HANDLE,
NULL,
- SePublicOpenUnrestrictedSd);
+ ReturnedSD);
/* Honor exclusive flag */
if (Exclusive) ObjectAttributes.Attributes |= OBJ_EXCLUSIVE;
0,
0,
(PVOID*)&CreatedDeviceObject);
- if (!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status))
+ {
+ if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
+
+ return Status;
+ }
/* Clear the whole Object and extension so we don't null stuff manually */
RtlZeroMemory(CreatedDeviceObject, TotalSize);
Status = IopCreateVpb(CreatedDeviceObject);
if (!NT_SUCCESS(Status))
{
+ if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
+
/* Dereference the device object and fail */
ObDereferenceObject(CreatedDeviceObject);
return Status;
1,
(PVOID*)&CreatedDeviceObject,
&TempHandle);
- if (!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status))
+ {
+ if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
+
+ return Status;
+ }
/* Now do the final linking */
ObReferenceObject(DriverObject);
/* Close the temporary handle and return to caller */
ObCloseHandle(TempHandle, KernelMode);
*DeviceObject = CreatedDeviceObject;
+
+ if (Dacl != NULL) ExFreePoolWithTag(Dacl, 'eSoI');
+
return STATUS_SUCCESS;
}