📄 irplist.cpp
字号:
//
// File: irplist.cpp
// Description: implementation of class IrpList
//
// Created: Wed. Jan 15, 2003
//
//
// Copyright and Disclaimer:
//
// ---------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL CONEXANT BE LIABLE TO ANY PARTY FOR DIRECT,
// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE
// AND ITS DOCUMENTATION, EVEN IF CONEXANT HAS BEEN ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2000-2001 Conexant Systems, Inc.
//
// All Rights Reserved.
// ---------------------------------------------------------------
//
// Module Revision Id:
//
//
#include "common.h"
#include "irplist.h"
/////////////////////////////////////////////////////////////////////////////////////////
//IrpList::IrpList (constructor)
//
// Initializes the list head and spinlock so that the list will be ready to use.
//
IrpList::IrpList()
{
KeInitializeSpinLock (&_spin_lock);
InitializeListHead (&_list_head);
}
/////////////////////////////////////////////////////////////////////////////////////////
//IrpList::add
//
// Adds an IRP to the tail of the list
//
VOID IrpList::add(PIRP p_irp)
{
PLIST_ENTRY p_list_entry = &p_irp->Tail.Overlay.ListEntry;
KIRQL old_irql;
KeAcquireSpinLock (&_spin_lock, &old_irql);
InsertTailList (&_list_head, p_list_entry);
KeReleaseSpinLock (&_spin_lock, old_irql);
}
/////////////////////////////////////////////////////////////////////////////////////////
//IrpList::remove
//
// Removes an IRP from the head of the list
//
PIRP IrpList::remove()
{
PIRP p_irp = NULL;
KIRQL old_irql;
KeAcquireSpinLock (&_spin_lock, &old_irql);
if (!IsListEmpty(&_list_head))
{
PLIST_ENTRY p_list_entry = RemoveHeadList(&_list_head);
p_irp = (PIRP) ((PUCHAR)p_list_entry - FIELD_OFFSET(IRP, Tail.Overlay.ListEntry));
}
KeReleaseSpinLock (&_spin_lock, old_irql);
return p_irp;
}
/////////////////////////////////////////////////////////////////////////////////////////
//IrpList::remove
//
//Removes a specific IRP from the list. Returns TRUE if the
// IRP was in the list
//
BOOLEAN IrpList::remove(PIRP p_irp)
{
//Get the list entry from the IRP
PLIST_ENTRY p_list_entry = &p_irp->Tail.Overlay.ListEntry;
BOOLEAN found = FALSE;
KIRQL old_irql;
KeAcquireSpinLock (&_spin_lock, &old_irql);
// Loop through the linked list checking for the IRP's entry.
PLIST_ENTRY p_current_entry = _list_head.Flink;
while (p_current_entry != &_list_head)
{
if(p_current_entry == p_list_entry)
{
//The IRP was found in the list. Remove it.
RemoveEntryList(p_list_entry);
found = TRUE;
break;
}
p_current_entry = p_current_entry->Flink;
}
KeReleaseSpinLock (&_spin_lock, old_irql);
return found;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -