Sysdriver: How to capture Input data and play user audio application data

Yes sir, Sysvad is not getting build for target 10240 version…

Audio Gain Problem creating By Audio Engine:
We have given Volume control to the Audio engine by removing mic node as you suggested. Volume controls are working fine.

My Observations are:
As we have given volume control to audio engine, it is boosting up the Audio signal after audio is fed to sysvad? Even we record silence, we are able to hear some noise through speakers since some gain is being applied on data. So I assume that audio engine is applying some gain over our audio.

   We captured audio by Inbuilt mic 
   Again, The same data we feed to Virtual Driver using some application(We are not using any gain). Now, Audio gain of both Inbuilt and Virtual Device is not same.

   How to Bypass gain controller with sysvad or how to set dB  range minimum -96db and maximum 0 db? 

Advance Thanks,
Dinesh

I can’t tell what you mean. If you don’t supply a volume control, the Audio Engine supplies one, as you say. For a speaker, that volume control is applied before you receive the data. For a microphone, that volume control is supplied after you send the data. It has to be that way.

If you don’t want the system to adjust your microphone output, then add the microphone node back in and ignore the setting.

If you don’t want the system to adjust your microphone output, then add the microphone node back in and ignore the setting

 We added the microphone node back in and controlling the volume by Processing application with wasapi. Its working fine.

 Do we need to clean the registry, every time we uninstall the driver? Because we observing the blue screens if we try to install the driver which is uninstalled previously.And if we clean the registry we are getting normal. Or anything is effecting these installation files?,sir

Advance Thanks
Dinesh

You shouldn’t need to “clean the registry”, whatever that means. If you get a blue screen on a second install, then you have a bug, and you should investigate.

Otherwise in one case:
If we install without uninstalling previous version, it is crashing …Whether we can take care this scenario i.e system should not crash and it should throw error like already installed …in case someone trying this once

we added in the installation script before installation steps------devcon.exe remove =MEDIA Driver_NAME
still it is crashing.

After crash, we cleaned registry then it is working fine, so,any alternative to this case sir. Or,only any bug in driver code is creating this problem?.

Hi Dinesh,

Sorry for bothering, I’m facing the same problem that you had deal with that I always get error code -2 after calling CreateFile with the audio driver path obtain from CM_Get_Device_Interface_List.
Would you please share how you resolve this problem? And if possible would you please also share the IOCTL scenes that you use?
Thanks in advance for your help.

I always get error code -2

Windows does not use negative error numbers. Do you mean error code 2, ERROR_FILE_NOT_FOUND? One common newbie mistake that can lead to that is to fetch the file name as Unicode and try to pass it to CreateFileA, or vice versa. Perhaps you should show us the code where you call CM_Get_Device_Interface_List and CreateFile.

Hi Tim,

Yes, you are right, that is a mistake and I mean error code 2 ERROR_FILE_NOT_FOUND as you mention, thanks for you correction.

And here is the code pieces I use to get the file name and attempt to open it.

int FindAndOpenDevice(void)
{
    GUID guid = { 0x96b4c8f2L, 0xeb14, 0x4a80, 0xa6, 0x11, 0x07, 0xfa, 0xc1, 0x07, 0x29, 0xa8 };
    CONFIGRET cr;
    PWSTR 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 -1;
    }

    DeviceInterfaceList = (PWSTR)HeapAlloc(
        GetProcessHeap(),
        HEAP_ZERO_MEMORY,
        DeviceInterfaceListLength * sizeof(WCHAR));

    if (DeviceInterfaceList == NULL) {
        wprintf(L"allocate interface list buffer fail\n");
        return -2;
    }

    cr = CM_Get_Device_Interface_List(
        &guid,
        NULL,
        DeviceInterfaceList,
        DeviceInterfaceListLength,
        CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES);

    if (cr != CR_SUCCESS) {
        wprintf(L"fail to get interface list\n");
        return -3;
    }

    wprintf(L"%s\n", DeviceInterfaceList);

    HANDLE hDev = INVALID_HANDLE_VALUE;

    hDev = CreateFile(
        DeviceInterfaceList,
        FILE_GENERIC_READ,
        0,
        NULL,
        OPEN_EXISTING,
        0,
        NULL
    );

    if (hDev == INVALID_HANDLE_VALUE) {
        wprintf(L"fail to open device (0x%X)\n", GetLastError());
        return -4;
    }

    CloseHandle(hDev);
}

Through above function, I will get the console output (compiled with Unicode character set)

\\?\ROOT#MEDIA#0001#{96b4c8f2-eb14-4a80-a611-07fac10729a8}
fail to open device (0x2)

I also try to execute the program as administrator, but it looks no difference.
Please advise me if there are anything need to check, thank you.

Did you call IoSetDeviceInterfaceState in your driver to make the interface active? Are you intercepting IRP_MJ_CREATE in your driver so you can handle these opens? The default Port Class handler expects other information after the file name and won’t know what to do with this.

You probably want to pass FILE_GENERIC_READ|FILE_GENERIC_WRITE, assuming you’ll need to send data in both directions.

Hi Tim,

I did call IoSetDeviceInterfaceState to activate the interface right after calling IoRegisterDeviceInterface.
But i guess i had missing the intercepting IRP_MJ_CREATE part, I will make this part up and check whether the issue gone.
Thank you very much for your valuable advice.

Hi guys, I need help in this project too. Can someone tell me where to implement IOCTL.

Where to implement WHAT ioctl? How much have you done? What do you have working already?

I am relatively new to this as well. I want the driver to record and play live audio instead of Sine wave. I am finding it difficult to progress. I read the previous comments and tried following it but I haven’t got any further. I need some help on which places to change codes.

I want the driver to record and play live audio instead of Sine wave.

That doesn’t make sense. The virtual driver has no connection at all to “live audio”. You can capture the speaker output from an application, but the microphone data has to be fed in from an external application.

This is a difficult project, and not a good place for a beginner.

Hi,

I have decoded PCM data that I want to feed to virtual microphone, using SYSVAD i have created virtual mic,but I dont understand how to feed the data to virtual mic, may I know which class in sysvad to change for the same ,

**basically I have captured (using WASAPI) audio data that I want to redirect to virtual microphone, instead of playing using speaker
**
need help…thanks in advance

Note: is virtual speaker really required to feed the data to virtual mic…plz suggest i am new to this

Welcome to the forum! First, this is a “necro-post”, which is a term describing bringing a thread back from long ago … best to create an entirely new thread asking specifically what you’re running into (“How do I send audio data to the virtual microphone in SysVAD” or something similar. Next, this topic has been asked and answered a number of times, so use the handy “search” function at the top right for “SysVAD” and you’ll run into what others have found. Finally, SysVAD fills a ring buffer from the microphone, in the example using a sine wave function … you will need to do the same, pushing data from [wherever] into the ring buffer which is then used by the Audio Engine …

Do some searching, then see if that helps out a bit … :slight_smile:

Hi Tim_Roberts ,

inside AddDevice function i have added

ntStatus = IoRegisterDeviceInterface(
PhysicalDeviceObject,
&RPC_IOCTL_AUDIO,
NULL,
&referenceIOCtlString
);

if (ntStatus == STATUS_SUCCESS)
{
	ntStatus = IoSetDeviceInterfaceState(&referenceIOCtlString, TRUE);
}

after that do I need to create call IoCreateSymbolicLink or not required.

or: where and how to create symbolic link in sysvad example??? plz help i am stuck with this

Hi ,

my createfile function returns INVALID_HANDLE_VALUE,

hDev = CreateFile(
(LPCSTR)DeviceInterfaceList,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL
);

i have below code in place:

inside driverentry:
DriverObject->MajorFunction[IRP_MJ_CREATE] = IoctlCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = IoctlCreateClose;

definition:

NTSTATUS IoctlCreateClose(In DEVICE_OBJECT* _DeviceObject,
Inout IRP* _Irp)
{
UNREFERENCED_PARAMETER(_DeviceObject);

PIO_STACK_LOCATION stackLocation = NULL;
stackLocation = IoGetCurrentIrpStackLocation(_Irp);

switch (stackLocation->MajorFunction)
{
case IRP_MJ_CREATE:
	DbgPrint("Handle to symbolink link %wZ opened", DEVICE_SYMBOLIC_NAME);
	break;
case IRP_MJ_CLOSE:
	DbgPrint("Handle to symbolink link %wZ closed", DEVICE_SYMBOLIC_NAME);
	break;
default:
	break;
}

_Irp->IoStatus.Information = 0;
_Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(_Irp, IO_NO_INCREMENT);
PcDispatchIrp(_DeviceObject, _Irp);

return STATUS_SUCCESS;

}

in output console i am getting

\?\ROOT#MEDIA#0001#{4d36e96c-e325-11ce-bfc1-08002be10318}/////////DeviceInterfaceList value
fail to open device (0x2)/////how to resolve this

hello All,

need your help on above post,
plz i am totally stuck on this, not able to find the reason why my CreateFile api gives ERROR_FILE_NOT_FOUND , while the value of device interface is ?\ROOT#MEDIA#0001#{4d36e96c-e325-11ce-bfc1-08002be10318}

Please do let me know if u need any more input inorder to understand my issue

after that do I need to create call IoCreateSymbolicLink or not required

Not required.

IoRegisterDeviceInterface … RPC_AUDIO_IOCTL

Is that actually a GUID? That’s a very strange name for a Device Interface GUID.

And WHERE do you want to access the device from? In user mode, you lookup the GUID using CM_Get_Device_Interface_List

None of the code that you posted makes much sense to me… I don’t feel like I’ve got the full picture of what you’re trying to do, where, and how…

Peter