77#include < string>
88#include < thread>
99#include < chrono>
10- #include < algorithm>
1110
1211#include < Windows.h>
1312#include < TlHelp32.h>
1413
1514#include " utils.h"
15+ #include " md5.h"
1616
1717using namespace std ;
1818
1919static void sys_sleep (uint32_t nMilliseconds)
2020{
2121 std::this_thread::sleep_for (std::chrono::milliseconds (nMilliseconds));
22- }
23-
24- static std::wstring LowerCase (const std::wstring& text)
25- {
26- std::wstring ret = text;
27- std::transform (ret.begin (), ret.end (), ret.begin (), tolower);
28- return ret;
2922}
3023
3124static uint64_t GetDLLBaseAddress (std::wstring needDllName, int32_t pid)
@@ -45,8 +38,8 @@ static uint64_t GetDLLBaseAddress(std::wstring needDllName, int32_t pid)
4538 int loaded_count = 0 ;
4639 while (bMore) {
4740 std::wstring dll_name = module .szModule ;
48- dll_name = LowerCase (dll_name);
49- needDllName = LowerCase (needDllName);
41+ dll_name = lower_case (dll_name);
42+ needDllName = lower_case (needDllName);
5043 if (dll_name == needDllName) {
5144 ret = (uint64_t )module .modBaseAddr ;
5245 break ;
@@ -74,11 +67,11 @@ static std::vector<DWORD> GetPidByProcessName(wstring process_name)
7467 if (!::Process32FirstW (hSnapshot, &lppe))
7568 return ret;
7669
77- process_name = LowerCase (process_name);
70+ process_name = lower_case (process_name);
7871
7972 do {
8073 wstring exeName = lppe.szExeFile ;
81- exeName = LowerCase (exeName);
74+ exeName = lower_case (exeName);
8275 if (exeName == process_name) {
8376 ret.push_back (lppe.th32ProcessID );
8477 }
@@ -120,7 +113,7 @@ class win10_wubi_patch
120113 uint32_t count = 0 ;
121114 while (!_exit) {
122115
123- sys_sleep (5000 );
116+ sys_sleep (2500 );
124117
125118 std::vector<DWORD> pids = GetPidByProcessName (s_target_process_name);
126119 for (auto pid : pids) {
@@ -133,7 +126,7 @@ class win10_wubi_patch
133126 } else {
134127 s_bok = " failed" ;
135128 }
136- printf (" ---- do patch, pid = %d, times = %d, result = %s\n " , pid, count, s_bok.c_str ());
129+ printf (" -- do patch, pid = %d, times = %d, result = %s\n " , pid, count, s_bok.c_str ());
137130 }
138131 }
139132 }
@@ -178,8 +171,37 @@ class win10_wubi_patch
178171 std::thread _thread;
179172};
180173
174+ bool check_support_version ()
175+ {
176+ std::string chs_ime_path = get_system_winodws_path ();
177+ chs_ime_path += " System32\\ InputMethod\\ CHS\\ ChsIME.exe" ;
178+ bool bSupport = false ;
179+ do
180+ {
181+ std::string file_md5 = md5file (chs_ime_path.c_str ());
182+ if (file_md5.empty ()) {
183+ break ;
184+ }
185+
186+ file_md5 = lower_case (file_md5);
187+ if (file_md5 == " b3448bf077665f2e1ca67094bcf2a7c5" ) {
188+ bSupport = true ;
189+ }
190+
191+ } while (0 );
192+ return bSupport;
193+ }
194+
181195int main ()
182196{
197+ printf (" ---Widows 10 Disable English Switch Key(Shift) For Wubi InputMethod---\n " );
198+ printf (" ==key press [Q] to exit==\n " );
199+ printf (" \n " );
200+
201+ if (!check_support_version ()) {
202+ printf (" file(ChsIME.exe) not support.\n " );
203+ return -1 ;
204+ }
183205
184206 if (!set_debug_privilege ()) {
185207 printf (" admin privileges are required.\n " );
@@ -190,7 +212,6 @@ int main()
190212
191213 win10_wubi_patch wubi_patch;
192214 wubi_patch.RunThread ();
193- printf (" ---Widows 10 Disable English Switch Key(Shift) For Wubi InputMethod--- =key press [Q] to exit=\n " );
194215 do {
195216 if (read_key () == ' q' ) {
196217 printf (" exit\n " );
0 commit comments