sir, now I am not getting the things
CM_Get_Device_Interface_List can return multiple strings (although that's not likely in your case). Rather than pass a fixed sized buffer, use CM_Get_Device_Interface_List_SizeW to fetch the actual buffer size you need.
Are you seeing debug messages that show your AddDevice routine is actually getting called? That matches code I've used many times.
actually I cant see any messages from kernel side, I don't know why
I think the packet is not being made which is why it's not showing
If you're not seeing debug messages, then you don't even know if your filter is loading. What tool are you using? KdPrint messages are filters through the registry, turned off by default. DebugView with the verbose setting shows you everything, but that can be overwhelming. Check here to find out how to turn them on:
@Tim_Roberts can we connect through google meet??
This is because I could not find any symbolic link in my target device and the debugger is not working even after your instruction
.
can we connect through google meet??
No. I do contract driver consulting as a career. I answer on the mailing lists because it helps many people, but I don't do individual consulting for free.
and the debugger is not working even after your instruction
That has to be job one. Without the debugger, you're just shooting in the dark. Are you using DebugView or WinDbg?
I am using WinDbg as a debugger, I gave Access to the Debug Print Filter using Regedit. But still, it is not printing anything.
Kdprint-
SIMPLEAUDIOSAMPLE: [AddDevice]
PcAddAdapterDevice succeeded: 00000000
IoRegisterDeviceInterface succeeded: 00000000
this is from add-device in DRIVE
DId you call IoSetDeviceInterfaceState to turn on the interface? Registration isn't enough.
Yes Sir, here is the code:- ntStatus = IoSetDeviceInterfaceState(&deviceInterfaceName, TRUE);
if (NT_SUCCESS(ntStatus)) {
DbgPrint("IoSetDeviceInterfaceState succeeded: %08X\n", ntStatus);
}
else {
DbgPrint("IoSetDeviceInterfaceState failed: %08X\n", ntStatus);
return ntStatus;
}
I guess this is not getting printed because my driver is not getting updated----> I am using Devcon update SimpleAudioSample.inf Root\SimpleAudioSample to update my driver
Hey @Tim_Roberts, I think my build is not getting updated for some reason. Can you tell me the next step so that I can transfer the audio buffer from user mode to kernel mode?
here is my code for the adapter:Add Device
NTSTATUS AddDevice(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PDEVICE_OBJECT PhysicalDeviceObject
)
{
PAGED_CODE();
NTSTATUS ntStatus;
ULONG maxObjects;
UNICODE_STRING deviceInterfaceName;
DPF(D_TERSE, ("[AddDevice]"));
maxObjects = g_MaxMiniports;
// Add the adapter device via the port class
ntStatus = PcAddAdapterDevice(
DriverObject,
PhysicalDeviceObject,
PCPFNSTARTDEVICE(StartDevice),
maxObjects,
0
)
if (NT_SUCCESS(ntStatus)) {
DbgPrint("PcAddAdapterDevice succeeded--------------> %08X\n", ntStatus);
}
else {
DbgPrint("PcAddAdapterDevice failed-------------> %08X\n", ntStatus);
return ntStatus;
}
//// Register a device interface for user-mode access
ntStatus = IoRegisterDeviceInterface(
PhysicalDeviceObject, // Use the PDO provided
&GUID_DEVINTERFACE_YOURDEVICE,
NULL,
&deviceInterfaceName // This will hold the device interface symbolic link
);
if (NT_SUCCESS(ntStatus)) {
DbgPrint("IoRegisterDeviceInterface succeeded: %08X\n", ntStatus);
if (deviceInterfaceName.Buffer != NULL) {
DbgPrint("Device Interface Name: %wZ\n", &deviceInterfaceName); // %wZ for UNICODE_STRING
}
else {
DbgPrint("Device Interface Name buffer is NULL\n");
}
}
else {
DbgPrint("IoRegisterDeviceInterface failed: %08X\n", ntStatus);
return ntStatus;
}
// Enable the device interface so it can be accessed by user-mode applications
ntStatus = IoSetDeviceInterfaceState(&deviceInterfaceName, TRUE);
if (NT_SUCCESS(ntStatus)) {
DbgPrint("IoSetDeviceInterfaceState succeeded: %08X\n", ntStatus);
}
else {
DbgPrint("IoSetDeviceInterfaceState failed: %08X\n", ntStatus);
// Print out specific error info
switch (ntStatus) {
case STATUS_INVALID_DEVICE_REQUEST: // Corrected: added missing semicolon
DbgPrint("Invalid device request.\n");
break;
case STATUS_INSUFFICIENT_RESOURCES:
DbgPrint("Insufficient resources to enable device interface.\n");
break;
default:
DbgPrint("IoSetDeviceInterfaceState error code: %08X\n", ntStatus);
}
return ntStatus;
}
return ntStatus; // Return success
}
Does "devcon update" tell you it succeeded? It won't update the driver unless the version in the INF changes.
Personally, I almost never reinstall my drivers while I'm in the early debugging phase. Assuming you aren't running into signing issues, all you have to do to update the driver is "devcon disable" the device, copy your mew .sys file into place, and "devcon enable" again. I'm a little worried that you have created a whole bunch of fake audio devices now.
Does "devcon update" tell you it succeeded? yes, it says that the driver is updated but none of the changes appear. Ok, so I am making a VM for my driver to test and debug. so think I need to update the driver every time I build with new changes.
sir, I also checked the common.cpp file where I found that we are adding all adapters using the way you told (using IoRegisterDeviceInterface), so should I make the changes there??
I don't know what you mean by "all adapters". That code is in AddDevice, right? That should only happen once for your device.
When you say "none of the changes appear", if you check the size and date of your driver's binary in \windows\system32\drivers, you should be able to figure out right away if the binary has been updated. One trick I always use is to put something like this in every file:
void
IdentifyAdapter()
{
DPF( TRACE, __DATE__ " " __TIME__ " " __FILE__ "\n" );
}
(where DPF is a wrapper around DbgPrintEx), and then call all of the "Identify" functions from my DriverEntry. Now, I can see at a glance the files have the compile times I expect.
sir, actually I can also see all all the files that have the compile times I expect. but I don't know why my VS is not producing the updated inf file, I mean the date, time, and file, are getting changed, but the inside content is not getting changed. I simply removed the "IoRegisterDeviceInterface" and built the driver to check if the issue was with Devcon or with VS. I found it VS. Could you please give me some time so we can connect via Google Meet, it is crucial, I will pay the charges that is need .
What you're saying makes no sense. Visual Studio is not broken. If the .sys file copied to your test system has the time and size you expect, then it's the same file and has your source code.
Perhaps you should describe your build and install process in detail. When you make a change to your source, exactly what steps do you take?
ok, so let say I did some changes in my code, I cleaned solution-> rebuilt Solution, then I copy that debug file to my VM and run devcon update SimpleAudioSample.inf Root\SimpleAudioSample.
sir, when I went inside the .inf file the version is not getting updated,
[Version]
Signature = "$Windows NT$"
Class = MEDIA
Provider = %ProviderName%
ClassGUID = {4d36e96c-e325-11ce-bfc1-08002be10318}
DriverVer = 10/17/2024,16.31.0.703
CatalogFile = SimpleAudioSample.cat
PnpLockDown = 1
so as you can see, DriverVer = 10/17/2024 and I built the driver just now.
What debug file? Are you copying the newly created INF and CAT files as well as the SYS?