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.

66 lines
1.8 KiB

  1. #define __DEBUG_MODULE_IN_USE__ CIC_DUALMODE_CPP
  2. #include "stdhdrs.h"
  3. //@doc
  4. // @doc
  5. /**********************************************************************
  6. *
  7. * @module DualMode.cpp |
  8. *
  9. * Implements functions that differ in USER and KERNEL modes.
  10. *
  11. * History
  12. * ----------------------------------------------------------
  13. * Mitchell S. Dernis Original
  14. *
  15. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  16. *
  17. * @topic DualMode |
  18. *
  19. **********************************************************************/
  20. #ifdef COMPILE_FOR_WDM_KERNEL_MODE
  21. //
  22. // @topic Overriding global new and delete |
  23. // The global new and delete are overriden to require
  24. // a placement argument specify the pool memory comes from.
  25. // The POOL_TYPE structure is defined in the NTDDK specifying
  26. // the page.<nl>
  27. // The user mode version ignores the POOL_TYPE (but must typedef it)
  28. // and uses the global new and delete.
  29. //
  30. // The debug version of new uses ExAllocatePoolWithTag (the tag is CICN),
  31. // the release version uses ExAllocatePool
  32. #if (DBG==1)
  33. void * __cdecl operator new(unsigned int uSize, POOL_TYPE poolType, LPSTR lpszFile, unsigned int uLine)
  34. {
  35. void *pvRet;
  36. pvRet = ExAllocatePoolWithTag(poolType, uSize, 'NCIC');
  37. DbgPrint("CIC: new allocating %d bytes at 0x%0.8x, called from file: %s, line:%d\n", uSize, pvRet, lpszFile, uLine);
  38. return pvRet;
  39. }
  40. #else
  41. void * __cdecl operator new(unsigned int uSize, POOL_TYPE poolType)
  42. {
  43. return ExAllocatePool(poolType, uSize);
  44. }
  45. #endif
  46. void __cdecl operator delete (void * pvRawMemory)
  47. {
  48. #if (DBG==1)
  49. DbgPrint("CIC: delete called for 0x%0.8x\n", pvRawMemory);
  50. #endif
  51. if( NULL == pvRawMemory ) return;
  52. ExFreePool( pvRawMemory );
  53. return;
  54. }
  55. #else //END WDM KERNEL MODE SECTION
  56. #endif //END USER MODE SECTION