⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exports.cpp

📁 Hook API 实现文件名自动变换。并提供相关的测试程序。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	{
		//---------------------------------------------------
		if( strnicmp(lpString, "斯博锐通", strlen("斯博锐通")) == 0)//IsDigital(lpString) || IsFloat(lpString) )
		{
			//fNumTmp = (float)(m_fNumber * strtod(lpString,NULL));	
			strcpy(sTmp, lpString);
			//strcpy(sTmp, "数据卫士");
			memmove(sTmp, L"数据卫士", 8);


			TextOutA(hdc, nXStart, nYStart, sTmp, strlen(sTmp));
			
		}
		else
		{
			TextOutA(hdc, nXStart, nYStart, lpString, cbString);
		}	
	}
	catch(...)
	{
		TextOutA(hdc, nXStart, nYStart, lpString, cbString);
	}
	
	//---------------------------------------------------
	//TextOutA(hdc, nXStart, nYStart, lpString, cbString);
	
	HookWin32Api(&g_TextOutAHook, HOOK_NEED_CHECK);

	return TRUE;
}

DLLEXPORT BOOL WINAPI NHTextOutW(HDC hdc,
							     int nXStart,
							     int nYStart,
							     LPCWSTR lpString,
							     int cbString)
{
	
	float fNumTmp;
	wchar_t sTmp[1024]={'\0'}; 

	// restore
	RestoreWin32Api(&g_TextOutWHook, HOOK_NEED_CHECK);
	
	
	//--------------------------------------------------------------
	try
	{


		if( wcsnicmp(lpString, L"斯博锐通", wcslen(L"斯博锐通")) == 0)//IsDigital(lpString) || IsFloat(lpString) )
		{
			//fNumTmp = (float)(m_fNumber * strtod(lpString,NULL));	
			wcscpy(sTmp, lpString);
			//wcscpy(sTmp, L"数据卫士");
			memmove(sTmp, L"数据卫士", wcslen(L"数据卫士")*2);


			TextOutW(hdc, nXStart, nYStart, sTmp, wcslen(sTmp));	
		}			
		else
		{
			// call ExtTextOutA
			TextOutW(hdc, nXStart, nYStart, lpString, cbString);
		}
	}
	catch(...)
	{
		TextOutW(hdc, nXStart, nYStart, lpString, cbString);
	}
	//--------------------------------------------------------------
	
	// call TextOutW
	//TextOutW(hdc, nXStart, nYStart, lpString, cbString);

	HookWin32Api(&g_TextOutWHook, HOOK_NEED_CHECK);

	return TRUE;
}

DLLEXPORT BOOL WINAPI NHExtTextOutA(HDC hdc,
								    int X,
								    int Y,
								    UINT fuOptions,
								    CONST RECT *lprc,
								    LPCTSTR lpString,
								    UINT cbCount,
								    CONST INT *lpDx)
{
	float fNumTmp=0;
	char sTmp[1024]={'\0'}; 

	// restore
	RestoreWin32Api(&g_ExtTextOutAHook, HOOK_NEED_CHECK);

	try
	{
		//---------------------------------------------------
	/*	if( IsDigital(lpString) || IsFloat(lpString) )
		{
			fNumTmp = (float)(m_fNumber * strtod(lpString,NULL));	
			sprintf(sTmp,"%0.2f",fNumTmp);
			ExtTextOutA(hdc, X-6, Y, fuOptions, lprc, sTmp, strlen(sTmp), lpDx);
			
		}*/

		if( strnicmp(lpString, "斯博锐通", strlen("斯博锐通")) == 0)//IsDigital(lpString) || IsFloat(lpString) )
		{
			//fNumTmp = (float)(m_fNumber * strtod(lpString,NULL));	
			strcpy(sTmp, lpString);
			//strcpy(sTmp, "数据卫士");
			memmove(sTmp, "数据卫士", 8);

		//	TextOutA(hdc, nXStart, nYStart, sTmp, strlen(sTmp));
			ExtTextOutA(hdc, X-6, Y, fuOptions, lprc, sTmp, strlen(sTmp), lpDx);
			
		}
		else
		{
			// call ExtTextOutA
			ExtTextOutA(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);
		}	
	}
	catch(...)
	{
		ExtTextOutA(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);
	}

	// call ExtTextOutA
	//ExtTextOutA(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);

	HookWin32Api(&g_ExtTextOutAHook, HOOK_NEED_CHECK);

	return TRUE;
}

