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.

85 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Force640x480x8.cpp
  5. Abstract:
  6. This shim is for games that assume the start resolution is 640x480x16.
  7. Notes:
  8. This is a general purpose shim.
  9. History:
  10. 01/20/2000 linstev Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(Force640x480x16)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_END
  17. #define CDS_WIDTH 640
  18. #define CDS_HEIGHT 480
  19. #define CDS_BITS 16
  20. VOID
  21. ChangeMode()
  22. {
  23. DEVMODEA dm;
  24. __try {
  25. EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dm);
  26. if ((dm.dmPelsWidth != CDS_WIDTH) ||
  27. (dm.dmPelsHeight != CDS_HEIGHT) ||
  28. (dm.dmBitsPerPel != CDS_BITS)) {
  29. //
  30. // The mode is different, so change
  31. //
  32. dm.dmPelsWidth = CDS_WIDTH;
  33. dm.dmPelsHeight = CDS_HEIGHT;
  34. dm.dmBitsPerPel = CDS_BITS;
  35. ChangeDisplaySettingsA(&dm, CDS_FULLSCREEN);
  36. }
  37. }
  38. __except(1) {
  39. DPFN( eDbgLevelWarning, "Exception trying to change mode");
  40. };
  41. }
  42. /*++
  43. Register hooked functions
  44. --*/
  45. BOOL
  46. NOTIFY_FUNCTION(
  47. DWORD fdwReason)
  48. {
  49. if (fdwReason == SHIM_STATIC_DLLS_INITIALIZED) {
  50. ChangeMode();
  51. }
  52. return TRUE;
  53. }
  54. HOOK_BEGIN
  55. CALL_NOTIFY_FUNCTION
  56. HOOK_END
  57. IMPLEMENT_SHIM_END