コード例 #1
0
ファイル: TabUnits.cpp プロジェクト: GotoHack/IDR
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::miRenameUnitClick(TObject *Sender)
{
    if (lbUnits->ItemIndex == -1) return;

    String item = lbUnits->Items->Strings[lbUnits->ItemIndex];
    DWORD adr;
    sscanf(item.c_str() + 1, "%lX", &adr);
    PUnitRec recU = GetUnit(adr);
    
    String text = "";
    for (int u = 0; u < recU->names->Count; u++)
    {
        if (u) text += "+";
        text += recU->names->Strings[u];
    }
    String sName = InputDialogExec("Enter UnitName", "Name:", text);
    if (sName != "")
    {
        recU->names->Clear();
        SetUnitName(recU, sName);
        
        ProjectModified = true;
        ShowUnits(true);
        lbUnits->SetFocus();
    }
}
コード例 #2
0
ファイル: TabUnits.cpp プロジェクト: GotoHack/IDR
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::miSortUnitsByNamClick(TObject *Sender)
{
    miSortUnitsByAdr->Checked = false;
    miSortUnitsByOrd->Checked = false;
    miSortUnitsByNam->Checked = true;
    UnitSortField = 2;
    ShowUnits(true);
    lbUnits->SetFocus();
}
コード例 #3
0
void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
{
    wxString      cmp_name;
    LIB_ALIAS*    libEntry;
    wxArrayString nameList;
    wxString      msg;

    m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );

    m_lastDrawItem = NULL;
    m_drawItem = NULL;

    LIB_PART *part = GetCurPart();
    PART_LIB* lib = GetCurLib();

    if( !lib )
    {
        SelectActiveLibrary();

        lib = GetCurLib();
        if( !lib )
        {
            DisplayError( this, _( "Please select a component library." ) );
            return;
        }
    }

    auto adapter( CMP_TREE_MODEL_ADAPTER::Create( Prj().SchLibs() ) );

    wxString name = part ? part->GetName() : wxString( wxEmptyString );
    adapter->SetPreselectNode( name, /* aUnit */ 0 );
    adapter->ShowUnits( false );
    adapter->AddLibrary( *lib );

    wxString dialogTitle;
    dialogTitle.Printf( _( "Delete Component (%u items loaded)" ), adapter->GetComponentsCount() );

    DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, m_convert );

    if( dlg.ShowModal() == wxID_CANCEL )
    {
        return;
    }

    libEntry = dlg.GetSelectedAlias( NULL );

    if( !libEntry )
    {
        msg.Printf( _( "Entry '%s' not found in library '%s'." ),
                    GetChars( libEntry->GetName() ),
                    GetChars( lib->GetName() ) );
        DisplayError( this, msg );
        return;
    }

    msg.Printf( _( "Delete component '%s' from library '%s' ?" ),
                GetChars( libEntry->GetName() ),
                GetChars( lib->GetName() ) );

    if( !IsOK( this, msg ) )
        return;

    part = GetCurPart();

    if( !part || !part->HasAlias( libEntry->GetName() ) )
    {
        lib->RemoveAlias( libEntry );
        m_canvas->Refresh();
        return;
    }

    // If deleting the current entry or removing one of the aliases for
    // the current entry, sync the changes in the current entry as well.

    if( GetScreen()->IsModify() && !IsOK( this, _(
        "The component being deleted has been modified."
        " All changes will be lost. Discard changes?" ) ) )
    {
        return;
    }

    LIB_ALIAS* nextEntry = lib->RemoveAlias( libEntry );

    if( nextEntry != NULL )
    {
        if( LoadOneLibraryPartAux( nextEntry, lib ) )
            Zoom_Automatique( false );
    }
    else
    {
        SetCurPart( NULL );     // delete CurPart
        m_aliasName.Empty();
    }

    m_canvas->Refresh();
}
コード例 #4
0
ファイル: TabUnits.cpp プロジェクト: GotoHack/IDR
//---------------------------------------------------------------------------
void __fastcall TFMain_11011981::lbUnitItemsDblClick(TObject *Sender)
{
    int         idx = -1, len, size, refCnt;
    WORD*       uses;
    DWORD       adr;
    char        *tmpBuf;
    PInfoRec    recN;
    MTypeInfo   tInfo;
    String      str;
    char        tkName[32], typeName[1024];

    if (lbUnitItems->ItemIndex == -1) return;

    String item = lbUnitItems->Items->Strings[lbUnitItems->ItemIndex];
    //Xrefs?
    if (item[11] == '<' || item[11] == '?')
        sscanf(item.c_str() + 1, "%lX%s%s", &adr, tkName, typeName);
    else
        sscanf(item.c_str() + 1, "%lX%d%s%s", &adr, &refCnt, tkName, typeName);
    String name = String(tkName);

    if (SameText(name, "????"))
    {
        //Find end of unexplored Data
        int bytes = 1024, pos = Adr2Pos(adr);
        //Get first byte (use later for filtering code?data)
        BYTE db = *(Code + pos);

        FExplorer_11011981->tsCode->TabVisible = true;
        FExplorer_11011981->ShowCode(adr, bytes);
        FExplorer_11011981->tsData->TabVisible = true;
        FExplorer_11011981->ShowData(adr, bytes);
        FExplorer_11011981->tsString->TabVisible = true;
        FExplorer_11011981->ShowString(adr, 1024);
        FExplorer_11011981->tsText->TabVisible = false;
        FExplorer_11011981->WAlign = 0;

        FExplorer_11011981->btnDefCode->Enabled = true;
        if (IsFlagSet(cfCode, pos)) FExplorer_11011981->btnDefCode->Enabled = false;
        FExplorer_11011981->btnUndefCode->Enabled = false;
        if (IsFlagSet(cfCode | cfData, pos)) FExplorer_11011981->btnUndefCode->Enabled = true;

        if (IsValidCode(adr) != -1 && db >= 0xF)
        	FExplorer_11011981->pc1->ActivePage = FExplorer_11011981->tsCode;
        else
        	FExplorer_11011981->pc1->ActivePage = FExplorer_11011981->tsData;

        if (FExplorer_11011981->ShowModal() == mrOk)
        {
            switch (FExplorer_11011981->DefineAs)
            {
            case DEFINE_AS_CODE:
                recN = GetInfoRec(adr);
                if (!recN)
                    recN = new InfoRec(pos, ikRefine);
                else if (recN->kind < ikRefine || recN->kind > ikFunc)
                {
                    delete recN;
                    recN = new InfoRec(pos, ikRefine);
                }

                //AnalyzeProcInitial(adr);
                AnalyzeProc1(adr, 0, 0, 0, false);
                AnalyzeProc2(adr, true, true);
                AnalyzeArguments(adr);
                AnalyzeProc2(adr, true, true);

                if (!ContainsUnexplored(GetUnit(adr))) ShowUnits(true);
                ShowUnitItems(GetUnit(adr), lbUnitItems->TopIndex, lbUnitItems->ItemIndex);
                ShowCode(adr, 0, -1, -1);
                break;
            case DEFINE_AS_STRING:
                break;
            }
        }
        return;
    }

    if (SameText(name, "<VMT>") && tsClassView->TabVisible)
    {
        ShowClassViewer(adr);
        return;
    }
    if (SameText(name, "<ResString>"))
    {
        FStringInfo_11011981->memStringInfo->Clear();
        FStringInfo_11011981->Caption = "ResString";
        recN = GetInfoRec(adr);
        FStringInfo_11011981->memStringInfo->Lines->Add(recN->rsInfo->value);
        FStringInfo_11011981->ShowModal();
        return;
    }
    if (SameText(name, "<ShortString>") ||
        SameText(name, "<AnsiString>")  ||
        SameText(name, "<WideString>")  ||
        SameText(name, "<PAnsiChar>")   ||
        SameText(name, "<PWideChar>"))
    {
        FStringInfo_11011981->memStringInfo->Clear();
        FStringInfo_11011981->Caption = "String";
        recN = GetInfoRec(adr);
        FStringInfo_11011981->memStringInfo->Lines->Add(recN->GetName());
        FStringInfo_11011981->ShowModal();
        return;
    }
    if (SameText(name, "<UString>"))
    {
        FStringInfo_11011981->memStringInfo->Clear();
        FStringInfo_11011981->Caption = "String";
        recN = GetInfoRec(adr);
        len = wcslen((wchar_t*)(Code + Adr2Pos(adr)));
        size = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)(Code + Adr2Pos(adr)), len, 0, 0, 0, 0);
        if (size)
        {
            tmpBuf = new char[size + 1];
            WideCharToMultiByte(CP_ACP, 0, (wchar_t*)(Code + Adr2Pos(adr)), len, tmpBuf, len, 0, 0);
            FStringInfo_11011981->memStringInfo->Lines->Add(String(tmpBuf, len));
            delete[] tmpBuf;
            FStringInfo_11011981->ShowModal();
        }
        return;
    }
    if (SameText(name, "<Integer>")     ||
        SameText(name, "<Char>")        ||
        SameText(name, "<Enumeration>") ||
        SameText(name, "<Float>")       ||
        SameText(name, "<Set>")         ||
        SameText(name, "<Class>")       ||
        SameText(name, "<Method>")      ||
        SameText(name, "<WChar>")       ||
        SameText(name, "<Array>")       ||
        SameText(name, "<Record>")      ||
        SameText(name, "<Interface>")   ||
        SameText(name, "<Int64>")       ||
        SameText(name, "<DynArray>")    ||
        SameText(name, "<ClassRef>")    ||
        SameText(name, "<Pointer>")     ||
        SameText(name, "<Procedure>"))
    {
        uses = KnowledgeBase.GetTypeUses(typeName);
        idx = KnowledgeBase.GetTypeIdxByModuleIds(uses, typeName);
        if (uses) delete[] uses;

        if (idx != -1)
        {
            idx = KnowledgeBase.TypeOffsets[idx].NamId;
            if (KnowledgeBase.GetTypeInfo(idx, INFO_FIELDS | INFO_PROPS | INFO_METHODS, &tInfo))
            {
                FTypeInfo_11011981->ShowKbInfo(&tInfo);
                //as delete tInfo;
            }
        }
        else
        {
            FTypeInfo_11011981->ShowRTTI(adr);
        }
        return;
    }
    if (SameText(name, "<Proc>")    	||
        SameText(name, "<Func>")     	||
        SameText(name, "<Constructor>") ||
        SameText(name, "<Destructor>")  ||
        SameText(name, "<EmbProc>") 	||
        SameText(name, "<EmbFunc>")  	||
        SameText(name, "<Emb?>")        ||
        SameText(name, "<ImpProc>")  	||
        SameText(name, "<ExpProc>")  	||
        SameText(name, "<ImpFunc>")  	||
        SameText(name, "<ExpFunc>")     ||
        SameText(name, "<Imp?>")        ||
        SameText(name, "<Exp?>")        ||
        SameText(name, "<?>"))
    {
        PROCHISTORYREC  rec;
        rec.adr = CurProcAdr;
        rec.itemIdx = lbCode->ItemIndex;
        rec.xrefIdx = lbCXrefs->ItemIndex;
        rec.topIdx = lbCode->TopIndex;
        ShowCode(adr, 0, -1, -1);
        CodeHistoryPush(&rec);
        pcWorkArea->ActivePage = tsCodeView;
    }
}