check for SDK with binary II header.
git-svn-id: https://profuse.googlecode.com/svn/branches/profuse_interim@379 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
1a0bdd875c
commit
699c44cf15
|
@ -208,16 +208,29 @@ BlockDevicePointer SDKImage::Open(const char *name)
|
||||||
|
|
||||||
bool SDKImage::Validate(MappedFile * f, const std::nothrow_t &)
|
bool SDKImage::Validate(MappedFile * f, const std::nothrow_t &)
|
||||||
{
|
{
|
||||||
|
|
||||||
// NuFile, alternating ASCII.
|
// NuFile, alternating ASCII.
|
||||||
static const char IdentityCheck[6] = { 0x4E, 0xF5, 0x46, 0xE9, 0x6C, 0xE5 };
|
static const char IdentityCheck[6] = { 0x4E, 0xF5, 0x46, 0xE9, 0x6C, 0xE5 };
|
||||||
|
static const char BXYIdentityCheck[3] = { 0x0A, 0x47, 0x4C };
|
||||||
|
|
||||||
if (f->length() < sizeof(IdentityCheck))
|
uint8_t *address = (uint8_t *)f->address();
|
||||||
return false;
|
size_t length = f->length();
|
||||||
|
|
||||||
if (std::memcmp(f->address(), IdentityCheck, sizeof(IdentityCheck)))
|
// check for a BXY header
|
||||||
return false;
|
if (length >= 128
|
||||||
|
&& std::memcmp(address, BXYIdentityCheck, sizeof(BXYIdentityCheck)) == 0)
|
||||||
|
{
|
||||||
|
length -= 128;
|
||||||
|
address += 128;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
|
if (length > sizeof(IdentityCheck)
|
||||||
|
&& std::memcmp(address, IdentityCheck, sizeof(IdentityCheck)) == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue