CH375EVT.ZIP中的CH375UD.c可以公布嗎??謝謝! 他只能看第二fat區(qū)的信息,不能對任意的扇區(qū)進行查看! 想修改一下,以讀取U盤的數(shù)據(jù)!!!
可以看任意扇區(qū)的數(shù)據(jù)啊!
如何查看U盤的?
后面加扇區(qū)號不就行了嗎!
CH375UD.c在CH375LIB.ZIP包里,小小何你難道不知道嗎??
不好意思! 我的lib文件沒有及時更新??! 現(xiàn)在已經(jīng)找到了! 謝謝??!
/* 2004.06.05 **************************************** ** Copyright (C) W.ch 1999-2004 ** ** Web: http://www.winchiphead.com ** **************************************** ** USB Host File Interface for CH375 ** ** VC5.0@PC ** **************************************** */
#define PC_DEBUG_DRIVE "\\\\.\\PHYSICALDRIVE1"
#include #include #include #include
main( ULONG argc, UCHAR *argv[] ) { UCHAR c; ULONG i, j; ULONG lba; HANDLE mhDevice; UCHAR buffer[512]; printf( "Copyright (C) W.ch 1998-2005, http://wch.cn\n" ); printf( "Show sector data in second physical disk\n" ); if ( argc <= 1 ) { printf( "This program only work under WINDOWS 2000/XP\n" ); printf( "Command line: CH375UD sector_number\n" ); printf( "Example:\n" ); printf( " to show 0# (0000H) sector: CH375UD 0\n" ); printf( " to show 63# (003FH) sector: CH375UD 63\n" ); printf( " to show 1758# (06DEH) sector: CH375UD 1758\n" ); printf( "to show sector data and save to TXT file:\n" ); printf( " CH375UD 1758 > file_name_for_saving_text\n" ); printf( "warning !!! to clear 1758# (06DEH) sector: CH375UD 1758 /C\n" ); exit( 1 ); } lba = atol( argv[1] ); mhDevice = CreateFile( PC_DEBUG_DRIVE, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if ( mhDevice == INVALID_HANDLE_VALUE ) { printf( "Please insert USB disk and retry\n" ); exit( 2 ); } i = lba * 512; j = SetFilePointer( mhDevice, i, NULL, FILE_BEGIN ); // 指定扇區(qū)號 if ( i != j ) { CloseHandle( mhDevice ); printf( "Error on set disk sector address\n" ); exit( 3 ); } i = 512; if ( ! ReadFile( mhDevice, buffer, 512, &i, NULL ) ) { // 讀一個扇區(qū)512字節(jié) CloseHandle( mhDevice ); printf( "Error on reading disk sector\n" ); exit( 4 ); } if ( i != 512 ) { CloseHandle( mhDevice ); printf( "Error on reading disk sector, return length = %d\n", i ); exit( 5 ); } for ( i = 0; i < 512; i += 16 ) { printf( "@%03X:", i ); for ( j = 0; j < 16; j ++ ) { if ( j == 8 ) printf( " -" ); printf( " %02X", buffer[i+j] ); } printf( " " ); for ( j = 0; j < 16; j ++ ) { c = buffer[i+j]; if ( c < 0x20 ) c = '.'; if ( c == 0x7f ) c = '.'; printf( "%c", c ); } printf( "\n" ); } if ( argc >= 3 ) { if ( argv[2][0] == '/' && ( argv[2][1] == 'C' || argv[2][1] == 'c' ) ) { printf( "Press TAB to confirm clear %ld# sector in second disk\n", lba ); if ( getch( ) == 9 ) { i = lba * 512; SetFilePointer( mhDevice, i, NULL, FILE_BEGIN ); // 指定扇區(qū)號 for ( i = 0; i < 512; i ++ ) buffer[i] = 0; if ( ! WriteFile( mhDevice, buffer, 512, &i, NULL ) ) { // 寫一個扇區(qū)512字節(jié) CloseHandle( mhDevice ); printf( "Error on writing disk sector\n" ); exit( 6 ); } if ( i == 512 ) printf( "Clear successfully\n" ); else printf( "Error return length = %d\n", i ); } else printf( "Canceled\n" ); } } CloseHandle( mhDevice ); printf( " CH375UD %ld | more or CH375UD %ld > SECTOR.TXT ", lba, lba ); return( 1 ); }