DLLEXPORT BOOL WINAPI NHExtTextOutW(HDC hdc,
								    int X,
								    int Y,
								    UINT fuOptions,
								    CONST RECT *lprc,
									LPCWSTR lpString,
								    UINT cbCount,
								    CONST INT *lpDx)
{
	float fNumTmp;
	wchar_t sTmp[1024]={'\0'};

	// restore
	RestoreWin32Api(&g_ExtTextOutWHook, HOOK_NEED_CHECK);
	
	//---------------------------------------------------
	try
	{
		if( wcsnicmp(lpString, L"斯博锐通", wcslen(L"斯博锐通")) == 0)//IsDigital(lpString) || IsFloat(lpString) )
		{
			//fNumTmp = (float)(m_fNumber * strtod(lpString,NULL));	
			wcscpy(sTmp, lpString);
			//wcsncpy(sTmp, L"数据卫士", wcslen(L"数据卫士"));
			memmove(sTmp, L"数据卫士", wcslen(L"数据卫士")*2);

		//	TextOutW(hdc, nXStart, nYStart, sTmp, wcslen(sTmp));	
			ExtTextOutW(hdc, X, Y, fuOptions, lprc, sTmp, wcslen(sTmp), lpDx);
		
			
		}
		else
		{
			// call ExtTextOutA
			ExtTextOutW(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);
		}
	}
	catch(...)
	{
		ExtTextOutW(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);
	}
	
	// call ExtTextOutW
	//ExtTextOutW(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);

	HookWin32Api(&g_ExtTextOutWHook, HOOK_NEED_CHECK);

	return TRUE;
}

//-------------------------------------------------------------------------
//消息回调函数
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{	
	HookAllTextOut();
	
	char sClass[255]={'\0'};	
	if(nCode >= 0) 
	{  
		LPMSG pMsg = (LPMSG)lParam;		
		g_hWndTag = pMsg->hwnd;
		
		if(NULL != g_hWndTag)
		{ 
			GetClassName(g_hWndTag,sClass,256);
			//如果这个窗口的类名是T开头的
			if( 0 == strncmp(sClass,"T",1) )
			{
				
				EnumChildWindows(g_hWndTag, EnumChildWindowsProc,0);
			}

		} 
	} 
	
	return CallNextHookEx(g_hHook, nCode, wParam, lParam);

}

//-------------------------------------------------------------------------
//枚举子窗体回调函数
BOOL CALLBACK EnumChildWindowsProc( HWND hWnd, LPARAM lParam )
{
	char buff[256]={'\0'};

	if(::GetWindowLong(hWnd,GWL_STYLE)& WS_VISIBLE)
	{
		::GetWindowText(hWnd,buff,256);

		//注销这些按钮或窗体
		if(NULL != strstr(buff,"打印") || 
			NULL != strstr(buff,"Excel") ||
			NULL != strstr(buff,"导出") )
		{
			//这种只是屏蔽,界面上仍可看见
			//EnableWindow(hWnd,FALSE);
			//彻底注销,一劳永逸:-)
			DestroyWindow(hWnd);
		}

	}

	return TRUE;
}


//-------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------
//输出函数
//开始钩
DLLEXPORT BOOL WINAPI SetNHW32()
{
	//------------------------------------------------------------
	LPCTSTR iniFile = ".\\config.ini";		// “.\\”表示当前路径		
	char sTmp[256] = {'\0'}; 
	GetPrivateProfileString("NUM","FNUM",NULL,sTmp,256,iniFile);
	//MsgErr(sTmp);
	m_fNumber = strtod(sTmp,NULL);
	if(m_fNumber<=0.00)
	{
		m_fNumber = 0.50;
	}
	
	//------------------------------------------------------------

	if(g_hHook == NULL)
	{
		g_hHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, g_hinstDll, 0);
		if (g_hHook == NULL)
		{
			//MessageBox(NULL, __TEXT("Error hooking."), 
			//		   __TEXT("GetWord"), MB_OK);
			return FALSE;
		}
	}

	return TRUE;
}

//-------------------------------------------------------------------------
//输出函数
//停止钩子
DLLEXPORT BOOL WINAPI ResetNHW32()
{
	if (g_hHook != NULL)
	{
		if (!UnhookWindowsHookEx(g_hHook))
		{
			return FALSE;
		}

		g_hHook = NULL;
		
	}

	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -