Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 9  
07 Mar 18 07:10
Ankit Jain
xxxxxx@outlook.com
Join Date: 07 Mar 2018
Posts To This List: 5
Symbolic link of device object is not visile in winobj global section

Hi, Please help me.. I'm creating a windows device object in the handler function of user land IOCTL. Device is getting created and IocreateSymblicname() also returnred successfully. But symbolic link is not shown in winobj. code:- Ioctl func(){ switch (code) { case IOCTL_BUSE_DEVICE_ADD: { DbgPrint("IOCTL_BUSE_DEVICE_ADD for device %i.\n", device_extension->DeviceNumber); if (inputBufferLength < sizeof(BUSE_ADD_DISK)) { DbgPrint("Invalid input buffer size. Got: %u Expected at least: %u.\n", inputBufferLength, (int)(sizeof(BUSE_ADD_DISK))); status = STATUS_INVALID_PARAMETER; break; } else if (outputBufferLength < sizeof(BUSE_ADD_DISK_RESPONSE)) { DbgPrint("Invalid output buffer size. Got: %u Expected at least: %u.\n", outputBufferLength, (int)(sizeof(BUSE_ADD_DISK_RESPONSE))); status = STATUS_INVALID_PARAMETER; break; } DbgPrint("Referencing handle %p.\n", *(PHANDLE)Irp->AssociatedIrp.SystemBuffer); PBUSE_ADD_DISK add_disk = (PBUSE_ADD_DISK)buffer; DbgPrint("IOCTL_BUSE_DEVICE_ADD info dev no %u, sec size %u, dev_size %u.\n", add_disk->ad_dev_number, add_disk->ad_dev_sec_size, add_disk->ad_dev_size_MB); status = BuseDiskAddDisk(DeviceObj->DriverObject, add_disk, L"G:"); if (!NT_SUCCESS(status)) { DbgPrint("Cannot add disk device (%#x).\n", status); return status; } } NTSTATUS BuseDiskAddDisk(PDRIVER_OBJECT DriverObject, PBUSE_ADD_DISK add_disk, PCWSTR letter) { PDEVICE_EXTENSION pDeviceExtension = NULL; UNICODE_STRING ntDeviceName; NTSTATUS status; WCHAR VirtVolInstanceName[128]; PDEVICE_OBJECT DeviceObject; ULONG device_characteristics; DEVICE_TYPE device_type; device_type = FILE_DEVICE_DISK; device_characteristics = 0; RtlStringCchPrintfW(VirtVolInstanceName, RTL_NUMBER_OF(VirtVolInstanceName), L"\\Device\\BuseVol%d", add_disk->ad_dev_number); RtlInitUnicodeString(&ntDeviceName, VirtVolInstanceName); DbgPrint("Creating device '%ws'. Device type %#x, characteristics %#x.\n", (PWSTR)VirtVolInstanceName, device_type, device_characteristics); status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION), &ntDeviceName, device_type, device_characteristics, FALSE, &DeviceObject); if (!NT_SUCCESS(status)) { DbgPrint("Cannot create DeviceObject (%#x).\n", status); return status; } DeviceObject->Flags |= DO_DIRECT_IO; pDeviceExtension = (PDEVICE_EXTENSION)(DeviceObject)->DeviceExtension; RtlZeroMemory(pDeviceExtension, sizeof(DEVICE_EXTENSION)); // Allocate memory for the volume image. pDeviceExtension->DevSz = add_disk->ad_dev_size_MB * BUSE_MB_TO_BYTES; pDeviceExtension->VolumeImage = ExAllocatePoolWithTag(NonPagedPool, pDeviceExtension->DevSz, BUSE_VOL_TAG); if (pDeviceExtension->VolumeImage) { RtlZeroMemory(pDeviceExtension->VolumeImage, pDeviceExtension->DevSz); pDeviceExtension->DiskGeometry.BytesPerSector = add_disk->ad_dev_sec_size; pDeviceExtension->DiskGeometry.SectorsPerTrack = 32; pDeviceExtension->DiskGeometry.TracksPerCylinder = 2; pDeviceExtension->DiskGeometry.Cylinders.QuadPart = pDeviceExtension->DevSz / pDeviceExtension->DiskGeometry.BytesPerSector / 32 / 2; // Our media type is FixedMedia pDeviceExtension->DiskGeometry.MediaType = FixedMedia; pDeviceExtension->DeviceNumber = add_disk->ad_dev_number; status = ExUuidCreate(&pDeviceExtension->UniqueIdGuid); UNICODE_STRING win32Name; RtlInitUnicodeString(&win32Name, DOS_DEVICE_NAME); pDeviceExtension->SymbolicLink.Buffer = (PWSTR)&pDeviceExtension->DosDeviceNameBuffer; pDeviceExtension->SymbolicLink.MaximumLength = sizeof(pDeviceExtension->DosDeviceNameBuffer); pDeviceExtension->SymbolicLink.Length = win32Name.Length; UNICODE_STRING driveletter; RtlInitUnicodeString(&driveletter, letter); pDeviceExtension->DriveLetter.Buffer = (PWSTR)&pDeviceExtension->DriveLetterBuffer; pDeviceExtension->DriveLetter.MaximumLength = sizeof(pDeviceExtension->DriveLetterBuffer); pDeviceExtension->DriveLetter.Length = driveletter.Length; RtlCopyUnicodeString(&pDeviceExtension->DriveLetter, &driveletter); RtlCopyUnicodeString(&pDeviceExtension->SymbolicLink, &win32Name); RtlAppendUnicodeStringToString(&pDeviceExtension->SymbolicLink, &driveletter); DbgPrint("Creating device '%ws'. Device symb '%ws'\n", (PWSTR)VirtVolInstanceName, (PWSTR)pDeviceExtension->DriveLetterBuffer); status = IoCreateUnprotectedSymbolicLink(&pDeviceExtension->SymbolicLink, &ntDeviceName); if (!NT_SUCCESS(status)) { DbgPrint("Cannot create pDeviceExtension device symblink (%#x).\n", status); IoDeleteDevice(DeviceObject); return status; } UNICODE_STRING ntName; RtlInitUnicodeString(&ntName, VirtVolInstanceName); pDeviceExtension->NtDeviceName.Buffer = (PWSTR)&pDeviceExtension->NtDeviceNameBuffer; pDeviceExtension->NtDeviceName.MaximumLength = sizeof(pDeviceExtension->NtDeviceNameBuffer); pDeviceExtension->NtDeviceName.Length = ntName.Length; RtlCopyUnicodeString(&pDeviceExtension->NtDeviceName, &ntName); } else { DbgPrint("Unable to grab memory\n"); } return status; }
  Message 2 of 9  
07 Mar 18 07:37
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
Symbolic link of device object is not visile in winobj global section

Good heavens! WHAT do we have to do to get people to stop writing drivers like this using WDM? Showing us the output produced in the debugger would help.. what is your DOS device name that you?re trying to assign? Peter OSR @OSRDrivers
  Message 3 of 9  
07 Mar 18 07:41
Ankit Jain
xxxxxx@outlook.com
Join Date: 07 Mar 2018
Posts To This List: 5
Symbolic link of device object is not visile in winobj global section

<< >> WHAT do we have to do to get people to stop writing drivers like this using WDM? I'm new in windows world and learning windows driver :). << >> << >> what is your DOS device name that you?re trying to assign? L"\\DosDevices\\E:" << >>
  Message 4 of 9  
07 Mar 18 07:46
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
Symbolic link of device object is not visile in winobj global section

<quote> I'm new in windows world and learning windows driver :) </quote> Then learn how to write the RIGHT KIND of driver. Under NO circumstances do you want to write a WDM driver. You want to use WDF: that is, KMDF or UMDF. Please. WDM is an old, outdated, complex, bug provoking, interface. You will either hate yourself while debugging your WDM driver or you will happily and unknowingly create a driver with many bugs. Peter OSR @OSRDrivers
  Message 5 of 9  
07 Mar 18 07:49
Ankit Jain
xxxxxx@outlook.com
Join Date: 07 Mar 2018
Posts To This List: 5
Symbolic link of device object is not visile in winobj global section

I was referring Ramdisk sample code for achieving this task (WDF model). I want to expose virtual drive when user perform add device IOCTL. But unable to find out the way of creating a new device object outside DriverEntry() or addDeviceEvt(). If you have any idea please guide me.
  Message 6 of 9  
07 Mar 18 07:51
Ankit Jain
xxxxxx@outlook.com
Join Date: 07 Mar 2018
Posts To This List: 5
Symbolic link of device object is not visile in winobj global section

Please let me know any standard example in WDF for learning purpose. It would be very helpful if you can point any standard book for it.
  Message 7 of 9  
07 Mar 18 08:07
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
Symbolic link of device object is not visile in winobj global section

Use the toaster sample from the WDK. There a book on WDF by Orwick and Fischer. It?s better than nothing. Peter OSR @OSRDrivers
  Message 8 of 9  
07 Mar 18 13:05
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11963
Symbolic link of device object is not visile in winobj global section

xxxxx@outlook.com wrote: > I was referring Ramdisk sample code for achieving this task (WDF model). I want to expose virtual drive when user perform add device IOCTL. > > But unable to find out the way of creating a new device object outside DriverEntry() or addDeviceEvt(). If you have any idea please guide me. You already said that IoCreateDevice worked, right?  Then you have found the way.  There's nothing particularly special about DriverEntry or AddDevice. Can you see your \Device in winobj?  (Not the symbolic link, but the base device.)  Did you do a "Refresh" in winobj after sending your ioctl?  Does the G: drive letter work? -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 9 of 9  
07 Mar 18 14:07
Ankit Jain
xxxxxx@outlook.com
Join Date: 07 Mar 2018
Posts To This List: 5
Symbolic link of device object is not visile in winobj global section

<< >> Can you see your \Device in winobj?? (Not the symbolic link, but the base device.)? Did you do a "Refresh" in winobj after sending your ioctl?=C2 Does the G: drive letter work? Yes, I've refreshed it multiple times but still no luck. Unable to see drive as well as symbolic link.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 04:09.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license