#define SystemTimeZoneInformation 44
+// memory information
+
+#define MemoryBasicInformation 0
+
// shutdown action
typedef enum SHUTDOWN_ACTION_TAG {
#define WaitAll 0
#define WaitAny 1
-
+
+// number of wait objects
+
+#define THREAD_WAIT_OBJECTS 3
+//#define MAXIMUM_WAIT_OBJECTS 64
+
// key restore flags
#define REG_WHOLE_HIVE_VOLATILE 1
} LPC_PORT_BASIC_INFORMATION, * PLPC_PORT_BASIC_INFORMATION;
-#endif
+#endif
DWORD BytesPerSector;
} DISK_GEOMETRY ;
+typedef struct _MEMORY_BASIC_INFORMATION {
+ PVOID BaseAddress;
+ PVOID AllocationBase;
+ DWORD AllocationProtect;
+ DWORD RegionSize;
+ DWORD State;
+ DWORD Protect;
+ DWORD Type;
+} MEMORY_BASIC_INFORMATION;
+typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION;
+
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
DWORD itemData;
} MEASUREITEMSTRUCT, *LPMEASUREITEMSTRUCT;
-typedef struct _MEMORY_BASIC_INFORMATION {
- PVOID BaseAddress;
- PVOID AllocationBase;
- DWORD AllocationProtect;
- DWORD RegionSize;
- DWORD State;
- DWORD Protect;
- DWORD Type;
-} MEMORY_BASIC_INFORMATION;
-typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION;
-
typedef struct _MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
#include <windows.h>
-#include <kernel32/proc.h>
-#include <kernel32/heap.h>
#include <crtdll/malloc.h>
int _heapchk (void)
* FILE: lib/kernel32/misc/except.c
* PURPOSE: Exception functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
- modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
+ * modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
* UPDATE HISTORY:
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
typedef LONG (STDCALL *LPTOP_LEVEL_EXCEPTION_FILTER)(
struct _EXCEPTION_POINTERS *ExceptionInfo
- );
+ );
UINT GlobalErrMode;
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
}
-
-
-
-
-
-
-
-
-
-
-LONG
+LONG
STDCALL
UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
HANDLE DebugPort;
NTSTATUS errCode;
-
-
if(ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) {
// might check read only resource
// Is there a debugger running ?
errCode = NtQueryInformationProcess(NtCurrentProcess(),ProcessDebugPort,&DebugPort,sizeof(HANDLE),NULL);
- if ( !NT_SUCCESS(errCode) ) {
+ if ( !NT_SUCCESS(errCode) ) {
SetLastError(RtlNtStatusToDosError(errCode));
return EXCEPTION_EXECUTE_HANDLER;
}
if ( DebugPort ) {
//return EXCEPTION_CONTINUE_SEARCH;
- }
- if(GlobalTopLevelExceptionFilter != NULL) {
+ }
+ if(GlobalTopLevelExceptionFilter != NULL) {
dbgRet = GlobalTopLevelExceptionFilter(ExceptionInfo);
if(dbgRet == EXCEPTION_EXECUTE_HANDLER)
return EXCEPTION_EXECUTE_HANDLER;
}
}
-
+
//if ( GetErrorMode() & SEM_NOGPFAULTERRORBOX == SEM_NOGPFAULTERRORBOX ) {
// produce a stack trace or pop a message
//sprintf( message, "Unhandled exception 0x%08lx at address 0x%08lx.",
return EXCEPTION_EXECUTE_HANDLER;
}
-
-
-
-
-
-
-
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <string.h>
#include <wchar.h>
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
WINBOOL
WCHAR DeviceNameW[MAX_PATH];
WCHAR TargetPathW[MAX_PATH];
-
-
- i = 0;
- while ((*lpDeviceName)!=0 && i < MAX_PATH)
- {
+ i = 0;
+ while ((*lpDeviceName)!=0 && i < MAX_PATH)
+ {
DeviceNameW[i] = *lpDeviceName;
lpDeviceName++;
i++;
- }
- DeviceNameW[i] = 0;
+ }
+ DeviceNameW[i] = 0;
i = 0;
- while ((*lpTargetPath)!=0 && i < MAX_PATH)
- {
+ while ((*lpTargetPath)!=0 && i < MAX_PATH)
+ {
TargetPathW[i] = *lpTargetPath;
lpTargetPath++;
i++;
- }
- TargetPathW[i] = 0;
+ }
+ TargetPathW[i] = 0;
return DefineDosDeviceW(dwFlags,DeviceNameW,TargetPathW);
-
}
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
-/* $Id: find.c,v 1.21 1999/08/29 06:59:01 ea Exp $
+/* $Id: find.c,v 1.22 1999/10/07 23:43:28 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
/* INCLUDES *****************************************************************/
+#include <ddk/ntddk.h>
#include <windows.h>
#include <wchar.h>
-#include <ddk/ntddk.h>
#include <string.h>
#define NDEBUG
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
-typedef struct _FILE_COMPLETION_INFORMATION {
- HANDLE CompletionPort;
- ULONG CompletionKey;
+typedef struct _FILE_COMPLETION_INFORMATION {
+ HANDLE CompletionPort;
+ ULONG CompletionKey;
} FILE_COMPLETION_INFORMATION;
-typedef FILE_COMPLETION_INFORMATION *PFILE_COMPLETION_INFORMATION;
+typedef FILE_COMPLETION_INFORMATION *PFILE_COMPLETION_INFORMATION;
-VOID
-STDCALL
+VOID
+STDCALL
FileIOCompletionRoutine(
- DWORD dwErrorCode,
- DWORD dwNumberOfBytesTransfered,
- LPOVERLAPPED lpOverlapped
+ DWORD dwErrorCode,
+ DWORD dwNumberOfBytesTransfered,
+ LPOVERLAPPED lpOverlapped
);
-HANDLE
+HANDLE
STDCALL
-CreateIoCompletionPort(
- HANDLE FileHandle,
- HANDLE ExistingCompletionPort,
- DWORD CompletionKey,
- DWORD NumberOfConcurrentThreads
+CreateIoCompletionPort(
+ HANDLE FileHandle,
+ HANDLE ExistingCompletionPort,
+ DWORD CompletionKey,
+ DWORD NumberOfConcurrentThreads
)
{
HANDLE CompletionPort = NULL;
return FALSE;
}
- if ( ExistingCompletionPort != NULL ) {
+ if ( ExistingCompletionPort != NULL ) {
CompletionPort = ExistingCompletionPort;
}
else {
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
-
+
}
if ( FileHandle != INVALID_HANDLE_VALUE ) {
CompletionInformation.CompletionPort = CompletionPort;
CompletionInformation.CompletionKey = CompletionKey;
-
+
errCode = NtSetInformationFile(FileHandle, &IoStatusBlock,&CompletionInformation,sizeof(FILE_COMPLETION_INFORMATION),FileCompletionInformation);
if ( !NT_SUCCESS(errCode) ) {
if ( ExistingCompletionPort == NULL )
NtClose(CompletionPort);
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
- }
+ }
}
-
+
return CompletionPort;
}
-
WINBOOL
STDCALL
GetQueuedCompletionStatus(
DWORD dwMilliseconds
)
{
-
NTSTATUS errCode;
ULONG CompletionStatus;
LARGE_INTEGER TimeToWait;
return FALSE;
}
- return TRUE;
-
+ return TRUE;
}
-
-WINBOOL
+WINBOOL
STDCALL
PostQueuedCompletionStatus(
- HANDLE CompletionPort,
- DWORD dwNumberOfBytesTransferred,
- DWORD dwCompletionKey,
- LPOVERLAPPED lpOverlapped
+ HANDLE CompletionPort,
+ DWORD dwNumberOfBytesTransferred,
+ DWORD dwCompletionKey,
+ LPOVERLAPPED lpOverlapped
)
{
+ NTSTATUS errCode;
+ errCode = NtSetIoCompletion(CompletionPort, dwCompletionKey, (PIO_STATUS_BLOCK)lpOverlapped , 0, (PULONG)&dwNumberOfBytesTransferred );
- NTSTATUS errCode;
- errCode = NtSetIoCompletion(CompletionPort, dwCompletionKey, (PIO_STATUS_BLOCK)lpOverlapped , 0, (PULONG)&dwNumberOfBytesTransferred );
-
-
- if ( !NT_SUCCESS(errCode) ) {
+ if ( !NT_SUCCESS(errCode) ) {
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
- }
- return TRUE;
+ }
+ return TRUE;
}
// this should be a place holder ??????????????????
-VOID
-STDCALL
+VOID
+STDCALL
FileIOCompletionRoutine(
- DWORD dwErrorCode,
- DWORD dwNumberOfBytesTransfered,
- LPOVERLAPPED lpOverlapped
+ DWORD dwErrorCode,
+ DWORD dwNumberOfBytesTransfered,
+ LPOVERLAPPED lpOverlapped
)
{
return;
}
-
-
-
-
-
-
-
-
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
* Copyright 1996 Alexandre Julliard
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <stdarg.h>
#include <stdio.h>
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <stdarg.h>
#include <kernel32/kernel32.h>
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <stdarg.h>
BOOL KERNEL32_AnsiToUnicode(PWSTR DestStr,
-/* $Id: section.c,v 1.4 1999/10/03 23:19:15 ea Exp $
+/* $Id: section.c,v 1.5 1999/10/07 23:44:28 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
/* FUNCTIONS *****************************************************************/
OBJECT_ATTRIBUTES ObjectAttributes;
ANSI_STRING AnsiName;
UNICODE_STRING UnicodeName;
-
+ PSECURITY_DESCRIPTOR SecurityDescriptor;
+
+ if (lpFileMappingAttributes)
+ {
+ SecurityDescriptor = lpFileMappingAttributes->lpSecurityDescriptor;
+ }
+ else
+ {
+ SecurityDescriptor = NULL;
+ }
+
MaximumSize.u.LowPart = dwMaximumSizeLow;
MaximumSize.u.HighPart = dwMaximumSizeHigh;
RtlInitAnsiString(&AnsiName, (LPSTR)lpName);
&UnicodeName,
0,
NULL,
- lpFileMappingAttributes);
- Status = ZwCreateSection(&SectionHandle,
+ SecurityDescriptor);
+ Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes,
&MaximumSize,
LARGE_INTEGER MaximumSize;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
-
+ PSECURITY_DESCRIPTOR SecurityDescriptor;
+
+ if (lpFileMappingAttributes)
+ {
+ SecurityDescriptor = lpFileMappingAttributes->lpSecurityDescriptor;
+ }
+ else
+ {
+ SecurityDescriptor = NULL;
+ }
+
MaximumSize.u.LowPart = dwMaximumSizeLow;
MaximumSize.u.HighPart = dwMaximumSizeHigh;
RtlInitUnicodeString(&UnicodeName, lpName);
&UnicodeName,
0,
NULL,
- lpFileMappingAttributes);
- Status = ZwCreateSection(&SectionHandle,
+ SecurityDescriptor);
+ Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes,
&MaximumSize,
)
{
NTSTATUS Status;
-
-
-
-
LARGE_INTEGER SectionOffset;
ULONG ViewSize;
ULONG Protect;
SectionOffset.u.LowPart = dwFileOffsetLow;
SectionOffset.u.HighPart = dwFileOffsetHigh;
-
-
-
-
-
- if ( ( dwDesiredAccess & FILE_MAP_WRITE ) == FILE_MAP_WRITE )
+ if ( ( dwDesiredAccess & FILE_MAP_WRITE ) == FILE_MAP_WRITE )
Protect = PAGE_READWRITE;
- else if ( ( dwDesiredAccess & FILE_MAP_READ ) == FILE_MAP_READ )
+ else if ( ( dwDesiredAccess & FILE_MAP_READ ) == FILE_MAP_READ )
Protect = PAGE_READONLY;
- else if ( ( dwDesiredAccess & FILE_MAP_ALL_ACCESS ) == FILE_MAP_ALL_ACCESS )
- Protect = PAGE_READWRITE;
- else if ( ( dwDesiredAccess & FILE_MAP_COPY ) == FILE_MAP_COPY )
+ else if ( ( dwDesiredAccess & FILE_MAP_ALL_ACCESS ) == FILE_MAP_ALL_ACCESS )
+ Protect = PAGE_READWRITE;
+ else if ( ( dwDesiredAccess & FILE_MAP_COPY ) == FILE_MAP_COPY )
Protect = PAGE_WRITECOPY;
else
Protect = PAGE_READWRITE;
-
Status = ZwMapViewOfSection(hFileMappingObject,
NtCurrentProcess(),
&BaseAddress,
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
return NULL;
}
return BaseAddress;
-
}
LPVOID
NTSTATUS Status;
Status = NtUnmapViewOfSection(NtCurrentProcess(),lpBaseAddress);
- if (!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
STDCALL
OpenFileMappingA (
DWORD dwDesiredAccess,
- WINBOOL bInheritHandle,
- LPCSTR lpName
+ WINBOOL bInheritHandle,
+ LPCSTR lpName
)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
ANSI_STRING AnsiName;
UNICODE_STRING UnicodeName;
-
+
ULONG Attributes = 0;
if ( bInheritHandle )
- Attributes = OBJ_INHERIT;
-
+ Attributes = OBJ_INHERIT;
+
RtlInitAnsiString(&AnsiName, lpName);
RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, TRUE);
Attributes,
NULL,
NULL);
- Status = ZwOpenSection(&SectionHandle,
+ Status = NtOpenSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes
);
STDCALL
OpenFileMappingW (
DWORD dwDesiredAccess,
- WINBOOL bInheritHandle,
- LPCWSTR lpName
+ WINBOOL bInheritHandle,
+ LPCWSTR lpName
)
{
NTSTATUS Status;
HANDLE SectionHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
-
+
ULONG Attributes = 0;
if ( bInheritHandle )
Attributes = OBJ_INHERIT;
-
+
RtlInitUnicodeString(&UnicodeName, lpName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
return SectionHandle;
}
-
/* EOF */
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
/* FUNCTIONS *****************************************************************/
* FILE: lib/kernel32/misc/atom.c
* PURPOSE: Atom functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
- modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
+ * modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
* UPDATE HISTORY:
* Created 01/11/98
*/
+#include <ddk/ntddk.h>
#include <kernel32/atom.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
* 19990204 EA SetConsoleTitleA
* 19990306 EA Stubs
*/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <ddk/ntddblue.h>
+#include <windows.h>
#include <assert.h>
#include <wchar.h>
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <kernel32/proc.h>
#include <internal/teb.h>
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
#include <string.h>
#define MAX_ENVIRONMENT_VARS 255
#define MAX_VALUE 1024
-typedef struct _ENV_ELEMENT
+typedef struct _ENV_ELEMENT
{
UNICODE_STRING Name;
UNICODE_STRING Value;
while (i < nEnvVar)
{
- if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
+ if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
lstrcpynW(lpBuffer,Environment[i].Value.Buffer,min(nSize,Environment[i].Value.Length/sizeof(WCHAR)));
return lstrlenW(Environment[i].Value.Buffer);
int i=0;
while ((*lpName)!=0 && i < MAX_PATH)
- {
+ {
NameW[i] = *lpName;
lpName++;
i++;
- }
- NameW[i] = 0;
+ }
+ NameW[i] = 0;
i = 0;
-
+
while ((*lpValue)!=0 && i < MAX_PATH)
- {
+ {
ValueW[i] = *lpValue;
lpValue++;
i++;
- }
- ValueW[i] = 0;
+ }
+ ValueW[i] = 0;
return SetEnvironmentVariableW(NameW,ValueW);
-
-
}
+
WINBOOL
STDCALL
SetEnvironmentVariableW(
while (i < nEnvVar)
{
- if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
+ if ( _wcsnicmp(Environment[i].Name.Buffer,lpName,min(NameLen,Environment[i].Name.Length/sizeof(WCHAR))) != 0 ) {
if ( lpValue != NULL ) {
lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,Environment[i].Value.MaximumLength/sizeof(WCHAR)));
return TRUE;
Environment[i].Name.Length = 0;
return FALSE;
}
-
-
-
}
i++;
}
if ( nEnvVar >= MAX_ENVIRONMENT_VARS )
return FALSE;
- while (i < nEnvVar)
+ while (i < nEnvVar)
{
- if ( Environment[i].Valid == FALSE )
+ if ( Environment[i].Valid == FALSE )
break;
i++;
}
lstrcpynW(Environment[i].Name.Buffer,lpValue,min(NameLen,(Environment[i].Name.MaximumLength-sizeof(WCHAR))/sizeof(WCHAR)));
Environment[i].Name.Length = NameLen*sizeof(WCHAR);
-
lstrcpynW(Environment[i].Value.Buffer,lpValue,min(ValueLen,(Environment[i].Value.MaximumLength-sizeof(WCHAR)))/sizeof(WCHAR));
Environment[i].Value.Length = ValueLen*sizeof(WCHAR);
-
-
-
- return TRUE;
+ return TRUE;
}
-DWORD
+DWORD
STDCALL
GetVersion(VOID)
{
DWORD Version = 0;
OSVERSIONINFO VersionInformation;
GetVersionExW(&VersionInformation);
-
+
Version |= ( VersionInformation.dwMajorVersion << 8 );
Version |= VersionInformation.dwMinorVersion;
-
+
Version |= ( VersionInformation.dwPlatformId << 16 );
return Version;
-
}
-WINBOOL
+WINBOOL
STDCALL
GetVersionExW(
LPOSVERSIONINFO lpVersionInformation
return TRUE;
}
-WINBOOL
+WINBOOL
STDCALL
GetVersionExA(
LPOSVERSIONINFO lpVersionInformation
}
-
-
-
-LPSTR STDCALL GetEnvironmentStringsA(VOID)
+LPSTR
+STDCALL
+GetEnvironmentStringsA(VOID)
{
#if 0
WCHAR *EnvironmentStringsW;
}
-LPWSTR STDCALL GetEnvironmentStringsW(VOID)
+LPWSTR
+STDCALL
+GetEnvironmentStringsW(VOID)
{
#if 0
int size = 0;
-/* $Id: error.c,v 1.11 1999/08/29 06:59:02 ea Exp $
+/* $Id: error.c,v 1.12 1999/10/07 23:45:07 ekohl Exp $
*
* reactos/lib/kernel32/misc/error.c
*
*/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <ddk/ntddbeep.h>
* UPDATE HISTORY:
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
-
-WINBOOL
-WINAPI
-GetHandleInformation(
- HANDLE hObject,
- LPDWORD lpdwFlags
+WINBOOL
+WINAPI
+GetHandleInformation(
+ HANDLE hObject,
+ LPDWORD lpdwFlags
)
{
OBJECT_DATA_INFORMATION HandleInfo;
if ( HandleInfo.bProtectFromClose )
*lpdwFlags &= HANDLE_FLAG_PROTECT_FROM_CLOSE;
return TRUE;
-
-
-}
-
-WINBOOL
-STDCALL
-SetHandleInformation(
- HANDLE hObject,
- DWORD dwMask,
- DWORD dwFlags
+}
+
+
+WINBOOL
+STDCALL
+SetHandleInformation(
+ HANDLE hObject,
+ DWORD dwMask,
+ DWORD dwFlags
)
-{
+{
OBJECT_DATA_INFORMATION HandleInfo;
NTSTATUS errCode;
ULONG BytesWritten;
return TRUE;
}
-
-WINBOOL
+WINBOOL
STDCALL
CloseHandle( HANDLE hObject )
{
-
NTSTATUS errCode;
- errCode = NtClose(hObject);
- if(!NT_SUCCESS(errCode)) {
- SetLastError(RtlNtStatusToDosError(errCode));
- return FALSE;
+ errCode = NtClose(hObject);
+ if(!NT_SUCCESS(errCode)) {
+ SetLastError(RtlNtStatusToDosError(errCode));
+ return FALSE;
}
-
+
return TRUE;
}
-
WINBOOL
STDCALL
DuplicateHandle(
- HANDLE hSourceProcessHandle,
- HANDLE hSourceHandle,
- HANDLE hTargetProcessHandle,
- LPHANDLE lpTargetHandle,
- DWORD dwDesiredAccess,
- BOOL bInheritHandle,
- DWORD dwOptions
+ HANDLE hSourceProcessHandle,
+ HANDLE hSourceHandle,
+ HANDLE hTargetProcessHandle,
+ LPHANDLE lpTargetHandle,
+ DWORD dwDesiredAccess,
+ BOOL bInheritHandle,
+ DWORD dwOptions
)
{
-
-
NTSTATUS errCode;
-
+
errCode = NtDuplicateObject(hSourceProcessHandle,hSourceHandle,hTargetProcessHandle,lpTargetHandle, dwDesiredAccess, (BOOLEAN)bInheritHandle,dwOptions);
if ( !NT_SUCCESS(errCode) ) {
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
-
-
-
+
return TRUE;
-
}
UINT STDCALL
{
return nCount;
}
-
-
-
-
-
-
-
-/* $Id: stubs.c,v 1.6 1999/10/03 23:19:15 ea Exp $
+/* $Id: stubs.c,v 1.7 1999/10/07 23:45:07 ekohl Exp $
*
* KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them.
}
-
-
DWORD
STDCALL
ExpungeConsoleCommandHistoryW (
}
-
WINBOOL
STDCALL
-FlushViewOfFile (
+FlushViewOfFile(
LPCVOID lpBaseAddress,
- DWORD dwNumberOfBytesToFlush
+ DWORD dwNumberOfBytesToFlush
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
}
-
int
STDCALL
FoldStringA (
}
-
DWORD
STDCALL
FormatMessageW (
}
-
-
DWORD
STDCALL
InvalidateConsoleDIBits (
}
-
-
WINBOOL
STDCALL
IsDBCSLeadByte (
}
-
int
STDCALL
MulDiv (
}
-
-
WINBOOL
STDCALL
UpdateResourceA (
}
-
-
-
WINBOOL
STDCALL
WaitCommEvent (
}
-
-
-
WINBOOL
STDCALL
WritePrivateProfileSectionA (
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
-#include <string.h>
+#include <windows.h>
#include <internal/string.h>
#include <string.h>
/* INCLUDES ****************************************************************/
#define UNICODE
+#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
/* INCLUDES ****************************************************************/
#define WIN32_NO_PEHDR
+#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
-/* $Id: lib.c,v 1.3 1999/08/29 06:59:03 ea Exp $
+/* $Id: lib.c,v 1.4 1999/10/07 23:45:25 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
/* INCLUDES ****************************************************************/
#define UNICODE
+#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
-/* $Id: proc.c,v 1.20 1999/09/12 20:58:29 ekohl Exp $
+/* $Id: proc.c,v 1.21 1999/10/07 23:45:25 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
/* INCLUDES ****************************************************************/
#define UNICODE
+#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/proc.h>
#include <kernel32/thread.h>
{
return _stricmp(lpString1,lpString2);
}
+
LPSTR
STDCALL
lstrcpynA(
int
STDCALL
lstrcmpW(
- LPCWSTR lpString1,
- LPCWSTR lpString2
- )
+ LPCWSTR lpString1,
+ LPCWSTR lpString2
+ )
{
return wcscmp(lpString1,lpString2);
}
)
{
return wcslen(lpString);
-
}
* Created 01/11/98
*/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
#include <wchar.h>
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
+#include <windows.h>
/* FUNCTIONS *****************************************************************/
* Created 01/11/98
*/
+#include <ddk/ntddk.h>
#include <windows.h>
#include <wchar.h>
-#include <ddk/ntddk.h>
HANDLE
STDCALL
/* INCLUDES ******************************************************************/
+#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/thread.h>
-#include <ddk/ntddk.h>
#include <string.h>
#include <internal/i386/segment.h>
* FILE: lib/kernel32/thread/tls.c
* PURPOSE: Thread functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
- * Tls functions are modified from WINE
+ * Tls functions are modified from WINE
* UPDATE HISTORY:
* Created 01/11/98
*/
/* INCLUDES ******************************************************************/
+#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/thread.h>
-#include <ddk/ntddk.h>
#include <string.h>
/* FUNCTIONS *****************************************************************/
#define WIN32_NO_PEHDR
#include <ddk/ntddk.h>
-//#include <windows.h>
-//#include <kernel32/proc.h>
-//#include <kernel32/thread.h>
#include <wchar.h>
#include <string.h>
#include <pe.h>
#include <internal/teb.h>
#include <ntdll/base.h>
-//#define NDEBUG
+#define NDEBUG
#include <ntdll/ntdll.h>
/* FUNCTIONS ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#define STUB(x) void x(void) { UNICODE_STRING UnicodeString; \
-/* $Id: registry.c,v 1.18 1999/08/29 06:59:05 ea Exp $
+/* $Id: registry.c,v 1.19 1999/10/07 23:33:22 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
*/
#undef WIN32_LEAN_AND_MEAN
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <wchar.h>
/* Note: Bias[minutes] = UTC - local time */
TIME_ZONE_INFORMATION SystemTimeZoneInfo;
+
/* FUNCTIONS ****************************************************************/
VOID
}
+
NTSTATUS
STDCALL
NtSetSystemTime (
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <windows.h>
+#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/ke.h>
#include <internal/symbol.h>
/* INCLUDES *****************************************************************/
+#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/ke.h>
#include <internal/hal.h>
-#include <windows.h>
+#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/ke.h>
#include <internal/symbol.h>
/* INCLUDES ***************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
/* FUNCTIONS *****************************************************************/
/* INCLUDES ***************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
/* FUNCTIONS **************************************************************/
/* INCLUDES *****************************************************************/
+#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <string.h>
#include <internal/string.h>
#include <internal/mmhal.h>
#include <internal/halio.h>
+#define NDEBUG
+#include <internal/debug.h>
+
+/* GLOBALS ******************************************************************/
+
//#define BOCHS_DEBUGGING 1
//#define SERIAL_DEBUGGING
#define SERIAL_PORT 0x03f8
#define SERIAL_BAUD_RATE 19200
#define SERIAL_LINE_CONTROL (SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO)
-#define NDEBUG
-#include <internal/debug.h>
-
-/* GLOBALS ******************************************************************/
#define IDMAP_BASE (0xd0000000)
-#include <windows.h>
+/* $Id: usercall.c,v 1.4 1999/10/07 23:35:10 ekohl Exp $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/hal/x86/usercall.c
+ * PURPOSE: 2E interrupt handler
+ * PROGRAMMER: ???
+ * UPDATE HISTORY:
+ * ???
+ */
+
+#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/ke.h>
#include <internal/symbol.h>
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/io.h>
#include <string.h>
/* INCLUDES ***************************************************************/
-#include <wchar.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#define NDEBUG
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/ps.h>
/* INCLUDES *****************************************************************/
-#include <internal/ke.h>
#include <ddk/ntddk.h>
+#include <internal/ke.h>
#include <internal/debug.h>
-/* $Id: main.c,v 1.22 1999/08/29 06:59:10 ea Exp $
+/* $Id: main.c,v 1.23 1999/10/07 23:36:00 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES *****************************************************************/
-#include <windows.h>
-
+#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/version.h>
#include <internal/mm.h>
/* INCLUDES ******************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ke.h>
{
PKWAIT_BLOCK current;
PLIST_ENTRY current_entry;
+ PKWAIT_BLOCK PrevBlock;
DPRINT("KeDispatcherObjectWakeAll(hdr %x)\n",hdr);
WaitListEntry);
DPRINT("Waking %x\n",current->Thread);
- if (current->NextWaitBlock != NULL)
+ if (current->WaitType == WaitAny)
{
- DbgPrint("DANGLING POINTERS!!! We're in trouble!\n");
+ DPRINT("WaitAny: Remove all wait blocks.\n");
+ current->Thread->WaitBlockList = NULL;
+ }
+ else
+ {
+ DPRINT("WaitAll: Remove the current wait block only.\n");
+
+ PrevBlock = current->Thread->WaitBlockList;
+ if (PrevBlock)
+ {
+ if (PrevBlock->NextWaitBlock == current)
+ {
+ DPRINT("WaitAll: Current block is list head.\n");
+ PrevBlock->NextWaitBlock = current->NextWaitBlock;
+ }
+ else
+ {
+ DPRINT("WaitAll: Current block is list head.\n");
+ while (PrevBlock &&
+ PrevBlock->NextWaitBlock != current)
+ {
+ PrevBlock = PrevBlock->NextWaitBlock;
+ }
+
+ if (PrevBlock)
+ {
+ PrevBlock->NextWaitBlock = current->NextWaitBlock;
+ }
+ }
+ }
+ else
+ {
+ DPRINT("WaitAll: Wait Block List is empty!\n");
+ }
}
PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb));
{
PKWAIT_BLOCK current;
PLIST_ENTRY current_entry;
+ PKWAIT_BLOCK PrevBlock;
DPRINT("KeDispatcherObjectWakeOn(hdr %x)\n",hdr);
DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
current = CONTAINING_RECORD(current_entry,KWAIT_BLOCK,
WaitListEntry);
DPRINT("current_entry %x current %x\n",current_entry,current);
+
+
+ if (current->WaitType == WaitAny)
+ {
+ DPRINT("WaitAny: Remove all wait blocks.\n");
+ current->Thread->WaitBlockList = NULL;
+ }
+ else
+ {
+ DPRINT("WaitAll: Remove the current wait block only.\n");
+
+ PrevBlock = current->Thread->WaitBlockList;
+ if (PrevBlock)
+ {
+ if (PrevBlock->NextWaitBlock == current)
+ {
+ DPRINT("WaitAll: Current block is list head.\n");
+ PrevBlock->NextWaitBlock = current->NextWaitBlock;
+ }
+ else
+ {
+ DPRINT("WaitAll: Current block is list head.\n");
+ while (PrevBlock && PrevBlock->NextWaitBlock != current)
+ {
+ PrevBlock = PrevBlock->NextWaitBlock;
+ }
+
+ if (PrevBlock)
+ {
+ PrevBlock->NextWaitBlock = current->NextWaitBlock;
+ }
+ }
+ }
+ else
+ {
+ DPRINT("WaitAll: Wait Block List is empty!\n");
+ }
+ }
+
DPRINT("Waking %x\n",current->Thread);
if (hdr->Type == SemaphoreType)
hdr->SignalState--;
case ID_THREAD_OBJECT:
return(KeDispatcherObjectWakeAll(hdr));
}
- DbgPrint("Dispatcher object %x has unknown type\n",hdr);
+ DPRINT("Dispatcher object %x has unknown type\n",hdr);
KeBugCheck(0);
return(FALSE);
}
{
DISPATCHER_HEADER* hdr = (DISPATCHER_HEADER *)Object;
KWAIT_BLOCK blk;
+ PKTHREAD CurrentThread;
DPRINT("Entering KeWaitForSingleObject(Object %x) "
"PsGetCurrentThread() %x\n",Object,PsGetCurrentThread());
+ CurrentThread = KeGetCurrentThread();
+
KeAcquireDispatcherDatabaseLock(FALSE);
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
}
KeReleaseDispatcherDatabaseLock(FALSE);
- return(STATUS_SUCCESS);
+ return(STATUS_WAIT_0);
}
if (Timeout != NULL)
{
- KeAddThreadTimeout(KeGetCurrentThread(),Timeout);
+ KeAddThreadTimeout(CurrentThread,Timeout);
}
- blk.Object=Object;
- blk.Thread=KeGetCurrentThread();
+ /* Append wait block to the KTHREAD wait block list */
+ CurrentThread->WaitBlockList = &blk;
+
+ blk.Object = Object;
+ blk.Thread = CurrentThread;
blk.WaitKey = 0;
- blk.WaitType = WaitAll;
+ blk.WaitType = WaitAny;
blk.NextWaitBlock = NULL;
InsertTailList(&(hdr->WaitListHead),&(blk.WaitListEntry));
// DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
if (Timeout != NULL)
{
KeCancelTimer(&KeGetCurrentThread()->Timer);
+ if (KeReadStateTimer(&KeGetCurrentThread()->Timer))
+ return(STATUS_TIMEOUT);
}
DPRINT("Returning from KeWaitForSingleObject()\n");
- return(STATUS_SUCCESS);
+ return(STATUS_WAIT_0);
}
NTSTATUS KeWaitForMultipleObjects(ULONG Count,
{
DISPATCHER_HEADER* hdr;
PKWAIT_BLOCK blk;
+ PKTHREAD CurrentThread;
ULONG CountSignaled;
ULONG i;
- DbgPrint("Entering KeWaitForMultipleObjects(Count %lu Object[] %p) "
+ DPRINT("Entering KeWaitForMultipleObjects(Count %lu Object[] %p) "
"PsGetCurrentThread() %x\n",Count,Object,PsGetCurrentThread());
CountSignaled = 0;
+ CurrentThread = KeGetCurrentThread();
if (WaitBlockArray == NULL)
{
- DbgPrint("FIXME: Use internal wait blocks!\n");
- return STATUS_UNSUCCESSFUL;
+ if (Count > 3)
+ {
+ DbgPrint("(%s:%d) Too many objects!\n",
+ __FILE__,__LINE__);
+ return STATUS_UNSUCCESSFUL;
+ }
+ blk = &CurrentThread->WaitBlock[1];
}
else
{
if (Count > 64)
{
- DbgPrint("Too many objects!\n");
+ DbgPrint("(%s:%d) Too many objects!\n",
+ __FILE__,__LINE__);
return STATUS_UNSUCCESSFUL;
}
blk = WaitBlockArray;
{
hdr = (DISPATCHER_HEADER *)Object[i];
-// DbgPrint("hdr->SignalState %d\n", hdr->SignalState);
+ DPRINT("hdr->SignalState %d\n", hdr->SignalState);
if (hdr->SignalState > 0)
{
if (WaitType == WaitAny)
{
KeReleaseDispatcherDatabaseLock(FALSE);
- DbgPrint("One object is already signaled!\n");
- return(STATUS_SUCCESS);
+ DPRINT("One object is already signaled!\n");
+ return(STATUS_WAIT_0 + i);
}
}
}
if ((WaitType == WaitAll) && (CountSignaled == Count))
{
KeReleaseDispatcherDatabaseLock(FALSE);
- DbgPrint("All objects are already signaled!\n");
- return(STATUS_SUCCESS);
+ DPRINT("All objects are already signaled!\n");
+ return(STATUS_WAIT_0);
}
if (Timeout != NULL)
{
- KeAddThreadTimeout(KeGetCurrentThread(),Timeout);
+ KeAddThreadTimeout(CurrentThread,Timeout);
}
+ /* Append wait block to the KTHREAD wait block list */
+ CurrentThread->WaitBlockList = blk;
+
for (i = 0; i < Count; i++)
{
hdr = (DISPATCHER_HEADER *)Object[i];
- DbgPrint("hdr->SignalState %d\n", hdr->SignalState);
+ DPRINT("hdr->SignalState %d\n", hdr->SignalState);
- blk->Object=Object[i];
- blk->Thread=KeGetCurrentThread();
+ blk->Object = Object[i];
+ blk->Thread = CurrentThread;
blk->WaitKey = i;
blk->WaitType = WaitType;
if (i == Count - 1)
blk->NextWaitBlock = NULL;
else
blk->NextWaitBlock = (PVOID)((ULONG)blk+sizeof(KWAIT_BLOCK));
- DbgPrint("blk %p blk->NextWaitBlock %p\n",
+ DPRINT("blk %p blk->NextWaitBlock %p\n",
blk, blk->NextWaitBlock);
InsertTailList(&(hdr->WaitListHead),&(blk->WaitListEntry));
KeReleaseDispatcherDatabaseLock(FALSE);
- DbgPrint("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__,
- KeGetCurrentIrql());
+ DPRINT("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__,
+ KeGetCurrentIrql());
PsSuspendThread(PsGetCurrentThread());
if (Timeout != NULL)
{
KeCancelTimer(&KeGetCurrentThread()->Timer);
+ if (KeReadStateTimer(&KeGetCurrentThread()->Timer))
+ return(STATUS_TIMEOUT);
}
- DbgPrint("Returning from KeWaitForMultipleObjects()\n");
+ DPRINT("Returning from KeWaitForMultipleObjects()\n");
+
+ if (WaitType == WaitAny)
+ {
+ for (i = 0; i < Count; i++)
+ {
+ if (((DISPATCHER_HEADER *)Object[i])->SignalState)
+ return(STATUS_WAIT_0+i);
+ }
+ }
- return STATUS_SUCCESS;
+ return(STATUS_WAIT_0);
}
VOID KeInitializeDispatcher(VOID)
IN PLARGE_INTEGER Time
)
{
- KWAIT_BLOCK WaitBlockArray[64];
- PVOID ObjectPtrArray[64];
-// KWAIT_BLOCK WaitBlockArray[MAXIMUM_WAIT_OBJECTS];
-// PVOID ObjectPtrArray[MAXIMUM_WAIT_OBJECTS];
+ KWAIT_BLOCK WaitBlockArray[64]; /* FIXME: use MAXIMUM_WAIT_OBJECTS instead */
+ PVOID ObjectPtrArray[64]; /* FIXME: use MAXIMUM_WAIT_OBJECTS instead */
NTSTATUS Status;
ULONG i, j;
-
DPRINT("NtWaitForMultipleObjects(Count %lu Object[] %x, Alertable %d, Time %x)\n",
Count,Object,Alertable,Time);
- if (Count > 64)
-// if (Count > MAXIMUM_WAIT_OBJECTS)
+ if (Count > 64) /* FIXME: use MAXIMUM_WAIT_OBJECTS instead */
return STATUS_UNSUCCESSFUL;
-// return WAIT_FAIL; /* this must be returned by WaitForMultipleObjects */
/* reference all objects */
for (i = 0; i < Count; i++)
/* INCLUDES *****************************************************************/
-#include <windows.h>
-
+#include <ddk/ntddk.h>
#include <internal/i386/segment.h>
#include <internal/linkage.h>
#include <internal/module.h>
#include <internal/string.h>
#include <internal/symbol.h>
#include <internal/teb.h>
-#include <ddk/ntddk.h>
//#define NDEBUG
#include <internal/debug.h>
-/* $Id: loader.c,v 1.31 1999/09/05 12:40:20 ekohl Exp $
+/* $Id: loader.c,v 1.32 1999/10/07 23:36:24 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES *****************************************************************/
-#include <windows.h>
-
+#include <ddk/ntddk.h>
#include <internal/i386/segment.h>
#include <internal/linkage.h>
#include <internal/module.h>
#include <internal/string.h>
#include <internal/symbol.h>
-#include <ddk/ntddk.h>
-
#define NDEBUG
#include <internal/debug.h>
-/* $Id: syspath.c,v 1.1 1999/07/17 23:10:27 ea Exp $
+/* $Id: syspath.c,v 1.2 1999/10/07 23:36:25 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES *****************************************************************/
-#include <windows.h>
+#include <ddk/ntddk.h>
#include <wchar.h>
#include <string.h>
-#include <ddk/ntddk.h>
/**********************************************************************
/* INCLUDES *****************************************************************/
+#include <ddk/ntddk.h>
#include <internal/hal/io.h>
#include <internal/i386/segment.h>
#include <internal/stddef.h>
/* INCLUDES ****************************************************************/
+#include <ddk/ntddk.h>
#include <string.h>
#include <internal/string.h>
#include <internal/stddef.h>
#define NDEBUG
#include <internal/debug.h>
-#include <ddk/ntddk.h>
#if 0
/* INCLUDES ****************************************************************/
-#include <internal/ntoskrnl.h>
#include <ddk/ntddk.h>
+#include <internal/ntoskrnl.h>
#include <internal/pool.h>
#define NDEBUG
/* INCLUDE *****************************************************************/
+#include <ddk/ntddk.h>
#include <internal/mm.h>
#include <internal/mmhal.h>
#include <internal/ob.h>
OUT PULONG ResultLength
)
{
- UNIMPLEMENTED;
+ NTSTATUS Status;
+ PEPROCESS Process;
+ MEMORY_AREA* MemoryArea;
+
+#if 0
+ DbgPrint("NtReadVirtualMemory(ProcessHandle %x, Address %x, "
+ "VirtualMemoryInformationClass %d, VirtualMemoryInformation %x, "
+ "Length %lu ResultLength %x)\n",ProcessHandle,Address,
+ VirtualMemoryInformationClass,VirtualMemoryInformation,
+ Length,ResultLength);
+#endif
+ switch(VirtualMemoryInformationClass)
+ {
+ case MemoryBasicInformation:
+ {
+ PMEMORY_BASIC_INFORMATION Info =
+ (PMEMORY_BASIC_INFORMATION)VirtualMemoryInformation;
+
+ if (Length < sizeof(MEMORY_BASIC_INFORMATION))
+ {
+ ObDereferenceObject(Process);
+ return(STATUS_INFO_LENGTH_MISMATCH);
+ }
+
+ *ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
+
+
+ Status = ObReferenceObjectByHandle(ProcessHandle,
+ PROCESS_QUERY_INFORMATION,
+ NULL,
+ UserMode,
+ (PVOID*)(&Process),
+ NULL);
+
+ if (!NT_SUCCESS(Status))
+ {
+// DbdPrint("NtQueryVirtualMemory() = %x\n",Status);
+ return(Status);
+ }
+
+ MemoryArea = MmOpenMemoryAreaByAddress(Process,
+ Address);
+
+ if (MemoryArea == NULL)
+ {
+ Info->State = MEM_FREE;
+ DbgPrint("Virtual memory at %p is free.\n", Address);
+ ObDereferenceObject(Process);
+ return (STATUS_SUCCESS);
+ }
+
+ if (MemoryArea->Type == MEMORY_AREA_COMMIT)
+ {
+ Info->State = MEM_COMMIT;
+ }
+ else
+ {
+ Info->State = MEM_RESERVE;
+ }
+
+ Info->BaseAddress = MemoryArea->BaseAddress;
+ Info->RegionSize = MemoryArea->Length;
+
+ DbgPrint("BaseAddress %p, Length %x\n",
+ Info->BaseAddress, Info->RegionSize);
+
+
+ ObDereferenceObject(Process);
+ return (STATUS_SUCCESS);
+ }
+ break;
+ }
+
+ return(STATUS_INVALID_INFO_CLASS);
+
+// UNIMPLEMENTED;
}
-/* $Id: handle.c,v 1.11 1999/08/29 06:59:11 ea Exp $
+/* $Id: handle.c,v 1.12 1999/10/07 23:38:08 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <string.h>
CurrentThread->ThreadsProcess = NULL;
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
CurrentThread->Tcb.State = THREAD_STATE_TERMINATED;
+ CurrentThread->Tcb.DispatcherHeader.SignalState = TRUE;
KeDispatcherObjectWake(&CurrentThread->Tcb.DispatcherHeader);
ZwYieldExecution();
for(;;);
PiNrThreads--;
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
Thread->Tcb.State = THREAD_STATE_TERMINATED;
+ Thread->Tcb.DispatcherHeader.SignalState = TRUE;
KeDispatcherObjectWake(&Thread->Tcb.DispatcherHeader);
ObDereferenceObject(Thread->ThreadsProcess);
Thread->ThreadsProcess = NULL;
PiTerminateProcessThreads(Process, ExitStatus);
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED;
+ Process->Pcb.DispatcherHeader.SignalState = TRUE;
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
if (PsGetCurrentThread()->ThreadsProcess == Process)
{
/* INCLUDES **************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ps.h>
-/* $Id: thread.c,v 1.26 1999/09/06 21:28:33 ekohl Exp $
+/* $Id: thread.c,v 1.27 1999/10/07 23:38:30 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* INCLUDES ****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/ob.h>
}
+static NTSTATUS
+PsCreateTeb (HANDLE ProcessHandle,
+ PNT_TEB *TebPtr,
+ PETHREAD Thread,
+ PINITIAL_TEB InitialTeb)
+{
+ MEMORY_BASIC_INFORMATION Info;
+ NTSTATUS Status;
+ ULONG ByteCount;
+ ULONG RegionSize;
+ ULONG TebSize;
+ PVOID TebBase;
+ NT_TEB Teb;
+
+ TebBase = (PVOID)0x7FFDE000;
+ TebSize = PAGESIZE;
+
+ while (TRUE)
+ {
+ Status = NtQueryVirtualMemory(ProcessHandle,
+ TebBase,
+ MemoryBasicInformation,
+ &Info,
+ sizeof(MEMORY_BASIC_INFORMATION),
+ &ByteCount);
+ if (!NT_SUCCESS(Status))
+ {
+ DbgPrint ("NtQueryVirtualMemory (Status %x)\n",Status);
+ return Status;
+ }
+
+ if (Info.State == MEM_FREE)
+ {
+ DbgPrint("Virtual memory at %p is free.\n",
+ TebBase);
+ }
+ else
+ {
+ DbgPrint("Virtual memory at %p is allocated (BaseAddress %p RegionSize %x).\n",
+ TebBase, Info.BaseAddress, Info.RegionSize);
+ }
+
+ if (Info.State == MEM_FREE)
+ {
+ break;
+ }
+
+ TebBase = Info.BaseAddress - TebSize;
+ }
+
+// if (Info.State != MEM_FREE)
+// return STATUS_SUCCESS;
+
+
+ /* The TEB must reside in user space */
+ Status = NtAllocateVirtualMemory(ProcessHandle,
+ &TebBase,
+ 0,
+ &TebSize,
+ MEM_COMMIT,
+ PAGE_READWRITE);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DbgPrint ("TEB allocation failed!\n");
+ DbgPrint ("Status %x\n",Status);
+ return Status;
+ }
+
+ DbgPrint ("TebBase %p TebSize %lu\n", TebBase, TebSize);
+
+
+ /* set all pointers to and from the TEB */
+ Teb.Tib.Self = TebBase;
+ if (Thread->ThreadsProcess)
+ {
+ Teb.Peb = Thread->ThreadsProcess->Peb; /* No PEB yet!! */
+ }
+
+ /* store stack information from InitialTeb */
+ if (InitialTeb != NULL)
+ {
+ Teb.Tib.StackBase = InitialTeb->StackBase;
+ Teb.Tib.StackLimit = InitialTeb->StackLimit;
+
+ /*
+ * I don't know if this is really stored in a WNT-TEB,
+ * but it's needed to free the thread stack. (Eric Kohl)
+ */
+ Teb.StackCommit = InitialTeb->StackCommit;
+ Teb.StackCommitMax = InitialTeb->StackCommitMax;
+ Teb.StackReserved = InitialTeb->StackReserved;
+ }
+
+
+ /* more initialization */
+ Teb.Cid.UniqueThread = Thread->Cid.UniqueThread;
+ Teb.Cid.UniqueProcess = Thread->Cid.UniqueProcess;
+
+ /* write TEB data into teb page */
+ Status = NtWriteVirtualMemory(ProcessHandle,
+ TebBase,
+ &Teb,
+ sizeof(NT_TEB),
+ &ByteCount);
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* free TEB */
+ DbgPrint ("Writing TEB failed!\n");
+
+ RegionSize = 0;
+ NtFreeVirtualMemory(ProcessHandle,
+ TebBase,
+ &RegionSize,
+ MEM_RELEASE);
+
+ return Status;
+ }
+
+ /* FIXME: fs:[0] = TEB */
+
+ if (TebPtr != NULL)
+ {
+// *TebPtr = (PNT_TEB)TebBase;
+ }
+
+ DbgPrint ("TEB allocated at %p\n", TebBase);
+
+ return Status;
+}
+
+
NTSTATUS
STDCALL
NtCreateThread (
)
{
PETHREAD Thread;
+ PNT_TEB TebBase;
NTSTATUS Status;
DPRINT("NtCreateThread(ThreadHandle %x, PCONTEXT %x)\n",
{
return(Status);
}
+
+ Status = PsCreateTeb (ProcessHandle,
+ &TebBase,
+ Thread,
+ InitialTeb);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ /* Attention: TebBase is in user memory space */
+// Thread->Tcb.Teb = TebBase;
+
Thread->StartAddress=NULL;
if (Client!=NULL)
/* INCLUDES *****************************************************************/
+#include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/linkage.h>
-#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#define NDEBUG
/* INCLUDES *****************************************************************/
-#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
IN HANDLE ClientToken,
IN ACCESS_MASK DesiredAccess,
IN PGENERIC_MAPPING GenericMapping,
- OUT PPRIVILEGE_SET PrivilegeSet,
+ OUT PPRIVILEGE_SET PrivilegeSet,
OUT PULONG ReturnLength,
OUT PULONG GrantedAccess,
OUT PBOOLEAN AccessStatus)