how to mount and unmount a ramdisk never to restart system?

N

Nick Ryan

Open a handle to the volume, then call
FSCTL_LOCK_VOLUME/FSCTL_DISMOUNT_VOLUME, do your thing, then finish with
FSCTL_UNLOCK_VOLUME. Next access to the volume will cause a mount.
 
V

Vic.Dong

Nick Ryan, hello!
very thanks!
But those control codes was called by DeviceIoControl() function which
is only one of win32 APIs. I want to be called through kernel mode. can i
send that control codes by IRP_MJ_INTERNAL_DEVICE_CONTROL code within kernel
mode without by win32 application mode?
or have any way to do in kernel mode?

Thanks

Vic
 
N

Nick Ryan

You can send these control codes in kernel-mode using the major code
IRP_MJ_FILE_SYSTEM_CONTROL, minor code IRP_MN_KERNEL_CALL.
 
V

Vic.Dong

Nick Ryan:
Sorry!
I find those control codes of IRP_MN_KERNEL_CALL has already defined in
ntddk.h,thank u!
But i want to ask another questions:
1, IRP_MN_MOUNT_VOLUME : i think that means maybe mount volume. now,
what means of control code IRP_MN_KERNEL_CALL? what doing it is called by
specifies IRP_MN_KERNEL_CALL? about unmount volume?
2, if it succeeded to be called by IRP_MN_KERNEL_CALL, whether i call
another IRP by specify minor code IRP_MN_MOUNT_VOLUME?

Thanks
Vic
 
N

Nick Ryan

You don't need to send any IRPs to cause a volume to be mounted - the
system does this automatically whenever it determines that an unmounted
volume is being accessed in certain ways (i.e. the user clicks on the
drive letter in explorer). IRP_MN_KERNEL_CALL is simply an indication to
the system that the IRP_MJ_FILE_SYSTEM_CONTROL IRP is coming from a
trusted kernel-mode component, and not from user-mode.

This is all documented in the IFS kit.
 
V

Vic.Dong

Nick:
thank you!
I maybe very stupid and i also don't know how to unmount volume so far,
to unmount volume that can send IRP by specify major code
IRP_MJ_FILE_SYSTEM_CONTROL and minor code IRP_MN_KERNEL_CALL, is it? To
mount volume that done by system automatically, is it also?

I hope that don't faze you!

Regards

Vic
 
N

Nick Ryan

You of course also need to set FsControlCode in the IRP stack to the
appropriate value (FSCTL_DISMOUNT_VOLUME, etc.)
 
V

Vic.Dong

hi, all:
I am doing a ramdisk base on MS ramdisk sample, i want to change ramdisk
size whenever and not need to restart system, so i need to unmount ramdisk
volume before re-initialize and mount ramdisk after initialized, but i dont
know which control code can be performed in kernel mode.
who can help me?

Regards

Vic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top