QWidget * EmbeddedObjectClassPropertyInlineEditor::makeEditor(QWidget *parent, bool readOnly)
{
	pAssert( m_Object != NULL );
	pAssert( m_Property != NULL );
	pAssert( m_ElementEditor == NULL );

	m_ElementEditor = new EmbeddedObjectInlineElementEditor( parent );
	m_ElementEditor->setup( m_Object, m_Offset, m_Property, readOnly );

	return m_ElementEditor;
}
Ejemplo n.º 2
0
PColorRGBA::PColorRGBA(const pFloat32* rgba)
{
    pAssert(rgba[0] >= 0 && rgba[0] <= 1);
    pAssert(rgba[1] >= 0 && rgba[1] <= 1);
    pAssert(rgba[2] >= 0 && rgba[2] <= 1);
    pAssert(rgba[3] >= 0 && rgba[3] <= 1);

    m_rgba[0] = FLOAT32_TO_UINT8(rgba[0]);
    m_rgba[1] = FLOAT32_TO_UINT8(rgba[1]);
    m_rgba[2] = FLOAT32_TO_UINT8(rgba[2]);
    m_rgba[3] = FLOAT32_TO_UINT8(rgba[3]);
}
Ejemplo n.º 3
0
PColorRGBA::PColorRGBA(pFloat32 r, pFloat32 g, pFloat32 b, pFloat32 a)
{
    pAssert(r >= 0 && r <= 1);
    pAssert(g >= 0 && g <= 1);
    pAssert(b >= 0 && b <= 1);
    pAssert(a >= 0 && a <= 1);

    m_rgba[0]   = FLOAT32_TO_UINT8(r);
    m_rgba[1] = FLOAT32_TO_UINT8(g);
    m_rgba[2]  = FLOAT32_TO_UINT8(b);
    m_rgba[3] = FLOAT32_TO_UINT8(a);
}
Ejemplo n.º 4
0
/* This function is called to process a _TPM_Hash_Data() indication. */
LIB_EXPORT void
_TPM_Hash_Data(
	       uint32_t         dataSize,      // IN: size of data to be extend
	       unsigned char   *data           // IN: data buffer
	       )
{
    UINT32           i;
    HASH_OBJECT     *hashObject;
    TPMI_DH_PCR      pcrHandle = TPMIsStarted()
				 ? PCR_FIRST + DRTM_PCR : PCR_FIRST + HCRTM_PCR;
    // If there is no DRTM sequence object, then _TPM_Hash_Start
    // was not called so this function returns without doing
    // anything.
    if(g_DRTMHandle == TPM_RH_UNASSIGNED)
	return;
    hashObject = (HASH_OBJECT *)HandleToObject(g_DRTMHandle);
    pAssert(hashObject->attributes.eventSeq);
    // For each of the implemented hash algorithms, update the digest with the
    // data provided.
    for(i = 0; i < HASH_COUNT; i++)
	{
	    // make sure that the PCR is implemented for this algorithm
	    if(PcrIsAllocated(pcrHandle,
			      hashObject->state.hashState[i].hashAlg))
		// Update sequence object
		CryptDigestUpdate(&hashObject->state.hashState[i], dataSize, data);
	}
    return;
}
Ejemplo n.º 5
0
//*** _cpri__StartHash()
// Functions starts a hash stack
// Start a hash stack and returns the digest size. As a side effect, the
// value of 'stateSize' in hashState is updated to indicate the number of bytes
// of state that were saved. This function calls GetHashServer() and that function
// will put the TPM into failure mode if the hash algorithm is not supported.
// return type:     CRTYP_RESULT
//  0           hash is TPM_ALG_NULL
// >0           digest size
UINT16
_cpri__StartHash(
    TPM_ALG_ID hashAlg,         // IN: hash algorithm
    BOOL sequence,              // IN: TRUE if the state should be saved
    CPRI_HASH_STATE *hashState  // OUT: the state of hash stack.
    )
{
    OSSL_HASH_STATE *state = (OSSL_HASH_STATE *)&hashState->state;
    const HASH_INFO *hashInfo = GetHashInfoPointer(hashAlg);
    UINT16 retVal = 0;

    // Not supported
    pAssert(sequence == FALSE);

    // Valid algorithm?
    if (hashInfo == NULL)
    {
        goto Cleanup;
    }

    if (BCryptCreateHash(g_hAlg[GetHashIndex(hashAlg)], &state->hHash, NULL, 0, NULL, 0, 0) != 0)
    {
        goto Cleanup;
    }

    retVal = _cpri__GetDigestSize(hashAlg);
    hashState->hashAlg = hashAlg;

Cleanup:
    return retVal;
}
Ejemplo n.º 6
0
/* This function requires that handle references a loaded object or a permanent handle. */
OBJECT*
HandleToObject(
	       TPMI_DH_OBJECT   handle         // IN: handle of the object
	       )
{
    UINT32              index;
    // Return NULL if the handle references a permanent handle because there is no
    // associated OBJECT.
    if(HandleGetType(handle) == TPM_HT_PERMANENT)
	return NULL;
    // In this implementation, the handle is determined by the slot occupied by the
    // object.
    index = handle - TRANSIENT_FIRST;
    pAssert(index < MAX_LOADED_OBJECTS);
    pAssert(s_objects[index].attributes.occupied);
    return &s_objects[index];
}
Ejemplo n.º 7
0
/* FALSE object is not an HMAC, hash, or event sequence object */
BOOL
ObjectIsSequence(
		 OBJECT          *object         // IN: handle to be checked
		 )
{
    pAssert(object != NULL);
    return (object->attributes.hmacSeq == SET
	    || object->attributes.hashSeq == SET
	    || object->attributes.eventSeq == SET);
}
Ejemplo n.º 8
0
/* This function is used to clear a persistent data entry and commit it to NV */
void
NvClearPersistent(
		  UINT32           offset,        // IN: the offset in the PERMANENT_DATA
		  //     structure to be cleared (zeroed)
		  UINT32           size           // IN: number of bytes to clear
		  )
{
    pAssert(offset + size <= sizeof(gp));
    MemorySet((&gp) + offset, 0, size);
    NvWrite(offset, size, (&gp) + offset);
}
Ejemplo n.º 9
0
/* This function is used to update a value in the PERSISTENT_DATA structure and commits the value to
   NV. */
