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.

75 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. CorrectCreateIcon.cpp
  5. Abstract:
  6. Clears Alpha channel of ICON's XOR-bits to make them look pretty.
  7. Notes:
  8. This is a general purpose shim.
  9. History:
  10. 1/23/2001 a-larrsh Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(CorrectCreateIcon)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_ENTRY(CreateIcon)
  17. APIHOOK_ENUM_END
  18. HICON APIHOOK(CreateIcon)(
  19. HINSTANCE hInstance, // handle to application instance
  20. int nWidth, // icon width
  21. int nHeight, // icon height
  22. BYTE cPlanes, // number of planes in XOR bitmask
  23. BYTE cBitsPixel, // number of BPP in XOR bitmask
  24. CONST BYTE *lpbANDbits, // AND bitmask
  25. CONST BYTE *lpbXORbits // XOR bitmask
  26. )
  27. {
  28. if (lpbXORbits)
  29. {
  30. if(cBitsPixel == 32)
  31. {
  32. DPFN( eDbgLevelInfo, "Zero Alpha - CreateIcon(hInstance%x, nWidth:%d, nHeight:%d, cPlanes:%d, cBitsPixel:%d, lpbANDbits:%x, lpbXORbits:%x)", hInstance, nWidth, nHeight, (int)cPlanes, (int)cBitsPixel, lpbANDbits, lpbXORbits);
  33. int n = (nWidth*nHeight);
  34. DWORD *pXORbits = (DWORD*)lpbXORbits;
  35. while(n--)
  36. {
  37. // Clears the alpha channel of XOR-bits only.
  38. *(pXORbits++) &= 0x00FFFFFF;
  39. }
  40. }
  41. }
  42. return ORIGINAL_API(CreateIcon)(hInstance, nWidth, nHeight, cPlanes, cBitsPixel, lpbANDbits, lpbXORbits);
  43. }
  44. /*++
  45. Register hooked functions
  46. --*/
  47. HOOK_BEGIN
  48. APIHOOK_ENTRY(USER32.DLL, CreateIcon)
  49. HOOK_END
  50. IMPLEMENT_SHIM_END