Example #1
0
ULONG
NTAPI
ExInterlockedAddUlong(
    IN OUT PULONG Addend,
    IN ULONG Increment,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    ULONG OldValue;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Save the old value */
    OldValue = *Addend;

    /* Do the operation */
    *Addend += Increment;

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* Return the old value */
    return OldValue;
}
Example #2
0
PSINGLE_LIST_ENTRY
FASTCALL
ExfInterlockedPushEntryList(
    IN OUT PSINGLE_LIST_ENTRY ListHead,
    IN PSINGLE_LIST_ENTRY ListEntry,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    PSINGLE_LIST_ENTRY OldListEntry;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Save the old top entry */
    OldListEntry = ListHead->Next;

    /* Push a new entry on the list */
    PushEntryList(ListHead, ListEntry);

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* return the entry */
    return OldListEntry;
}
Example #3
0
LARGE_INTEGER
NTAPI
ExInterlockedAddLargeInteger(
    IN OUT PLARGE_INTEGER Addend,
    IN LARGE_INTEGER Increment,
    IN OUT PKSPIN_LOCK Lock)
{
    LARGE_INTEGER OldValue;
    BOOLEAN Enable;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Save the old value */
    OldValue.QuadPart = Addend->QuadPart;

    /* Do the operation */
    Addend->QuadPart += Increment.QuadPart;

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* Return the old value */
    return OldValue;
}
Example #4
0
PSINGLE_LIST_ENTRY
FASTCALL
ExfInterlockedPopEntryList(
    IN OUT PSINGLE_LIST_ENTRY ListHead,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    PSINGLE_LIST_ENTRY ListEntry;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Pop the first entry from the list */
    ListEntry = PopEntryList(ListHead);
#if DBG
    if (ListEntry)
        ListEntry->Next = (PSINGLE_LIST_ENTRY)0xBADDD0FF;
#endif

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* return the entry */
    return ListEntry;
}
Example #5
0
PLIST_ENTRY
FASTCALL
ExfInterlockedRemoveHeadList(
    IN OUT PLIST_ENTRY ListHead,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    PLIST_ENTRY ListEntry;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Check if the list is empty */
    if (IsListEmpty(ListHead))
    {
        /* Return NULL */
        ListEntry = NULL;
    }
    else
    {
        /* Remove the first entry from the list head */
        ListEntry = RemoveHeadList(ListHead);
#if DBG
        ListEntry->Flink = (PLIST_ENTRY)0x0BADD0FF;
        ListEntry->Blink = (PLIST_ENTRY)0x0BADD0FF;
#endif
    }

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* return the entry */
    return ListEntry;
}
Example #6
0
PLIST_ENTRY
FASTCALL
ExfInterlockedInsertTailList(
    IN OUT PLIST_ENTRY ListHead,
    IN PLIST_ENTRY ListEntry,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    PLIST_ENTRY LastEntry;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Save the last entry */
    LastEntry = ListHead->Blink;

    /* Insert the new entry */
    InsertTailList(ListHead, ListEntry);

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* Return the old last entry or NULL for empty list */
    return (LastEntry == ListHead) ? NULL : LastEntry;
}
Example #7
0
PLIST_ENTRY
NTAPI
ExInterlockedInsertHeadList(
    IN OUT PLIST_ENTRY ListHead,
    IN OUT PLIST_ENTRY ListEntry,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    PLIST_ENTRY FirstEntry;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Save the first entry */
    FirstEntry = ListHead->Flink;

    /* Insert the new entry */
    InsertHeadList(ListHead, ListEntry);

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* Return the old first entry or NULL for empty list */
    return (FirstEntry == ListHead) ? NULL : FirstEntry;
}
Example #8
0
PSINGLE_LIST_ENTRY
NTAPI
ExInterlockedPopEntryList(
    IN OUT PSINGLE_LIST_ENTRY ListHead,
    IN OUT PKSPIN_LOCK Lock)
{
    BOOLEAN Enable;
    PSINGLE_LIST_ENTRY ListEntry;

    /* Disable interrupts and acquire the spinlock */
    Enable = _ExiDisableInteruptsAndAcquireSpinlock(Lock);

    /* Pop the first entry from the list */
    ListEntry = PopEntryList(ListHead);

    /* Release the spinlock and restore interrupts */
    _ExiReleaseSpinLockAndRestoreInterupts(Lock, Enable);

    /* Return the entry */
    return ListEntry;
}