Solved

Notification on disk access

Posted on 1998-06-16
11
727 Views
Last Modified: 2012-05-04
Hy!

I'd like my software to get a notification each time the system
accesses (reads or writes) a hard disk or network drive.
DeviceIoControl / IOCTL_DISK_PERFORMANCE seems to be a way to
poll that information, but I can't open a handle to a disk drive
under Win95. It just doesn't work.
0
Comment
Question by:holz
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 2

Expert Comment

by:kinkajou
ID: 1166016
How to get a handle to a Win95 disk drive (example for the A: drive):

In Win95 you need to open the handle not to the logical device, but instead to a VXD. Therefore, you need to specify "\\\\.\\vwin32" in a call to CreateFile(), to specify the system vxd, VWIN32.VXD, which supports the input and output control (IOCTL) functions originally provided by MS-DOS Interrupt 21h. At that point you can either call DeviceIOControl or call int21 directly.

The article http://support.microsoft.com/support/kb/articles/q163/9/20.asp gives an example of how to open the floppy and query its device characteristics under Win95.

HANDLE pFile;

     pFile = CreateFile("\\\\.\\vwin32",
                                GENERIC_READ | GENERIC_WRITE,
                                FILE_SHARE_READ | FILE_SHARE_WRITE,
                                NULL,
                                OPEN_EXISTING,
                                0,
                                NULL );

Use this example for the floppy for any disk drive device under windows 95.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1166017
Don't forget that when you use DeviceIoControl in that matter, you're communicating with VWIN32.VXD, not with the drive!  You are simulating int 21h and therefore, arguments must be different then the documented ones.

For more documentation and sample code see:
  http://www.dejanews.com/getdoc.xp?AN=207816158
  http://www.dejanews.com/getdoc.xp?AN=211688212
  http://www.microsoft.com/kb/articles/q168/1/80.htm
  http://www.microsoft.com/kb/articles/q163/9/20.htm
0
 

Author Comment

by:holz
ID: 1166018
Thanks, but this still leaves questions open:
1. When I open the driver instead of the HD, how do I tell the system which drive I want
    to have information about? IOCTL_DISK_PERFORMANCE doesn't acceppt ANY
    input variables.
2. Some article from the KB suggested that IOCTL_* functions are not available under
    Windows 95. Sorry, I can't find that article any more. But: Is it true and is there
    another way to query how many bytes were read from a certain drive until now?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1166019
Nonono!!!!
You do *not* use IOCTL_DISK_PERFORMANCE.  You simulate the int 21h IOCTL function with the correct parameters.  See the first two URLs I provided for samples (by Raymond Chen from MS).

0
 

Author Comment

by:holz
ID: 1166020
"You simulate the int 21h IOCTL function with the correct parameters." sounds nice, but I can't find an interrupt doing the same work as IOCTL_DISK_PERFORMANCE would. Are you sure it does exist?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:sprinkmeier
ID: 1166021
There is a set of functions under the WIN32 API that can notify you when disk stuff hapens. Look up:
FindFirstChangeNotification
I'm not sure it's exactly what you want, but it might help.
(I got a simple demo program, lemme know if you want it)
0
 
LVL 2

Expert Comment

by:sprinkmeier
ID: 1166022
There is a set of functions under the WIN32 API that can notify you when disk stuff hapens. Look up:
FindFirstChangeNotification
I'm not sure it's exactly what you want, but it might help.
(I got a simple demo program, lemme know if you want it)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1166023
OK, holz, the bad news:
1. IOCTL_DISK_PERFORMANCE is supported only under NT.
2. There is *absolutely* no VWIN32 or INT 21h equivalent (according to Ralf Brown's interrupt list, MSDN and other sources of information).

You could get the Win95 DDK and check if a custom VxD could do it but I doubt it.

FindFirstChangeNotification() will let you monitor file/directory changes in a subtree but not more than that.

I guess that the answer is, regretfully, that it cannot be done [at least without a custom VxD].
0
 
LVL 2

Accepted Solution

by:
lucidity earned 200 total points
ID: 1166024
This should do the trick
http://www.sysinternals.com/
look under Source for Win95, FileMon

Its VERY handy and does exactly what you want, just give me a good grade.
0
 

Author Comment

by:holz
ID: 1166025
Thanks, I'd already given up.
0
 

Expert Comment

by:JonathanJames
ID: 1166026
sprinkmeier, I would like to obtain your demoprogram if that's ok.. My Email is Jonathan.James@home.se

Thankyou
Regards
Jonathan James
"advanced VB programmer, converting to C++" :D
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Converting to C# also VS2015 5 117
Which IDE to use to begin C++ training? 5 59
Dynamically allocate memory 9 55
C++ error cannot convert from std::string to const char * 6 123
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now