WWW.ИСХОДНИКИ.РУ cpp.sources.ru
java.sources.ru web.sources.ru soft.sources.ru
jdbc.sources.ru asp.sources.ru api.sources.ru

  Форум на исходниках
  C / C++ / Visual C++
  Чтение физических секторов винта под 9х

СПРОСИТЬ  ОТВЕТИТЬ
профайл | регистрация | faq

Автор Тема:   Чтение физических секторов винта под 9х
Ritchie опубликован 07-02-2002 04:17 MSK   Click Here to See the Profile for Ritchie   Click Here to Email Ritchie  
Может, кто знает, как такое в 9х сделать, а?
Susik опубликован 07-02-2002 16:53 MSK     Click Here to See the Profile for Susik  Click Here to Email Susik     
Это также можно отнести к прежнему топику (Про произвольное чтение).
На чтение винт я проверял: читал вроде бы нормально, начиная с нулевого сектора. Проверял это дело (менял метку диска, по-другому пока никак не знаю :) ), все нормально было. Писать не пробовал по известным причинам, хотя можно было найти пустое место на винте, но все же не стал. :)

Могу кинуть тело функции для чтения дисков под вин9х. Нулевое кольцо там не юзается.

Ritchie опубликован 08-02-2002 11:28 MSK     Click Here to See the Profile for Ritchie  Click Here to Email Ritchie     
Кинь, если не сложно.
Susik опубликован 11-02-2002 12:21 MSK     Click Here to See the Profile for Susik  Click Here to Email Susik     
Было это написано в какой-то статье, не помню где (потому что было то ышо летом).

#define VWIN32_DIOC_DOS_INT25 2
#define VWIN32_DIOC_DOS_INT26 3
#define VWIN32_DIOC_DOS_DRIVEINFO 6
#define CARRY_FLAG 1
#define LENGTH_STRING_DISKS 120

typedef struct _DIOC_REGISTERS
{DWORD reg_EBX;
DWORD reg_EDX;
DWORD reg_ECX;
DWORD reg_EAX;
DWORD reg_EDI;
DWORD reg_ESI;
DWORD reg_Flags;
} DIOC_REGISTERS, *PDIOC_REGISTERS;

#pragma pack(1)
typedef struct _DISKIO {
DWORD dwStartSector; // starting logical sector number
WORD wSectors; // number of sectors
DWORD dwBuffer; // address of read/write buffer
} DISKIO, * PDISKIO;
#pragma pack()


//******************************************************************************
/*--------------- ;---------------- ;---------------- ;---------------- ;---
NewReadSectors(hDev, bDrive, dwStartSector, wSectors, lpSectBuff)
Purpose:
Reads the specified number of sectors into a caller-supplied buffer. Uses Int 21h function 7305h
Parameters:
hDev - Handle of VWIN32
bDrive The MS-DOS logical drive number. 0 = default, 1 = A, 2 = B,3 = C, etc.
dwStartSector The first sector to read.
wSectors The number of sectors to read.
lpSectBuff The caller-supplied buffer to read into.
Return Value:
Returns TRUE if successful, or FALSE if failure.
Comments:
This function does not validate its parameters. It assumes that
lpSectBuff is allocated by the caller and is large enough to
hold all of the data from all of the sectors being read.
-------------&# 45;---------------&# 45;---------------&# 45;---------------&# 45;----*/
char NewReadSectors (HANDLE hDev, BYTE bDrive,DWORD dwStartSector,WORD wSectors,LPBYTE lpSectBuff)
{ BOOL fResult;
DWORD cb;
DIOC_REGISTERS reg = {0};
DISKIO dio;

dio.dwStartSector = dwStartSector;
dio.wSectors = wSectors;
dio.dwBuffer=(DWORD)lpSectBuff;

reg.reg_EAX = 0x7305; // Ext_ABSDiskReadWrite
reg.reg_EBX = (DWORD)&dio; reg.reg_ECX = -1;
reg.reg_EDX = bDrive; // Int 21h, fn 7305h drive numbers are 1-based

fResult = DeviceIoControl(hDev, VWIN32_DIOC_DOS_DRIVEINFO,
®, sizeof(reg),
®, sizeof(reg), &cb, 0);
// Determine if the DeviceIoControl call and the read succeeded.
fResult=fResult&&!(reg.reg_Flags & CARRY_FLAG);
if(!fResult)return READ_ERROR;
return 0;
}


