PBYTE Crypt::ExportPublicKey( __out DWORD* dataLen )
{
	// Public key value, (G^X) mod P is calculated.


	// Get the size for the key BLOB.
	BOOL fReturn = CryptExportKey(
		m_PrivateKey,
		NULL,
		PUBLICKEYBLOB,
		0,
		NULL,
		dataLen );
	if ( !fReturn )
		ReleaseResources();

	// Allocate the memory for the key BLOB.
	if ( !( m_KeyBlob = (PBYTE)malloc( *dataLen ) ) )
		ReleaseResources();

	// Get the key BLOB.
	fReturn = CryptExportKey(
		m_PrivateKey,
		0,
		PUBLICKEYBLOB,
		0,
		m_KeyBlob,
		dataLen );
	if ( !fReturn )
		ReleaseResources();

	return m_KeyBlob;
}
bool Crypt::GeneratePrivateKey()
{
	// Acquire a provider handle for party 1.
	BOOL fReturn = CryptAcquireContext( &m_ProvParty, NULL, MS_ENH_DSS_DH_PROV, PROV_DSS_DH, CRYPT_VERIFYCONTEXT );
	if ( !fReturn )
	{
		ReleaseResources();
		return false;
	}

	// Create an ephemeral private key for party 1.
	// 임시 비밀 키 생성 
	fReturn = CryptGenKey( m_ProvParty, CALG_DH_EPHEM, DHKEYSIZE << 16 | CRYPT_EXPORTABLE | CRYPT_PREGEN, &m_PrivateKey );
	if ( !fReturn )
	{
		ReleaseResources();
		return false;
	}

	// Set the prime for party 1's private key.
	// P값 설정 
	fReturn = CryptSetKeyParam( m_PrivateKey, KP_P, (PBYTE)&m_P, 0 );
	if ( !fReturn )
	{
		ReleaseResources();
		return false;
	}

	// Set the generator for party 1's private key.
	// 비밀 키 생성기 장착
	fReturn = CryptSetKeyParam( m_PrivateKey, KP_G, (PBYTE)&m_G, 0 );
	if ( !fReturn )
	{
		ReleaseResources();
		return false;
	}

	// Generate the secret values for party 1's private key.
	// 비밀 키 생성 
	fReturn = CryptSetKeyParam( m_PrivateKey, KP_X, NULL, 0 );
	if ( !fReturn )
	{
		ReleaseResources();
		return false;
	}

	return true;
}
Example #3
0
bool
DeprecatedTextureClientShmem::EnsureAllocated(gfx::IntSize aSize,
                                    gfxContentType aContentType)
{
  if (aSize != mSize ||
      aContentType != mContentType ||
      !IsSurfaceDescriptorValid(mDescriptor)) {
    ReleaseResources();

    mContentType = aContentType;
    mSize = aSize;

    if (!mForwarder->AllocSurfaceDescriptor(gfxIntSize(mSize.width, mSize.height),
                                            mContentType, &mDescriptor)) {
      NS_WARNING("creating SurfaceDescriptor failed!");
    }
    if (mContentType == GFX_CONTENT_COLOR_ALPHA) {
      gfxASurface* surface = GetSurface();
      if (!surface) {
        return false;
      }
      nsRefPtr<gfxContext> context = new gfxContext(surface);
      context->SetColor(gfxRGBA(0, 0, 0, 0));
      context->SetOperator(gfxContext::OPERATOR_SOURCE);
      context->Paint();
    }
  }
  return true;
}
RefPtr<ShutdownPromise>
MediaDecoderReader::Shutdown()
{
  MOZ_ASSERT(OnTaskQueue());
  mShutdown = true;

  mBaseAudioPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
  mBaseVideoPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);

  mDataArrivedListener.DisconnectIfExists();

  ReleaseResources();
  mDuration.DisconnectIfConnected();
  mBuffered.DisconnectAll();
  mIsSuspended.DisconnectAll();

  // Shut down the watch manager before shutting down our task queue.
  mWatchManager.Shutdown();

  mDecoder = nullptr;

  ReaderQueue::Instance().Remove(this);

  return mTaskQueue->BeginShutdown();
}
Example #5
0
void ApplicationContext::DestroyContext() {
	ReleaseResources();
	Trace("Destroying application context: " + _desc._name);
	SaveConfiguration();
	// services
	_pImpl.DestroyServices();
}
/**
 * Stops the current wave instance and detaches it from the source.	
 */
