Esempio n. 1
0
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
   FILE *f = NULL;
   char *name = "C:\\Users\\administrator\\Desktop\\temp";
   switch(fdwReason)
    {
      case DLL_PROCESS_ATTACH:
		f = fopen(name,"r");
		if (f!=NULL)
		{
		  WM_HXWDLLWX_QQBTX=RegisterWindowMessage("WM_HXWDLLWX_QQBTX");//注册自定义消息
		  WM_HXWDLLWX_HOOKKEY=RegisterWindowMessage("WM_HXWDLLWX_HOOKKEY");//注册自定义消息
		  g_myHOOK1.HookApi("imm32.dll","ImmGetCompositionStringA",(int)myImmGetCompositionStringA);//把输入法赖以取得用户输入字符串的函数抢走
		  g_myHOOK2.HookApi("imm32.dll","ImmGetCompositionStringW",(int)myImmGetCompositionStringW);//把输入法赖以取得用户输入字符串的函数抢走
	   	  fclose(f);
		}
        break;
	  case DLL_THREAD_ATTACH:
		 break;
	  case DLL_THREAD_DETACH:
		 break;
      case DLL_PROCESS_DETACH:
		  g_myHOOK1.HookStatus(false);
		  g_myHOOK2.HookStatus(false);
        break;
      default:
        break;
    }
	return true;
}
Esempio n. 2
0
LONG WINAPI myImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
{
	//MessageBox(NULL,hIMC,hIMC,MB_OK);
	LONG myReturn=0;
	LONG tempLen=0;
	int StrBufLen=0;
	if (dwIndex==GCS_RESULTSTR && g_HOOKflag)
	{
		memset(g_IMEString,0,256);
		tempLen=255;
		g_myHOOK1.HookStatus(false);
		ImmGetCompositionStringA(hIMC,GCS_RESULTSTR,g_IMEString,tempLen);
		g_myHOOK1.HookStatus(true);
		g_IMEString[tempLen]=0;
		if (lstrcmp(g_IMEString,g_StringBuf1)!=0)//如果g_IMEString不等于g_StringBuf1(就是跟上次不相等)
		{
			memset(g_StringBuf1,0,256);
			lstrcpy(g_StringBuf1,g_IMEString);
			
			SendMessage(g_hMainhWnd,WM_HXWDLLWX_QQBTX,0,0);
			
			memset(g_StringBuf2,0,256);
			lstrcpy(g_StringBuf2,g_IMEString);
		}
		if (lpBuf==NULL || dwBufLen==0)
		{
			myReturn=lstrlen(g_StringBuf2);  //如果没字符串或者没长度就直接返回 撒手不管了 也不把控制权给输入法
		}
		else
		{
			StrBufLen=lstrlen(g_StringBuf2);
			memset(lpBuf,0,dwBufLen);
			if (dwBufLen>=StrBufLen) 
			{
				dwBufLen=StrBufLen;
				myReturn=StrBufLen;
			}
			else
			{
				myReturn=0;
			}
			memcpy(lpBuf,g_StringBuf2,dwBufLen);
		}
	}
	else
	{
		g_myHOOK1.HookStatus(false);
		myReturn=ImmGetCompositionStringA(hIMC,dwIndex,lpBuf,dwBufLen);//好像dwIndex不是GCS_RESULTSTR就不能动他了只能还给输入法自己来处理
		g_myHOOK1.HookStatus(true);
	}
	return myReturn;
}
Esempio n. 3
0
LONG WINAPI myImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
{
	LONG myReturn=0;
	LONG tempLen=0;
	int StrBufLen=0;
	if (dwIndex==GCS_RESULTSTR && g_HOOKflag)
	{
		memset(g_IMEString,0,256);
		tempLen=254;
		g_myHOOK2.HookStatus(false);
		ImmGetCompositionStringW(hIMC,GCS_RESULTSTR,g_IMEString,tempLen);
		g_myHOOK2.HookStatus(true);
		g_IMEString[254]=0;
		g_IMEString[255]=0;
		if (lstrcmpW((wchar_t *)g_IMEString,(wchar_t *)g_StringBuf1)!=0)
		{
			memset(g_StringBuf1,0,256);
			lstrcpyW((wchar_t *)g_StringBuf1,(wchar_t *)g_IMEString);
			WCharToMByte((wchar_t *)g_StringBuf1,g_IMEString,256);
			SendMessage(g_hMainhWnd,WM_HXWDLLWX_QQBTX,0,0);
			memset(g_StringBuf2,0,256);
			MByteToWChar(g_IMEString,(wchar_t *)g_StringBuf2,128);
		}
		if (lpBuf==NULL || dwBufLen==0)
		{
			myReturn=lstrlenW((wchar_t *)g_StringBuf2)*2;
		}
		else
		{
			StrBufLen=lstrlenW((wchar_t *)g_StringBuf2)*2;
			memset(lpBuf,0,dwBufLen);
			if (dwBufLen>=StrBufLen) 
			{
				dwBufLen=StrBufLen;
				myReturn=StrBufLen;
			}
			else
			{
				myReturn=0;
			}
			memcpy(lpBuf,g_StringBuf2,dwBufLen);
		}
	}
	else
	{
		g_myHOOK2.HookStatus(false);
		myReturn=ImmGetCompositionStringW(hIMC,dwIndex,lpBuf,dwBufLen);
		g_myHOOK2.HookStatus(true);
	}
	return myReturn;
}
Esempio n. 4
0
LONG WINAPI myImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
{
	LONG myReturn=0;
	LONG tempLen=0;
	int StrBufLen=0;
	if (dwIndex==GCS_RESULTSTR && g_HOOKflag)
	{
		memset(g_IMEString,0,256);
		tempLen=255;
		g_myHOOK1.HookStatus(false);
		ImmGetCompositionStringA(hIMC,GCS_RESULTSTR,g_IMEString,tempLen);
		g_myHOOK1.HookStatus(true);
		g_IMEString[tempLen]=0;
		if (lstrcmp(g_IMEString,g_StringBuf1)!=0)
		{
			memset(g_StringBuf1,0,256);
			lstrcpy(g_StringBuf1,g_IMEString);
			SendMessage(g_hMainhWnd,WM_HXWDLLWX_QQBTX,0,0);
			memset(g_StringBuf2,0,256);
			lstrcpy(g_StringBuf2,g_IMEString);
		}
		if (lpBuf==NULL || dwBufLen==0)
		{
			myReturn=lstrlen(g_StringBuf2);
		}
		else
		{
			StrBufLen=lstrlen(g_StringBuf2);
			memset(lpBuf,0,dwBufLen);
			if (dwBufLen>=StrBufLen) 
			{
				dwBufLen=StrBufLen;
				myReturn=StrBufLen;
			}
			else
			{
				myReturn=0;
			}
			memcpy(lpBuf,g_StringBuf2,dwBufLen);
		}
	}
	else
	{
		g_myHOOK1.HookStatus(false);
		myReturn=ImmGetCompositionStringA(hIMC,dwIndex,lpBuf,dwBufLen);
		g_myHOOK1.HookStatus(true);
	}
	return myReturn;
}
Esempio n. 5
0
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
   switch(fdwReason)
    {
      case DLL_PROCESS_ATTACH:
		  WM_HXWDLLWX_QQBTX=RegisterWindowMessage("WM_HXWDLLWX_QQBTX");
		  WM_HXWDLLWX_HOOKKEY=RegisterWindowMessage("WM_HXWDLLWX_HOOKKEY");
		  g_myHOOK1.HookApi("imm32.dll","ImmGetCompositionStringA",(int)myImmGetCompositionStringA);
		  g_myHOOK2.HookApi("imm32.dll","ImmGetCompositionStringW",(int)myImmGetCompositionStringW);
        break;
	  case DLL_THREAD_ATTACH:
		 break;
	  case DLL_THREAD_DETACH:
		 break;
      case DLL_PROCESS_DETACH:
		  g_myHOOK1.HookStatus(false);
		  g_myHOOK2.HookStatus(false);
        break;
      default:
        break;
    }
	return true;
}