Example #1
0
VOID Image(IMG img, VOID * v)
{
    for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec))
    {
        for (RTN rtn = SEC_RtnHead(sec); RTN_Valid(rtn); rtn = RTN_Next(rtn))
        {
            RTN_Open(rtn);
            
            for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins))
            {
                if( INS_IsPredicated(ins) )
                    GlobalStatsStatic.predicated[ INS_Category(ins) ]++;
                else
                    GlobalStatsStatic.unpredicated[ INS_Category(ins) ]++;
            }

            RTN_Close(rtn);
        }
    }

    if( KnobProfileStaticOnly.Value() )
    {
        Fini(0,0);
        exit(0);
    }
}
Example #2
0
//--------------------------------------------------------------------------------------------------
//啟動
bool GameManager::Run()
{
	//系統初始
	if ( !m_Hge->System_Initiate() )
		return false;

	GLog::Print("GameDemo Really Start!!!!!!");

	//參數初始(Resource得在System_Initiate之後才讀的到東西)
	m_LoginStage.SetHGE(m_Hge);
	m_GameStage.SetHGE(m_Hge);
	m_StageMgr = StageManager::GetInstance();
	m_StageMgr->SetStageNum(GS_MAX);
	m_StageMgr->Add(GS_LOGIN,&m_LoginStage);
	m_StageMgr->Add(GS_GAME,&m_GameStage);
	m_StageMgr->ChangeStage(GS_LOGIN);


	//系統主迴圈(理論上會卡在這裡面跑迴圈)
	m_Hge->System_Start();

	m_StageMgr->Fini();
	Fini();
	return true;
}
Example #3
0
	MScheduler::~MScheduler()
	{
		Fini();

#if !AX_HAS_THREADLOCAL && defined( _WIN32 )
		TlsFree( m_dwWorkerIdTLS );
#endif
	}
Example #4
0
int PASCAL WinMain( HINSTANCE thishandle, HINSTANCE prevhandle, LPSTR cmdline, int cmdshow )
{
    if( !Init32BitTask( thishandle, prevhandle, cmdline, cmdshow ) )
        return( 0 );

    InvokeWin32();
    Fini( 0 );
    return( (int)ReturnCode );

} /* WinMain */
Example #5
0
void AxPluginRegistry::RemoveFactory( const CLSID& clsid )
{
	std::vector<AxPluginFctryPrtcl*>::iterator iter;

	iter = Find( clsid );
	assert( iter != _factoryV.end() );

	delete *iter;
	_factoryV.erase( iter );

	// Self destruct if empty.
	// This ensures memory used by this (singleton) object will
	// be released when the last item is removed from the registry.
	if ( _factoryV.empty() ) {
		Fini();
	}
}
Example #6
0
void classTable::setOpen( bool bOpen )
{
    QListViewItem::setOpen( bOpen );
    listView()->setSelected( listView()->selectedItem(), false );
    if ( bOpen )
    {
		LoadColumns();
		pPrimaryKeys	= new classPrimaryKeys( this, pCanvas, hDbc, (char *)qsName.data() );
		pIndexs 		= new classIndexs( this, pCanvas, hDbc, (char *)qsName.data() );
		pSpecialColumns = new classSpecialColumns( this, pCanvas, hDbc, (char *)qsName.data() );
//        listView()->setSelected( listView()->selectedItem(), false );
//        setSelected( true );
    }
    else
    {
        Fini();
    }
}
Example #7
0
VOID use_xed(ADDRINT pc) {
#if defined(TARGET_IA32E)
    static const xed_state_t dstate = {XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b};
#else
    static const xed_state_t dstate = { XED_MACHINE_MODE_LEGACY_32, XED_ADDRESS_WIDTH_32b};
#endif
    xed_decoded_inst_t xedd;
    xed_decoded_inst_zero_set_mode(&xedd,&dstate);
    UINT64 ticks_start, ticks_stop, delta;
    //FIXME: pass in the proper length...
    const unsigned int max_inst_len = 15;
    ticks_start = get_time();
#define USE_DECODE_CACHE
#if defined(USE_DECODE_CACHE)
    xed_error_enum_t xed_code = xed_decode_cache(&xedd, reinterpret_cast<UINT8*>(pc), max_inst_len, &cache);
#else
    xed_error_enum_t xed_code = xed_decode(&xedd, reinterpret_cast<UINT8*>(pc), max_inst_len);
#endif
    ticks_stop = get_time();
    delta = ticks_stop - ticks_start;
    //cerr << ticks_start << " " << ticks_stop << " " << delta << endl;
    UINT64 bin = delta/50;
    if ((INT64)delta < 0)
        rejects++;
    else if (bin >= MAX_BINS)
        histo[MAX_BINS-1] += 1;
    else
        histo[bin] += 1;
    BOOL xed_ok = (xed_code == XED_ERROR_NONE);
    i++;
    if (i>(1024*1024) && xed_ok) {
        i=0;
        j++;
        *out << j*1024*1024  << endl;
        Fini(0,0);
        *out << hex << std::setw(8) << pc << " " << dec;
        char buf[2048];
        xed_decoded_inst_dump_intel_format(&xedd, buf, 2048, 0);
        *out << buf << endl;
    }

}
Example #8
0
void classTable::setOpen( bool bOpen )
{
  if ( bOpen ) // Always refresh
  {
    LoadColumns();
    pSpecialColumns = new classSpecialColumns( this, NULL,            pCanvas, hDbc, qsTable, qsLibrary );
    pPrimaryKeys    = new classPrimaryKeys(    this, pSpecialColumns, pCanvas, hDbc, qsTable, qsLibrary );
    pIndexs         = new classIndexs(         this, pPrimaryKeys,    pCanvas, hDbc, qsTable, qsLibrary );
    selectionChanged( this ) ;
  }
  else
  {
    Fini();
  }

#ifdef QT_V4LAYOUT
  Q3ListViewItem::setOpen( bOpen );
#else
  QListViewItem::setOpen( bOpen );
#endif
}
Example #9
0
/*
 * Init32BitTask - load and initialize the 32-bit application
 */