void FSLESSoundSource::Stop( void )
{
	if( WaveInstance )
	{
		
		// set the player's state to stopped
		SLresult result = (*SL_PlayerPlayInterface)->SetPlayState(SL_PlayerPlayInterface, SL_PLAYSTATE_STOPPED);
		check(SL_RESULT_SUCCESS == result);
		
		// Unregister looping callback
		if( WaveInstance->LoopingMode != LOOP_Never ) 
		{
			result = (*SL_PlayerBufferQueue)->RegisterCallback(SL_PlayerBufferQueue, NULL, NULL);
		}
		
		DestroyPlayer();
		ReleaseResources();
		
		Paused = false;
		Playing = false;
		Buffer = NULL;
	}
	
	FSoundSource::Stop();
}
/**
 * Clean up any hardware referenced by the sound source
 */
FSLESSoundSource::~FSLESSoundSource( void )
{

	DestroyPlayer();

	ReleaseResources();
}
D2DPrintJobChecker::~D2DPrintJobChecker()
{
    ReleaseResources();

    // Release resources used by the critical section object.
    DeleteCriticalSection(&m_criticalSection);
}
Example #9
0
bool Shader::Reload(ID3D11Device* device)
{
	Shader copy(this->mDescriptor);
	copy.mID = this->mID;
	ReleaseResources();
	this->mID = copy.mID;
	return CompileShaders(device, copy.mDescriptor);
}
Example #10
0
/*
    Module exit point
    Release all resource acquired during module init
*/ 
void probe_processes_exit(void)
{
    trace(DETAIL_LEVEL, "Entering cleanup_module()\n");

    ReleaseResources(true, true);

    trace(INFO_LEVEL, "Exiting cleanup_module()\n");
}
Example #11
0
/**
 * Terminates the program with a certain code
 */
void TerminateRippl(int iExitCode)
{
    // Release Resources
    ReleaseResources();

    // Terminate Main Thread
    TerminateProcess(GetCurrentProcess(), iExitCode);
}
HRESULT CWASAPIRenderFilter::Cleanup()
{
  HRESULT hr = CQueuedAudioSink::Cleanup();

  CAutoLock lock(&m_csResources);
  ReleaseResources();

  return hr;
}
Example #13
0
/*
    Module entry point 
    Acquire resources and initialize global variables.
    Resources allocated are:
    1. Allocate circular log buffer
    2. Install hooks on
    2.1 On entry call of free_task
    2.2 On exit call of do_fork
    3. Create a proc file 
*/ 
int probe_processes_init(void)
{
    int iRet              = 0;
    int ijprobe_free_task = -1;
    int iret_do_fork      = -1;
    int iproc_file        = -1;
    trace(DETAIL_LEVEL, "Entering, init_module(); iMaxLineSize=%d, iMaxNbOfLines=%d, iDebugLevel=%d\n", 
        iMaxLineSize, iMaxNbOfLines, iDebugLevel);

    atomic_set(&s_wrOff, 0);
    atomic_set(&s_cnt, 0);

    do {
        // Create circular log buffer
        s_pLog = (char*)kmalloc(iMaxLineSize * iMaxNbOfLines, GFP_KERNEL);
        if(s_pLog == NULL) {
            iRet = -ENOMEM;
            break;
        }
        memset(s_pLog, 0, iMaxLineSize * iMaxNbOfLines);

        // Register hook on the entry of free_task kernel method
        if ((ijprobe_free_task = register_jprobe(&jprobe_free_task)) < 0) {
            trace(ERROR_LEVEL, "register_jprobe(%s) failed, returned %d\n", 
                jprobe_free_task.kp.symbol_name, ijprobe_free_task);
            iRet = ijprobe_free_task;
            break;
        }
        trace(DETAIL_LEVEL, "On call of %s at %p, handler addr %p\n", 
            jprobe_free_task.kp.symbol_name, jprobe_free_task.kp.addr, jprobe_free_task.entry);

        // Register hook on the exit of do_fork kernel method
        if ((iret_do_fork = register_kretprobe(&kret_do_fork)) < 0) {
            trace(ERROR_LEVEL, "register_kretprobe(%s) failed, returned %d\n", 
                kret_do_fork.kp.symbol_name, iret_do_fork);
            iRet = iret_do_fork;
            break;
        }
        trace(DETAIL_LEVEL, "On return of %s at %p, handler addr %p\n", 
            kret_do_fork.kp.symbol_name, kret_do_fork.kp.addr, kret_do_fork.handler);

        // Create a /proc/taskinfo file
        if((iproc_file = CreateProcFile()) < 0) {
            iRet = iproc_file;
            break;
        }
    } while(false);

    // Run clean up code if we fail to acquire any resources.
    if(iRet < 0) {
        ReleaseResources(ijprobe_free_task==0?true:false, iret_do_fork==0?true:false);
    }

    trace(INFO_LEVEL, "Exiting, %d = init_module();\n", iRet);
    return iRet;
}
	virtual void ReleaseResources() override
	{
		if (RHITexture.IsValid())
		{
			auto D3D11TS = static_cast<FD3D11Texture2DSet*>(RHITexture->GetTexture2D());
			FOvrSessionShared::AutoSession OvrSession(Session);
			D3D11TS->ReleaseResources(OvrSession);
			RHITexture = nullptr;
		}
	}
	// Basic destructor. Checks to see if the render variables have been released.
	// If not then they will be released and cleaned up here.
	CRender::~CRender()
	{
		ReleaseResources();

		if( m_pAmbientColour )
			delete m_pAmbientColour;

		if( m_pSpecularColour )
			delete m_pSpecularColour;
	}
