Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove the dependency on CoCreateInpustance from mozc_tip32.dll and mozc_tip64.dll to comply with GUID_TFCAT_TIPCAP_COMLESS #837

@yukawa

Description

@yukawa

Description

Mozc does specify GUID_TFCAT_TIPCAP_COMLESS.

// The categories this text service is registered under.
// This needs to be const as the included constants are defined as const.
const GUID kCategories[] = {
GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, // It supports inline input.
GUID_TFCAT_TIPCAP_COMLESS, // It's a COM-Less module.
GUID_TFCAT_TIPCAP_INPUTMODECOMPARTMENT, // It supports input mode.
GUID_TFCAT_TIPCAP_UIELEMENTENABLED, // It supports UI less mode.
GUID_TFCAT_TIP_KEYBOARD, // It's a keyboard input method.
GUID_TFCAT_TIPCAP_IMMERSIVESUPPORT, // It supports Metro mode.
GUID_TFCAT_TIPCAP_SYSTRAYSUPPORT, // It supports Win8 systray.
};

Thus mozc_tip32.dll and mozc_tip64.dll should not call any COM-based APIs such as CoCreateInpustance.

lang_bar_item_mgr_ =
ComCreateInstance<ITfLangBarItemMgr>(CLSID_TF_LangBarItemMgr);

The solution is to use nano-COM style APIs provided by msctf.dll.

For instance, GetCategoryMgr() in tip_text_service.cc does this already.

// A COM-independent way to instantiate Category Manager object.
wil::com_ptr_nothrow<ITfCategoryMgr> GetCategoryMgr() {
const HMODULE module = WinUtil::GetSystemModuleHandle(L"msctf.dll");
if (module == nullptr) {
return nullptr;
}
const auto tf_create_tegory_mgr =
reinterpret_cast<decltype(&TF_CreateCategoryMgr)>(
GetProcAddress(module, "TF_CreateCategoryMgr"));
if (tf_create_tegory_mgr == nullptr) {
return nullptr;
}
wil::com_ptr_nothrow<ITfCategoryMgr> ptr;
return SUCCEEDED(tf_create_tegory_mgr(&ptr)) ? ptr : nullptr;
}

To avoid loader-lock problem, it'd be safer to let mozc_tip32.dll and mozc_tip64.dll implicitly link to msctf.dll by creating a fake import library, like we did so for input.dll at f470414, rather than relying on GetProcAddress.

Version or commit-id

51e0d20

Environment

  • OS: Windows 11 22H2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions