Okey
asked on
How to Lock a Drive from DOS on Windows
I wannted to do Direct Drive IO.
I can read directly but write is blocked!
Try to lock up Drive for so that Write to drive isn't blocked,
but the system is normally crashing then when I do any Direct Drive IO!
Ralph Brown has commented that Lock is only allocating 26 Bytes, but 32 Bytes Space using!
Saw someone doin it maybe over IOCTL-INT-API.
How to lock a drive in Pascal and assembler without causing a systemcrash through buggy Lock-command?
I can read directly but write is blocked!
Try to lock up Drive for so that Write to drive isn't blocked,
but the system is normally crashing then when I do any Direct Drive IO!
Ralph Brown has commented that Lock is only allocating 26 Bytes, but 32 Bytes Space using!
Saw someone doin it maybe over IOCTL-INT-API.
How to lock a drive in Pascal and assembler without causing a systemcrash through buggy Lock-command?
ASKER
Links are very nice,
but I didn't got my program running!
OK I could do an EXEC(GETENV('COMSPEC'),'/C LOCK C:');
in TRUE TYPE DOS,
But in windows,
it seems that something is just obtaing an exclusive locklevel.
So can someone write a snippet which runs upwards WIN9X?
This is my testing snippet
(and I'am really not satisfied with!):
PROGRAM TEST_DIRECT_DRIVE_IO_BY_WR ITING_VOLU MEID;
USES DOS;
TYPE
T_FAT32_BS=RECORD
BS_jmpBoot :ARRAY[1..03] OF BYTE;
BS_OEMName :ARRAY[1..08] OF CHAR;
BPB_BytsPerSec : WORD;
BPB_SecPerClus : BYTE;
BPB_RsvdSecCnt : WORD;
BPB_NumFATs : BYTE;
BPB_RootEntCnt : WORD;
BPB_TotSec16 : WORD;
BPB_Media : BYTE;
BPB_FATSz16 : WORD;
BPB_SecPerTrk : WORD;
BPB_NumHeads : WORD;
BPB_HiddSec : LONGINT;
BPB_TotSec32 : LONGINT;
BPB_FATSz32 : LONGINT;
BPB_ExtFlags : WORD;
BPB_FSVer : WORD;
BPB_RootClus : LONGINT;
BPB_FSInfo : WORD;
BPB_BkBootSec : WORD;
BPB_Reserved :ARRAY[1..12] OF BYTE;
BS_DrvNum : BYTE;
BS_Reserved1 : BYTE;
BS_BootSig : BYTE;
BS_VolID : LONGINT;
BS_VolLab :ARRAY[1..11] OF CHAR;
BS_FilSysType :ARRAY[1..08] OF CHAR;
Executable_Code :ARRAY[1..356]OF BYTE;
First_Partition :ARRAY[1..$10]OF BYTE;
Second_Partition :ARRAY[1..$10]OF BYTE;
Third_Partition :ARRAY[1..$10]OF BYTE;
Last_Partition :ARRAY[1..$10]OF BYTE;
Executable_Marker : Word;
END;
T_WIN95_SECTOR_IO_INFO_PAR AMETER_BLO CK=RECORD
No:LONGINT;
Count :WORD;
Buffer :POINTER
END;
{_________________________ __________ __________ __________ __________ __________ _
}
CONST
READ_UNKOWN_SECTOR=0;
WRITE_UNKOWN_SECTOR=1;
{_________________________ __________ __________ __________ __________ __________ _
}
Function WIN95_SECTOR_IO(DRIVE:BYTE ;INFOBUF:P OINTER;FLA GS:WORD):B OOLEAN;
ASSEMBLER;
ASM
PUSH DS
PUSHA
MOV AX,$7305
MOV CX,$FFFF
MOV DL,DRIVE
MOV SI,FLAGS
LDS BX,INFOBUF
INT 21H
POPA
POP DS
JNC @ENDE
MOV AX,FALSE
@ENDE:
END;
VAR
BS32:T_FAT32_BS;
WIN95_SECTOR_IO_INFO_PARAM ETER_BLOCK :T_WIN95_S ECTOR_IO_I NFO_PARAME TER_BLOCK;
PTR_W95_SEC_INF_PB:^T_WIN9 5_SECTOR_I O_INFO_PAR AMETER_BLO CK;
CONST
LOGIC_DRIVE_NO=3;
BEGIN
{SET WIN95 DIRECT DRIVE SECTOR IO PARAMETERBLOCK}
PTR_W95_SEC_INF_PB:=ADDR(W IN95_SECTO R_IO_INFO_ PARAMETER_ BLOCK);
WITH WIN95_SECTOR_IO_INFO_PARAM ETER_BLOCK
DO BEGIN
No:=0;
Count:=1;
Buffer:=ADDR(BS32);
END;
{
READING THE MASTER BOOT RECORD AND
OUTPUT TO SCREEN,
IF SECTOR READING WAS SUCCESSFUL.
}
WRITELN('SECTOR IO:',
WIN95_SECTOR_IO(LOGIC_DRIV E_NO,
PTR_W95_SEC_INF_PB,
READ_UNKOWN_SECTOR
)
);
{EXCHANGING THE VOLUME-ID-FIELD IN BS32 RECORD OF READ BOOT-SECTOR.}
BS32.BS_VOLID:=0;
{
CALLING DOS LOCK-COMMAND
THEN REWRITEING MASTER BOOT SECTOR
AND CALLING DOS UNLOCK-COMMAND
(
THIS METHOD RUNS IN TRUE TYPE DOS WELL,
BUT IN WIN98,
THE UN/LOCK-COMMAND IS UNABLE TO DO A UN/LOCK,
SO THAT THE USE OF THIS IO-METHOD CAUSES AN EXCEPTION CHAIN,
UNTIL SYSTEM TOTALLY CRASHES!
THE USE OF THIS IO-METHOD UNDER WIN98
NORMALLY CAUSES AN ERROR/TRAP MESSAGE LIKE:
``OLD DOS PROGRAM IS ...oo
``TRYING DIRECTLY TO WRITE ON HARDDISK ...oo
``DO YOU WANT TO ...oo
``YES RUN ON WITHOUT WRITEoo<=|=>`` NO ABORT PROGRAM oo
YOU CAN CONTINUE BUT WRITE OPPERATION WONT SUCCEED!
)
}
SWAPVECTORS;
EXEC(GETENV('COMSPEC'),'/c LOCK C:');
SWAPVECTORS;
WRITELN('SECTOR IO:',
WIN95_SECTOR_IO(LOGIC_DRIV E_NO,
PTR_W95_SEC_INF_PB,
WRITE_UNKOWN_SECTOR
)
);
SWAPVECTORS;
EXEC(GETENV('COMSPEC'),'/c UNLOCK C:');
SWAPVECTORS;
WRITELN('SECTOR IO:',WIN95_SECTOR_IO(LOGIC _DRIVE_NO, PTR_W95_SE C_INF_PB,R EAD_UNKOWN _SECTOR));
END.
but I didn't got my program running!
OK I could do an EXEC(GETENV('COMSPEC'),'/C
in TRUE TYPE DOS,
But in windows,
it seems that something is just obtaing an exclusive locklevel.
So can someone write a snippet which runs upwards WIN9X?
This is my testing snippet
(and I'am really not satisfied with!):
PROGRAM TEST_DIRECT_DRIVE_IO_BY_WR
USES DOS;
TYPE
T_FAT32_BS=RECORD
BS_jmpBoot :ARRAY[1..03] OF BYTE;
BS_OEMName :ARRAY[1..08] OF CHAR;
BPB_BytsPerSec : WORD;
BPB_SecPerClus : BYTE;
BPB_RsvdSecCnt : WORD;
BPB_NumFATs : BYTE;
BPB_RootEntCnt : WORD;
BPB_TotSec16 : WORD;
BPB_Media : BYTE;
BPB_FATSz16 : WORD;
BPB_SecPerTrk : WORD;
BPB_NumHeads : WORD;
BPB_HiddSec : LONGINT;
BPB_TotSec32 : LONGINT;
BPB_FATSz32 : LONGINT;
BPB_ExtFlags : WORD;
BPB_FSVer : WORD;
BPB_RootClus : LONGINT;
BPB_FSInfo : WORD;
BPB_BkBootSec : WORD;
BPB_Reserved :ARRAY[1..12] OF BYTE;
BS_DrvNum : BYTE;
BS_Reserved1 : BYTE;
BS_BootSig : BYTE;
BS_VolID : LONGINT;
BS_VolLab :ARRAY[1..11] OF CHAR;
BS_FilSysType :ARRAY[1..08] OF CHAR;
Executable_Code :ARRAY[1..356]OF BYTE;
First_Partition :ARRAY[1..$10]OF BYTE;
Second_Partition :ARRAY[1..$10]OF BYTE;
Third_Partition :ARRAY[1..$10]OF BYTE;
Last_Partition :ARRAY[1..$10]OF BYTE;
Executable_Marker : Word;
END;
T_WIN95_SECTOR_IO_INFO_PAR
No:LONGINT;
Count :WORD;
Buffer :POINTER
END;
{_________________________
}
CONST
READ_UNKOWN_SECTOR=0;
WRITE_UNKOWN_SECTOR=1;
{_________________________
}
Function WIN95_SECTOR_IO(DRIVE:BYTE
ASSEMBLER;
ASM
PUSH DS
PUSHA
MOV AX,$7305
MOV CX,$FFFF
MOV DL,DRIVE
MOV SI,FLAGS
LDS BX,INFOBUF
INT 21H
POPA
POP DS
JNC @ENDE
MOV AX,FALSE
@ENDE:
END;
VAR
BS32:T_FAT32_BS;
WIN95_SECTOR_IO_INFO_PARAM
PTR_W95_SEC_INF_PB:^T_WIN9
CONST
LOGIC_DRIVE_NO=3;
BEGIN
{SET WIN95 DIRECT DRIVE SECTOR IO PARAMETERBLOCK}
PTR_W95_SEC_INF_PB:=ADDR(W
WITH WIN95_SECTOR_IO_INFO_PARAM
DO BEGIN
No:=0;
Count:=1;
Buffer:=ADDR(BS32);
END;
{
READING THE MASTER BOOT RECORD AND
OUTPUT TO SCREEN,
IF SECTOR READING WAS SUCCESSFUL.
}
WRITELN('SECTOR IO:',
WIN95_SECTOR_IO(LOGIC_DRIV
PTR_W95_SEC_INF_PB,
READ_UNKOWN_SECTOR
)
);
{EXCHANGING THE VOLUME-ID-FIELD IN BS32 RECORD OF READ BOOT-SECTOR.}
BS32.BS_VOLID:=0;
{
CALLING DOS LOCK-COMMAND
THEN REWRITEING MASTER BOOT SECTOR
AND CALLING DOS UNLOCK-COMMAND
(
THIS METHOD RUNS IN TRUE TYPE DOS WELL,
BUT IN WIN98,
THE UN/LOCK-COMMAND IS UNABLE TO DO A UN/LOCK,
SO THAT THE USE OF THIS IO-METHOD CAUSES AN EXCEPTION CHAIN,
UNTIL SYSTEM TOTALLY CRASHES!
THE USE OF THIS IO-METHOD UNDER WIN98
NORMALLY CAUSES AN ERROR/TRAP MESSAGE LIKE:
``OLD DOS PROGRAM IS ...oo
``TRYING DIRECTLY TO WRITE ON HARDDISK ...oo
``DO YOU WANT TO ...oo
``YES RUN ON WITHOUT WRITEoo<=|=>`` NO ABORT PROGRAM oo
YOU CAN CONTINUE BUT WRITE OPPERATION WONT SUCCEED!
)
}
SWAPVECTORS;
EXEC(GETENV('COMSPEC'),'/c
SWAPVECTORS;
WRITELN('SECTOR IO:',
WIN95_SECTOR_IO(LOGIC_DRIV
PTR_W95_SEC_INF_PB,
WRITE_UNKOWN_SECTOR
)
);
SWAPVECTORS;
EXEC(GETENV('COMSPEC'),'/c
SWAPVECTORS;
WRITELN('SECTOR IO:',WIN95_SECTOR_IO(LOGIC
END.
ASKER
Can someone maybe explain something about Volume locking?
I've heard,
that there is a tool for obtaining the right to access lock-levels under WIN9X!
Knows someone something about it?
How is this with obtaining lock levels under WIN.NT?
Knows someone something about it?
I've heard,
that there is a tool for obtaining the right to access lock-levels under WIN9X!
Knows someone something about it?
How is this with obtaining lock levels under WIN.NT?
Knows someone something about it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hmmhhhh,
I'm very sory but It seems that Ive written this fast and easy readable example somehow a little bit wrong! :-(
I won't place here any corrections to this,
because I think everyone who could answer this question somehow will know how this code has to look like and what it needs to be run propably.
Again a thanks to dbrunton!
If someone knows something I'll stay locked at this question,
but I'll give the points away and accept dbrunton's answer now!
I'm very sory but It seems that Ive written this fast and easy readable example somehow a little bit wrong! :-(
I won't place here any corrections to this,
because I think everyone who could answer this question somehow will know how this code has to look like and what it needs to be run propably.
Again a thanks to dbrunton!
If someone knows something I'll stay locked at this question,
but I'll give the points away and accept dbrunton's answer now!
which will lead to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win9x/devio_2b1v.asp
And don't know what you are doing but you may wish to read
https://www.experts-exchange.com/questions/10132856/DOS-'Lock'-Command-under-Windows.html