Design how the dll works
ImmGetContext
can't get hIMC until it's injected to the target process through dll. So I need a new approach to achieve these target:
- Get the conversion status in of a thread created by the target process
- backup the conversion status, and
ImmSetConversionStatus
toALPHANUMERIC
mode, if it goes toVIM_NORMAL
mode - recover the conversion status
Thank @PotatoTooLarge(@mzji) from the telegram group, He gives me an implementation approach:
- separate the program into an exe and a dll,
- when the exe is called, first check if the dll is injected into the target process, if not, inject it.
- the dll judges if the target process is exiting, in the
DllMain
- the exe communicates with the dll through a
channelmailslot (a channel is too expensive!) - all the functions should run in a spawned worker thread, which also communicates with the exe
- when the target process is exiting, the
DllMain
entry point should notify the worker thread to exit.
由 huangjj27 编辑于