void
NvUpdatePersistent(
		   UINT32           offset,        // IN: location in PERMANENT_DATA to be updated
		   UINT32           size,          // IN: size of the value
		   void            *buffer         // IN: the new data
		   )
{
    pAssert(offset + size <= sizeof(gp));
    MemoryCopy(&gp + offset, buffer, size);
    NvWrite(offset, size, buffer);
}
Ejemplo n.º 10
0
void ClassSelectionDialog::init(const MetaClass * baseClass, bool allowAbstractClasses)
{
	m_AllowAbstractClasses = allowAbstractClasses;

	const MetaClass * mc = baseClass;
	pAssert( mc != NULL );
		
	QTreeWidgetItem * root = new QTreeWidgetItem( m_Tree, QStringList( baseClass->getClassName().c_str() ) );
	root->setIcon( 0, mc->isAbstract() ? *m_AbstractClassIcon : *m_ClassIcon );
	collectClasses( baseClass->getClassName(), root );
}
Ejemplo n.º 11
0
void PStreamFile::skip(pUint32 bytes)
{
    pAssert(m_file != P_NULL);
    if (m_file == P_NULL)
    {
        pLogError("Unable to open file for reading");
        return ;
    }

    pfseek(m_file, bytes, P_FILE_SEEK_FROM_HERE);
}
Ejemplo n.º 12
0
/* This function is used to move reserved data from NV memory to RAM. */
void
NvRead(
       void            *outBuffer,     // OUT: buffer to receive data
       UINT32           nvOffset,      // IN: offset in NV of value
       UINT32           size           // IN: size of the value to read
       )
{
    // Input type should be valid
    pAssert(nvOffset + size < NV_MEMORY_SIZE);
    _plat__NvMemoryRead(nvOffset, size, outBuffer);
    return;
}
Ejemplo n.º 13
0
void ClassSelectionDialog::tryToFinishDialog( string selectedClass )
{
	const MetaClass * mc = MetaClass::getClassByName( selectedClass );
	pAssert( mc != NULL );
	if( mc->isAbstract() && !m_AllowAbstractClasses )
	{
		QMessageBox::information( this, "Error", "Abstract classes are not allowed!" );
		return;
	}
	m_SelectedClass = (MetaClass*)mc;
	accept();
}
Ejemplo n.º 14
0
/* This function requires that the object is loaded. */
void
FlushObject(
	    TPMI_DH_OBJECT   handle         // IN: handle to be freed
	    )
{
    UINT32      index = handle - TRANSIENT_FIRST;
    pAssert(index < MAX_LOADED_OBJECTS);
    // Clear all the object attributes
    MemorySet((BYTE*)&(s_objects[index].attributes),
	      0, sizeof(OBJECT_ATTRIBUTES));
    return;
}
Ejemplo n.º 15
0
/* NO all the available handles has been returned */
TPMI_YES_NO
ObjectCapGetLoaded(
		   TPMI_DH_OBJECT   handle,        // IN: start handle
		   UINT32           count,         // IN: count of returned handles
		   TPML_HANDLE     *handleList     // OUT: list of handle
		   )
{
    TPMI_YES_NO          more = NO;
    UINT32               i;
    pAssert(HandleGetType(handle) == TPM_HT_TRANSIENT);
    // Initialize output handle list
    handleList->count = 0;
    // The maximum count of handles we may return is MAX_CAP_HANDLES
    if(count > MAX_CAP_HANDLES) count = MAX_CAP_HANDLES;
    // Iterate object slots to get loaded object handles
    for(i = handle - TRANSIENT_FIRST; i < MAX_LOADED_OBJECTS; i++)
	{
	    if(s_objects[i].attributes.occupied == TRUE)
		{
		    // A valid transient object can not be the copy of a persistent object
		    pAssert(s_objects[i].attributes.evict == CLEAR);
		    if(handleList->count < count)
			{
			    // If we have not filled up the return list, add this object
			    // handle to it
			    handleList->handle[handleList->count] = i + TRANSIENT_FIRST;
			    handleList->count++;
			}
		    else
			{
			    // If the return list is full but we still have loaded object
			    // available, report this and stop iterating
			    more = YES;
			    break;
			}
		}
	}
    return more;
}
Ejemplo n.º 16
0
void PStreamFile::open()
{
    pAssert(m_file == P_NULL);

    if (m_writable)
    {
        m_file = pfopen(m_filePath.c_str(), P_FILE_WRITEONLY_BINARY);
    }
    else
    {
        m_file = pfopen(m_filePath.c_str(), P_FILE_READONLY_BINARY);
    }
}
Ejemplo n.º 17
0
/* This function is used to post reserved data for writing to NV memory. Before the TPM completes
   the operation, the value will be written. */
void
NvWrite(
	UINT32           nvOffset,      // IN: location in NV to receive data
	UINT32           size,          // IN: size of the data to move
	void            *inBuffer       // IN: location containing data to write
	)
{
    // Input type should be valid
    pAssert(nvOffset + size <= NV_MEMORY_SIZE);
    _plat__NvMemoryWrite(nvOffset, size, inBuffer);
    // Set the flag that a NV write happened
    SET_NV_UPDATE(UT_NV);
    return;
}
Ejemplo n.º 18
0
Object *ObjectCreationDialog::execute(QWidget *parent, ClassCreator *cc) {
	Object *result = NULL;

	STD_GLOBAL_EXCEPTION_HANDLER_START
	ObjectCreationDialog *diag = new ObjectCreationDialog(parent);
	pAssert(cc != NULL);
	if (cc == NULL) return NULL;
	const MetaClass *edmc = cc->getInstanceClass()->getGUIDescriptor()->getDefaultClassEditor();
	pAssert(edmc != NULL);
	if (edmc == NULL) return NULL;
	ClassEditor *ed = (ClassEditor*)edmc->newInstance();
	QVBoxLayout *l = new QVBoxLayout(diag->ui.frameCreatorEditor);
	l->setMargin(0);
	l->setSpacing(0);
	l->addWidget(ed->makeEditor(diag->ui.frameCreatorEditor, cc));
	if (diag->exec() == QDialog::Accepted) {
		result = cc->makeObject();
	}
	delete ed;
	STD_GLOBAL_EXCEPTION_HANDLER_END

	return result;
}
Ejemplo n.º 19
0
/* This function is called to process a _TPM_Hash_Start() indication. */
LIB_EXPORT void
_TPM_Hash_Start(
		void
		)
{
    TPM_RC              result;
    TPMI_DH_OBJECT      handle;
    // If a DRTM sequence object exists, free it up
    if(g_DRTMHandle != TPM_RH_UNASSIGNED)
	{
	    FlushObject(g_DRTMHandle);
	    g_DRTMHandle = TPM_RH_UNASSIGNED;
	}
    // Create an event sequence object and store the handle in global
    // g_DRTMHandle. A TPM_RC_OBJECT_MEMORY error may be returned at this point
    // The NULL value for the first parameter will cause the sequence structure to
    // be allocated without being set as present. This keeps the sequence from
    // being left behind if the sequence is terminated early.
    result = ObjectCreateEventSequence(NULL, &g_DRTMHandle);
    // If a free slot was not available, then free up a slot.
    if(result != TPM_RC_SUCCESS)
	{
	    // An implementation does not need to have a fixed relationship between
	    // slot numbers and handle numbers. To handle the general case, scan for
	    // a handle that is assigned and free it for the DRTM sequence.
	    // In the reference implementation, the relationship between handles and
	    // slots is fixed. So, if the call to ObjectCreateEvenSequence()
	    // failed indicating that all slots are occupied, then the first handle we
	    // are going to check (TRANSIENT_FIRST) will be occupied. It will be freed
	    // so that it can be assigned for use as the DRTM sequence object.
	    for(handle = TRANSIENT_FIRST; handle < TRANSIENT_LAST; handle++)
		{
		    // try to flush the first object
		    if(IsObjectPresent(handle))
			break;
		}
	    // If the first call to find a slot fails but none of the slots is occupied
	    // then there's a big problem
	    pAssert(handle < TRANSIENT_LAST);
	    // Free the slot
	    FlushObject(handle);
	    // Try to create an event sequence object again.  This time, we must
	    // succeed.
	    result = ObjectCreateEventSequence(NULL, &g_DRTMHandle);
	    if(result != TPM_RC_SUCCESS)
		FAIL(FATAL_ERROR_INTERNAL);
	}
    return;
}
Ejemplo n.º 20
0
void PStreamFile::seek(pUint32 position)
{
    // we don't have seek when writing.
    if (m_writable)
    {
        return ;
    }

    pAssert(m_file != P_NULL);
    if (m_file == P_NULL)
    {
        pLogError("Unable to open file for reading");
        return ;
    }

    pfseek(m_file, position, P_FILE_SEEK_FROM_BEGINNING);
}
Ejemplo n.º 21
0
/*
void setupScene(PContext* context)
{
    PScene* scene = context->getScene();
    PLayer* layer = pNew(PLayer(scene));

    // sprint 1 mesh (stream) -> suyu, resource -> lihw
    PMesh* mesh = context->getResourceManager()->retainMesh("object.mes");
    PTexture* texture = context->getResourceManager()->retainTexture("texture.png");
    PShader* shader = context->getResourceManager()->retainShader("vert.glsl", "frag.glsl");

    // sprint 2
    PDrawable* drawable = pNew(PDrawable(layer));
    drawable->getMaterial()->setShader(shader);
    drawable->getMaterial()->addTexture(texture);
    drawable->getGeometry()->setMesh(mesh);
    
    // sprint 1 -> jihao
    layer->getCamera()->setPosition(10, 0, 0);
    layer->getCamera()->setOrientation(0, 0, 0, 0, 1, 0);
    layer->getCamera()->setProjection(P_CAMERA_PROJECTION_PERSPECTIVE);

    // sprint 3
    layer->getCulling()->setCulling(P_CULLING_DEFAULT);
    layer->getSorting()->setSorting(P_SORTING_DEFAULT); 
    
    // sprint 1 -> jihao
    layer->getRenderTarget()->setViewport(-1, -1, -1, -1);
    layer->getRenderTarget()->setStencilWritable(false);
    layer->getRenderTarget()->setFrameBuffer(P_NULL);

    // sprint 1, object hierachy -> PData/PObject -> suyu
}
*/
void pMain(int argc, char* argv[])
{
    pAssert(PActivity::s_activity != P_NULL);

    if (PActivity::s_activity != P_NULL)
    {
        PContextProperties contextProperties;
        contextProperties.m_contextName = PString("default");
        contextProperties.m_multisamples = 2;

        PContext* context = pNew(PContext(contextProperties));
        PActivity::s_activity->addContext(context);

        //setupScene(context);
    }
    else
    {
        pLogError("No running activity");
    }
}
Ejemplo n.º 22
0
bool MusicPlayer::getVolume() const
{
    pAssert(mVolume == mMusic.getVolume(), "MusicPlayer volume level mismatch");
    return mVolume;
}
card32 EmbeddedObjectClassPropertyInlineEditor::getPreferredHeight()
{
	pAssert( m_ElementEditor != NULL );
	return m_ElementEditor->height();
}
Ejemplo n.º 24
0
void LegacyClassNameTranslation::registerTranslation(string legacyClassName, const MetaClass *currentClass) {
   pAssert(translations.find(legacyClassName) == translations.end());
   pAssert(!MetaClass::isClassRegistered(legacyClassName));
   translations.insert(pair<string, const MetaClass*>(legacyClassName, currentClass));
}
Ejemplo n.º 25
0
/* c) An object handle belongs to its hierarchy. All other handles belong to the platform
   hierarchy. or an NV Index. */
TPMI_RH_HIERARCHY
EntityGetHierarchy(
		   TPMI_DH_ENTITY   handle         // IN :handle of entity
		   )
{
    TPMI_RH_HIERARCHY       hierarchy = TPM_RH_NULL;
    switch(HandleGetType(handle))
	{
	  case TPM_HT_PERMANENT:
	    // hierarchy for a permanent handle
	    switch(handle)
		{
		  case TPM_RH_PLATFORM:
		  case TPM_RH_ENDORSEMENT:
		  case TPM_RH_NULL:
		    hierarchy = handle;
		    break;
		    // all other permanent handles are associated with the owner
		    // hierarchy. (should only be TPM_RH_OWNER and TPM_RH_LOCKOUT)
		  default:
		    hierarchy = TPM_RH_OWNER;
		    break;
		}
	    break;
	  case TPM_HT_NV_INDEX:
	    // hierarchy for NV index
	      {
		  NV_INDEX        *nvIndex = NvGetIndexInfo(handle, NULL);
		  pAssert(nvIndex != NULL);
		  // If only the platform can delete the index, then it is
		  // considered to be in the platform hierarchy, otherwise it
		  // is in the owner hierarchy.
		  if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV,
				  PLATFORMCREATE))
		      hierarchy = TPM_RH_PLATFORM;
		  else
		      hierarchy = TPM_RH_OWNER;
	      }
	      break;
	  case TPM_HT_TRANSIENT:
	    // hierarchy for an object
	      {
		  OBJECT          *object;
		  object = HandleToObject(handle);
		  if(object->attributes.ppsHierarchy)
		      {
			  hierarchy = TPM_RH_PLATFORM;
		      }
		  else if(object->attributes.epsHierarchy)
		      {
			  hierarchy = TPM_RH_ENDORSEMENT;
		      }
		  else if(object->attributes.spsHierarchy)
		      {
			  hierarchy = TPM_RH_OWNER;
		      }
	      }
	      break;
	  case TPM_HT_PCR:
	    hierarchy = TPM_RH_OWNER;
	    break;
	  default:
	    FAIL(FATAL_ERROR_INTERNAL);
	    break;
	}
    // this is unreachable but it provides a return value for the default
    // case which makes the complier happy
    return hierarchy;
}
Ejemplo n.º 26
0
/* The return value is the hash algorithm for the policy. */
TPMI_ALG_HASH
EntityGetAuthPolicy(
		    TPMI_DH_ENTITY   handle,        // IN: handle of entity
		    TPM2B_DIGEST    *authPolicy     // OUT: authPolicy of the entity
		    )
{
    TPMI_ALG_HASH       hashAlg = TPM_ALG_NULL;
    authPolicy->t.size = 0;
    switch(HandleGetType(handle))
	{
	  case TPM_HT_PERMANENT:
	    switch(handle)
		{
		  case TPM_RH_OWNER:
		    // ownerPolicy for TPM_RH_OWNER
		    *authPolicy = gp.ownerPolicy;
		    hashAlg = gp.ownerAlg;
		    break;
		  case TPM_RH_ENDORSEMENT:
		    // endorsementPolicy for TPM_RH_ENDORSEMENT
		    *authPolicy = gp.endorsementPolicy;
		    hashAlg = gp.endorsementAlg;
		    break;
		  case TPM_RH_PLATFORM:
		    // platformPolicy for TPM_RH_PLATFORM
		    *authPolicy = gc.platformPolicy;
		    hashAlg = gc.platformAlg;
		    break;
		  case TPM_RH_LOCKOUT:
		    // lockoutPolicy for TPM_RH_LOCKOUT
		    *authPolicy = gp.lockoutPolicy;
		    hashAlg = gp.lockoutAlg;
		    break;
		  default:
		    return TPM_ALG_ERROR;
		    break;
		}
	    break;
	  case TPM_HT_TRANSIENT:
	    // authPolicy for an object
	      {
		  OBJECT *object = HandleToObject(handle);
		  *authPolicy = object->publicArea.authPolicy;
		  hashAlg = object->publicArea.nameAlg;
	      }
	      break;
	  case TPM_HT_NV_INDEX:
	    // authPolicy for a NV index
	      {
		  NV_INDEX        *nvIndex = NvGetIndexInfo(handle, NULL);
		  pAssert(nvIndex != 0);
		  *authPolicy = nvIndex->publicArea.authPolicy;
		  hashAlg = nvIndex->publicArea.nameAlg;
	      }
	      break;
	  case TPM_HT_PCR:
	    // authPolicy for a PCR
	    hashAlg = PCRGetAuthPolicy(handle, authPolicy);
	    break;
	  default:
	    // If any other handle type is present it is a code defect.
	    FAIL(FATAL_ERROR_INTERNAL);
	    break;
	}
    return hashAlg;
}
Ejemplo n.º 27
0
/* count number of bytes in the authValue with zeros stripped */
UINT16
EntityGetAuthValue(
		   TPMI_DH_ENTITY   handle,        // IN: handle of entity
		   TPM2B_AUTH      *auth           // OUT: authValue of the entity
		   )
{
    TPM2B_AUTH      *pAuth = NULL;
    auth->t.size = 0;
    switch(HandleGetType(handle))
	{
	  case TPM_HT_PERMANENT:
	      {
		  switch(handle)
		      {
			case TPM_RH_OWNER:
			  // ownerAuth for TPM_RH_OWNER
			  pAuth = &gp.ownerAuth;
			  break;
			case TPM_RH_ENDORSEMENT:
			  // endorsementAuth for TPM_RH_ENDORSEMENT
			  pAuth = &gp.endorsementAuth;
			  break;
			case TPM_RH_PLATFORM:
			  // platformAuth for TPM_RH_PLATFORM
			  pAuth = &gc.platformAuth;
			  break;
			case TPM_RH_LOCKOUT:
			  // lockoutAuth for TPM_RH_LOCKOUT
			  pAuth = &gp.lockoutAuth;
			  break;
			case TPM_RH_NULL:
			  // nullAuth for TPM_RH_NULL. Return 0 directly here
			  return 0;
			  break;
#ifdef  VENDOR_PERMANENT
			case VENDOR_PERMANENT:
			  // vendor authorization value
			  pAauth = &g_platformUniqueDetails;
#endif
			default:
			  // If any other permanent handle is present it is
			  // a code defect.
			  FAIL(FATAL_ERROR_INTERNAL);
			  break;
		      }
		  break;
	      }
	  case TPM_HT_TRANSIENT:
	    // authValue for an object
	    // A persistent object would have been copied into RAM
	    // and would have an transient object handle here.
	      {
		  OBJECT          *object;
		  object = HandleToObject(handle);
		  // special handling if this is a sequence object
		  if(ObjectIsSequence(object))
		      {
			  pAuth = &((HASH_OBJECT *)object)->auth;
		      }
		  else
		      {
			  // Authorization is available only when the private portion of
			  // the object is loaded.  The check should be made before
			  // this function is called
			  pAssert(object->attributes.publicOnly == CLEAR);
			  pAuth = &object->sensitive.authValue;
		      }
	      }
	      break;
	  case TPM_HT_NV_INDEX:
	    // authValue for an NV index
	      {
		  NV_INDEX        *nvIndex = NvGetIndexInfo(handle, NULL);
		  pAssert(nvIndex != NULL);
		  pAuth = &nvIndex->authValue;
	      }
	      break;
	  case TPM_HT_PCR:
	    // authValue for PCR
	    pAuth = PCRGetAuthValue(handle);
	    break;
	  default:
	    // If any other handle type is present here, then there is a defect
	    // in the unmarshaling code.
	    FAIL(FATAL_ERROR_INTERNAL);
	    break;
	}
    // Copy the authValue
    if (!pAuth)                                                    /* libtpms changed begin (ubsan) */
        MemoryCopy2B(&auth->b, NULL, sizeof(auth->t.buffer));
    else
        MemoryCopy2B(&auth->b, &pAuth->b, sizeof(auth->t.buffer)); /* libtpms changed end */
    MemoryRemoveTrailingZeros(auth);
    return auth->t.size;
}
Ejemplo n.º 28
0
int main(int argc, char* argv[])
{
    int exitCode = EXIT_SUCCESS;

    PActivity* activity = pNew(PActivity(argc, argv));
    
    // Enable memory leak checks and heap validation. 
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
    _CrtSetBreakAlloc(-1);
    
    pMain(argc, argv);

    // Set console title.
    SetConsoleTitle(L"protoss debug console");
    
    // Disable the close button of the console window.
    HWND hConsoleWindow = GetConsoleWindow();
    if (hConsoleWindow != NULL)
    {
        HMENU hMenu = GetSystemMenu(hConsoleWindow, 0);
        if (hMenu != NULL)
        {
            DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
            DrawMenuBar(hConsoleWindow);
        }
    }

    PContext* context = activity->findContext(pUint32(0));
    pAssert(context != P_NULL);
    if (context == P_NULL)
    {
        exitCode = EXIT_FAILURE;
        pDelete(activity);
        return exitCode;
    }

    PWin32Window window(context);

    if (!window.create())
    {
        exitCode = EXIT_FAILURE;
        pDelete(activity);
        return exitCode;
    }
    
    // Initialize the context. 
    // kzaPlatformSetInstanceHandle(context, GetModuleHandle(NULL));
    context->setState(P_CONTEXT_STATE_UNINITIALIZED);
    if (!context->initialize())
    {
        exitCode = EXIT_FAILURE;
    }

    if (!context->onInitialized())
    {
        context->setState(P_CONTEXT_STATE_ERROR);
    }
    else
    {
        pLogDebug("Starting program main loop");
        context->setState(P_CONTEXT_STATE_RUNNING);
    }

    if (context->getState() == P_CONTEXT_STATE_ERROR)
    {
        exitCode = EXIT_FAILURE;
    }

    // The mainloop of window.
    window.run();

    // Right before destroy the context, user might have
    // something to do.
    context->onDestroy();

    context->destroy();
    
    // Destroy native window.
    window.destroy();

    // Destroy the activity
    pDelete(activity);

    // If debugger is present, a pause is required to keep the console output
    // visible. Otherwise the pause is automatic. 
    if (IsDebuggerPresent())
    {
        system("pause");
    }

    return exitCode;
}
void EmbeddedObjectClassPropertyInlineEditor::update()
{
	pAssert( m_ElementEditor != NULL );
	m_ElementEditor->sltUpdate();
}