//******************************************************************************
/*-------------- ;---------------- ;---------------- ;---------------- ;----
NewWriteSectors(hDev, bDrive, dwStartSector, wSectors, lpSectBuff)
Purpose:
Writes the specified number of sectors from a caller-supplied
buffer. Uses Int 21h function 7305h
Parameters:
hDev Handle of VWIN32
bDrive The MS-DOS logical drive number. 0 = default, 1 = A, 2 = B,3 = C, etc.
dwStartSector The first sector to write.
wSectors The number of sectors to write.
lpSectBuff The caller-supplied buffer from which to write.
Return Value:
Returns TRUE if successful, or FALSE if failure.
Comments:
This function does not validate its parameters. It assumes that
lpSectBuff is allocated by the caller and is large enough to
hold all of the data to be written.
------------- ;---------------- ;---------------- ;---------------- ;-----*/
BOOL NewWriteSectors (HANDLE hDev, BYTE bDrive,DWORD dwStartSector,WORD wSectors,LPBYTE lpSectBuff)
{ BOOL fResult;
DWORD cb;
DIOC_REGISTERS reg = {0};
DISKIO dio;

dio.dwStartSector = dwStartSector;
dio.wSectors = wSectors;
dio.dwBuffer = (DWORD)lpSectBuff;

reg.reg_EAX = 0x7305; // Ext_ABSDiskReadWrite
reg.reg_EBX = (DWORD)&dio;
reg.reg_ECX = -1;
reg.reg_EDX = bDrive; // Int 21h, fn 7305h drive numbers are 1-based
reg.reg_ESI = 0x6001; // Normal file data (See function
// documentation for other values)

fResult = DeviceIoControl(hDev, VWIN32_DIOC_DOS_DRIVEINFO,
®, sizeof(reg),
®, sizeof(reg), &cb, 0);

// Determine if the DeviceIoControl call and the write succeeded.
fResult = fResult && !(reg.reg_Flags & CARRY_FLAG);
if(!fResult)return WRITE_ERROR;
return 0;
}
//******************************************************************************


WRITE_ERROR и READ_ERROR - по твоему усмотрению, как понимаешь. :))
Это для физического доступа, т.е. в обод логики диска. Там были ышо 2 функции (чтение/запись) и для логических дисков, но я их не юзал.

Susik опубликован 11-02-2002 12:24 MSK     Click Here to See the Profile for Susik  Click Here to Email Susik     
Ой. Значок ® означает взятие адреса структуры reg (т.е. "& reg").
Ritchie опубликован 12-02-2002 12:19 MSK     Click Here to See the Profile for Ritchie  Click Here to Email Ritchie     
Может, я чего не понимаю, но по-моему для этой штуки нужен Dos-номер диска, то есть ссылка идет все равно не на винт, который у тебя включен, а на volume, который видит операционка (т.е. те же самые FAT(32) для 9x). А мой винт винды не видят, потому как там савсем другой файлсистем.
Так что, видимо, единственный способ, который я сейчас и пишу, это писать напрямую в порты из нулевого кольца.
Susik опубликован 12-02-2002 16:37 MSK     Click Here to See the Profile for Susik  Click Here to Email Susik     
Я не понимаю, че тут неясно. У меня все работает, вин98, все так, как те надо. :)

В обоих функциях второй параметр - номер диска (1 - а, 2 - б, 3 - твой винт(ц), 4 - ышо что-нить и т.д).
Первый параметр является типа ключом к дискам: указатель на ВхД, как написано в хелпе. :)
Получаешь его так:
HANDLE hVxD=CreateFile("\\\\.\\vwin32",0,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
if(hVxD==(HANDLE)INVALID_HANDLE_VALUE)
{//АШЫПКА!!!!!}

Ну и так далее...

СПРОСИТЬ  ОТВЕТИТЬ
Перейти:


E-mail | WWW.ИСХОДНИКИ.RU

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.