Author | Message |
|
---|
Kenny
Joined: 21 Sep 2008 Other dimension | | Hello. I like sectedit.exe programm and want to create same programs but for DOS and Windows platforms. What language/books/small tutorials can you recommend (for example: how can I create read/write 1st hdd sector program module from zero start point)? I know assembler, delphi and pascal. Thank you. |
|
Roadkil Joined: 28 Mar 2008 South Australia | | hey there... if you know ASM all you need is ralph browns interrupt listing guide.... its a huge warehouse of knowledge on anything asm.. has everything you need to know about disk function calls etc etc.... as for windows.. go to msdn.microsoft.com and look for "CreateFile" the page on that shoudl tell you all you need to know about windows disk IO!
Cheers :) |
|
Kenny
Joined: 21 Sep 2008 Other dimension | | Thank you very much.
"| VVENT +0 Le@rn A11 thi$ $tuFF"
Cheers to you too.
Kenny |
|
Kenny
Joined: 21 Sep 2008 Other dimension | | CreateFile(); * * * This function did not work in Win98/95 platforms properly..WinNT ONLY (XP) Is that right? What functions can you recommend than for Win98? :) 8GB limitations not funny....and in assembler with INT 13h AH=41h.. returned 0100 in AX with CF=1.. under MS-DOS 6.22 from bootable 3.5" and BIOS from Gigabyte i865PE chipset motherboard.... asm not so good idea maybe "IN" and "OUT" instructions can be used somehow instead..(there is a difference in each HDD manufacturer) :( |
|
Kenny
Joined: 21 Sep 2008 Other dimension | | Ok. I had found solution fot Win9x OS but have another question now...
Why "Roadkil's Sector Editor" detect 20013741 sectors for
HDD Fujitsu MPF3102AT (10.24GB) when function GetDiskGeometry for VER_PLATFORM_WIN32_NT
AND Disk Property detect only 10240440832 bytes which are 20000861
(+ 63 + 1 for GetDiskGeometry) sectors ONLY?? |
|
Roadkil Joined: 28 Mar 2008 South Australia | | Your correct.. CreateFile is for NT or later systems only.
Here is some code that might be useful for you - its what i use to detect the size on 9x systems.
unsigned long DeviceSize_16Bit(unsigned char DiskID)
{
unsigned long return_value;
BPB.A_BF_BPB_bSpecFunc = 1;
// if (OSR2 == false)
// {
reg.reg_EAX = 0x440D;
reg.reg_EBX = DiskID;
reg.reg_ECX = 0x0860;
reg.reg_EDX = (DWORD)&BPB;
reg.reg_Flags = 0x0001;
/*
}
else
{
reg.reg_EAX = 0x440D;
reg.reg_EBX = DiskID;
reg.reg_ECX = 0x4860;
reg.reg_EDX = (DWORD)&BPB+7;
reg.reg_Flags = 0x0001;
}
*/
bResult = DeviceIoControl(hDev, VWIN32_DIOC_DOS_IOCTL, ®, sizeof(reg), ®, sizeof(reg), &cb, 0);
if ( !bResult || (reg.reg_Flags & 1) )
{
reg.reg_EAX = 0x440D;
reg.reg_EBX = DiskID;
reg.reg_ECX = 0x0860;
reg.reg_EDX = (DWORD)&BPB;
reg.reg_Flags = 0x0001;
bResult = DeviceIoControl(hDev, VWIN32_DIOC_DOS_IOCTL, ®, sizeof(reg), ®, sizeof(reg), &cb, 0);
if ( !bResult || (reg.reg_Flags & 1) )
{
return 0;
}
}
return_value = BPB.A_BF_BPB_TotalSectors -1;
if (return_value == 0 || return_value > 0xfffb)
{
return_value = BPB.A_BF_BPB_BigTotalSectors - 1;
}
return return_value;
}
|
|
Kenny
Joined: 21 Sep 2008 Other dimension | | First of all thank you for your patience.
As i said before, i found solution for Win9x (i think :)), just interesting why such detection in
your program in WinNT. 20013741sectors vs 20000894sectors? I used this:
hFile := CreateFile(PChar('\\.\PhysicalDrive'+IntToStr(Drive)),GENERIC_READ,
FILE_SHARE_READ + FILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);
if hFile = INVALID_HANDLE_VALUE then Exit;
Result := DeviceIoControl(hFile,IOCTL_DISK_GET_DRIVE_GEOMETRY,nil,0,
@DiskGeometry,SizeOf(TDiskGeometry),junk,nil) and (junk = SizeOf(TDiskGeometry));
...
SectorCt := DiskGeometry.Cylinders * DiskGeometry.TracksPerCylinder * DiskGeometry.SectorsPerTrack;
SectorCt is the number of sectors.
Cheers! :) |
|
Roadkil Joined: 28 Mar 2008 South Australia | | not really sure why the detection is so differnet.... should be exactly the same.. unfortunatley the program requires on windows for most of its routines so ill just blame windows as its ussually a safe bet :)
Cheers!
|
|
|
---|