mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-09 13:52:01 -04:00
Remove Qt deps from UEFIFind and fix issues
This commit is contained in:
parent
7d16c1d48d
commit
4d50d581fa
21 changed files with 275 additions and 225 deletions
|
@ -11,6 +11,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cctype>
|
||||
|
||||
#include "treemodel.h"
|
||||
#include "utility.h"
|
||||
#include "ffs.h"
|
||||
|
@ -375,3 +378,68 @@ UINT8 getPaddingType(const UByteArray & padding)
|
|||
return Subtypes::OnePadding;
|
||||
return Subtypes::DataPadding;
|
||||
}
|
||||
|
||||
static inline int char2hex(char c) {
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return c - 'A';
|
||||
if (c == '.')
|
||||
return -2;
|
||||
return -1;
|
||||
}
|
||||
|
||||
INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSize,
|
||||
const UINT8 *data, UINTN dataSize, UINTN dataOff) {
|
||||
if (patternSize == 0 || dataSize == 0 || dataOff >= dataSize || dataSize - dataOff < patternSize)
|
||||
return -1;
|
||||
|
||||
while (dataOff + patternSize < dataSize) {
|
||||
BOOLEAN matches = TRUE;
|
||||
for (UINTN i = 0; i < patternSize; i++) {
|
||||
if ((data[dataOff + i] & patternMask[i]) != pattern[i]) {
|
||||
matches = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matches)
|
||||
return static_cast<INTN>(dataOff);
|
||||
|
||||
dataOff++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOLEAN makePattern(const CHAR8 *textPattern, std::vector<UINT8> &pattern, std::vector<UINT8> &patternMask) {
|
||||
UINTN len = std::strlen(textPattern);
|
||||
|
||||
if (len == 0 || len % 2 != 0)
|
||||
return FALSE;
|
||||
|
||||
len /= 2;
|
||||
|
||||
pattern.resize(len);
|
||||
patternMask.resize(len);
|
||||
|
||||
for (UINTN i = 0; i < len; i++) {
|
||||
int v1 = char2hex(std::toupper(textPattern[i * 2]));
|
||||
int v2 = char2hex(std::toupper(textPattern[i * 2 + 1]));
|
||||
|
||||
if (v1 == -1 || v2 == -1)
|
||||
return FALSE;
|
||||
|
||||
if (v1 != -2) {
|
||||
patternMask[i] = 0xF0;
|
||||
pattern[i] = static_cast<UINT8>(v1) << 4;
|
||||
}
|
||||
|
||||
if (v2 != -2) {
|
||||
patternMask[i] |= 0x0F;
|
||||
pattern[i] |= static_cast<UINT8>(v2);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue