Author |
Message |
<z> #1 / 15
|
 Reading/Writing Sectors
Hi all, I need to perform the equivalent of an INT 25H (Absolute Sector Read) and INT 26H (Absolute Sector Write). How can I do this in VB6? Thanks, z
|
Sun, 07 Mar 2004 12:23:40 GMT |
|
 |
J Fren #2 / 15
|
 Reading/Writing Sectors
With great difficulty - I would never attempt it in VB and have failed to get it working in ASM in Delphi32 - no problem in Delphi16. AFAIK to do this you need to 'Thunk' - that is, move into 16bit mode. I shall watch this thread with interest. Quote:
>Hi all, >I need to perform the equivalent of an INT 25H (Absolute Sector Read) and >INT 26H (Absolute Sector Write). >How can I do this in VB6? >Thanks, >z
|
Sun, 07 Mar 2004 17:36:38 GMT |
|
 |
<z> #3 / 15
|
 Reading/Writing Sectors
I don't have to actually have it in VB, but need to be able to call it from VB. Is there a API call that can do it or does someone know of a DLL? This looked promising: http://www.planet-source-code.com/xq/ASP/txtCodeId.21381/lngWId.1/qx/... pts/ShowCode.htm But using the file name \\.\A: did not yield the reading of the sectors of drive A:. Also when trying to position the file pointer and reading it always yielded the beginning of the file.
Quote: > With great difficulty - I would never attempt it in VB and have failed > to get it working in ASM in Delphi32 - no problem in Delphi16. > AFAIK to do this you need to 'Thunk' - that is, move into 16bit mode.
> >I need to perform the equivalent of an INT 25H (Absolute Sector Read) and > >INT 26H (Absolute Sector Write). > >How can I do this in VB6?
|
Mon, 08 Mar 2004 00:39:30 GMT |
|
 |
Frank Ad #4 / 15
|
 Reading/Writing Sectors
Quote:
>http://www.planet-source-code.com/xq/ASP/txtCodeId.21381/lngWId.1/qx/... >pts/ShowCode.htm >But using the file name \\.\A: did not yield the reading of the sectors of >drive A:. Also when trying to >position the file pointer and reading it always yielded the beginning of the >file.
Without looking at that URL and the code.. are you trying to do low level access over a network ? I would hope that networks would have security in place to prevent anyone doing that. Was this possible to do pre win32 ? <snip> Regards, Frank
|
Mon, 08 Mar 2004 12:57:29 GMT |
|
 |
<z> #5 / 15
|
 Reading/Writing Sectors
Quote:
>http://www.planet-source-code.com/xq/ASP/txtCodeId.21381/lngWId.1/qx/... i > >pts/ShowCode.htm > >But using the file name \\.\A: did not yield the reading of the sectors of > >drive A:. Also when trying to > >position the file pointer and reading it always yielded the beginning of the > >file. > Without looking at that URL and the code.. are you trying to do low > level access over a network ? I would hope that networks would have > security in place to prevent anyone doing that.
I believed that was how you specified a file for the drive itself and nothing to with networking. For my project I am creating a disk server which feeds requests from a serial port. z
|
Mon, 08 Mar 2004 16:45:32 GMT |
|
 |
J Fren #6 / 15
|
 Reading/Writing Sectors
Longish snip from Win 32 Programmer's Reference <snip> Disk Devices Windows NT: You can use the CreateFile function to open a disk drive or a partition on a disk drive. The function returns a handle to the disk device; that handle can be used with the DeviceIOControl function. The following requirements must be met in order for such a call to succeed: The caller must have administrative privileges for the operation to succeed on a hard disk drive. The lpFileName string should be of the form \\.\PHYSICALDRIVEx to open the hard disk x. Hard disk numbers start at zero. For example: String Meaning \\.\PHYSICALDRIVE2 Obtains a handle to the third physical drive on the user's computer. The lpFileName string should be \\.\x: to open a floppy drive x or a partition x on a hard disk. For example: String Meaning \\.\A: Obtains a handle to drive A on the user's computer. \\.\C: Obtains a handle to drive C on the user's computer. Windows 95: This technique does not work for opening a logical drive. In Windows 95, specifying a string in this form causes CreateFile to return an error. </snip> Basically the stuff at PlanetSource shows you how to use the CreateFile API - under Windows NT CreateFile allows you to 'open' a floppy directly - by{*filter*}ering around with the file name. All profoundly useful if you are not using Win NT - and IMO a damn stupid way of doing things - imagine a slightly smart user entering \\.\C: as a file name. The thought is horrific. As yet I am not familiar with 'thunking' - and I must confess that I only use Int 25 and (more seriously) Int 26 under some duress, but I would recommend that you get hold of a copy of 16 bit Delphi and use that to write the stuff you need. You should be able to drive it via SendMessage. Quote:
>I don't have to actually have it in VB, but need to be able to call it from >VB. >Is there a API call that can do it or does someone know of a DLL? >This looked promising: > http://www.*-*-*.com/ >pts/ShowCode.htm >But using the file name \\.\A: did not yield the reading of the sectors of >drive A:. Also when trying to >position the file pointer and reading it always yielded the beginning of the >file.
>> With great difficulty - I would never attempt it in VB and have failed >> to get it working in ASM in Delphi32 - no problem in Delphi16. >> AFAIK to do this you need to 'Thunk' - that is, move into 16bit mode.
>> >I need to perform the equivalent of an INT 25H (Absolute Sector Read) and >> >INT 26H (Absolute Sector Write). >> >How can I do this in VB6?
|
Mon, 08 Mar 2004 18:07:00 GMT |
|
 |
