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

This result error 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 operating with This result

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.”. The first useful question is which native API, IRP, protocol operation, or subsystem in the kernel, native API, or subsystem that returned the status produced that status.

Debugging sequence

  • Preserve this result before RtlNtStatusToDosError, HRESULT conversion, exception translation, or provider-specific remapping removes information.
  • Correlate this result with ETW, Event Viewer, protocol traces, or a dump from the component that owns object / name / exists; do not diagnose from translated text alone.
  • For kernel I/O, keep the device stack, IRP major/minor function, request parameters, completion routine, and the first component that completed the request with it.

Recovery considerations

A retry is appropriate only after the owner of it has changed the state described by “{Object Exists} An attempt was made to create an object and the object name already existed.”, or when its contract explicitly marks the status as transient. If the value reports corruption, invalid format, access policy, or a lifecycle mismatch, preserve evidence and correct that cause before repeating the request.

Official references


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