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.

49 lines
1.3 KiB

  1. #include "protocol.h"
  2. #include "kernel.h"
  3. #pragma PAGEDCODE
  4. CProtocol::CProtocol()
  5. {
  6. m_Status = STATUS_INSUFFICIENT_RESOURCES;
  7. device = NULL;
  8. memory = NULL;
  9. debug = NULL;
  10. m_Status = STATUS_SUCCESS;
  11. };
  12. CProtocol::CProtocol(CDevice* device)
  13. {
  14. m_Status = STATUS_INSUFFICIENT_RESOURCES;
  15. this->device = device;
  16. memory = kernel->createMemory();
  17. debug = kernel->createDebug();
  18. if(ALLOCATED_OK(memory))
  19. {
  20. pOutputBuffer = (PUCHAR) memory->allocate(NonPagedPool,PROTOCOL_OUTPUT_BUFFER_SIZE);
  21. pInputBuffer = (PUCHAR) memory->allocate(NonPagedPool,PROTOCOL_INPUT_BUFFER_SIZE);
  22. if(pOutputBuffer && pInputBuffer)
  23. {
  24. OutputBufferLength = PROTOCOL_OUTPUT_BUFFER_SIZE;
  25. InputBufferLength = PROTOCOL_INPUT_BUFFER_SIZE;
  26. }
  27. else
  28. {
  29. if(pOutputBuffer) memory->free(pOutputBuffer);
  30. if(pInputBuffer) memory->free(pInputBuffer);
  31. pOutputBuffer = NULL;
  32. pInputBuffer = NULL;
  33. }
  34. }
  35. TRACE("New Protocol %8.8lX was created...\n",this);
  36. if(ALLOCATED_OK(memory) && device) m_Status = STATUS_SUCCESS;
  37. };
  38. CProtocol::~CProtocol()
  39. {
  40. if(pOutputBuffer) memory->free(pOutputBuffer);
  41. if(pInputBuffer) memory->free(pInputBuffer);
  42. if(memory) memory->dispose();
  43. if(debug) debug->dispose();
  44. TRACE("Protocol %8.8lX was destroied...\n",this);
  45. };