#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <locale>
#include <iostream>
#pragma warning(disable : 4996)
HANDLE hDisk = NULL;
BYTE Buffer[512];
BYTE BootRec[512];
char nFind[25];
char fName[25];
using namespace std;
bool ReadSector(int n, BYTE * lpBuf) {
LONG lFilePointer;
lFilePointer = n * 512;
SetFilePointer(hDisk, // handle of file
lFilePointer, // number of bytes to move file pointer
NULL, // address of high-order word of distance to move
FILE_BEGIN // how to move
);
DWORD nCount;
ReadFile(hDisk, lpBuf, 512, &nCount, NULL);
if (nCount != 512) {
return false;
}
return true;
}
void main(void);
void main() {
setlocale(LC_ALL,"RUSSIAN");
hDisk = CreateFile ("\\\\.\\H:",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS,
0);
if (hDisk == INVALID_HANDLE_VALUE) {
printf("error");
getch();
return;
}
std::cout<<" Введи имя файла: "<<' ';
std::cin>>nFind;
ReadSector(0, BootRec);
int nCopyFat, nFatSectors, nRes, nDirSectors,nLogSector,nHead;
nCopyFat = *(BootRec+16);
nFatSectors = *((WORD*)(BootRec+22));
nRes = *((WORD*)(BootRec+14));
nDirSectors = *((WORD*)(BootRec+17)) * 32 / 512;
//nLogSector = *(BootRec+13);
//nHead = *((WORD*)(BootRec+26))* 32 / 512;
printf ("Число Копий Fat %d\n", nCopyFat);
printf ("Число Секторов в одной копии Fat %d\n", nFatSectors);
printf ("Число резервных секторов %d\n", nRes);
printf ("Максимальное число элементов корневого каталога %d\n", nCopyFat);
//printf ("Число логических секторов %d\n",nLogSector);
//printf ("Число головок(сторон) %d\n",nHead);
int i, j;
char sName[16];
FILE *res = fopen("C:\\result.txt", "w+b");
for (i = 0; i < nDirSectors; i++) {
ReadSector(i + nRes + nFatSectors*nCopyFat, Buffer);
for (j=0; j < 16; j++) {
strncpy(sName, (char*)(Buffer+j*32), 11);
if (sName[0] == 0 || sName[0] == 0xE5) continue;
printf("%s\n", sName);
getch();
//fprintf(res,"%s\n",sName);
}
}
_getch();}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.