Source code of Windows XP (NT5)
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.

50 lines
1.3 KiB

  1. #include "pch.h"
  2. #include "SampleSW.h"
  3. #pragma hdrstop
  4. // Needed as MSVC doesn't throw bad_alloc upon failed new(), unless
  5. // we specifically make it do.
  6. _PNH g_OldNewHandler= NULL;
  7. int _cdecl NewHandlerThatThrows( size_t size )
  8. {
  9. throw std::bad_alloc();
  10. // Tell new to stop allocation attempts.
  11. return 0;
  12. }
  13. CMyDriver* CMyDriver::sm_pGlobalDriver= NULL;
  14. DX8SDDIFW::COSDetector DX8SDDIFW::g_OSDetector;
  15. BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved)
  16. {
  17. switch (dwReason)
  18. {
  19. case DLL_PROCESS_ATTACH:
  20. g_OldNewHandler = _set_new_handler( NewHandlerThatThrows);
  21. CMyDriver::sm_pGlobalDriver= new CMyDriver;
  22. break;
  23. // DLL_PROCESS_DETACH will be called if ATTACH returned FALSE.
  24. case DLL_PROCESS_DETACH:
  25. delete CMyDriver::sm_pGlobalDriver;
  26. CMyDriver::sm_pGlobalDriver= NULL;
  27. _set_new_handler( g_OldNewHandler);
  28. break;
  29. case DLL_THREAD_ATTACH:
  30. case DLL_THREAD_DETACH:
  31. break;
  32. }
  33. return TRUE;
  34. }
  35. HRESULT APIENTRY
  36. D3D8GetSWInfo( D3DCAPS8* pCaps, PD3D8_SWCALLBACKS pCallbacks,
  37. DWORD* pNumTextures, DDSURFACEDESC** ppTexList)
  38. {
  39. return CMyDriver::sm_pGlobalDriver->GetSWInfo( *pCaps, *pCallbacks,
  40. *pNumTextures, *ppTexList );
  41. }