示例#1
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
(void) hInstance;
(void) hPrevInstance;
(void) lpCmdLine;
(void) nCmdShow;

TCHAR dir[MAX_PATH], libName[MAX_PATH], *pch;
HWND hServerWnd;
ActivateSpyFn activateSpyFn = NULL;
HINSTANCE spyDll = NULL;
int ret = -1;
MSG msg;

	if( !parentIsGD() )
		return -1;

	while( 1 ) {
		ThTypes_Init();
		if( GlobalData == NULL || GlobalData32 == NULL) 
			break;
		hServerWnd = LongToHandle( GlobalData32->ServerWND );

		GetModuleFileName( NULL, dir, MAX_PATH );
		pch = dir + lstrlen( dir );
		while( pch != dir && *pch != '\\' ) pch--;
		*(pch + 1) = 0;
		lstrcpy( libName, dir );
		lstrcat( libName, _T("GdTextOutSpy64.dll") );

		SetLowLabelToGDSynchroObjects();

		memset( GlobalData, 0, sizeof( TGlobalDLLData ) );
		lstrcpy( GlobalData->LibName, dir );
		lstrcat( GlobalData->LibName, _T("GdTextOutHook64.dll") );
		GlobalData->ServerWND = hServerWnd;

		spyDll = LoadLibrary( libName );
		if ( spyDll )
			activateSpyFn = ( ActivateSpyFn ) GetProcAddress( spyDll, "ActivateTextOutSpying" );
		if( !activateSpyFn ) {
			ret = -2;
			break;
		}

		activateSpyFn( TRUE );

		while( GetMessage( &msg, 0, 0, 0 ) )
			DispatchMessage( &msg );

		activateSpyFn( FALSE );

		ret = 0;
		break;
	}

	if( spyDll )
		FreeLibrary( spyDll );
	ThTypes_End();
	return ret;
}
示例#2
0
BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
(void) reserved;
    switch (reason)
    {
      case DLL_PROCESS_ATTACH:
			g_hInstance = hInst;
			ThTypes_Init();
#ifdef __WIN64
			if( GlobalData == NULL || GlobalData32 == NULL ) {
#else
			if( GlobalData == NULL ) {
#endif
				ThTypes_End();
				return FALSE;
			}
			ourProcessID = GetCurrentProcessId();
			if(hSynhroMutex==0) {
				hSynhroMutex = CreateMutex(NULL, FALSE, "GoldenDictTextOutSpyMutex");
				if(hSynhroMutex==0) {
					return(FALSE);
				}
			}
			uGdAskMessage = RegisterWindowMessage(GD_MESSAGE_NAME);
			FindGetPhysicalCursorPos();
        break;

      case DLL_PROCESS_DETACH:
//			if(hSynhroMutex) WaitForSingleObject(hSynhroMutex, INFINITE);
			if(hSynhroMutex) WaitForSingleObject(hSynhroMutex, 2000);
			if (TimerID) {
				KillTimer(0, TimerID);
				TimerID=0;
			}
			if(hSynhroMutex) {
				ReleaseMutex(hSynhroMutex);
				CloseHandle(hSynhroMutex);
				hSynhroMutex=0;
			}
			{
				MSG msg ;
				while (PeekMessage (&msg, 0, WM_TIMER, WM_TIMER, PM_REMOVE));
			}
			if ( (hGetWordLib != 0) && (hGetWordLib != INVALID_HANDLE_VALUE) ) {
				FreeLibrary(hGetWordLib);
			}
			ThTypes_End();
        break;

      case DLL_THREAD_ATTACH:
        break;

      case DLL_THREAD_DETACH:
        break;
    }

    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}