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.

51 lines
1.4 KiB

  1. #ifndef SBuffer_h
  2. #define SBuffer_h
  3. #include "KrmCommStructs.h"
  4. class SBuffer{
  5. friend DRM_STATUS checkTerm(SBuffer& S);
  6. public:
  7. SBuffer(BYTE* Buf, unsigned int Len); // caller supplied;
  8. void reset(); // reset get/put pointer
  9. ~SBuffer();
  10. // Insertion operators
  11. SBuffer& operator << (const DWORD Val);
  12. SBuffer& operator << (const PVOID Ptr);
  13. SBuffer& operator << (const PDRMRIGHTS R);
  14. SBuffer& operator << (const PSTREAMKEY S);
  15. SBuffer& operator << (const PCERT C);
  16. SBuffer& operator << (const PDRMDIGEST D);
  17. // Extraction operators
  18. SBuffer& operator >> (DWORD& Val);
  19. SBuffer& operator >> (PDRMRIGHTS R);
  20. SBuffer& operator >> (PSTREAMKEY S);
  21. SBuffer& operator >> (PCERT C);
  22. // buffer access
  23. BYTE* getBuf(){return buf;};
  24. unsigned int getPutPos(){return putPos;};
  25. unsigned int getLen(){return len;};
  26. DRM_STATUS getGetPosAndAdvance(unsigned int *pos, unsigned int Len);
  27. DRM_STATUS getPutPosAndAdvance(unsigned int *pos, unsigned int Len);
  28. DRM_STATUS append(BYTE* Data, DWORD datLen);
  29. // error return
  30. DRM_STATUS getLastError(){return lasterror;};
  31. protected:
  32. void err(const char* Msg, DRM_STATUS err);
  33. DRM_STATUS lasterror;
  34. unsigned int len;
  35. unsigned int getPos, putPos;
  36. BYTE* buf;
  37. };
  38. // sentinels
  39. DRM_STATUS term(SBuffer& S);
  40. DRM_STATUS checkTerm(SBuffer& S);
  41. #endif