mirror of
https://github.com/ksherlock/profuse.git
synced 2024-12-22 05:30:03 +00:00
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,17 +208,30 @@ BlockDevicePointer SDKImage::Open(const char *name)
|
||||
|
||||
bool SDKImage::Validate(MappedFile * f, const std::nothrow_t &)
|
||||
{
|
||||
|
||||
// NuFile, alternating ASCII.
|
||||
static const char IdentityCheck[6] = { 0x4E, 0xF5, 0x46, 0xE9, 0x6C, 0xE5 };
|
||||
static const char BXYIdentityCheck[3] = { 0x0A, 0x47, 0x4C };
|
||||
|
||||
if (f->length() < sizeof(IdentityCheck))
|
||||
return false;
|
||||
uint8_t *address = (uint8_t *)f->address();
|
||||
size_t length = f->length();
|
||||
|
||||
if (std::memcmp(f->address(), IdentityCheck, sizeof(IdentityCheck)))
|
||||
return false;
|
||||
// check for a BXY header
|
||||
if (length >= 128
|
||||
&& std::memcmp(address, BXYIdentityCheck, sizeof(BXYIdentityCheck)) == 0)
|
||||
{
|
||||
length -= 128;
|
||||
address += 128;
|
||||
}
|
||||
|
||||
|
||||
if (length > sizeof(IdentityCheck)
|
||||
&& std::memcmp(address, IdentityCheck, sizeof(IdentityCheck)) == 0)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool SDKImage::Validate(MappedFile * f)
|
||||
|
Loading…
Reference in New Issue
Block a user