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.

77 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. TonkaConstruction.cpp
  5. Abstract:
  6. Workaround for GDI behavior difference when bltting palettized bitmaps. On
  7. Win9x GDI first looked at the current index for a color match when building
  8. a lookup table, but on NT, it simply searches from the beginning. This
  9. breaks palette animation. The fix is to make sure that the entries that are
  10. animated are different from all the others.
  11. Notes:
  12. This is an app specific shim.
  13. History:
  14. 12/02/2001 linstev Created
  15. --*/
  16. #include "precomp.h"
  17. IMPLEMENT_SHIM_BEGIN(TonkaConstruction)
  18. #include "ShimHookMacro.h"
  19. APIHOOK_ENUM_BEGIN
  20. APIHOOK_ENUM_ENTRY(CreatePalette)
  21. APIHOOK_ENUM_END
  22. /*++
  23. Make sure index 10->15 are different from all other entries.
  24. --*/
  25. HPALETTE
  26. APIHOOK(CreatePalette)(
  27. CONST LOGPALETTE *lplgpl
  28. )
  29. {
  30. Restart:
  31. for (int i=10; i<=15; i++) {
  32. LPDWORD p1 = (DWORD *)&lplgpl->palPalEntry[i];
  33. for (int j=16; j<=255; j++) {
  34. LPDWORD p2 = (DWORD *)&lplgpl->palPalEntry[j];
  35. if (*p1 == *p2) {
  36. //
  37. // Entry is the same, so make it different
  38. //
  39. *p1 = *p1-1;
  40. goto Restart;
  41. }
  42. }
  43. }
  44. return ORIGINAL_API(CreatePalette)(lplgpl);
  45. }
  46. /*++
  47. Register hooked functions
  48. --*/
  49. HOOK_BEGIN
  50. APIHOOK_ENTRY(GDI32.DLL, CreatePalette)
  51. HOOK_END
  52. IMPLEMENT_SHIM_END