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.

91 lines
2.7 KiB

  1. #include "drmkPCH.h"
  2. #include "CBCKey.h"
  3. #include "KList.h"
  4. #include "HandleMgr.h"
  5. //------------------------------------------------------------------------------
  6. HandleMgr* TheHandleMgr=NULL;
  7. //------------------------------------------------------------------------------
  8. HandleMgr::HandleMgr(){
  9. KCritical c(critMgr);
  10. TheHandleMgr=this;
  11. return;
  12. };
  13. //------------------------------------------------------------------------------
  14. HandleMgr::~HandleMgr(){
  15. KCritical c(critMgr);
  16. POS p=connects.getHeadPosition();
  17. while(p!=NULL){
  18. ConnectStruct* cs=connects.getNext(p);
  19. delete cs;
  20. };
  21. return;
  22. };
  23. //------------------------------------------------------------------------------
  24. bool HandleMgr::newHandle(PVOID HandleRef, OUT ConnectStruct*& TheConnect){
  25. if(!critMgr.isOK()){
  26. _DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
  27. return false;
  28. };
  29. KCritical c(critMgr);
  30. POS p=connects.getHeadPosition();
  31. while(p!=NULL){
  32. ConnectStruct* cs=connects.getNext(p);
  33. if(cs->handleRef==HandleRef){
  34. _DbgPrintF(DEBUGLVL_VERBOSE,("Handle already exists"));
  35. return false;
  36. };
  37. };
  38. TheConnect=new ConnectStruct;
  39. if(TheConnect==NULL){
  40. _DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
  41. return false;
  42. };
  43. memset(TheConnect, 0, sizeof(*TheConnect));
  44. TheConnect->handleRef=HandleRef;
  45. TheConnect->secureStreamStarted=false;
  46. bool ok=connects.addTail(TheConnect);
  47. if(!ok){
  48. delete TheConnect;
  49. return false;
  50. };
  51. return true;
  52. };
  53. //------------------------------------------------------------------------------
  54. bool HandleMgr::deleteHandle(PVOID HandleRef){
  55. if(!critMgr.isOK()){
  56. _DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
  57. return false;
  58. };
  59. KCritical c(critMgr);
  60. POS p=connects.getHeadPosition();
  61. while(p!=NULL){
  62. POS oldP=p;
  63. ConnectStruct* cs=connects.getNext(p);
  64. if(cs->handleRef==HandleRef){
  65. ConnectStruct* cs1=connects.getAt(oldP);
  66. delete cs1;
  67. connects.removeAt(oldP);
  68. return true;
  69. };
  70. };
  71. _DbgPrintF(DEBUGLVL_VERBOSE,("Handle does not exist"));
  72. return false;
  73. };
  74. //------------------------------------------------------------------------------
  75. ConnectStruct* HandleMgr::getConnection(PVOID HandleRef){
  76. if(!critMgr.isOK()){
  77. _DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
  78. return false;
  79. };
  80. KCritical c(critMgr);
  81. POS p=connects.getHeadPosition();
  82. while(p!=NULL){
  83. ConnectStruct* cs=connects.getNext(p);
  84. if(cs->handleRef==HandleRef)return cs;
  85. };
  86. _DbgPrintF(DEBUGLVL_VERBOSE,("Handle does not exist"));
  87. return NULL;
  88. };
  89. //------------------------------------------------------------------------------
  90. //------------------------------------------------------------------------------
  91. //------------------------------------------------------------------------------