Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1990-1998 Microsoft Corporation, All Rights Reserved
  3. Module Name:
  4. FAKEIME.C
  5. ++*/
  6. #include <windows.h>
  7. #include "immdev.h"
  8. #include "fakeime.h"
  9. #include "resource.h"
  10. #include "immsec.h"
  11. extern HANDLE hMutex;
  12. /**********************************************************************/
  13. /* DLLEntry() */
  14. /**********************************************************************/
  15. BOOL WINAPI DLLEntry (
  16. HINSTANCE hInstDLL,
  17. DWORD dwFunction,
  18. LPVOID lpNot)
  19. {
  20. LPTSTR lpDicFileName;
  21. #ifdef DEBUG
  22. TCHAR szDev[80];
  23. #endif
  24. MyDebugPrint((TEXT("DLLEntry:dwFunc=%d\n"),dwFunction));
  25. switch(dwFunction)
  26. {
  27. PSECURITY_ATTRIBUTES psa;
  28. case DLL_PROCESS_ATTACH:
  29. //
  30. // Create/open a system global named mutex.
  31. // The initial ownership is not needed.
  32. // CreateSecurityAttributes() will create
  33. // the proper security attribute for IME.
  34. //
  35. psa = CreateSecurityAttributes();
  36. if ( psa != NULL ) {
  37. hMutex = CreateMutex( psa, FALSE, TEXT("FakeIme_Mutex"));
  38. FreeSecurityAttributes( psa );
  39. if ( hMutex == NULL ) {
  40. // Failed
  41. }
  42. }
  43. else {
  44. // Failed, not NT system
  45. }
  46. hInst= hInstDLL;
  47. IMERegisterClass( hInst );
  48. // Initialize for FAKEIME.
  49. lpDicFileName = (LPTSTR)&szDicFileName;
  50. lpDicFileName += GetWindowsDirectory(lpDicFileName,256);
  51. if (*(lpDicFileName-1) != TEXT('\\'))
  52. *lpDicFileName++ = TEXT('\\');
  53. LoadString( hInst, IDS_DICFILENAME, lpDicFileName, 128);
  54. SetGlobalFlags();
  55. #ifdef DEBUG
  56. wsprintf(szDev,TEXT("DLLEntry Process Attach hInst is %lx"),hInst);
  57. ImeLog(LOGF_ENTRY, szDev);
  58. #endif
  59. break;
  60. case DLL_PROCESS_DETACH:
  61. UnregisterClass(szUIClassName,hInst);
  62. UnregisterClass(szCompStrClassName,hInst);
  63. UnregisterClass(szCandClassName,hInst);
  64. UnregisterClass(szStatusClassName,hInst);
  65. if (hMutex)
  66. CloseHandle( hMutex );
  67. #ifdef DEBUG
  68. wsprintf(szDev,TEXT("DLLEntry Process Detach hInst is %lx"),hInst);
  69. ImeLog(LOGF_ENTRY, szDev);
  70. #endif
  71. break;
  72. case DLL_THREAD_ATTACH:
  73. #ifdef DEBUG
  74. wsprintf(szDev,TEXT("DLLEntry Thread Attach hInst is %lx"),hInst);
  75. ImeLog(LOGF_ENTRY, szDev);
  76. #endif
  77. break;
  78. case DLL_THREAD_DETACH:
  79. #ifdef DEBUG
  80. wsprintf(szDev,TEXT("DLLEntry Thread Detach hInst is %lx"),hInst);
  81. ImeLog(LOGF_ENTRY, szDev);
  82. #endif
  83. break;
  84. }
  85. return TRUE;
  86. }