What does NTSTATUS 0x40000000 (STATUS_OBJECT_NAME_EXISTS) mean?

 
Previous Next
STATUS_SPACES_REDIRECT STATUS_THREAD_WAS_SUSPENDED

STATUS_OBJECT_NAME_EXISTS

Meaning and context of STATUS_OBJECT_NAME_EXISTS

STATUS_OBJECT_NAME_EXISTS is returned when calling functions that create a named object and an object with the same name already exists. This code is not an error. If the driver checks the return value using the NT_SUCCESS macro, the macro will evaluate to TRUE (which indicates no errors).

Example of code handling STATUS_OBJECT_NAME_EXISTS

NTSTATUS CreateMyDevice(IN PDRIVER_OBJECT pDriverObject)
{
	NTSTATUS status;
	UNICODE_STRING devName;//device name
	UNICODE_STRING sysLinkName;//System symbolic link name
	PDEVICE_OBJECT pDevObject;//Used to return to create a device

	RtlInitUnicodeString(&devName, L"\\Device\\MyDevObj");
	status = IoCreateDevice(pDriverObject, 0, &devName, FILE_DEVICE_UNKNOWN, 0, TRUE, &pDevObject);
	if (!NT_SUCCESS(status))
	{
		if (status == STATUS_INSUFFICIENT_RESOURCES)
		{
			KdPrint(("Insufficient resources\n"));
		}
		if (status == STATUS_OBJECT_NAME_EXISTS)
		{
			KdPrint(("Specified object name exists\n"));
		}
		if (status == STATUS_OBJECT_NAME_COLLISION)
		{
			KdPrint(("Object name conflict"));
		}
		return status;
	}
	KdPrint(("Device created successfully\n"));
	pDevObject->Flags |= DO_BUFFERED_IO;//Read and write in buffer mode
	RtlInitUnicodeString(&sysLinkName, L"\\??\\MySysData");
	IoDeleteSymbolicLink(&sysLinkName);
	status = IoCreateSymbolicLink(&sysLinkName, &devName);//Determine whether the symbolic link is successfully generated
	if (!NT_SUCCESS(status))
	{
		KdPrint(("Failed to generate symbolic link\n"));
		IoDeleteDevice(pDevObject);
		return status;
	}
	KdPrint(("Generate symbolic link successfully"));

	return STATUS_SUCCESS;
}

Native status interpretation

STATUS_OBJECT_NAME_EXISTS is 0x40000000, an NTSTATUS informational value. AllStat describes it as “{Object Exists} An attempt was made to create an object and the object name already existed.”

Official references


Looking for a different code? Search another status or error code.