void FunctionParameterInfo()
{
	STACKFRAME     callStack;
	BOOL           bResult = FALSE;
	CONTEXT        context;
	TCHAR          lpszFnInfo[BUFFERSIZE];
	HANDLE         hProcess = GetCurrentProcess();
	HANDLE         hThread = GetCurrentThread();

	::ZeroMemory( &context, sizeof(context) );
	context.ContextFlags = CONTEXT_FULL;

	if ( !GetThreadContext( hThread, &context ) )
	{
	   OutputDebugStringFormat( _T("Function info(thread=0x%X) failed.\n") );
		return;
	}
	
	::ZeroMemory( &callStack, sizeof(callStack) );
	callStack.AddrPC.Offset    = context.Eip;
	callStack.AddrStack.Offset = context.Esp;
	callStack.AddrFrame.Offset = context.Ebp;
	callStack.AddrPC.Mode      = AddrModeFlat;
	callStack.AddrStack.Mode   = AddrModeFlat;
	callStack.AddrFrame.Mode   = AddrModeFlat;

	for( ULONG index = 0; index < 2; index++ ) 
	{
		bResult = StackWalk(
			IMAGE_FILE_MACHINE_I386,
			hProcess,
			hThread,
			&callStack,
			NULL, 
			NULL,
			SymFunctionTableAccess,
			SymGetModuleBase,
			NULL);
	}

	if ( bResult && callStack.AddrFrame.Offset != 0) 
	{
	   GetFunctionInfoFromAddresses( callStack.AddrPC.Offset, callStack.AddrFrame.Offset, lpszFnInfo );
	   OutputDebugStringFormat( _T("Function info(thread=0x%X) : %s\n"), GetCurrentThreadId(), lpszFnInfo );
	}
	else
	   OutputDebugStringFormat( _T("Function info(thread=0x%X) failed.\n") );
}
예제 #2
0
bool Shader::CreateFromMemory( LPCVOID buffer,size_t size )
{
	Graphics* graphics = Graphics::GetInstance();

	if( m_pEffect )
	{
		m_pEffect.Release();
		graphics->DelResource( this );
	}

	LPD3DXBUFFER pBuffer = NULL;

	HRESULT hr = D3DXCreateEffect(
		graphics->GetDirect3DDevice(),
		buffer,
		size,
		NULL,NULL,0,NULL,&m_pEffect,&pBuffer );

	if( pBuffer )
	{
		tstring error = to_tstring( (char*)pBuffer->GetBufferPointer() );
		OutputDebugStringFormat( _T("effect compiled\n%s"),error.c_str() );

		pBuffer->Release();
	}

	if( hr!=D3D_OK )
	{
		return false;
	}

	graphics->AddResource( this );

	return true;
}
예제 #3
0
bool Shader::CreateFromFile( const tstring& filePath )
{
	if( m_pEffect )
	{
		m_pEffect.Release();
		Graphics::GetInstance()->DelResource( this );
	}

	LPD3DXBUFFER pBuffer = NULL;

	HRESULT hr = D3DXCreateEffectFromFile( 
		Graphics::GetInstance()->GetDirect3DDevice(),
		filePath.c_str(),
		NULL,NULL,0,NULL,&m_pEffect,&pBuffer );

	if( pBuffer )
	{
		tstring error = to_tstring( (char*)pBuffer->GetBufferPointer() );
		OutputDebugStringFormat( _T("effect compiled\n%s"),error.c_str() );

		pBuffer->Release();
	}

	if( hr!=D3D_OK )
	{
		return false;
	}

	Graphics::GetInstance()->AddResource( this );

	return true;
}
// TRACE message with source link. 
// The format is: sourcefile(linenumber) : message
void SrcLinkTrace( LPCTSTR lpszMessage, LPCTSTR lpszFileName, ULONG nLineNumber )
{
	OutputDebugStringFormat( 
			_T("%s(%d) : %s"), 
			lpszFileName, 
			nLineNumber, 
			lpszMessage );
}
예제 #5
0
void Shader::OnLostDevice()
{
	OutputDebugStringFormat( _T("Shader(%p)::OnLostDevice\n"),this );

	if( m_pEffect )
	{
		m_pEffect->OnLostDevice();
	}
}
예제 #6
0
inline static void _win32_shutdownHeap( void )
{
    // Make sure the DebugHeap manager is not damaged.
    LIST_VALIDATE( g_privateMemory.root );
    
#ifdef PAGE_HEAP_MEMORY_STATS
    // Memory debugging statistics.
    unsigned int blockCount = 0;
    unsigned int pageCount = 0;
    size_t memLeaked = 0;
#endif //PAGE_HEAP_MEMORY_STATS

    // Check all blocks in order and free them
    while ( !LIST_EMPTY( g_privateMemory.root ) )
    {
        _memIntro *item = LIST_GETITEM( _memIntro, g_privateMemory.root.next, memList );
    
#ifdef PAGE_HEAP_MEMORY_STATS
        // Keep track of stats.
        blockCount++;
        pageCount += MEM_PAGE_MOD( item->objSize + sizeof(_memIntro) + sizeof(_memOutro) );
        memLeaked += item->objSize;
#endif //PAGE_HEAP_MEMORY_STATS

        _win32_freeMem( item + 1 );
    }

#ifdef PAGE_HEAP_MEMORY_STATS
    if ( blockCount != 0 )
    {
        OutputDebugString( "Heap Memory Leak Protocol:\n" );
        OutputDebugStringFormat(
            "* leaked memory: %u\n" \
            "* blocks/pages allocated: %u/%u [%u]\n",
            memLeaked,
            blockCount, pageCount, blockCount * g_systemInfo.dwPageSize
        );
    }
    else
        OutputDebugString( "No memory leaks detected." );
#endif //PAGE_HEAP_MEMORY_STATS
}
void StackTrace( HANDLE hThread, LPCTSTR lpszMessage )
{
	STACKFRAME     callStack;
	BOOL           bResult;
	CONTEXT        context;
	TCHAR          symInfo[BUFFERSIZE] = _T("?");
	TCHAR          srcInfo[BUFFERSIZE] = _T("?");
	HANDLE         hProcess = GetCurrentProcess();

   // If it's not this thread, let's suspend it, and resume it at the end
	if ( hThread != GetCurrentThread() )
		if ( SuspendThread( hThread ) == -1 )
		{
		   // whaaat ?!
		   OutputDebugStringFormat( _T("Call stack info(thread=0x%X) failed.\n") );
			return;
		}

	::ZeroMemory( &context, sizeof(context) );
	context.ContextFlags = CONTEXT_FULL;

	if ( !GetThreadContext( hThread, &context ) )
	{
      OutputDebugStringFormat( _T("Call stack info(thread=0x%X) failed.\n") );
	   return;
	}
	
	::ZeroMemory( &callStack, sizeof(callStack) );
	callStack.AddrPC.Offset    = context.Eip;
	callStack.AddrStack.Offset = context.Esp;
	callStack.AddrFrame.Offset = context.Ebp;
	callStack.AddrPC.Mode      = AddrModeFlat;
	callStack.AddrStack.Mode   = AddrModeFlat;
	callStack.AddrFrame.Mode   = AddrModeFlat;

	for( ULONG index = 0; ; index++ ) 
	{
		bResult = StackWalk(
			IMAGE_FILE_MACHINE_I386,
			hProcess,
			hThread,
	      &callStack,
			NULL, 
			NULL,
			SymFunctionTableAccess,
			SymGetModuleBase,
			NULL);

		if ( index == 0 )
		   continue;

		if( !bResult || callStack.AddrFrame.Offset == 0 ) 
			break;
	
		GetFunctionInfoFromAddresses( callStack.AddrPC.Offset, callStack.AddrFrame.Offset, symInfo );
		GetSourceInfoFromAddress( callStack.AddrPC.Offset, srcInfo );

		OutputDebugStringFormat( _T("     %s : %s\n"), srcInfo, symInfo );
	}

	if ( hThread != GetCurrentThread() )
		ResumeThread( hThread );
}