📄 drmmemory.c
字号:
/*
// $Header: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/AviDrm/libDrmDecrypt/DrmMemory.c 2 2/15/04 7:41p Lotan $
// Copyright (c) DivXNetworks, Inc. http://www.divxnetworks.com
// All rights reserved.
//
// This software is the confidential and proprietary information of DivxNetworks
// Inc. ("Confidential Information"). You shall not disclose such Confidential
// Information and shall use it only in accordance with the terms of the license
// agreement you entered into with DivXNetworks, Inc.
*/
#include "Config.h" // Global Configuration - do not remove!
#include "Playcore\Nav_Clips\AviDrm\libDrmDecrypt\DrmLocal.h"
#ifdef AVI_DRM_SUPPORT
#include "Playcore\Nav_Clips\AviDrm\libDrmDecrypt\DrmLocal.h"
#include "Playcore\Nav_Clips\AviDrm\libDrmDecrypt\Bits.h"
#include "Playcore\Nav_Clips\AviDrm\libDrmDecrypt\DrmAdpApi.h"
#include "Playcore\Nav_Clips\AviDrm\libDrmDecrypt\DrmAdpHelper.h"
#include "Playcore\Nav_Clips\AviDrm\LibDrmCommon\DrmErrors.h"
//#include "../../libDrmCommon/src/randomi.h"
#include "Kernel\EventDef.H"
#include "Kernel\Ker_API.h"
#include "Playcore\PS\ps.h"
#include <stdio.h>
#include <string.h>
uint8_t packDrmMemory(DrmMemory memory, DrmPackedMemory *packedMemory)
{
return packLogic(&memory, packedMemory, (uint8_t) B_BECOMES_A);
}
uint8_t unpackDrmMemory(DrmPackedMemory packedMemory, DrmMemory *memory)
{
return packLogic(memory, &packedMemory, (uint8_t) A_BECOMES_B);
}
uint8_t packLogic(DrmMemory *memory, DrmPackedMemory *packedMemory, uint8_t direction)
{
uint8_t packedIndex; /* Keep incrementing as we assign to unpacked memory. */
uint8_t slotIndex;
uint8_t multiUseIndex; /* Uses to count byte placement in DrmMemory fields. */
packedIndex = 0;
/* Get owner. */
for (multiUseIndex = 0; multiUseIndex < OWNER_GUARD_BYTES; multiUseIndex++)
{
assign(&(memory->owner.guard[multiUseIndex]), &(packedMemory->packed[packedIndex++]), direction);
}
for (multiUseIndex = 0; multiUseIndex < KEY_SIZE_BYTES; multiUseIndex++)
{
assign(&(memory->owner.key[multiUseIndex]), &(packedMemory->packed[packedIndex++]), direction);
}
for (multiUseIndex = 0; multiUseIndex < OWNER_USER_ID_BYTES; multiUseIndex++)
{
assign(&(memory->owner.userId[multiUseIndex]), &(packedMemory->packed[packedIndex++]), direction);
}
/* Get slots. */
for (slotIndex = 0; slotIndex < TOTAL_PLAY_SLOTS; slotIndex++)
{
for (multiUseIndex = 0; multiUseIndex < SLOT_SERIAL_NUMBER_BYTES; multiUseIndex++)
{
assign(&(memory->slots[slotIndex].serialNumber[multiUseIndex]), &(packedMemory->packed[packedIndex++]), direction);
}
assign(&(memory->slots[slotIndex].counter), &(packedMemory->packed[packedIndex++]), direction);
}
return 0;
}
uint8_t loadDrmMemory(DrmMemory *memory)
{
uint8_t returnCode = DRM_ERROR_NONE;
returnCode = localLoadDrmMemory(memory);
return returnCode;
}
uint8_t saveDrmMemory(DrmMemory *memory)
{
uint8_t returnCode = DRM_ERROR_NONE;
returnCode = localSaveDrmMemory(memory);
// Robin_0205_2005, protect the drmmemory saving
#if 1 // fadih maybe need if 0
PS_Save();
#else
dCmd = (((DWORD)PS_UPDATE_DRM_MEMORY)<<16);
ie_send_ex(IE_CORE_UPDATE_PS, (void *)dCmd);
#endif
return returnCode;
}
uint8_t randomizeGuard(DrmMemory *memory)
{
uint8_t i;
uint8_t randomByte;
uint8_t returnCode = DRM_ERROR_NONE;
memcpy(memory->owner.guard, nullGuard, OWNER_GUARD_BYTES);
for (i = 0; i < OWNER_GUARD_BYTES; i++)
{
returnCode = getRandomByte(&randomByte);
if (returnCode != DRM_ERROR_NONE)
{
return returnCode;
}
memory->owner.guard[i] = randomByte;
}
/* Ensure guard cannot be null guard. This should be a 2^24 chance. */
if (0 == memcmp(memory->owner.guard, nullGuard, OWNER_GUARD_BYTES))
{
memory->owner.guard[0] = 1;
}
return returnCode;
}
#endif // AVI_DRM_SUPPORT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -