Author: hbelusca
Date: Mon Sep 2 21:09:56 2013
New Revision: 59965
URL:
http://svn.reactos.org/svn/reactos?rev=59965&view=rev
Log:
[NTOS:LPC]: Code formatting, with hardocded_flags--;
Modified:
trunk/reactos/ntoskrnl/include/internal/lpc.h
trunk/reactos/ntoskrnl/lpc/close.c
trunk/reactos/ntoskrnl/lpc/reply.c
trunk/reactos/ntoskrnl/lpc/send.c
Modified: trunk/reactos/ntoskrnl/include/internal/lpc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/lpc.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/lpc.h [iso-8859-1] Mon Sep 2 21:09:56 2013
@@ -58,6 +58,12 @@
LPCP_THREAD_FLAG_NO_IMPERSONATION)
//
+// LPC Locking Flags
+//
+#define LPCP_LOCK_OWNED 1
+#define LPCP_LOCK_RELEASE 2
+
+//
// Internal Port Management
//
VOID
@@ -86,7 +92,7 @@
NTAPI
LpcpFreeToPortZone(
IN PLPCP_MESSAGE Message,
- IN ULONG Flags
+ IN ULONG LockFlags
);
VOID
@@ -104,7 +110,7 @@
LpcpSaveDataInfoMessage(
IN PLPCP_PORT_OBJECT Port,
IN PLPCP_MESSAGE Message,
- IN ULONG LockHeld
+ IN ULONG LockFlags
);
//
Modified: trunk/reactos/ntoskrnl/lpc/close.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/lpc/close.c?rev=5…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/close.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/lpc/close.c [iso-8859-1] Mon Sep 2 21:09:56 2013
@@ -50,14 +50,17 @@
VOID
NTAPI
LpcpFreeToPortZone(IN PLPCP_MESSAGE Message,
- IN ULONG Flags)
+ IN ULONG LockFlags)
{
PLPCP_CONNECTION_MESSAGE ConnectMessage;
PLPCP_PORT_OBJECT ClientPort = NULL;
PETHREAD Thread = NULL;
- BOOLEAN LockHeld = Flags & 1, ReleaseLock = Flags & 2;
+ BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_OWNED);
+ BOOLEAN ReleaseLock = (LockFlags & LPCP_LOCK_RELEASE);
+
PAGED_CODE();
- LPCTRACE(LPC_CLOSE_DEBUG, "Message: %p. Flags: %lx\n", Message, Flags);
+
+ LPCTRACE(LPC_CLOSE_DEBUG, "Message: %p. LockFlags: %lx\n", Message,
LockFlags);
/* Acquire the lock if not already */
if (!LockHeld) KeAcquireGuardedMutex(&LpcpLock);
@@ -183,7 +186,7 @@
Thread->LpcReplyMessage = NULL;
/* And remove the message from the port zone */
- LpcpFreeToPortZone(Message, 1);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED);
NextEntry = Port->LpcReplyChainHead.Flink;
}
@@ -210,7 +213,7 @@
InitializeListHead(&Message->Entry);
/* Remove it from the port zone */
- LpcpFreeToPortZone(Message, 1);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED);
}
/* Release the lock */
@@ -404,7 +407,7 @@
/* Free queued messages */
RemoveEntryList(&Message->Entry);
InitializeListHead(&Message->Entry);
- LpcpFreeToPortZone(Message, 1);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED);
/* Restart at the head */
NextEntry = ListHead->Flink;
@@ -417,7 +420,7 @@
/* Remove it */
RemoveEntryList(&Message->Entry);
InitializeListHead(&Message->Entry);
- LpcpFreeToPortZone(Message, 1);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED);
/* Restart at the head */
NextEntry = ListHead->Flink;
Modified: trunk/reactos/ntoskrnl/lpc/reply.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/lpc/reply.c?rev=5…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/reply.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/lpc/reply.c [iso-8859-1] Mon Sep 2 21:09:56 2013
@@ -48,7 +48,7 @@
/* Unlink and free it */
RemoveEntryList(&Message->Entry);
InitializeListHead(&Message->Entry);
- LpcpFreeToPortZone(Message, 1);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED);
break;
}
@@ -61,8 +61,10 @@
NTAPI
LpcpSaveDataInfoMessage(IN PLPCP_PORT_OBJECT Port,
IN PLPCP_MESSAGE Message,
- IN ULONG LockHeld)
-{
+ IN ULONG LockFlags)
+{
+ BOOLEAN LockHeld = (LockFlags & LPCP_LOCK_OWNED);
+
PAGED_CODE();
/* Acquire the lock */
@@ -236,7 +238,7 @@
Request) != LPC_REQUEST)))
{
/* It isn't, fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
if (ConnectionPort) ObDereferenceObject(ConnectionPort);
ObDereferenceObject(WakeupThread);
ObDereferenceObject(Port);
@@ -255,7 +257,7 @@
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(WakeupThread);
ObDereferenceObject(Port);
_SEH2_YIELD(return _SEH2_GetExceptionCode());
@@ -480,7 +482,7 @@
Request) != LPC_REQUEST)))
{
/* It isn't, fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
if (ConnectionPort) ObDereferenceObject(ConnectionPort);
ObDereferenceObject(WakeupThread);
ObDereferenceObject(Port);
@@ -637,7 +639,7 @@
if (Message->Request.u2.s2.DataInfoOffset)
{
/* It does, save it, and don't free the message below */
- LpcpSaveDataInfoMessage(Port, Message, 1);
+ LpcpSaveDataInfoMessage(Port, Message, LPCP_LOCK_OWNED);
Message = NULL;
}
}
@@ -659,7 +661,7 @@
if (Message)
{
/* Free it and release the lock */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
}
else
{
Modified: trunk/reactos/ntoskrnl/lpc/send.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/lpc/send.c?rev=59…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/send.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/lpc/send.c [iso-8859-1] Mon Sep 2 21:09:56 2013
@@ -26,7 +26,10 @@
ULONG MessageType;
PLPCP_MESSAGE Message;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
+ PETHREAD Thread = PsGetCurrentThread();
+
PAGED_CODE();
+
LPCTRACE(LPC_SEND_DEBUG, "Port: %p. Message: %p\n", Port, LpcMessage);
/* Check if this is a non-datagram message */
@@ -59,7 +62,7 @@
/* Can't have data information on this type of call */
if (LpcMessage->u2.s2.DataInfoOffset) return STATUS_INVALID_PARAMETER;
- /* Validate message sizes */
+ /* Validate the message length */
if (((ULONG)LpcMessage->u1.s1.TotalLength > Port->MaxMessageLength) ||
((ULONG)LpcMessage->u1.s1.TotalLength <=
(ULONG)LpcMessage->u1.s1.DataLength))
{
@@ -80,7 +83,7 @@
LpcMessage,
LpcMessage + 1,
MessageType,
- &PsGetCurrentThread()->Cid);
+ &Thread->Cid);
/* Acquire the LPC lock */
KeAcquireGuardedMutex(&LpcpLock);
@@ -101,7 +104,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
return STATUS_PORT_DISCONNECTED;
}
}
@@ -112,7 +115,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
return STATUS_PORT_DISCONNECTED;
}
}
@@ -136,7 +139,7 @@
Message->Request.CallbackId = 0;
/* No Message ID for the thread */
- PsGetCurrentThread()->LpcReplyMessageId = 0;
+ Thread->LpcReplyMessageId = 0;
/* Insert the message in our chain */
InsertTailList(&QueuePort->MsgQueue.ReceiveHead, &Message->Entry);
@@ -161,7 +164,7 @@
}
/* If we got here, then free the message and fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
if (ConnectionPort) ObDereferenceObject(ConnectionPort);
return STATUS_PORT_DISCONNECTED;
}
@@ -281,7 +284,7 @@
if (!QueuePort)
{
/* We have no connected port, fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
return STATUS_PORT_DISCONNECTED;
}
@@ -297,7 +300,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
return STATUS_PORT_DISCONNECTED;
}
}
@@ -309,7 +312,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
return STATUS_PORT_DISCONNECTED;
}
}
@@ -409,9 +412,8 @@
Message->RepliedToThread = NULL;
}
-
/* Free the message */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
}
else
{
@@ -444,15 +446,16 @@
NtRequestPort(IN HANDLE PortHandle,
IN PPORT_MESSAGE LpcRequest)
{
+ NTSTATUS Status;
PLPCP_PORT_OBJECT Port, QueuePort, ConnectionPort = NULL;
+ ULONG MessageType;
+ PLPCP_MESSAGE Message;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
- NTSTATUS Status;
- PLPCP_MESSAGE Message;
PETHREAD Thread = PsGetCurrentThread();
-
PKSEMAPHORE Semaphore;
- ULONG MessageType;
+
PAGED_CODE();
+
LPCTRACE(LPC_SEND_DEBUG,
"Handle: %p. Message: %p. Type: %lx\n",
PortHandle,
@@ -505,10 +508,10 @@
{
/* Copy it */
LpcpMoveMessage(&Message->Request,
- LpcRequest,
- LpcRequest + 1,
- MessageType,
- &Thread->Cid);
+ LpcRequest,
+ LpcRequest + 1,
+ MessageType,
+ &Thread->Cid);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
@@ -533,7 +536,7 @@
if (!QueuePort)
{
/* We have no connected port, fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
@@ -547,7 +550,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
@@ -560,7 +563,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
@@ -587,7 +590,7 @@
Message->Request.CallbackId = 0;
/* No Message ID for the thread */
- PsGetCurrentThread()->LpcReplyMessageId = 0;
+ Thread->LpcReplyMessageId = 0;
/* Insert the message in our chain */
InsertTailList(&QueuePort->MsgQueue.ReceiveHead, &Message->Entry);
@@ -626,7 +629,7 @@
Status);
/* The wait failed, free the message */
- if (Message) LpcpFreeToPortZone(Message, 3);
+ if (Message) LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
if (ConnectionPort) ObDereferenceObject(ConnectionPort);
@@ -759,7 +762,7 @@
if (!QueuePort)
{
/* We have no connected port, fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
@@ -776,7 +779,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}
@@ -789,7 +792,7 @@
if (!ConnectionPort)
{
/* Fail */
- LpcpFreeToPortZone(Message, 3);
+ LpcpFreeToPortZone(Message, LPCP_LOCK_OWNED | LPCP_LOCK_RELEASE);
ObDereferenceObject(Port);
return STATUS_PORT_DISCONNECTED;
}