📄 nudisk21e.h
字号:
#ifdef __cplusplus
extern "C" {
#endif
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the NUDISK21E_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// NUDISK21E_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef NUDISK21E_EXPORTS
#define NUDISK21E_API __declspec(dllexport)
#else
#define NUDISK21E_API __declspec(dllimport)
#endif
// This class is exported from the NuDisk21E.dll
class NUDISK21E_API CNuDisk21E {
public:
CNuDisk21E(void);
// TODO: add your methods here.
};
///////////////////////////////////////////////////////
//
// Type Definition
//
//////////////////////////////////////////////////////
typedef struct _Get_PD_Device_Info
{
char HubName[MAX_PATH];
int PortNo;
} GET_PD_DEVICE_INFO;
typedef struct _Drive_Info
{
BYTE gCurDevLunDiskType; //Keep the Disk-type of LUN number of the device associated with current access handle
char gCurDriveLetter; //Keep the Drive-letter associated with current access handle
} DRIVE_INFO;
typedef struct _Get_Drive_Device_Info
{
BYTE DiskCounts;
DRIVE_INFO Disk[2];
} GET_DRIVE_DEVICE_INFO;
///////////////////////////////////////////////////////
//
// Emurations
//
//////////////////////////////////////////////////////
enum APP_TYPE //Application type
{
PRODUCTION_APP=0, //Ex: USB PD tool ==> Picked up from the ports of hubs
DEBUG_APP, //Ex: USB Debug tool ==> Picked up from the drive-letter
UTILITY_APP, //for USB iFormat application ==> Picked up from the drive-letter and the device must be producted
};
enum PROTECT_STATUS
{
STATUS_SECURITY_PROTECTED=0, //Security Disk: Protected because of login not yet
STATUS_SECURITY_UNPROTECTED, //Security Disk: Un-Protected because of login already
STATUS_UNSECURITY, //Non-Security Disk:
STATUS_ERROR //Error
};
enum DRIVER_TYPE
{
DRIVER_DISK=0,
DRIVER_CDROM,
DRIVER_ALL
};
enum FLASH_DISK_TYPE
{
DSK_TP_FIX=0, //Fix type disk
DSK_TP_RMV, //Removable type disk
DSK_TP_CDROM //CD-ROM type disk
};
enum ERROR_CODE_UDISK_LIBRARY
{
ERROR_FREE = 0,
//ERROR_CODE_WRITE_ISO
ERROR_INVALID_DRIVELETTER,
ERROR_NOT_CDROM,
ERROR_WRITE_PROTECT_SWITCH_ON,
ERROR_NOT_ISO_FILE,
ERROR_OPEN_FILE, //5
ERROR_FILE_SIZE,
ERROR_ALLOCATE_MEMORY,
ERROR_READ_FILE,
ERROR_ACQUIRE_DEVICE_HANDLE,
ERROR_GET_SYSTEM_TABLES, //10
ERROR_UPDATE_ATTRIBUTE,
ERROR_WRITE_ISO_FILE,
//ERROR_CODE_FILE_MODE_ACCESS_PRIVATE_AREA
ERROR_PF_MALLOCFAIL,
ERROR_PF_NODEIVCE,
ERROR_PF_FILENOTFOUND, //15
ERROR_PF_FILEEXISTED,
ERROR_PF_NOTASCII,
ERROR_PF_INVALIDPOINTER,
ERROR_PF_NOFREEFATSPACE,
ERROR_PF_MEMORYALLOCFAIL, //20
ERROR_PF_FILENOTOPEN,
ERROR_PF_HANDLEOVERFLOW,
ERROR_PF_DISKNOTFORMAT,
ERROR_PF_DIRECTORYOVERFLOW,
ERROR_PF_FILESYSTEMNOTINITIAL, //25
ERROR_PF_DIRBUFFERNOTINITIAL,
ERROR_PF_FILEMODEERROR,
ERROR_PF_FILENAMEERROR,
ERROR_PF_BUFFERERROR,
ERROR_PF_LENGTHERROR, //30
ERROR_PF_INVALIDHANDLE,
ERROR_PF_NOTAUTHENTICATE,
ERROR_PF_DIRECTORYNOTFOUND,
ERROR_PF_ACQUIRYDEVICEFAIL,
//Add by Morisa(20070126)
ERROR_NOT_SET_CURRENT_DRIVE, //35
ERROR_ACQUIRY_DEVICE_FAIL,
//Add by Morisa(20070129)
ERROR_APP_TYPE_SUPPORT,
ERROR_COUNT_PARAMETER,
ERROR_MAJOR_VER_INFO,
ERROR_HUB_NAME_INFO, //40
ERROR_PORT_NO_INFO,
ERROR_STRING_LENGTH,
ERROR_STRING_NULL,
ERROR_GET_PARAMETER,
ERROR_NO_FLASH, //45
ERROR_GET_CONFIG_FAIL,
ERROR_NO_PRODUCTED,
ERROR_GET_CONFIG_OTHERS_ERR,
//20070131 add by George
ERROR_BUFFER_MEMORY_ALLOC,
ERROR_BLOCK0_IS_BAD_BLOCK, //50
ERROR_VENDOR_ERASE_FLASH,
ERROR_VENDOR_WRITE_FLASH,
ERROR_DECODE,
ERROR_BUILD_ZT,
ERROR_CAPACITY_SIZE_ZERO, //55
ERROR_FIXED_CAPACITY,
ERROR_LUN_OR_ELEMENT_SIZE_SETTING,
ERROR_FILL_SIB_STRUCT,
ERROR_READ_WRITE_MEMORY,
ERROR_NO_SIB, //60
ERROR_CHS_VALUE,
ERROR_FDISKFORMAT,
ERROR_FDISK,
ERROR_FORAMT,
ERROR_COPY_DIR_CONTENTS, //65
ERROR_MODIFY_ELEM_ATRIBUTE,
//Add by Morisa(20070625)
// ERROR_GET_REGISTRY_PROPERTY_SIZE,
// ERROR_MEMORY_ALLOC_PROPERTY,
// ERROR_GET_REGISTRY_PROPERTY_DATA,
ERROR_LOGIN_FAIL,
ERROR_NOT_REMOVEABLE, //70
ERROR_ASSIGN_FLASH, //Add by Morisa(20070806)
//Add by Morisa(20070813)
ERROR_FIND_FLASH_INFO,
ERROR_CHIP_SIZE_ZERO,
ERROR_NOT_XBBT,
ERROR_XBBT_COUNT,
ERROR_BUF_SIZE,
ERROR_CHIP_NOT_MOUNT,
ERROR_INVALID_CHIP_IDX,
};
//Set the application type
NUDISK21E_API BOOL fx_SetAppType(UCHAR AppCate=UTILITY_APP);
//Get the number of the USB device.
NUDISK21E_API ULONG fx_GetNumberOfPDDevice(int *Devices);
//Get the information of all devices picked-up
NUDISK21E_API ULONG fx_GetAllDeviceInfoForPD(GET_PD_DEVICE_INFO *pAllDeviceInfo, BYTE DeviceCounts);
//Get the number of the USB Flash disk. Please refer DRIVER_TYPE definition as above for valid input parameter
NUDISK21E_API ULONG fx_GetNumberOfDrive(int *Drives, int *Devices, int DriverType=DRIVER_DISK, char *SCSIVStr8=NULL, char *SCSIPStr16=NULL); //Initial = DRIVER_DISK //Modify by Morisa(20070129)
//Get all of the information of USB Flash disk
NUDISK21E_API ULONG fx_GetAllDeviceInfoForDrives(GET_DRIVE_DEVICE_INFO *pAllDriveDeviceInfo, BYTE DeviceCounts);
//Authentication for privateArea
NUDISK21E_API BOOL fx_AuthenticatePrivateArea(int DevIdx, char *Password, int ThreadNo);
//UnAuthentication for privateArea
NUDISK21E_API BOOL fx_UnAuthenticatePrivateArea(int DevIdx, int ThreadNo);
//change the password for the authenticated privateArea
NUDISK21E_API BOOL fx_ChangePrivateAreaPWD(int DevIdx, char *OldPassword, char *NewPassword, int ThreadNo);
//Get the Capacity of the authenticated privateArea
NUDISK21E_API BOOL fx_GetPrivateCapacity(int DevIdx, DWORD *p_user_capacity, int ThreadNo);
// the following function will return 0 when function success,
// otherwise return an non-zero error code
// Important note ---------------------------------------------------------------
// 1. please call pInitialFileSys() before use any private area file system function
// 2. do not support subdirectories
// 3. support 8.3 file name format
// 4. call pCloseFileSystem() after use the file system
// ------------------------------------------------------------------------------
#define PA_PFILE_OPEN 0x01
#define PA_PFILE_CREATE 0x02
#define PA_PDIR_OPEN 0x03
#define PA_PDIR_CREATE 0x04
#define PA_PSUBD_CREATE 0x05
typedef struct _DirList
{
char DirFileName[256];
int DirFileSize;
unsigned char DirFileDate[20];
} PA_DIRLIST;
//initial private area file system
NUDISK21E_API ULONG fx_InitialFileSystem(int DevIdx, int ThreadNo);
//close private area file system
NUDISK21E_API ULONG fx_CloseFileSystem(int DevIdx, int ThreadNo);
//get the directory of private area file system
// dirBuffer --- out --- directory buffer
// nf --- out --- return the number of file on this disk
// freeSpace --- out --- retrun the free space of private disk
// Before call this function lease allocate dirBuffer = sizeof(DirList) * numberOfFile
NUDISK21E_API ULONG fx_FileDir(int DevIdx, int &freeSpace, int &nf, PA_DIRLIST dirBuffer[], int ThreadNo);
NUDISK21E_API ULONG fx_pFileDir_FreeSpace(int DevIdx, int &freeSpace, int ThreadNo);
// open an existed file on private area, return a handle when success,
//#define PFILE_OPEN 0x01 ---- mode
//#define PFILE_CREATE 0x02 ---- mode
// mode ---in --- file open mode , PFILE_OPEN (when file is existed),
// PFILE_CREATE (when file is not existed)
// handle --- out ---this function will return a handle when file open success
// filename --- in ---file name to open
NUDISK21E_API ULONG fx_pFileOpen(int DevIdx, unsigned char mode, ULONG &handle, char* fileName, int ThreadNo);
// read a number of byte from file, always read data from current position
// handle --- in --- file handle to write
// buffer --- in --- buffer to read, the size of buffer should equal to numberOfRead
// numberOfRead --- in/out --- input the number of byte to read, return the number of byte
// read from file
NUDISK21E_API ULONG fx_pFileRead(int DevIdx, ULONG handle,unsigned char* buffer, ULONG &numberOfRead, int ThreadNo);
// write a number of byte to the file, always add new data to the end of file
// handle --- in --- file handle to write
// buffer --- in --- buffer to write, the size of buffer should equal to numberOfWrite
// numberOfWrite --- in/out --- input the number of byte to write, return the number of byte
// written to file
NUDISK21E_API ULONG fx_pFileWrite(int DevIdx, ULONG handle,unsigned char* buffer, ULONG &numberOfWrite, int ThreadNo);
// delete an existed file on private area
// fileName --- in --- file name to be deleted
NUDISK21E_API ULONG fx_pFileDelete(int DevIdx, char* fileName, int ThreadNo);
// close an existed file on private area
// handle --- in --- file handle to be closed
NUDISK21E_API ULONG fx_pFileClose(int DevIdx, ULONG handle, int ThreadNo);
//get the USB list number
NUDISK21E_API BOOL fx_getUsbListNum(int DevIdx, char *pUsbListNum, int ThreadNo);
//Get the vendor string and product string.
NUDISK21E_API BOOL fx_GetString(int DevIdx, char *VS, char *PS, int DiskIdxOfDev);
//Set the vendor string and product string.
NUDISK21E_API BOOL fx_SetString(int DevIdx, char *VS, char *PS, int DiskIdxOfDev);
/*
[Return value]
Nonzero if successful. If 0, it may result from the following reasons:
(1) Vendor string length is over 8 characters.
(2) Product string length is over 16 characters.
[Remarks]
The maximum length of vendor string without null pointer is limited to 8, and that of product string
without null pointer is limited to 16.
*/
//Set the current disk to security mode.
NUDISK21E_API BOOL fx_Protect(int DevIdx, int DiskIdxOfDev);
//Set the current drive to unprotected mode.
NUDISK21E_API BOOL fx_Unprotect(int DevIdx, char *Password, int DiskIdxOfDev);
//Change the password of the current disk.
NUDISK21E_API BOOL fx_ChangePassword(int DevIdx, char *OldPassword, char *NewPassword, int DiskIdxOfDev);
//Write ISO file to current drive which is CDROM type
NUDISK21E_API BYTE fx_UpdateISOFile(int DevIdx, char* FileName, int DiskIdxOfDev);
//Eject Current USB device
NUDISK21E_API BOOL EjectCurrentUSB(int DevIdx);
//Set the current device to Protect mode.
NUDISK21E_API BOOL fx_DeviceProtect(int DevIdx, int ThreadNo);
//Set the current device to UnProtect mode.
NUDISK21E_API BOOL fx_DeviceUnProtect(int DevIdx, int ThreadNo);
//Get the current device to Protect mode.
NUDISK21E_API BOOL fx_IsWriteDeviceProtect(int DevIdx, int ThreadNo);
//文件名是否存在
NUDISK21E_API BOOL fx_getFileBeing(int DevIdx, char* fileName, int ThreadNo);
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -