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.

81 lines
2.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: ilbmem.hxx
  7. //
  8. // Contents: ILockBytes memory implementation
  9. //
  10. // Classes: CMapBytes
  11. //
  12. //--------------------------------------------------------------------------
  13. #ifndef __ILB_HXX__
  14. #include "../../h/ref.hxx"
  15. #define ULISetLow(li, v) ((li).u.LowPart = (v))
  16. #define ULISetHigh(li, v) ((li).u.HighPart = (v))
  17. #define ULIGetLow(li) ((li).u.LowPart)
  18. #define ULIGetHigh(li) ((li).u.HighPart)
  19. #ifdef _WIN32
  20. #define AtomicInc(lp) InterlockedIncrement(lp)
  21. #define AtomicDec(lp) InterlockedDecrement(lp)
  22. #else
  23. inline void AtomicInc(long *lp) { (*lp)++; }
  24. inline void AtomicDec(long *lp) { (*lp)--; }
  25. #endif
  26. #if DBG == 1
  27. DECLARE_DEBUG(ol);
  28. #define olDebugOut(parms) olInlineDebugOut parms
  29. #include <assert.h>
  30. #define olAssert(exp) assert(exp)
  31. #else // DBG != 1
  32. #define olDebugOut(parms)
  33. #define olAssert(exp)
  34. #endif // DBG == 1
  35. class CMapBytes : public ILockBytes
  36. {
  37. public:
  38. CMapBytes(void);
  39. STDMETHOD(QueryInterface) (REFIID riid, LPVOID FAR* ppvObj);
  40. STDMETHOD_(ULONG,AddRef) (void);
  41. STDMETHOD_(ULONG,Release) (void);
  42. STDMETHOD(ReadAt) (ULARGE_INTEGER ulOffset,
  43. VOID HUGEP *pv,
  44. ULONG cb,
  45. ULONG FAR *pcbRead);
  46. STDMETHOD(WriteAt) (ULARGE_INTEGER ulOffset,
  47. VOID const HUGEP *pv,
  48. ULONG cb,
  49. ULONG FAR *pcbWritten);
  50. STDMETHOD(Flush) (void);
  51. STDMETHOD(GetSize) (ULARGE_INTEGER FAR *pcb);
  52. STDMETHOD(SetSize) (ULARGE_INTEGER cb);
  53. STDMETHOD(LockRegion) (ULARGE_INTEGER libOffset,
  54. ULARGE_INTEGER cb,
  55. DWORD dwLockType);
  56. STDMETHOD(UnlockRegion) (ULARGE_INTEGER libOffset,
  57. ULARGE_INTEGER cb,
  58. DWORD dwLockType);
  59. STDMETHOD(Stat) (STATSTG FAR *pstatstg, DWORD grfStatFlag);
  60. private:
  61. LONG _ulRef; // reference count
  62. ULONG _ulSize; // memory map size
  63. void FAR *_pv; // memory map
  64. };
  65. #endif // #ifndef __ILB_HXX__