J Fren #7 / 15
|
 Reading/Writing Sectors
Hmm - your reply to Frank popped up just after I posted. Why do you need Absolute Disk write for something that is servicing a COM port ? - or am I missing something ? Quote:
>>http://www.planet-source-code.com/xq/ASP/txtCodeId.21381/lngWId.1/qx/... >i >> >pts/ShowCode.htm >> >But using the file name \\.\A: did not yield the reading of the sectors >of >> >drive A:. Also when trying to >> >position the file pointer and reading it always yielded the beginning of >the >> >file. >> Without looking at that URL and the code.. are you trying to do low >> level access over a network ? I would hope that networks would have >> security in place to prevent anyone doing that. >I believed that was how you specified a file for the drive itself and >nothing >to with networking. >For my project I am creating a disk server which feeds requests from a >serial port. >z
|
Mon, 08 Mar 2004 20:12:00 GMT |
|
 |
Howard Henry Schlunde #8 / 15
|
 Reading/Writing Sectors
That isn't a problem because in this raw mode, you can only read/write/seek on sector boundaries. Since general file writting code doesn't "think" in terms of sectors, it is incredibly likely to fail. Howard Henry Schlunder Quote:
> All profoundly useful if you are not using Win NT - and IMO a damn > stupid way of doing things - imagine a slightly smart user entering > \\.\C: as a file name. The thought is horrific.
|
Tue, 09 Mar 2004 06:48:49 GMT |
|
 |
Howard Henry Schlunde #9 / 15
|
 Reading/Writing Sectors
First and foremost, are you running Windows NT or 2000? I've written a fairly semi-complete volume imaging program which does very similarly what you are talking about. I never thought I would release it in any fashion, but oh well. Full source and a signed executable can be downloaded from [ http://venus.ajusd.org/~hschlund/products/VolumeImager.zip ]. I usually use it to copy floppies and CDs to my hard drive. The main thing you have to keep in mind when working with volumes like this is that you have to read and write a whole sector at a time. I believe the same goes for seeking. Howard Henry Schlunder Quote:
> I don't have to actually have it in VB, but need to be able to call it from > VB. > Is there a API call that can do it or does someone know of a DLL? > This looked promising: > http://www.planet-source-code.com/xq/ASP/txtCodeId.21381/lngWId.1/qx/... > pts/ShowCode.htm > But using the file name \\.\A: did not yield the reading of the sectors of > drive A:. Also when trying to > position the file pointer and reading it always yielded the beginning of the > file.
> > With great difficulty - I would never attempt it in VB and have failed > > to get it working in ASM in Delphi32 - no problem in Delphi16. > > AFAIK to do this you need to 'Thunk' - that is, move into 16bit mode.
> > >I need to perform the equivalent of an INT 25H (Absolute Sector Read) and > > >INT 26H (Absolute Sector Write). > > >How can I do this in VB6?
|
Tue, 09 Mar 2004 07:13:19 GMT |
|
 |
<z> #10 / 15
|
 Reading/Writing Sectors
Quote: > AFAIK to do this you need to 'Thunk' - that is, move into 16bit mode. > I shall watch this thread with interest.
You are absolutely write about the thunking part. I found a dll that should work and maybe you can help me out. I just need to know how to call the functions in this dll from my VB6 program. John Newbigin wrote rawwrite for windows which can be found here: http://uranus.it.swin.edu.au/~jn/linux/rawwrite.htm On that page is a link telling how to access a disk: http://uranus.it.swin.edu.au/~jn/linux/diskio/index.htm He has already written and thunked a dll called diskio.dll that should do the trick. However, I am not quite clear in how I was call it from my VB6 program. In the DLL is several functions and one being that to set which disk you are using. First off I am just trying to call the function SetDisk. In my VB6 program I put in: Private Declare Function SETDISK Lib "DISKIO.DLL" (disk As Integer) As Boolean In my code I have a call to SetDisk(0). However, I get RunTime Error 48 File not found diskio.dll. I have the dll in the same directory and even copied it to the windows system directory. Can someone tell me how I can use this dll from VB6? Thanks, z
|
Tue, 09 Mar 2004 07:25:39 GMT |
|
 |