FSplineMeshSceneProxy::~FSplineMeshSceneProxy()
{
    ReleaseResources();

    for (FSplineMeshSceneProxy::FLODResources& LODResource : LODResources)
    {
        delete LODResource.VertexFactory;
    }
    LODResources.Empty();
}
Example #17
0
Shader::~Shader(void)
{
#if _DEBUG 
	//Log::Info("Shader dtor: %s", m_name.c_str());
#endif

	// todo: this really could use smart pointers...

	// release constants
	ReleaseResources();
}
Example #18
0
void GaussianMain::OnD3D11DestroyDevice()
{
	ReleaseResources();

	SAFE_RELEASE(g_pFX_Render);
	SAFE_RELEASE(g_pSRV_Background);
	SAFE_RELEASE(g_pScreenQuadVB);
	SAFE_RELEASE(g_pQuadLayout);
	SAFE_RELEASE(g_pRTV_Default);
	SAFE_RELEASE(g_pDSV_Default);
}
Example #19
0
void
ImportLoader::Done()
{
  mReady = true;
  uint32_t l = mLinks.Length();
  for (uint32_t i = 0; i < l; i++) {
    DispatchLoadEvent(mLinks[i]);
  }
  UnblockScripts();
  ReleaseResources();
}
Example #20
0
void Pyx::Graphics::Gui::ImGuiImpl::Shutdown()
{
    if (m_isInitialized)
    {

        if (m_isResourcesCreated)
            ReleaseResources();

        m_isInitialized = false;
    }
}
void RenderAPI_D3D12::ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces)
{
	switch (type)
	{
	case kUnityGfxDeviceEventInitialize:
		s_D3D12 = interfaces->Get<IUnityGraphicsD3D12v2>();
		CreateResources();
		break;
	case kUnityGfxDeviceEventShutdown:
		ReleaseResources();
		break;
	}
}
Example #22
0
void
ImportLoader::Error(bool aUnblockScripts)
{
  mDocument = nullptr;
  mStopped = true;
  uint32_t l = mLinks.Length();
  for (uint32_t i = 0; i < l; i++) {
    DispatchErrorEvent(mLinks[i]);
  }
  if (aUnblockScripts) {
    UnblockScripts();
  }
  ReleaseResources();
}
Example #23
0
// This sample processes audio buffers during the render cycle of the application.
// As long as the sample maintains a high-enough frame rate, this approach should
// not glitch audio. In game code, it is best for audio buffers to be processed
// on a separate thread that is not synced to the main render loop of the game.
void Audio::Render()
{
    if (m_engineExperiencedCriticalError)
    {
        ReleaseResources();
        Initialize();
        CreateResources();
        Start();
        if (m_engineExperiencedCriticalError)
        {
            return;
        }
    }
}
Example #24
0
/**
 * WinMain Function
 *	Main Windows program entry point
 */
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	// Initialize Resources
	InitResources(hInstance);


	// Main Loop
	while(true){Sleep(5000);}
	
	// Release Resources
	ReleaseResources();

	// Return Success
	return 0;
}
// destructor
//--------------------------------------------------------------------------------
CPUTGuiControllerOGL::~CPUTGuiControllerOGL()
{
    // delete all the controls under you
    ReleaseResources();
    DeleteAllControls();
    SAFE_RELEASE(mpTextMaterial);
    SAFE_RELEASE(mpControlMaterial);
    // FPS counter

    // delete arrays
    SAFE_DELETE_ARRAY(mpTextMirrorBuffer);
    SAFE_DELETE_ARRAY(mpMirrorBuffer);
    SAFE_DELETE_ARRAY(mpFocusedControlMirrorBuffer);
    SAFE_DELETE_ARRAY(mpFocusedControlTextMirrorBuffer);
}
void
TextureClientShmem::SetDescriptor(const SurfaceDescriptor& aDescriptor)
{
  if (IsSurfaceDescriptorValid(aDescriptor)) {
    ReleaseResources();
    mDescriptor = aDescriptor;
  } else {
    EnsureAllocated(mSize, mContentType);
  }

  mSurface = nullptr;

  NS_ASSERTION(mDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc ||
               mDescriptor.type() == SurfaceDescriptor::TShmem ||
               mDescriptor.type() == SurfaceDescriptor::TRGBImage,
               "Invalid surface descriptor");
}
long Burger::DisplayDirectX9Software8::ResetLostDevice(void)
{
	ReleaseResources();
	D3DPRESENT_PARAMETERS Parms;
	m_D3D9Settings.GetPresentParameters(&Parms);
	HRESULT hResult = m_pDirect3DDevice9->Reset(&Parms);
	if (hResult<0) {
		if (hResult!=D3DERR_DEVICELOST) {
			--m_uResetAttempts;
		} else {
			m_uResetAttempts = DIRECTXRESETATTEMPTS;
		}
	} else {
		hResult = AllocateResources();
	}
	return hResult;
}
// destructor
//--------------------------------------------------------------------------------
CPUTGuiControllerDX11::~CPUTGuiControllerDX11()
{
    // delete all the controls under you
	ReleaseResources();
    DeleteAllControls();

    // FPS counter
    SAFE_DELETE(mpFPSCounter);
    SAFE_DELETE(mpFPSTimer);

    // delete arrays
    SAFE_DELETE_ARRAY(mpTextMirrorBuffer);
    SAFE_DELETE_ARRAY(mpMirrorBuffer);
    SAFE_DELETE_ARRAY(mpFocusedControlMirrorBuffer);
    SAFE_DELETE_ARRAY(mpFocusedControlTextMirrorBuffer);
    SAFE_DELETE_ARRAY(mpFPSMirrorBuffer);
}
void
TextureClientShmem::EnsureAllocated(gfx::IntSize aSize,
                                    gfxASurface::gfxContentType aContentType)
{
  if (aSize != mSize ||
      aContentType != mContentType ||
      !IsSurfaceDescriptorValid(mDescriptor)) {
    ReleaseResources();

    mContentType = aContentType;
    mSize = aSize;

    if (!mForwarder->AllocSurfaceDescriptor(gfxIntSize(mSize.width, mSize.height),
                                            mContentType, &mDescriptor)) {
      NS_WARNING("creating SurfaceDescriptor failed!");
    }
  }
}
Example #30
0
// -------------------------------------------------------------------
// ExecuteDisconnection
// -------------------------------------------------------------------
void BitSwarmClient::ExecuteDisconnection() 
{
	boost::shared_ptr<map<string, boost::shared_ptr<void> > > args (new map<string, boost::shared_ptr<void> >());
	args->insert(pair<string, boost::shared_ptr<void> >("reason", (boost::static_pointer_cast<void>)(ClientDisconnectionReason::UNKNOWN)));

	boost::shared_ptr<BitSwarmEvent> evt (new BitSwarmEvent(BitSwarmEvent::DISCONNECT, args));
	sfs->DispatchEvent(evt);

	/*
	 * --==|| Clear resources ||==--
	 * 
	 * Without this all thread will remain active even if the API are done with the Session
	 * 
	 * @since 1.0.8
	 * @by Lapo
	 */
	ReleaseResources ();
}