int Init32BitTask( HINSTANCE thishandle, HINSTANCE prevhandle, LPSTR cmdline,
                    int cmdshow )
{
    WORD                i,amount,bytes_read,j;
    WORD                sel;
    int                 handle;
    tiny_ret_t          rc;
    DWORD               size,currsize,curroff,minmem,maxmem;
    DWORD               relsize,exelen;
    struct wstart_vars  __far *dataptr;
    void                __far *aliasptr;
    DWORD               __far *relptr;
    struct fpu_area     __far *fpuptr;
    rex_exe             exe;
    exe_data            exedat;
    char                file[128];
    DWORD               flags;
    version_info        vi;
    DWORD               file_header_size;
    BOOL                tried_global_compact;
    DWORD               save_maxmem;
    DWORD               adata[2];

    flags = GetWinFlags();
    /*
     * verify that we are running on a 32-bit DPMI
     */
    _fDPMIGetVersion( &vi );
    if( !(vi.flags & VERSION_80386) ) {
        MessageBox( NULL, "Not running on a 386 DPMI implementation",MsgTitle,
                        MB_OK | MB_ICONHAND | MB_TASKMODAL );
        return( FALSE );
    }

    /*
     * get exe to load
     */
    GetModuleFileName( thishandle, file, 128 );
    rc = _fTinyOpen( file, TIO_READ );
    if( TINY_ERROR( rc ) ) {
        return( Fini( 2, (char _FAR *)"Error opening file",
                    (char _FAR *)file) );
    }
    handle = TINY_INFO( rc );

    _TinySeek( handle, 0x38, TIO_SEEK_START );
    _fTinyRead( handle, &exelen, sizeof( DWORD ) );
    _TinySeek( handle, exelen, TIO_SEEK_START );

    /*
     * check if we are being run by the debugger.  When the debugger
     * sees the 'DEADBEEF' bytes at the start of the code segment
     * (see begin.asm), it swaps them to be BEEFDEAD.  The debugger
     * then tells us to go, and if we see that we have BEEFDEAD,
     * we execute a breakpoint just before we call our 32-bit code.
     * Then the debugger traces a single instruction and it looks to
     * the user like the start of his/her code is the start of
     * the application.
     */
    if( deadbeef == 0xBEEFDEAD ) {
        InDebugger = 0;
    } else {
        InDebugger = 1;
    }
    DPL = (CS() & 0x03) << 5;   /* our privilege level */

    /*
     * validate header signature
     */
    _fTinyRead( handle, &exe, sizeof( rex_exe ) );
//    BreakPoint();
    if( !(exe.sig[0] == 'M' && exe.sig[1] == 'Q') ) {
        return( Fini( 1,(char _FAR *)"Invalid EXE" ) );
    }
    file_header_size = (DWORD) exe.file_header * 16L;
    /*
     * exe.one is supposed to always contain a 1 for a .REX file.
     * However, to allow relocation tables bigger than 64K, the
     * we extended the linker to have the .one field contain the
     * number of full 64K chunks of relocations, minus 1.
     */
    file_header_size += (exe.one-1)*0x10000L*16L;

    /*
     * get exe data - data start and stack start
     */
    _TinySeek( handle, exelen + file_header_size + (long)exe.initial_eip, TIO_SEEK_START );
    _fTinyRead( handle, &exedat, sizeof( exe_data ) );
    /*
     * get file size
     */
    size = (long) exe.file_size2 * 512L;
    if( exe.file_size1 > 0 ) {
        size += (long) exe.file_size1 - 512L;
    }

    /*
     * get stack size
     */
    StackSize = Align4K( exe.initial_esp - ((exedat.stackstart+15) & ~15ul) );
    if( StackSize < 0x1000 ) {
        StackSize = 0x1000;
    }

    /*
     * get minimum/maximum amounts of heap, then add in exe size
     * to get total area
     */
//    BreakPoint();
    minmem = (DWORD) exe.min_data *(DWORD) 4096L;
    if( exe.max_data == (WORD)-1 ) {
        maxmem = 4096L;
    } else {
        maxmem = (DWORD) exe.max_data*4096L;
    }
    minmem = Align4K( minmem + size + 0x10000ul );
    maxmem = Align4K( maxmem + size + 0x10000ul );
    if( minmem > maxmem ) {
        maxmem = minmem;
    }

    /*
     * get memory to load file
     */
    tried_global_compact = FALSE;
    save_maxmem = maxmem;
    for(;;) {
        i = DPMIGet32( adata, maxmem );
        if( i != 5 )  break;
        if( maxmem == minmem ) {
            if( tried_global_compact ) {
                return( Fini( 3,
                  (char _FAR *)"Not enough memory for application\n(minimum ",
                  dwordToStr( minmem ),(char _FAR *)" required)" ));
            }
            /*
             * GlobalCompact(-1) causes Windows to unfragment its
             * memory.  This might give us a chance to get a linear
             * chunk big enough
             */
            GlobalCompact( GlobalCompact( 0 ) );
            maxmem = save_maxmem;
            tried_global_compact = TRUE;
        } else if( maxmem < 64L * 1024L ) {
            maxmem = minmem;
        } else {
            maxmem -= 64L * 1024L;
            if( maxmem < minmem ) {                     /* 09-aug-93 */
                maxmem = minmem;
            }
        }
    }
    DataHandle = adata[1];
    BaseAddr   = adata[0] + 0x10000ul;
#if FLAT
    i = InitFlatAddrSpace( BaseAddr, 0L );
#else
    i = InitFlatAddrSpace( BaseAddr, maxmem );
#endif
    BaseAddr = 0L;
    if( i ) {
        DPMIFreeMemoryBlock( DataHandle );
        return( Fini( 2,(char _FAR *)"Allocation error ", dwordToStr( i ) ) );
    }
    SaveSP = BaseAddr + StackSize;
    CodeLoadAddr = SaveSP;
    MyDataSelector = DataSelector;
    GetDataSelectorInfo();
    CodeEntry.off = exe.initial_eip + CodeLoadAddr + sizeof( exe_data );

    /*
     * this builds a collection of LDT selectors that are ready for
     * allocation
     */
    if( InitSelectorCache() != 0 ) {
        return( Fini( 1,(char _FAR *)outOfSelectors) );
    }

    /*
     * read the exe into memory
     */
    currsize = size - file_header_size;
    _TinySeek( handle, exelen + file_header_size, TIO_SEEK_START );
    i = DPMIGetAliases( CodeLoadAddr, (LPDWORD) &aliasptr, 0 );
    if( i ) {
        return( Fini( 3,(char _FAR *)"Error ",
                dwordToStr( i ),
                (char _FAR *)" getting alias for read" ) );
    }
    dataptr = aliasptr;
    sel = ((DWORD) dataptr) >> 16;
    curroff = CodeLoadAddr;
    while( currsize != 0 ) {

        if( currsize >= (DWORD) READSIZE ) {
            amount = READSIZE;
        } else {
            amount = (WORD) currsize;
        }
        rc = _fTinyRead( handle, dataptr, amount );
        bytes_read = TINY_INFO( rc );
        if( bytes_read != amount ) {
            return( Fini( 1,(char _FAR *)"Read error" ) );
        }
        currsize -= (DWORD) amount;
        curroff += (DWORD) amount;
        DPMISetSegmentBaseAddress( sel, DataSelectorBase + curroff );
    }
    EDataAddr = curroff;                        // 03-jan-95

    DPMISetSegmentBaseAddress( sel, DataSelectorBase );
    relptr = (DWORD __far *)aliasptr;             // point to 32-bit stack area
    /*
     * get and apply relocation table
     */
    relsize = sizeof( DWORD ) * (DWORD) exe.reloc_cnt;
    {
        DWORD   realsize;
        WORD    kcnt;

        realsize = file_header_size - (DWORD) exe.first_reloc;
        kcnt = realsize / (0x10000L*sizeof(DWORD));
        relsize += kcnt * (0x10000L*sizeof(DWORD));
    }
    if( relsize != 0 ) {
        _TinySeek( handle, exelen + (DWORD)exe.first_reloc, TIO_SEEK_START );
        if( StackSize >= (DWORD) READSIZE ) {
            amount = READSIZE;
        } else {
            amount = (WORD) StackSize;
        }
        while( relsize != 0L ) {
            if( relsize < (DWORD)amount ) {
                amount = (WORD) relsize;
            }
            rc = _fTinyRead( handle, relptr, amount );
            bytes_read = TINY_INFO( rc );
            if( bytes_read != amount ) {
                return( Fini( 1,(char _FAR *)"Relocation read error" ) );
            }
            CodeRelocate( relptr, amount/sizeof(DWORD) );
            relsize -= (DWORD) amount;
        }
    }

    _TinyClose( handle );

    /* initialize emulator 8087 save area 20-oct-94 */

    fpuptr = (struct fpu_area __far *)((char __far *)aliasptr + FPU_AREA);
    _fmemset( fpuptr, 0, sizeof(struct fpu_area) );
    fpuptr->control_word = 0x033F;
    fpuptr->tag_word = 0xFFFF;

    /*
     * set dataptr to special area in data segment of 32-bit app
     */
    curroff = exedat.datastart;
    if( exe.reloc_cnt != 0 )  curroff += CodeLoadAddr;
    DPMISetSegmentBaseAddress( sel, DataSelectorBase + curroff );

    /*
     * insert command line parms
     */
    dataptr->thishandle = (WORD)thishandle;
    dataptr->prevhandle = (WORD)prevhandle;
    dataptr->cmdline    = (DWORD) cmdline;
    dataptr->cmdshow    = cmdshow;
    dataptr->_no87      = _no87;

    /*
     * set hardware selectors for screen memory
     */
    dataptr->_A000H     = (WORD) &_A000H;
    dataptr->_B000H     = (WORD) &_B000H;
    dataptr->_B800H     = (WORD) &_B800H;
    dataptr->_C000H     = (WORD) &_C000H;
    dataptr->_D000H     = (WORD) &_D000H;
    dataptr->_E000H     = (WORD) &_E000H;
    dataptr->_F000H     = (WORD) &_F000H;

    /*
     * ptrs to some data areas
     */
    dataptr->CodeSelectorBase.seg =  (WORD) FP_SEG( &CodeSelectorBase );
    dataptr->CodeSelectorBase.off = (DWORD) FP_OFF( &CodeSelectorBase );
    dataptr->DataSelectorBase.seg =  (WORD) FP_SEG( &DataSelectorBase );
    dataptr->DataSelectorBase.off = (DWORD) FP_OFF( &DataSelectorBase );
    dataptr->_32BitCallBackAddr.seg =  (WORD) FP_SEG( &_32BitCallBackAddr );
    dataptr->_32BitCallBackAddr.off = (DWORD) FP_OFF( &_32BitCallBackAddr );
    dataptr->_DLLEntryAddr.seg =  (WORD) FP_SEG( &_DLLEntryAddr );
    dataptr->_DLLEntryAddr.off = (DWORD) FP_OFF( &_DLLEntryAddr );
    dataptr->_WEPAddr.seg =  (WORD) FP_SEG( &_WEPAddr );
    dataptr->_WEPAddr.off = (DWORD) FP_OFF( &_WEPAddr );
    dataptr->_16BitCallBackAddr = &__CallBack;

    /*
     * insert glue routines into data area of caller
     */
    for( j = 0; j < MaxGlueRoutines; j++ ) {
        dataptr->gluertns[j].seg =  (WORD) FP_SEG( Glue[j].rtn );
        dataptr->gluertns[j].off = (DWORD) FP_OFF( Glue[j].rtn );
    }
    DPMIFreeAlias( sel );

    /*
     * check for FPU and WGod
     */
    if( flags & WF_80x87 ) {
        Has87 = TRUE;
    } else {
        Has87 = FALSE;
    }
    if( CheckWin386Debug() == WGOD_VERSION ) {
//    BreakPoint();
        HasWGod = TRUE;
        if( !Has87 ) {
            EMUInit();
            EMURegister( CodeEntry.seg, SaveSP - StackSize + FPU_AREA );
        }
    } else {
        HasWGod = FALSE;
    }
    return( TRUE );

} /* Init32BitTask */
Example #10
0
classTable::~classTable()
{
  Fini();
}
Example #11
0
ActionState::~ActionState()
{
	Fini();
}
Example #12
0
GameManager::~GameManager(void)
{
	Fini();
}
Example #13
0
Acceptor::~Acceptor()
{
   	Fini();
}
Example #14
0
void LuaEngine::Init(const char* main_script_file)
{
    Fini();
    int ret = 0;

    // TODO: 定时器个数采用宏配置
    heap_timer_ = new HeapTimer(1024);
    CHECK(heap_timer_ != NULL)
        << "timer heap init error!";

    master_state_ = luaL_newstate();
    CHECK(master_state_ != NULL)
        << "luaL_newstate error!";

    luaL_openlibs(master_state_);
    lua_tinker::init(master_state_);
    lua_tinker::init_s64(master_state_);
    lua_tinker::init_u64(master_state_);

    // 将script_main.lua所在文件夹路径加入require路径搜索
    char script_path[256] = {0};
    realpath(main_script_file, script_path);
    strncpy(script_path, dirname(script_path), 256);

    AddRequirePath(script_path);
    AddRequireCPath(script_path);

    // package.path 处理
    std::ostringstream oss_require;
    oss_require
        << "package.path = \"" << oss_require_path_.str() << "\"";

    ret = luaL_dostring(master_state_, oss_require.str().c_str());
    LOG(INFO) << "luaL_dostring [" << oss_require.str().c_str() << "]";
    CHECK(ret == 0)
        << "luaL_dostring [" << oss_require.str().c_str()
        << "] error!";

    oss_require.str("");
    oss_require_path_.str("");

    // package.cpath 处理
    oss_require
        << "package.cpath = \"" << oss_require_cpath_.str() << "\"";

    ret = luaL_dostring(master_state_, oss_require.str().c_str());
    LOG(INFO) << "luaL_dostring [" << oss_require.str().c_str() << "]";
    CHECK(ret == 0)
        << "luaL_dostring [" << oss_require.str().c_str()
        << "] error!";

    oss_require.str("");
    oss_require_cpath_.str("");

    // 设置LUA_SCRIPT_PATH
    SetGlobal("LUA_SCRIPT_PATH", script_path);

    // 注册log函数
    RegFunc("C_LOG_INFO", &LuaEngine::LogInfo);
    RegFunc("C_LOG_ERROR", &LuaEngine::LogError);
    // lua_tinker中日志函数
    RegFunc("_ALERT", &LuaEngine::LogInfo);

    ret = luaL_dofile(master_state_, main_script_file);
    if (ret != 0) {
        LOG(ERROR) << lua_tostring(master_state_, -1);
    }
    CHECK(ret == 0)
        << "luaL_dofile error!";

    // 第一次加载模块
    Reload();

    // 设置检查信号宏
    SetGlobal<int>("CHECK_SIG_OK", CHECK_SIG_OK);
    SetGlobal<int>("CHECK_SIG_TIMEOUT", CHECK_SIG_TIMEOUT);

    // 设置定时器
    SetHandler(this, &LuaEngine::OnTimer);
}
Example #15
0
AsyncPool::~AsyncPool()
{
	Fini();
}
Example #16
0
TestClient::~TestClient()
{
	Fini();
}
VOID ExitInProbeMode(INT code)
{
    Fini(code, 0);
    (*origExit)(code);
}
ResourceManager::~ResourceManager(void)
{
    Fini();
}
Example #19
0
TcpSocketUtil::~TcpSocketUtil()
{
    Fini();
}