Fixed bug reported by Michael Rich in kernel32 compilation.

svn path=/trunk/; revision=1155
This commit is contained in:
Emanuele Aliberti 2000-05-14 09:31:05 +00:00
parent f5c8f9fdab
commit 0726ddaa11
3 changed files with 162 additions and 47 deletions

View file

@ -1,4 +1,5 @@
/*
/* $Id: npipe.c,v 1.2 2000/05/14 09:31:01 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/npipe.c
@ -19,7 +20,7 @@
/* FUNCTIONS ****************************************************************/
HANDLE CreateNamedPipeA(LPCSTR lpName,
HANDLE STDCALL CreateNamedPipeA(LPCSTR lpName,
DWORD dwOpenMode,
DWORD dwPipeMode,
DWORD nMaxInstances,
@ -49,7 +50,7 @@ HANDLE CreateNamedPipeA(LPCSTR lpName,
return(NamedPipeHandle);
}
HANDLE CreateNamedPipeW(LPCWSTR lpName,
HANDLE STDCALL CreateNamedPipeW(LPCWSTR lpName,
DWORD dwOpenMode,
DWORD dwPipeMode,
DWORD nMaxInstances,
@ -168,7 +169,7 @@ HANDLE CreateNamedPipeW(LPCWSTR lpName,
return(PipeHandle);
}
BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName,
BOOL STDCALL WaitNamedPipeA(LPCSTR lpNamedPipeName,
DWORD nTimeOut)
{
BOOL r;
@ -185,7 +186,7 @@ BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName,
return(r);
}
BOOL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
BOOL STDCALL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
DWORD nTimeOut)
{
UNICODE_STRING NamedPipeName;
@ -245,7 +246,7 @@ BOOL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
return(TRUE);
}
BOOL ConnectNamedPipe(HANDLE hNamedPipe,
BOOL STDCALL ConnectNamedPipe(HANDLE hNamedPipe,
LPOVERLAPPED lpOverLapped)
{
NPFS_LISTEN ListenPipe;
@ -284,7 +285,7 @@ BOOL ConnectNamedPipe(HANDLE hNamedPipe,
return(TRUE);
}
BOOL SetNamedPipeHandleState(HANDLE hNamedPipe,
BOOL STDCALL SetNamedPipeHandleState(HANDLE hNamedPipe,
LPDWORD lpMode,
LPDWORD lpMaxCollectionCount,
LPDWORD lpCollectDataTimeout)
@ -374,3 +375,5 @@ BOOL SetNamedPipeHandleState(HANDLE hNamedPipe,
}
return(TRUE);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.16 2000/05/13 13:50:57 dwelch Exp $
/* $Id: stubs.c,v 1.17 2000/05/14 09:31:04 ea Exp $
*
* KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them.
@ -333,19 +333,6 @@ ConsoleMenuControl (
}
WINBOOL
STDCALL
ContinueDebugEvent (
DWORD dwProcessId,
DWORD dwThreadId,
DWORD dwContinueStatus
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
LCID
STDCALL
ConvertDefaultLocale (
@ -3417,18 +3404,6 @@ SetMailslotInfo (
WINBOOL
STDCALL
SetPriorityClass (
HANDLE hProcess,
DWORD dwPriorityClass
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
WINBOOL
STDCALL
SetProcessShutdownParameters (
@ -3708,19 +3683,6 @@ WaitCommEvent (
}
WINBOOL
STDCALL
WaitForDebugEvent (
LPDEBUG_EVENT lpDebugEvent,
DWORD dwMilliseconds
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
int
STDCALL
WideCharToMultiByte (

View file

@ -1,4 +1,5 @@
/*
/* $Id: process.c,v 1.41 2000/05/14 09:31:05 ea Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/process.c
@ -730,3 +731,152 @@ NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle,
return(Status);
}
/**********************************************************************
* NAME INTERNAL
* PiSnapshotProcessTable
*
* DESCRIPTION
* Compute the size of a process+thread snapshot as
* expected by NtQuerySystemInformation.
*
* RETURN VALUE
* 0 on error; otherwise the size, in bytes of the buffer
* required to write a full snapshot.
*
* NOTE
* We assume (sizeof (PVOID) == sizeof (ULONG)) holds.
*/
NTSTATUS
STDCALL
PiSnapshotProcessTable (
IN PVOID SnapshotBuffer,
IN ULONG Size,
IN PULONG pRequiredSize
)
{
KIRQL OldIrql;
PLIST_ENTRY CurrentEntry;
PEPROCESS Current;
ULONG RequiredSize = 0L;
BOOLEAN SizeOnly = FALSE;
ULONG SpiSizeLast = 0L;
ULONG SpiSizeCurrent = 0L;
PSYSTEM_PROCESS_INFORMATION pInfoP = (PSYSTEM_PROCESS_INFORMATION) SnapshotBuffer;
PSYSTEM_THREAD_INFO pInfoT = NULL;
/*
* Lock the process list.
*/
KeAcquireSpinLock (
& PsProcessListLock,
& OldIrql
);
/*
* Scan the process list. Since the
* list is circular, the guard is false
* after the last process.
*/
for ( CurrentEntry = PsProcessListHead.Flink;
(CurrentEntry != & PsProcessListHead);
CurrentEntry = CurrentEntry->Flink
)
{
/*
* Get a reference to the
* process object we are
* handling.
*/
Current = CONTAINING_RECORD(
CurrentEntry,
EPROCESS,
Pcb.ProcessListEntry
);
/* FIXME: assert (NULL != Current) */
/*
* Compute how much space is
* occupied in the snapshot
* by adding this process info.
*/
SpiSizeCurrent =
sizeof (SYSTEM_PROCESS_INFORMATION)
+ (
(Current->ThreadCount - 1)
* sizeof (SYSTEM_THREAD_INFORMATION)
);
RequiredSize += SpiSizeCurrent;
/*
* Do not write process data in the
* buffer if it is too small.
*/
if (TRUE == SizeOnly) continue;
/*
* Check if the buffer can contain
* the full snapshot.
*/
if (Size < RequiredSize)
{
SizeOnly = TRUE;
continue;
}
/*
* Compute the offset of the
* SYSTEM_PROCESS_INFORMATION
* descriptor in the snapshot
* buffer for this process.
*/
if (0L != SpiSizeLast)
{
(ULONG) pInfoP += SpiSizeLast;
/* Save current process SpiSize */
SpiSizeLast = SpiSizeCurrent;
}
/*
* Write process data in the buffer.
*/
pInfoP->RelativeOffset = SpiSizeCurrent;
/* PROCESS */
pInfoP->ThreadCount =
pInfoP->ProcessId = Current->UniqueProcessId;
RtlInitUnicodeString (
& pInfoP->Name,
Current->ImageFileName
);
/* THREAD */
for ( ThreadIndex = 0;
(ThreadIndex < Current->ThreadCount);
ThreadIndex ++
)
{
}
}
/*
* Unlock the process list.
*/
KeReleaseSpinLock (
& PsProcessListLock,
OldIrql
);
/*
* Return the proper error status code,
* if the buffer was too small.
*/
if (TRUE == SizeOnly)
{
*pRequiredSize = RequiredSize;
return STATUS_INFO_LENGTH_MISMATCH;
}
/*
* Mark the end of the snapshot.
*/
pInfoP->RelativeOffset = 0L;
/* OK */
return STATUS_SUCCESS;
}
/* EOF */