Exemple #1
0
// msgdlg のように、メッセージが長い場合にはダイアログを拡げるようにした (2006.7.29 maya)
BOOL CInpDlg::OnInitDialog()
{
	RECT R;
	HDC TmpDC;
	HWND HEdit, HOk;
	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
	LOGFONT logfont;
	HFONT font, tmpfont;

	CDialog::OnInitDialog();
	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
	GetObject(font, sizeof(LOGFONT), &logfont);
	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
		SendDlgItemMessage(IDC_INPTEXT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
		SendDlgItemMessage(IDC_INPEDIT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
		SendDlgItemMessage(IDOK, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
	}

	GetDlgItemText(IDOK, uimsg2, sizeof(uimsg2));
	get_lang_msg("BTN_OK", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
	SetDlgItemText(IDOK, uimsg);

	SetWindowText(TitleStr);
	SetDlgItemText(IDC_INPTEXT,TextStr);
	SetDlgItemText(IDC_INPEDIT,DefaultStr);

	TmpDC = ::GetDC(GetDlgItem(IDC_INPTEXT)->GetSafeHwnd());
	if (DlgFont) {
		tmpfont = (HFONT)SelectObject(TmpDC, DlgFont);
	}
	CalcTextExtent(TmpDC,TextStr,&s);
	if (DlgFont && tmpfont != NULL) {
		SelectObject(TmpDC, tmpfont);
	}
	::ReleaseDC(GetDlgItem(IDC_INPTEXT)->GetSafeHwnd(),TmpDC);
	TW = s.cx + s.cx/10;
	TH = s.cy;

	HEdit = ::GetDlgItem(GetSafeHwnd(), IDC_INPEDIT);
	::GetWindowRect(HEdit,&R);
	EW = R.right-R.left;
	EH = R.bottom-R.top;

	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
	::GetWindowRect(HOk,&R);
	BW = R.right-R.left;
	BH = R.bottom-R.top;

	GetWindowRect(&R);
	WW = R.right-R.left;
	WH = R.bottom-R.top;

	Relocation(TRUE, WW);

	BringupWindow(this->m_hWnd);

	return TRUE;
}
Exemple #2
0
LONG CInpDlg::OnExitSizeMove(UINT wParam, LONG lParam)
{
	RECT R;

	GetWindowRect(&R);
	if (R.bottom-R.top == WH && R.right-R.left == WW) {
		// サイズが変わっていなければ何もしない
	}
	else if (R.bottom-R.top != WH || R.right-R.left < init_WW) {
		// 高さが変更されたか、最初より幅が狭くなった場合は元に戻す
		SetWindowPos(&wndTop,R.left,R.top,WW,WH,0);
	}
	else {
		// そうでなければ再配置する
		Relocation(FALSE, R.right-R.left);
	}

	return CDialog::DefWindowProc(WM_EXITSIZEMOVE,wParam,lParam);
}
void ExecFileParser::load_eh_frame_relocations() {

    for (auto& psec : reader->sections) {
        if (psec->get_name() == ".eh_frame") { //TODO: is this portable?
            auto start = (uint32_t*) psec->get_data();

            uint32_t* p = start;

            while (*p != 0) {
                assert(*p < 0xfffffff0); //otherwise, we need to add support for 64-bit DWARF

                if (p[1]) { // FDE record
                    Elf64_Addr offset = (Elf64_Addr) (p+2) - (Elf64_Addr) start + psec->get_address();
                    _eh_frame_relocations.relo_vec.push_back(Relocation(offset, R_X86_64_PC32, 0));

                } // else CIE record, we can ignore it

                // advance p by the size of the record
                p += (*p/4) + 1;
            }
        }
    }
}
void DotOFileParser::load_relocations() {
    // Relocations
    for (auto &psec : reader->sections) {
        if ((reader->get_class() == ELFCLASS32 && psec->get_type() == SHT_REL) ||
            (reader->get_class() == ELFCLASS64 && psec->get_type() == SHT_RELA)) {

            try {
                Section &targetSection = _sections.at((Elf_Half) psec->get_info());
                // We need to ignore relocations on !allocated sections,
                // since they don't have memory addresses
                if (!targetSection.allocated)
                    continue;

                vector<Relocation> &relo_vec = targetSection.relo_vec;

                const auto relocations = relocation_section_accessor(*reader, psec);
                auto relo_num = relocations.get_entries_num();

                for (unsigned int i = 0; i < relo_num; ++i) {
                    Elf64_Addr offset;
                    Elf_Word symbol;
                    Elf64_Addr symbolValue;
                    std::string symbolName;
                    Elf_Word type;
                    Elf_Sxword addend;
                    Elf_Sxword calcValue;

                    relocations.get_entry(i, offset, symbolValue, symbolName, type, addend, calcValue);
                    if (strncmp(symbolName.c_str(), "_TRaP_Linux", sizeof("_TRaP_Linux")-1) == 0) continue;

                    bool elf32 = reader->get_class() == ELFCLASS32;
                    bool elf64 = reader->get_class() == ELFCLASS64;

                    if (std::find(std::begin(RelocWhitelist), std::end(RelocWhitelist), type) !=
                        std::end(RelocWhitelist)) {
                        relo_vec.push_back(Relocation(offset, type, addend));
#if OFPreadprint >= 2
                        printf("%4d: 0x%08llx 0x%08x %+lld %i\n", i, offset, symbol, addend, type);
#endif
                    } else {
                        cerr << "Unknown type " << type << " (file '" << filename << "', "
                        << "section: " << psec->get_name() << ", "
                        << "offset: " << hex << offset << dec << ", "
                        << "relo index: " << i << "/" << relo_num << ")" << endl;
                        exit(13);
                    }
                }
            } catch (std::out_of_range e) {} // for .sr.text
        }
    }

#ifdef OFPprintres
    for (auto &it : _sections) {
        if (!it.second.executable)
            continue;
        printf("sec %d: %s\n", it.first, it.second.name.c_str());

        auto &sym_vec = it.second.sym_vec;
        printf("  symbols:\n");
        sort(sym_vec.begin(), sym_vec.end());
        for (auto &jt : sym_vec) {
            printf("    %08lx %08ld\n", jt.start, jt.size);
        }

        auto &relo_vec = it.second.relo_vec;
        printf("  relocations:\n");
        sort(relo_vec.begin(), relo_vec.end());
        for (auto &jt : relo_vec) {
            printf("    %08lx %d\n", jt.offset, jt.type);
        }
    }
#endif
}