本文整理汇总了C++中CompareMem函数的典型用法代码示例。如果您正苦于以下问题:C++ CompareMem函数的具体用法?C++ CompareMem怎么用?C++ CompareMem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CompareMem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareVariableName
/**
Compare two variable names, one of them may be inconsecutive.
@param StoreInfo Pointer to variable store info structure.
@param Name1 Pointer to one variable name.
@param Name2 Pointer to another variable name.
@param NameSize Variable name size.
@retval TRUE Name1 and Name2 are identical.
@retval FALSE Name1 and Name2 are not identical.
**/
BOOLEAN
CompareVariableName (
IN VARIABLE_STORE_INFO *StoreInfo,
IN CONST CHAR16 *Name1,
IN CONST CHAR16 *Name2,
IN UINTN NameSize
)
{
EFI_PHYSICAL_ADDRESS TargetAddress;
EFI_PHYSICAL_ADDRESS SpareAddress;
UINTN PartialNameSize;
if (StoreInfo->FtwLastWriteData != NULL) {
TargetAddress = StoreInfo->FtwLastWriteData->TargetAddress;
SpareAddress = StoreInfo->FtwLastWriteData->SpareAddress;
if (((UINTN) Name1 < (UINTN) TargetAddress) && (((UINTN) Name1 + NameSize) > (UINTN) TargetAddress)) {
//
// Name1 is inconsecutive.
//
PartialNameSize = (UINTN) TargetAddress - (UINTN) Name1;
//
// Partial content is in NV storage.
//
if (CompareMem ((UINT8 *) Name1, (UINT8 *) Name2, PartialNameSize) == 0) {
//
// Another partial content is in spare block.
//
if (CompareMem ((UINT8 *) (UINTN) SpareAddress, (UINT8 *) Name2 + PartialNameSize, NameSize - PartialNameSize) == 0) {
return TRUE;
}
}
return FALSE;
} else if (((UINTN) Name2 < (UINTN) TargetAddress) && (((UINTN) Name2 + NameSize) > (UINTN) TargetAddress)) {
//
// Name2 is inconsecutive.
//
PartialNameSize = (UINTN) TargetAddress - (UINTN) Name2;
//
// Partial content is in NV storage.
//
if (CompareMem ((UINT8 *) Name2, (UINT8 *) Name1, PartialNameSize) == 0) {
//
// Another partial content is in spare block.
//
if (CompareMem ((UINT8 *) (UINTN) SpareAddress, (UINT8 *) Name1 + PartialNameSize, NameSize - PartialNameSize) == 0) {
return TRUE;
}
}
return FALSE;
}
}
//
// Both Name1 and Name2 are consecutive.
//
if (CompareMem ((UINT8 *) Name1, (UINT8 *) Name2, NameSize) == 0) {
return TRUE;
}
return FALSE;
}
示例2: ID
/**
Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
channel.
@param[in] This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
@param[in, out] Target On input, a pointer to the Target ID (an array of size
TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
On output, a pointer to the Target ID (an array of
TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
channel. An input value of 0xF(all bytes in the array are 0xF) in the
Target array retrieves the Target ID of the first SCSI device present on a
SCSI channel.
@param[in, out] Lun On input, a pointer to the LUN of a SCSI device present on the SCSI
channel. On output, a pointer to the LUN of the next SCSI device present
on a SCSI channel.
@retval EFI_SUCCESS The Target ID and LUN of the next SCSI device on the SCSI
channel was returned in Target and Lun.
@retval EFI_INVALID_PARAMETER Target array is not all 0xF, and Target and Lun were
not returned on a previous call to GetNextTargetLun().
@retval EFI_NOT_FOUND There are no more SCSI devices on this SCSI channel.
**/
EFI_STATUS
EFIAPI
IScsiExtScsiPassThruGetNextTargetLun (
IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
IN OUT UINT8 **Target,
IN OUT UINT64 *Lun
)
{
ISCSI_DRIVER_DATA *Private;
ISCSI_SESSION_CONFIG_NVDATA *ConfigNvData;
UINT8 TargetId[TARGET_MAX_BYTES];
Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (This);
ConfigNvData = &Private->Session.ConfigData.NvData;
if ((*Target)[0] == 0 && (CompareMem (Lun, ConfigNvData->BootLun, sizeof (UINT64)) == 0)) {
//
// Only one <Target, Lun> pair per iSCSI Driver instance.
//
return EFI_NOT_FOUND;
}
SetMem (TargetId, TARGET_MAX_BYTES, 0xFF);
if (CompareMem (*Target, TargetId, TARGET_MAX_BYTES) == 0) {
(*Target)[0] = 0;
CopyMem (Lun, ConfigNvData->BootLun, sizeof (UINT64));
return EFI_SUCCESS;
}
return EFI_INVALID_PARAMETER;
}
示例3: SdtCheckPciDeviceInfoChanged
/**
Check input Pci device info is changed from the default values
@param PciDeviceInfo Pointer to PCI_DEVICE_INFO
@param UpdatePRT Pointer to BOOLEAN
@param UpdatePRW Pointer to BOOLEAN
**/
VOID
SdtCheckPciDeviceInfoChanged (
IN PCI_DEVICE_INFO *PciDeviceInfo,
IN BOOLEAN *UpdatePRT,
IN BOOLEAN *UpdatePRW
)
{
UINTN Index = 0;
if (mQNCPciInfo == NULL) {
*UpdatePRT = FALSE;
*UpdatePRW = FALSE;
return;
}
*UpdatePRT = TRUE;
*UpdatePRW = TRUE;
for (Index = 0;Index < CURRENT_PCI_DEVICE_NUM; Index++) {
if ((mQNCPciInfo[Index].BridgeAddress == PciDeviceInfo->BridgeAddress)
&& (mQNCPciInfo[Index].DeviceAddress == PciDeviceInfo->DeviceAddress)) {
//
// Find one matched entry
//
if (CompareMem (&(mQNCPciInfo[Index].INTA[0]), &PciDeviceInfo->INTA[0], 10) == 0) {
*UpdatePRT = FALSE;
*UpdatePRW = FALSE;
//DEBUG ((EFI_D_ERROR, "Find one matched entry[%d] and no change\n", Index));
} else {
if (CompareMem (&(mQNCPciInfo[Index].INTA[0]), &PciDeviceInfo->INTA[0], 8) == 0)
*UpdatePRT = FALSE;
if (CompareMem (&(mQNCPciInfo[Index].GPEPin), &PciDeviceInfo->GPEPin, 2) == 0)
*UpdatePRW = FALSE;
if (*(UINT64 *)(&PciDeviceInfo->INTA[0]) == 0xFFFFFFFFFFFFFFFFULL)
*UpdatePRT = FALSE;
if (*(UINT16 *)(&PciDeviceInfo->GPEPin) == 0xFFFF)
*UpdatePRW = FALSE;
//DEBUG ((EFI_D_ERROR, "Find one matched entry[%d] and but need update PRT:0x%x PRW:0x%x\n", Index, *UpdatePRT, *UpdatePRW));
}
break;
}
}
//if (Index == 42) {
// DEBUG ((EFI_D_ERROR, "Find No matched entry\n"));
//}
return;
}
示例4: IScsiCHAPAuthTarget
/**
The initator checks the CHAP response replied by target against its own
calculation of the expected hash value.
@param[in] AuthData iSCSI CHAP authentication data.
@param[in] TargetResponse The response from target.
@retval EFI_SUCCESS The response from target passed authentication.
@retval EFI_SECURITY_VIOLATION The response from target was not expected value.
@retval Others Other errors as indicated.
**/
EFI_STATUS
IScsiCHAPAuthTarget (
IN ISCSI_CHAP_AUTH_DATA *AuthData,
IN UINT8 *TargetResponse
)
{
EFI_STATUS Status;
UINT32 SecretSize;
UINT8 VerifyRsp[ISCSI_CHAP_RSP_LEN];
Status = EFI_SUCCESS;
SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
Status = IScsiCHAPCalculateResponse (
AuthData->OutIdentifier,
AuthData->AuthConfig->ReverseCHAPSecret,
SecretSize,
AuthData->OutChallenge,
AuthData->OutChallengeLength,
VerifyRsp
);
if (CompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN) != 0) {
Status = EFI_SECURITY_VIOLATION;
}
return Status;
}
示例5: Source
/**
Searches Source for Search pattern of size SearchSize
and replaces it with Replace up to MaxReplaces times.
@param Source Source bytes that will be searched.
@param SourceSize Number of bytes in Source region.
@param Search Bytes to search for.
@param SearchSize Number of bytes in Search.
@param Replace Bytes that will replace found bytes in Source (size is SearchSize).
@param MaxReplaces Maximum number of replaces. If MaxReplaces <= 0, then there is no restriction.
@retval Number of replaces done.
**/
UINTN
VideoBiosPatchSearchAndReplace (
IN UINT8 *Source,
IN UINTN SourceSize,
IN UINT8 *Search,
IN UINTN SearchSize,
IN UINT8 *Replace,
IN INTN MaxReplaces
)
{
UINTN NumReplaces = 0;
BOOLEAN NoReplacesRestriction = MaxReplaces <= 0;
UINT8 *End = Source + SourceSize;
DBG ("VideoBiosPatchSearchAndReplace:");
while (Source < End && (NoReplacesRestriction || MaxReplaces > 0)) {
if (CompareMem(Source, Search, SearchSize) == 0) {
CopyMem(Source, Replace, SearchSize);
NumReplaces++;
MaxReplaces--;
DBG (" offset = 0x%x.", Source);
Source += SearchSize;
} else {
Source++;
}
}
DBG ("\n");
return NumReplaces;
}
示例6: AsusAICPUPMPatch
VOID
AsusAICPUPMPatch (
UINT8 *Driver,
UINT32 DriverSize,
CHAR8 *InfoPlist,
UINT32 InfoPlistSize
)
{
UINTN Index1;
UINTN Index2;
UINTN Count;
Count = 0;
//TODO: we should scan only __text __TEXT
for (Index1 = 0; Index1 < DriverSize; Index1++) {
// search for MovlE2ToEcx
if (CompareMem ((Driver + Index1), MovlE2ToEcx, sizeof (MovlE2ToEcx)) == 0) {
// search for wrmsr in next few bytes
for (Index2 = (Index1 + sizeof (MovlE2ToEcx)); Index2 < (Index1 + sizeof (MovlE2ToEcx) + 16); Index2++) {
if ((Driver[Index2] == Wrmsr[0]) && (Driver[Index2 + 1] == Wrmsr[1])) {
// found it - patch it with nops
Count++;
Driver[Index2] = 0x90;
Driver[Index2 + 1] = 0x90;
}
}
}
}
}
示例7: SearchAndReplace
//
// Searches Source for Search pattern of size SearchSize
// and replaces it with Replace up to MaxReplaces times.
// If MaxReplaces <= 0, then there is no restriction on number of replaces.
// Replace should have the same size as Search.
// Returns number of replaces done.
//
UINTN
SearchAndReplace (
UINT8 *Source,
UINT32 SourceSize,
CHAR8 *Search,
UINTN SearchSize,
CHAR8 *Replace,
INTN MaxReplaces
)
{
UINTN NumReplaces;
BOOLEAN NoReplacesRestriction;
UINT8 *End;
NumReplaces = 0;
NoReplacesRestriction = MaxReplaces <= 0;
End = Source + SourceSize;
while (Source < End && (NoReplacesRestriction || MaxReplaces > 0)) {
if (CompareMem (Source, Search, SearchSize) == 0) {
CopyMem (Source, Replace, SearchSize);
NumReplaces++;
MaxReplaces--;
Source += SearchSize;
} else {
Source++;
}
}
return NumReplaces;
}
示例8: MatchPadEntry
/**
Find the matching PAD with Indexer.
@param[in] PadId The pointer to the EFI_IPSEC_PAD_ID structure.
@param[in] Data The pointer to the EFI_IPSEC_PAD_DATA structure.
@param[in] Indexer The pointer to the SPD_ENTRY_INDEXER structure.
@retval TRUE The matched PAD is found.
@retval FALSE The matched PAD is not found.
**/
BOOLEAN
MatchPadEntry (
IN EFI_IPSEC_PAD_ID *PadId,
IN EFI_IPSEC_PAD_DATA *Data,
IN PAD_ENTRY_INDEXER *Indexer
)
{
BOOLEAN Match;
Match = FALSE;
if (!IsMemoryZero (&Indexer->PadId, sizeof (EFI_IPSEC_PAD_ID))) {
Match = (BOOLEAN) ((Indexer->PadId.PeerIdValid == PadId->PeerIdValid) &&
((PadId->PeerIdValid &&
(StrCmp (
(CONST CHAR16 *) Indexer->PadId.Id.PeerId,
(CONST CHAR16 *) PadId->Id.PeerId
) == 0)) ||
((!PadId->PeerIdValid) &&
(Indexer->PadId.Id.IpAddress.PrefixLength == PadId->Id.IpAddress.PrefixLength) &&
(CompareMem (
&Indexer->PadId.Id.IpAddress.Address,
&PadId->Id.IpAddress.Address,
sizeof (EFI_IP_ADDRESS)
) == 0))));
} else {
if (Indexer->Index == 0) {
Match = TRUE;
}
Indexer->Index--;
}
return Match;
}
示例9: CompareWithValidVariable
/**
This function compares a variable with variable entries in database.
@param Variable Pointer to the variable in our database
@param VariableName Name of the variable to compare to 'Variable'
@param VendorGuid GUID of the variable to compare to 'Variable'
@param PtrTrack Variable Track Pointer structure that contains Variable Information.
@retval EFI_SUCCESS Found match variable
@retval EFI_NOT_FOUND Variable not found
**/
EFI_STATUS
CompareWithValidVariable (
IN VARIABLE_HEADER *Variable,
IN CONST CHAR16 *VariableName,
IN CONST EFI_GUID *VendorGuid,
OUT VARIABLE_POINTER_TRACK *PtrTrack
)
{
VOID *Point;
if (VariableName[0] == 0) {
PtrTrack->CurrPtr = Variable;
return EFI_SUCCESS;
} else {
//
// Don't use CompareGuid function here for performance reasons.
// Instead we compare the GUID a UINT32 at a time and branch
// on the first failed comparison.
//
if ((((INT32 *) VendorGuid)[0] == ((INT32 *) &Variable->VendorGuid)[0]) &&
(((INT32 *) VendorGuid)[1] == ((INT32 *) &Variable->VendorGuid)[1]) &&
(((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&
(((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])
) {
ASSERT (NameSizeOfVariable (Variable) != 0);
Point = (VOID *) GetVariableNamePtr (Variable);
if (CompareMem (VariableName, Point, NameSizeOfVariable (Variable)) == 0) {
PtrTrack->CurrPtr = Variable;
return EFI_SUCCESS;
}
}
}
return EFI_NOT_FOUND;
}
示例10: tp_draw_logo
void tp_draw_logo(EFI_GRAPHICS_OUTPUT_PROTOCOL* gop)
{
if (NULL == gop){
return;
}
acpi_bgrt = NULL;
for (UINTN i = 0; gST->NumberOfTableEntries > i; ++i){
EFI_GUID* guid = &(gST->ConfigurationTable[i].VendorGuid);
UINT8* table = (UINT8*)(gST->ConfigurationTable[i].VendorTable);
if (0 == CompareMem(guid, &gEfiAcpiTableGuid, sizeof(EFI_GUID))){
tp_get_bgrt(table);
if (NULL == acpi_bgrt){
return;
}
tp_draw_logo2(gop);
break;
}
}
}
示例11: IsLoadForbidden
/**
Check whether the DevicePath is in the device path forbid list
(mAccessInfo.LoadForbid).
@param[in] DevicePath Points to device path.
@retval TRUE The DevicePath is in the device path forbid list.
@retval FALSE The DevicePath is not in the device path forbid list.
**/
BOOLEAN
IsLoadForbidden (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
UINTN OffSet;
UINTN DPSize;
UINTN Size;
EFI_DEVICE_PATH_PROTOCOL *Dp;
OffSet = 0;
Size = GetDevicePathSize (DevicePath);
//
// Check each device path.
//
while (OffSet < mAccessInfo.LoadForbidLen) {
Dp = (EFI_DEVICE_PATH_PROTOCOL *) (mAccessInfo.LoadForbid + OffSet);
DPSize = GetDevicePathSize (Dp);
//
// Compare device path.
//
if ((DPSize == Size) && (CompareMem (DevicePath, Dp, Size) == 0)) {
return TRUE;
}
OffSet += DPSize;
}
return FALSE;
}
示例12: InternalCompareBlock
EFI_STATUS
InternalCompareBlock (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT8 *Buffer
)
{
EFI_STATUS Status;
VOID *CompareBuffer;
UINT32 NumBytes;
INTN CompareResult;
NumBytes = BLOCK_SIZE;
CompareBuffer = AllocatePool (NumBytes);
if (CompareBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
Status = SpiFlashRead ((UINTN) BaseAddress, &NumBytes, CompareBuffer);
if (EFI_ERROR (Status)) {
goto Done;
}
CompareResult = CompareMem (CompareBuffer, Buffer, BLOCK_SIZE);
if (CompareResult != 0) {
Status = EFI_VOLUME_CORRUPTED;
}
Done:
if (CompareBuffer != NULL) {
FreePool (CompareBuffer);
}
return Status;
}
示例13: IsFvHeaderValid
/**
Check the integrity of firmware volume header
@param[in] FwVolHeader A pointer to a firmware volume header
@retval TRUE The firmware volume is consistent
@retval FALSE The firmware volume has corrupted.
**/
STATIC
BOOLEAN
IsFvHeaderValid (
IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
)
{
UINT16 Checksum;
// Skip nv storage fv
if (CompareMem (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid, sizeof(EFI_GUID)) != 0 ) {
return FALSE;
}
if ( (FwVolHeader->Revision != EFI_FVH_REVISION) ||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
(FwVolHeader->FvLength == ((UINTN) -1)) ||
((FwVolHeader->HeaderLength & 0x01 ) !=0) ) {
return FALSE;
}
Checksum = CalculateCheckSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength);
if (Checksum != 0) {
DEBUG (( DEBUG_ERROR,
"ERROR - Invalid Firmware Volume Header Checksum, change 0x%04x to 0x%04x\r\n",
FwVolHeader->Checksum,
(UINT16)( Checksum + FwVolHeader->Checksum )));
return FALSE;
}
return TRUE;
}
示例14: GetCursorPos
void __fastcall TScreenSpy::GetNext()
{
TRect rt;
TPoint pt;
int i, l, t;
FmsScr->Clear();
for (i = 0; i < BNUMS; i++)
{
FFlag1[i] = FFocus[i] > 0;
FFlag2[i] = false;
}
GetCursorPos(&pt);
FFlag1[pt.x / FBWidth + pt.y / FBHeight * BSIZE] = true;
FDC = GetDC(0);
i = 0;
while (i < BNUMS)
{
if (FFlag1[i] && (!FFlag2[i]))
{
FFlag2[i] = true;
l = (i % BSIZE) * FBWidth;
t = (i / BSIZE) * FBHeight;
FBmps[BNUMS]->Canvas->Lock();
try
{
BitBlt(FBmps[BNUMS]->Canvas->Handle, 0, 0, FBWidth, FBHeight, FDC, l, t, SRCCOPY);
}
__finally
{
FBmps[BNUMS]->Canvas->Unlock();
}
if (CompareMem(FBmps[i]->ScanLine[FBHeight - 1], FBmps[BNUMS]->ScanLine[FBHeight - 1], FSize))
FFocus[i] = Max(FFocus[i] - 1, 0);
else
{
FBmps[i]->Canvas->Lock();
try
{
BitBlt(FBmps[i]->Canvas->Handle, 0, 0, FBWidth, FBHeight, FDC, l, t, SRCCOPY);
}
__finally
{
FBmps[i]->Canvas->Unlock();
}
FFocus[i] = 5;
SetRect(&rt, l, t, l + FBWidth, t + FBHeight);
FmsScr->WriteBuffer(&rt, sizeof(rt));
FBmps[i]->SaveToStream(FmsScr);
if ((i - BSIZE) >= 0) FFlag1[i - BSIZE] = true;
if ((i + BSIZE) <= (BNUMS - 1)) FFlag1[i + BSIZE] = true;
if ((i % BSIZE) != 0) FFlag1[i - 1] = true;
if ((i % BSIZE) != (BSIZE - 1)) FFlag1[i + 1] = true;
i = Max(Min(i - BSIZE, i - 1), 0);
continue;
}
}
i++;
}
示例15: show_signature_support
EFI_STATUS
show_signature_support(EFI_SYSTEM_TABLE *systab, UINTN showguid)
{
EFI_STATUS rc = EFI_SUCCESS;
char *data = NULL;
UINTN data_size = 0;
UINTN found = 0;
EFI_GUID *guid;
int i, j;
struct {
EFI_GUID *guid;
CHAR16 *name;
int required;
} hashes[] = {
{ &gEfiCertSha1Guid, L"SHA-1", 1 },
{ &gEfiCertSha256Guid, L"SHA-256", 0 },
{ &gEfiCertRsa2048Guid, L"RSA-2048", 0 },
{ &gEfiCertRsa2048Sha1Guid, L"RSA-2048 + SHA-1", 0 },
{ &gEfiCertRsa2048Sha256Guid, L"RSA-2048 + SHA-256", 0 },
{ &gEfiCertX509Guid, L"X509", 1 },
{ &gEfiCertPkcs7Guid, L"PKCS-7", 0 },
{ NULL, L"" }
};
data = LibGetVariableAndSize(L"SignatureSupport", &EfiGlobalVariable,
&data_size);
guid = (EFI_GUID *)data;
Print(L"Supported hashes:\n");
for (i = 0; i < data_size / sizeof(*guid); i++, guid++) {
found = 0;
for (j = 0; hashes[j].guid != NULL; j++) {
if (!CompareMem(hashes[j].guid, guid, sizeof(*guid))) {
if (showguid)
Print(L" %s (%g)\n", hashes[j].name, guid);
else
Print(L" %s\n", hashes[j].name);
hashes[j].required = 0;
found = 1;
continue;
}
}
if (!found) {
Print(L" Unknown hash (%g)\n", guid);
}
}
for (j = 0; hashes[j].guid != NULL; j++) {
if (hashes[j].required) {
Print(L"ERROR: Did not find required hash \"%s\"\n",
hashes[j].name);
rc = EFI_NOT_FOUND;
}
}
FreePool(data);
return rc;
}