@Tim_Roberts said:
You don’t need to call IoCreateSymbolicLink
, but you do need to call IoSetDeviceInterfaceState
to turn it on.
4d36e96c-e325-11ce-bfc1-08002be10318
That’s the Media class GUID. Your driver should already be registered there. How did you define RPC_IOCTL_AUDIO
? Where did DEVICE_SYMBOLIC_LINK
come from in your driver code?
Also, you need to remember that you are going to see IRP_MJ_CREATE calls both from your test application AND from the Audio Engine. Audio Engine opens many file handles into an audio device: some for the filter while it’s probing, some for the filter while it is operating, and some for each of the pins, where the traffic really flows. You need to check in your “create” handler whether it is a request from your app or not. If it is, you handle it and complete it. If not, you pass it to PcDispatchIrp
.
_Irp->IoStatus.Information = 0;
_Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(_Irp, IO_NO_INCREMENT);
PcDispatchIrp(_DeviceObject, _Irp);
If you were looking for the fastest way to generate a blue screen, this is it. Do you really not understand what’s going on here at all? PcDispatchIrp
tells the Port Class driver to handle this request using its normal processing. It’s going to go through it’s own “create” processing, then it will complete the request. Since you have already completed, it, BANG, blue screen. You need to ONE or the OTHER. Never both. If you handle the IRP, then you don’t let Port Class see it. If you don’t handle it, then you pass it to Port Class.
Hi,
my device is already registered at 4d36e96c-e325-11ce-bfc1-08002be10318 in registry,
#define IOCTL_NT_DEVICE_NAME L"\Device\RemotePCVad"
UNICODE_STRING referenceIOCtlString;
DEFINE_GUIDSTRUCT(“4d36e96c-e325-11ce-bfc1-08002be10318”, RPC_IOCTL_AUDIO);
#define RPC_IOCTL_AUDIO DEFINE_GUIDNAMED(RPC_IOCTL_AUDIO)
I think since i am using
RtlInitUnicodeString(&referenceIOCtlString, IOCTL_NT_DEVICE_NAME);
ntStatus = IoRegisterDeviceInterface(
PhysicalDeviceObject,
&RPC_IOCTL_AUDIO,
NULL,
&referenceIOCtlString
);
if (ntStatus == STATUS_SUCCESS)
{
ntStatus = IoSetDeviceInterfaceState(&referenceIOCtlString, TRUE);
}
so Symbolinclink is not required, I will remove DbgPrint(“Handle to symbolink link %wZ opened”, DEVICE_SYMBOLIC_NAME); code from IoctlCreateClose function
but why Createfile returns ERROR_FILE_NOT_FOUND;
my testapp code:
GUID guid = { 0x4d36e96c, 0xe325, 0x11ce, 0xbf, 0xc1, 0x8, 0x0, 0x2b, 0xe1, 0x3, 0x18 };/
CONFIGRET cr;
PZZSTR DeviceInterfaceList = NULL;
ULONG DeviceInterfaceListLength = 0;
cr = CM_Get_Device_Interface_List_Size(
&DeviceInterfaceListLength,
&guid,
NULL,
CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES
);
if (cr != CR_SUCCESS) {
wprintf(L"fail to get interface list size\n");
return ;
}
DeviceInterfaceList = (PZZSTR)HeapAlloc(
GetProcessHeap(),
HEAP_ZERO_MEMORY,
DeviceInterfaceListLength * sizeof(WCHAR));
if (DeviceInterfaceList == NULL) {
wprintf(L"allocate interface list buffer fail\n");
return ;
}
cr = CM_Get_Device_Interface_List(
&guid,
NULL,
DeviceInterfaceList,
DeviceInterfaceListLength,
CM_GET_DEVICE_INTERFACE_LIST_PRESENT);
if (cr != CR_SUCCESS) {
wprintf(L"fail to get interface list\n");
return ;
}
// strncpy_s(DevicePath, DeviceInterfaceListLength,DeviceInterfaceList, DeviceInterfaceListLength);
//StringCchCopy(DevicePath, DeviceInterfaceListLength, DeviceInterfaceList);
///printf(L"%s\n", (const char*)DeviceInterfaceList);
_tprintf(_T("%s\n"), (LPCSTR)DeviceInterfaceList);
HANDLE hDev = INVALID_HANDLE_VALUE;
hDev = CreateFile(
(LPCSTR)DeviceInterfaceList,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL
);
errNum = GetLastError();//////errNum value is 2/////this is issue i am facing
in registry i can see my device registered under:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses{4d36e96c-e325-11ce-bfc1-08002be10318}##?#ROOT#MEDIA#0001#{4d36e96c-e325-11ce-bfc1-08002be10318}
How to know who(user app or audio engine) calls IRP_MJ_CREATE