Frank Ad #11 / 15
|
 Reading/Writing Sectors
Quote:
>> Without looking at that URL and the code.. are you trying to do low >> level access over a network ? I would hope that networks would have >> security in place to prevent anyone doing that. >I believed that was how you specified a file for the drive itself and >nothing >to with networking.
It's ok, i was a bit cross eyed from a couple of days of fixing my {*filter*}y network and when i saw the double backslash, i freaked. :-) Quote: >For my project I am creating a disk server which feeds requests from a >serial port.
DeviceIoControl API may be your shot here. I think it's compatible with NT, although NTFS may have other ideas on that. Regards, Frank
|
Tue, 09 Mar 2004 07:48:11 GMT |
|
 |
<z> #12 / 15
|
 Reading/Writing Sectors
Ok, my last post was in error. The diskio.dll has the following functions: READDISKGEOMETRY RESETDISK READPHYSICALSECTOR WRITEPHYSICALSECTOR From searching the web it looks like I will need to thunk to these routines. Can anyone tell me how I to do this in VB6? Thanks, z
|
Tue, 09 Mar 2004 14:45:34 GMT |
|
 |
J Fren #13 / 15
|
 Reading/Writing Sectors
The error 48 is a standard gotcha for using DLLs in the IDE ChDir App.Path in the{*filter*}statement will fix it It is simply that for some idiotic reason, in the IDE the default directory is not the App.Path - so the DLL is not found. I am off for a week in literally a few minutes - if you have not solved the problem then Email me. Quote:
>> AFAIK to do this you need to 'Thunk' - that is, move into 16bit mode. >> I shall watch this thread with interest. >You are absolutely write about the thunking part. >I found a dll that should work and maybe you can help me out. >I just need to know how to call the functions in this dll from my VB6 >program. >John Newbigin wrote rawwrite for windows which can be found here: > http://www.*-*-*.com/ ~jn/linux/rawwrite.htm >On that page is a link telling how to access a disk: > http://www.*-*-*.com/ ~jn/linux/diskio/index.htm >He has already written and thunked a dll called diskio.dll that should do >the trick. >However, I am not quite clear in how I was call it from my VB6 program. >In the DLL is several functions and one being that to set which disk you are >using. >First off I am just trying to call the function SetDisk. In my VB6 program >I put in: >Private Declare Function SETDISK Lib "DISKIO.DLL" (disk As Integer) As >Boolean >In my code I have a call to SetDisk(0). However, I get RunTime Error 48 >File not >found diskio.dll. I have the dll in the same directory and even copied it >to the windows >system directory. Can someone tell me how I can use this dll from VB6? >Thanks, >z
|
Tue, 09 Mar 2004 17:07:13 GMT |
|
 |
<z> #14 / 15
|
 Reading/Writing Sectors
Quote: > The error 48 is a standard gotcha for using DLLs in the IDE
I get the error because it is a 16 bit DLL and I need to thunk to it. My last message was in error. The actual functions in the diskio.dll are: RESETDISK READPHYISICALSECTOR WRITEPHYSICALSECTOR READDISKGEOMETRY I've found a DLL called "DIRECT32" which does parts of what I need. Private Declare Function pb_Unload16 Lib "DIRECT32.DLL" (ByVal hDLL As Long) As Long Private Declare Function pb_Load16 Lib "DIRECT32.DLL" (ByVal dllName As String) As Long Private Declare Function pb_GetProc16 Lib "DIRECT32.DLL" (ByVal zDll As Long, ByVal zFunction As String) As Long Private Declare Function READDISKGEOMETRY Lib "DIRECT32.DLL" Alias "pb_Call16" (ByVal hProc As Long, Param1, Param2) As Long Dim hDLL As Long Dim pfnDTest As Long dim a hDLL = pb_Load16("DISKIO.DLL") pfnDTest = pb_GetProc16(hDLL, "READDISKGEOMETRY") a = READDISKGEOMETRY(pfnDTest, Param1, Param2) pb_Unload16 hDLL The loading of the 16bit dll works and the call to GetProc16 works. I am not sure how to declare READDISKGEOMETRY. I believe the first parameter is a pointer to sector info which is byte word byte byte byte The second parameter should be the size of the structure, but not sure if it is a interger or long. z
|
Sat, 13 Mar 2004 05:23:19 GMT |
|
 |
<z> #15 / 15
|
 Reading/Writing Sectors
Quote: > With great difficulty - I would never attempt it in VB and have failed > to get it working in ASM in Delphi32 - no problem in Delphi16.
Okay I found some code that has a vxd called INT13EXT that can read and write sectors. Can anyone tell me If and how I can use this from VB6? The code and vxd can be found at http://skyscraper.fortunecity.com/amd/887/greydevelop.htm under Delphi: Physical Disk Access Thanks, z
|
Sat, 13 Mar 2004 11:49:00 GMT |
|
|