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

#include "drmkPCH.h"
#include "CBCKey.h"
#include "KList.h"
#include "HandleMgr.h"
//------------------------------------------------------------------------------
HandleMgr* TheHandleMgr=NULL;
//------------------------------------------------------------------------------
HandleMgr::HandleMgr(){
KCritical c(critMgr);
TheHandleMgr=this;
return;
};
//------------------------------------------------------------------------------
HandleMgr::~HandleMgr(){
KCritical c(critMgr);
POS p=connects.getHeadPosition();
while(p!=NULL){
ConnectStruct* cs=connects.getNext(p);
delete cs;
};
return;
};
//------------------------------------------------------------------------------
bool HandleMgr::newHandle(PVOID HandleRef, OUT ConnectStruct*& TheConnect){
if(!critMgr.isOK()){
_DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
return false;
};
KCritical c(critMgr);
POS p=connects.getHeadPosition();
while(p!=NULL){
ConnectStruct* cs=connects.getNext(p);
if(cs->handleRef==HandleRef){
_DbgPrintF(DEBUGLVL_VERBOSE,("Handle already exists"));
return false;
};
};
TheConnect=new ConnectStruct;
if(TheConnect==NULL){
_DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
return false;
};
memset(TheConnect, 0, sizeof(*TheConnect));
TheConnect->handleRef=HandleRef;
TheConnect->secureStreamStarted=false;
bool ok=connects.addTail(TheConnect);
if(!ok){
delete TheConnect;
return false;
};
return true;
};
//------------------------------------------------------------------------------
bool HandleMgr::deleteHandle(PVOID HandleRef){
if(!critMgr.isOK()){
_DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
return false;
};
KCritical c(critMgr);
POS p=connects.getHeadPosition();
while(p!=NULL){
POS oldP=p;
ConnectStruct* cs=connects.getNext(p);
if(cs->handleRef==HandleRef){
ConnectStruct* cs1=connects.getAt(oldP);
delete cs1;
connects.removeAt(oldP);
return true;
};
};
_DbgPrintF(DEBUGLVL_VERBOSE,("Handle does not exist"));
return false;
};
//------------------------------------------------------------------------------
ConnectStruct* HandleMgr::getConnection(PVOID HandleRef){
if(!critMgr.isOK()){
_DbgPrintF(DEBUGLVL_VERBOSE,("Out of memory"));
return false;
};
KCritical c(critMgr);
POS p=connects.getHeadPosition();
while(p!=NULL){
ConnectStruct* cs=connects.getNext(p);
if(cs->handleRef==HandleRef)return cs;
};
_DbgPrintF(DEBUGLVL_VERBOSE,("Handle does not exist"));
return NULL;
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------