Repository navigation
Expand file tree
/
Copy pathUpdateBase.cpp
More file actions
98 lines (79 loc) · 2.04 KB
/
Copy pathUpdateBase.cpp
File metadata and controls
98 lines (79 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// UpdateBase.cpp: implementation of the CUpdateBase class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "UpdateBase.h"
#include "Config.h"
#include "USBTransc.h"
#define MAX_SEND_SCSI_LEN 6 //MAX 6
BYTE m_send_SCSI_cmd[MAX_SEND_SCSI_LEN] =
{
'A', 'N', 'Y', 'K', 'A', 0
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CConfig theConfig;
CUpdateBase::CUpdateBase()
{
m_hDisk = INVALID_HANDLE_VALUE;
}
CUpdateBase::~CUpdateBase()
{
}
int CUpdateBase::GetUDisk(char pDiskName[], int len)
{
DWORD MaxDriveSet;
DWORD drive;
TCHAR szDrvName[33];
int count = 0;
MaxDriveSet = GetLogicalDrives();//GetLogicalDrives
for (drive = 0; drive < 32; drive++)
{
if ( MaxDriveSet & (1 << drive) )
{
DWORD temp = 1<<drive;
_stprintf(szDrvName, _T("%c:\\"), 'A'+drive);//szDrvName
if(GetDriveType(szDrvName)== DRIVE_REMOVABLE && (drive > 1))
{
pDiskName[count++] = 'A'+ (char)drive;
if(count >= len)
{
break;
}
}
}
}
return count;
}
BOOL CUpdateBase::OpenDisk(char diskName)
{
DWORD accessMode = 0, shareMode = 0;//
TCHAR szBuf[260];//
shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; // default
accessMode = GENERIC_WRITE | GENERIC_READ; // default
_stprintf(szBuf, _T("\\\\?\\%c:"), diskName);//
m_hDisk = CreateFile(szBuf, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);//CreateFile
if(INVALID_HANDLE_VALUE == m_hDisk)//
{
return FALSE;
}
return TRUE;
}
void CUpdateBase::CloseDisk()
{
if(m_hDisk != INVALID_HANDLE_VALUE)
{
CloseHandle(m_hDisk);//CloseHandle
}
}
BOOL CUpdateBase::SendCommand()
{
if(INVALID_HANDLE_VALUE == m_hDisk)
{
return FALSE;
}
//ˇ˘ËÍCC
return BT_SendExSCSICommand(m_hDisk, 0xCC, m_send_SCSI_cmd, MAX_SEND_SCSI_LEN - 1);
}