#define ResourceOwnedExclusive 0x80
#define ResourceDisableBoost 0x08
+//#ifdef __USE_W32API
+//#define NONAMELESSUNION
+//#endif
+
+
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
return(ExAcquireResourceExclusiveLite(Resource,FALSE));
}
+#ifdef ExAcquireResourceExclusive
+#undef ExAcquireResourceExclusive
+#endif
+
+/*
+ * @implemented
+ */
BOOLEAN
STDCALL
ExAcquireResourceExclusive (
return(ExAcquireResourceExclusiveLite(Resource,Wait));
}
+
+/*
+ * @implemented
+ */
BOOLEAN
STDCALL
ExAcquireResourceExclusiveLite (
&& Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread())
{
/* it's ok : same lock for same thread */
- Resource->OwnerThreads[0].a.OwnerCount++;
+ Resource->OwnerThreads[0].OwnerCount++;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireResourceExclusiveLite() = TRUE\n");
return(TRUE);
Resource->Flag |= ResourceOwnedExclusive;
Resource->ActiveCount = 1;
Resource->OwnerThreads[0].OwnerThread = ExGetCurrentResourceThread();
- Resource->OwnerThreads[0].a.OwnerCount = 1;
+ Resource->OwnerThreads[0].OwnerCount = 1;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireResourceExclusiveLite() = TRUE\n");
return(TRUE);
if (Resource->OwnerThreads[1].OwnerThread == ResourceThreadId)
{
- Resource->OwnerThreads[1].a.OwnerCount--;
- if (Resource->OwnerThreads[1].a.OwnerCount == 0)
+ Resource->OwnerThreads[1].OwnerCount--;
+ if (Resource->OwnerThreads[1].OwnerCount == 0)
{
Resource->ActiveCount--;
Resource->OwnerThreads[1].OwnerThread = 0;
return(FALSE);;
}
- for (i=0; i<Resource->OwnerThreads[1].a.TableSize; i++)
+ for (i=0; i<Resource->OwnerThreads[1].TableSize; i++)
{
if (Resource->OwnerTable[i].OwnerThread == ResourceThreadId)
{
- Resource->OwnerTable[i].a.OwnerCount--;
- if (Resource->OwnerTable[i].a.OwnerCount == 0)
+ Resource->OwnerTable[i].OwnerCount--;
+ if (Resource->OwnerTable[i].OwnerCount == 0)
{
Resource->ActiveCount--;
Resource->OwnerTable[i].OwnerThread = 0;
{
/* no owner, it's easy */
Resource->OwnerThreads[1].OwnerThread = ExGetCurrentResourceThread();
- Resource->OwnerThreads[1].a.OwnerCount = 1;
+ Resource->OwnerThreads[1].OwnerCount = 1;
if (Resource->OwnerTable != NULL)
{
ExFreePool(Resource->OwnerTable);
TAG_OWNER_TABLE);
if (Resource->OwnerTable == NULL)
{
- KeBugCheck(0);
+ KEBUGCHECK(0);
return(FALSE);
}
memset(Resource->OwnerTable,0,sizeof(OWNER_ENTRY)*3);
sizeof(OWNER_ENTRY));
Resource->OwnerThreads[1].OwnerThread = 0;
- Resource->OwnerThreads[1].a.TableSize = 3;
+ Resource->OwnerThreads[1].TableSize = 3;
Resource->OwnerTable[1].OwnerThread = CurrentThread;
- Resource->OwnerTable[1].a.OwnerCount = 1;
+ Resource->OwnerTable[1].OwnerCount = 1;
Resource->ActiveCount++;
return(TRUE);
DPRINT("Search free entries\n");
DPRINT("Number of entries %d\n",
- Resource->OwnerThreads[1].a.TableSize);
+ Resource->OwnerThreads[1].TableSize);
freeEntry = NULL;
- for (i=0; i<Resource->OwnerThreads[1].a.TableSize; i++)
+ for (i=0; i<Resource->OwnerThreads[1].TableSize; i++)
{
if (Resource->OwnerTable[i].OwnerThread == CurrentThread)
{
DPRINT("Thread already owns resource\n");
- Resource->OwnerTable[i].a.OwnerCount++;
+ Resource->OwnerTable[i].OwnerCount++;
return(TRUE);
}
if (Resource->OwnerTable[i].OwnerThread == 0)
freeEntry =
ExAllocatePoolWithTag(NonPagedPool,
sizeof(OWNER_ENTRY)*
- (Resource->OwnerThreads[1].a.TableSize+1),
+ (Resource->OwnerThreads[1].TableSize+1),
TAG_OWNER_TABLE);
if (freeEntry == NULL)
{
- KeBugCheck(0);
+ KEBUGCHECK(0);
return(FALSE);
}
memcpy(freeEntry,Resource->OwnerTable,
- sizeof(OWNER_ENTRY)*(Resource->OwnerThreads[1].a.TableSize));
+ sizeof(OWNER_ENTRY)*(Resource->OwnerThreads[1].TableSize));
ExFreePool(Resource->OwnerTable);
Resource->OwnerTable=freeEntry;
- freeEntry=&Resource->OwnerTable[Resource->OwnerThreads[1].a.TableSize];
- Resource->OwnerThreads[1].a.TableSize++;
+ freeEntry=&Resource->OwnerTable[Resource->OwnerThreads[1].TableSize];
+ Resource->OwnerThreads[1].TableSize++;
}
DPRINT("Creating entry\n");
freeEntry->OwnerThread=ExGetCurrentResourceThread();
- freeEntry->a.OwnerCount=1;
+ freeEntry->OwnerCount=1;
Resource->ActiveCount++;
return(TRUE);
}
+/*
+ * @implemented
+ */
BOOLEAN
STDCALL
ExAcquireResourceSharedLite (
/*
* NOTE: Is this correct? Seems the same as ExConvertExclusiveToShared
*/
- Resource->OwnerThreads[0].a.OwnerCount++;
+ Resource->OwnerThreads[0].OwnerCount++;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireResourceSharedLite() = TRUE\n");
return(TRUE);
return(TRUE);
}
+/*
+ * @implemented
+ */
VOID
STDCALL
ExConvertExclusiveToSharedLite (
if (!(Resource->Flag & ResourceOwnedExclusive))
{
/* Might not be what the caller expects, better bug check */
- KeBugCheck(0);
+ KEBUGCHECK(0);
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
return;
}
//transfer infos from entry 0 to entry 1 and erase entry 0
Resource->OwnerThreads[1].OwnerThread=Resource->OwnerThreads[0].OwnerThread;
- Resource->OwnerThreads[1].a.OwnerCount=Resource->OwnerThreads[0].a.OwnerCount;
+ Resource->OwnerThreads[1].OwnerCount=Resource->OwnerThreads[0].OwnerCount;
Resource->OwnerThreads[0].OwnerThread=0;
- Resource->OwnerThreads[0].a.OwnerCount=0;
+ Resource->OwnerThreads[0].OwnerCount=0;
/* erase exclusive flag */
Resource->Flag &= (~ResourceOwnedExclusive);
/* if no shared waiters, that's all */
DPRINT("ExConvertExclusiveToSharedLite() finished\n");
}
+/*
+ * @implemented
+ */
VOID
STDCALL
ExDisableResourceBoostLite (
Resource->Flag |= ResourceDisableBoost;
}
+/*
+ * @implemented
+ */
ULONG
STDCALL
ExGetExclusiveWaiterCount (
return(Resource->NumberOfExclusiveWaiters);
}
+/*
+ * @implemented
+ */
BOOLEAN
STDCALL
ExAcquireSharedStarveExclusive (
if (Resource->ActiveCount == 0)
{
Resource->OwnerThreads[1].OwnerThread=ExGetCurrentResourceThread();
- Resource->OwnerThreads[1].a.OwnerCount=1;
+ Resource->OwnerThreads[1].OwnerCount=1;
Resource->ActiveCount=1;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireSharedStarveExclusive() = TRUE\n");
&& Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread())
{
/* exclusive, but by same thread : it's ok */
- Resource->OwnerThreads[0].a.OwnerCount++;
+ Resource->OwnerThreads[0].OwnerCount++;
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExAcquireSharedStarveExclusive() = TRUE\n");
return(TRUE);
return(TRUE);
}
+/*
+ * @implemented
+ */
BOOLEAN
STDCALL
ExAcquireSharedWaitForExclusive (
return(ExAcquireResourceSharedLite(Resource,Wait));
}
+
+#ifdef ExDeleteResource
+#undef ExDeleteResource
+#endif
+
+
+/*
+ * @implemented
+ */
NTSTATUS
STDCALL
ExDeleteResource (
return(ExDeleteResourceLite(Resource));
}
+/*
+ * @implemented
+ */
NTSTATUS
STDCALL
ExDeleteResourceLite (
return(STATUS_SUCCESS);;
}
+/*
+ * @implemented
+ */
ULONG
STDCALL
ExGetSharedWaiterCount (
return(Resource->NumberOfSharedWaiters);
}
+
+#ifdef ExInitializeResource
+#undef ExInitializeResource
+#endif
+
+/*
+ * @implemented
+ */
NTSTATUS
STDCALL
ExInitializeResource (
return(ExInitializeResourceLite(Resource));
}
+/*
+ * @implemented
+ */
NTSTATUS STDCALL
ExInitializeResourceLite (PERESOURCE Resource)
{
return(0);
}
+/*
+ * @implemented
+ */
BOOLEAN
STDCALL
ExIsResourceAcquiredExclusiveLite (
&& Resource->OwnerThreads[0].OwnerThread==ExGetCurrentResourceThread());
}
-ULONG
-STDCALL
-ExIsResourceAcquiredSharedLite (
- PERESOURCE Resource
- )
+
+
+#ifdef ExIsResourceAcquiredSharedLite
+#undef ExIsResourceAcquiredSharedLite
+#endif
+
+
+/*
+ * @implemented
+ */
+
+
+//NTOSAPI
+//DDKAPI
+USHORT STDCALL
+ExIsResourceAcquiredSharedLite(
+ IN PERESOURCE Resource)
/*
* FUNCTION: Returns whether the current thread has shared access to a given
* resource
ULONG i;
if (Resource->OwnerThreads[0].OwnerThread == ExGetCurrentResourceThread())
{
- return(Resource->OwnerThreads[0].a.OwnerCount);
+ return(Resource->OwnerThreads[0].OwnerCount);
}
if (Resource->OwnerThreads[1].OwnerThread == ExGetCurrentResourceThread())
{
- return(Resource->OwnerThreads[1].a.OwnerCount);
+ return(Resource->OwnerThreads[1].OwnerCount);
}
- if (!Resource->OwnerThreads[1].a.TableSize)
+ if (!Resource->OwnerThreads[1].TableSize)
{
return(0);
}
- for (i=0; i<Resource->OwnerThreads[1].a.TableSize; i++)
+ for (i=0; i<Resource->OwnerThreads[1].TableSize; i++)
{
if (Resource->OwnerTable[i].OwnerThread==ExGetCurrentResourceThread())
{
- return Resource->OwnerTable[i].a.OwnerCount;
+ return Resource->OwnerTable[i].OwnerCount;
}
}
return(0);
}
+/*
+ * @implemented
+ */
VOID
STDCALL
ExReinitializeResourceLite (
ExFreePool(Resource->OwnerTable);
}
Resource->OwnerThreads[0].OwnerThread=0;
- Resource->OwnerThreads[0].a.OwnerCount=0;
+ Resource->OwnerThreads[0].OwnerCount=0;
Resource->OwnerThreads[1].OwnerThread=0;
- Resource->OwnerThreads[1].a.OwnerCount=0;
+ Resource->OwnerThreads[1].OwnerCount=0;
}
+/*
+ * @implemented
+ */
VOID
FASTCALL
ExReleaseResourceLite (
ExGetCurrentResourceThread()));
}
+
+
+#ifdef ExReleaseResourceForThread
+#undef ExReleaseResourceForThread
+#endif
+
+
+/*
+ * @implemented
+ */
VOID
STDCALL
ExReleaseResourceForThread (
return(ExReleaseResourceForThreadLite(Resource,ResourceThreadId));
}
+
+/*
+ * @unimplemented
+ */
VOID
STDCALL
ExReleaseResourceForThreadLite (
{
DPRINT("Releasing from exclusive access\n");
- Resource->OwnerThreads[0].a.OwnerCount--;
- if (Resource->OwnerThreads[0].a.OwnerCount > 0)
+ Resource->OwnerThreads[0].OwnerCount--;
+ if (Resource->OwnerThreads[0].OwnerCount > 0)
{
KeReleaseSpinLock(&Resource->SpinLock, oldIrql);
DPRINT("ExReleaseResourceForThreadLite() finished\n");
}
+/*
+ * @unimplemented
+ */
VOID
STDCALL
ExSetResourceOwnerPointer (