which included commits to RCS files with non-trunk default branches.
svn path=/trunk/; revision=31
PagedPool,
PagedPoolCacheAligned,
};
-
-/*
- * Possible status codes
- * FIXME: These may not be the actual values used by NT
- */
-enum
-{
- STATUS_SUCCESS = 0x0,
- STATUS_INSUFFICIENT_RESOURCES = 0x80000000,
- STATUS_OBJECT_NAME_EXISTS,
- STATUS_OBJECT_NAME_COLLISION,
-// STATUS_DATATYPE_MISALIGNMENT,
- STATUS_CTL_FILE_NOT_SUPPORTED,
-// STATUS_ACCESS_VIOLATION,
- STATUS_PORT_ALREADY_SET,
- STATUS_SECTION_NOT_IMAGE,
- STATUS_BAD_WORKING_SET_LIMIT,
- STATUS_INCOMPATIBLE_FILE_MAP,
- STATUS_HANDLE_NOT_WAITABLE,
- STATUS_PORT_DISCONNECTED,
- STATUS_NOT_LOCKED,
- STATUS_NOT_MAPPED_VIEW,
- STATUS_UNABLE_TO_FREE_VM,
- STATUS_UNABLE_TO_DELETE_SECTION,
- STATUS_MORE_PROCESSING_REQUIRED,
- STATUS_INVALID_CID,
- STATUS_BAD_INITIAL_STACK,
- STATUS_INVALID_VOLUME_LABEL,
- STATUS_SECTION_NOT_EXTENDED,
- STATUS_NOT_MAPPED_DATA,
- STATUS_INFO_LENGTH_MISMATCH,
- STATUS_INVALID_INFO_CLASS,
- STATUS_SUSPEND_COUNT_EXCEEDED,
- STATUS_NOTIFY_ENUM_DIR,
- STATUS_REGISTRY_RECOVERED,
- STATUS_REGISTRY_IO_FAILED,
- STATUS_KEY_DELETED,
- STATUS_NO_LOG_SPACE,
- STATUS_KEY_HAS_CHILDREN,
- STATUS_CHILD_MUST_BE_VOLATILE,
- STATUS_REGISTRY_CORRUPT,
- STATUS_DLL_NOT_FOUND,
- STATUS_DLL_INIT_FAILED,
- STATUS_ORDINAL_NOT_FOUND,
- STATUS_ENTRYPOINT_NOT_FOUND,
-// STATUS_PENDING,
- STATUS_MORE_ENTRIES,
-// STATUS_INTEGER_OVERFLOW,
- STATUS_BUFFER_OVERFLOW,
- STATUS_NO_MORE_FILES,
- STATUS_NO_INHERITANCE,
- STATUS_NO_MORE_EAS,
- STATUS_NO_MORE_ENTRIES,
- STATUS_GUIDS_EXHAUSTED,
- STATUS_AGENTS_EXHAUSTED,
- STATUS_UNSUCCESSFUL,
- STATUS_NOT_IMPLEMENTED,
- STATUS_ILLEGAL_FUNCTION,
-// STATUS_IN_PAGE_ERROR,
- STATUS_PAGEFILE_QUOTA,
- STATUS_COMMITMENT_LIMIT,
- STATUS_SECTION_TOO_BIG,
- RPC_NT_SS_IN_NULL_CONTEXT,
- RPC_NT_INVALID_BINDING,
-// STATUS_INVALID_HANDLE,
- STATUS_OBJECT_FILE_MISMATCH,
- STATUS_FILE_CLOSED,
- STATUS_INVALID_PORT_HANDLE,
- STATUS_NOT_COMMITTED,
- STATUS_INVALID_PARAMETER,
- STATUS_INVALID_PARAMETER_1,
- STATUS_INVALID_PARAMETER_2,
- STATUS_INVALID_PARAMETER_3,
- STATUS_INVALID_PARAMETER_4,
- STATUS_INVALID_PARAMETER_5,
- STATUS_INVALID_PARAMETER_6,
- STATUS_INVALID_PARAMETER_7,
- STATUS_INVALID_PARAMETER_8,
- STATUS_INVALID_PARAMETER_9,
- STATUS_INVALID_PARAMETER_10,
- STATUS_INVALID_PARAMETER_11,
- STATUS_INVALID_PARAMETER_12,
- STATUS_INVALID_PARAMETER_MAX,
- STATUS_INVALID_PAGE_PROTECTION,
- STATUS_RESOURCE_DATA_NOT_FOUND,
- STATUS_RESOURCE_TYPE_NOT_FOUND,
- STATUS_RESOURCE_NAME_NOT_FOUND,
- STATUS_RESOURCE_LANG_NOT_FOUND,
- STATUS_NO_SUCH_DEVICE,
- STATUS_NO_SUCH_FILE,
- STATUS_INVALID_DEVICE_REQUEST,
- STATUS_END_OF_FILE,
- STATUS_FILE_FORCED_CLOSED,
- STATUS_WRONG_VOLUME,
- STATUS_NO_MEDIA,
- STATUS_NO_MEDIA_IN_DEVICE,
- STATUS_NONEXISTENT_SECTOR,
- STATUS_WORKING_SET_QUOTA,
-// STATUS_NO_MEMORY,
- STATUS_CONFLICTING_ADDRESS,
- STATUS_INVALID_SYSTEM_SERVICE,
- STATUS_THREAD_IS_TERMINATING,
- STATUS_PROCESS_IS_TERMINATING,
- STATUS_INVALID_LOCK_SEQUENCE,
- STATUS_INVALID_VIEW_SIZE,
- STATUS_ALREADY_COMMITTED,
- STATUS_ACCESS_DENIED,
- STATUS_FILE_IS_A_DIRECTORY,
- STATUS_CANNOT_DELETE,
- STATUS_INVALID_COMPUTER_NAME,
- STATUS_FILE_DELETED,
- STATUS_DELETE_PENDING,
- STATUS_PORT_CONNECTION_REFUSED,
- STATUS_NO_SUCH_PRIVILEGE,
- STATUS_PRIVILEGE_NOT_HELD,
- STATUS_CANNOT_IMPERSONATE,
- STATUS_LOGON_FAILURE,
- STATUS_ACCOUNT_RESTRICTION,
- STATUS_INVALID_LOGON_HOURS,
- STATUS_INVALID_WORKSTATION,
- STATUS_BUFFER_TOO_SMALL,
- STATUS_UNABLE_TO_DECOMMIT_VM,
- STATUS_DISK_CORRUPT_ERROR,
- STATUS_OBJECT_NAME_INVALID,
- STATUS_OBJECT_NAME_NOT_FOUND,
-// STATUS_OBJECT_NAME_COLLISION,
- STATUS_OBJECT_PATH_INVALID,
- STATUS_OBJECT_PATH_NOT_FOUND,
- STATUS_DFS_EXIT_PATH_FOUND,
- STATUS_OBJECT_PATH_SYNTAX_BAD,
- STATUS_DATA_OVERRUN,
- STATUS_DATA_LATE_ERROR,
- STATUS_DATA_ERROR,
- STATUS_CRC_ERROR,
- STATUS_SHARING_VIOLATION,
- STATUS_QUOTA_EXCEEDED,
- STATUS_MUTANT_NOT_OWNED,
- STATUS_SEMAPHORE_LIMIT_EXCEEDED,
- STATUS_DISK_FULL,
- STATUS_LOCK_NOT_GRANTED,
-
- STATUS_DEVICE_NOT_READY,
- STATUS_IO_TIMEOUT,
- STATUS_MEDIA_WRITE_PROTECTED,
- STATUS_NO_MEDIA_IN_DRIVE,
- STATUS_VERIFY_REQUIRED,
- STATUS_UNRECOGNIZED_MEDIA,
- STATUS_UNRECOGNIZED_VOLUME,
-// STATUS_WRONG_VOLUME,
- STATUS_FS_DRIVER_REQUIRED,
-};
/*
* This is a list of bug check types (not MS's)
enum
{
NotificationTimer,
- SynchronizationTimer,
+ SynchronizationTimer,
};
/*
typedef struct
{
LONG Count;
- PKTHREAD Owner;
+ struct _KTHREAD* Owner;
ULONG Contention;
KEVENT Event;
ULONG OldIrql;
+#ifndef __INCLUDE_DDK_IODEF_H
+#define __INCLUDE_DDK_IODEF_H
+
typedef enum _IO_QUERY_DEVICE_DESCRIPTION
{
IoQueryDeviceIdentifier = 0,
IRP_MJ_MAXIMUM_FUNCTION,
};
+enum
+/*
+ * PURPOSE: Details about the result of a file open or create
+ */
+{
+ FILE_CREATED,
+// FILE_OPENED,
+ FILE_OVERWRITTEN,
+ FILE_SUPERSEDED,
+ FILE_EXISTS,
+ FILE_DOES_NOT_EXIST,
+};
+
+#endif
*/
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(IRP* irp);
-PEPROCESS IoGetCurrentProcess(VOID);
+struct _EPROCESS* IoGetCurrentProcess(VOID);
NTSTATUS IoGetDeviceObjectPointer(PUNICODE_STRING ObjectName,
ACCESS_MASK DesiredAccess,
/* STRUCTURE TYPES ***********************************************************/
+typedef struct _ADAPTER_OBJECT
+{
+} ADAPTER_OBJECT, *PADAPTER_OBJECT;
+
/*
* PURPOSE: Special timer associated with each device
* NOTES: This is a guess
struct
{
KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
- PETHREAD Thread;
+ struct _ETHREAD* Thread;
PCHAR AuxiliaryBuffer;
LIST_ENTRY ListEntry;
struct _IO_STACK_LOCATION* CurrentStackLocation;
{
NotificationEvent,
SynchronizationEvent,
+ SemaphoreType,
} EVENT_TYPE;
typedef enum _KWAIT_REASON
/* KERNEL FUNCTIONS ********************************************************/
+struct _KAPC;
+
+void KeInitializeApc(
+ struct _KAPC *Apc,
+ PKTHREAD Thread,
+ UCHAR StateIndex,
+ PKKERNEL_ROUTINE KernelRoutine,
+ PKRUNDOWN_ROUTINE RundownRoutine,
+ PKNORMAL_ROUTINE NormalRoutine,
+ UCHAR Mode,
+ PVOID Context
+ );
+
+void KeInsertQueueApc(struct _KAPC *Apc, PVOID SystemArgument1,
+ PVOID SystemArgument2, UCHAR Mode);
+void KeAttachProcess(struct _EPROCESS* Process);
+void KeDetachProcess(VOID);
VOID KeDrainApcQueue(VOID);
-VOID KeInitializeApc(PKAPC Apc, PKNORMAL_ROUTINE NormalRoutine,
- PVOID NormalContext,
- PKTHREAD TargetThread);
-BOOLEAN KeInsertQueueApc(PKAPC Apc);
+PKPROCESS KeGetCurrentProcess(VOID);
/*
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
#ifndef __INCLUDE_DDK_KETYPES_H
#define __INCLUDE_DDK_KETYPES_H
+struct _KMUTANT;
+
typedef LONG KPRIORITY;
typedef VOID (*PKBUGCHECK_CALLBACK_ROUTINE)(PVOID Buffer, ULONG Length);
USHORT WaitType;
} KWAIT_BLOCK, *PKWAIT_BLOCK;
+typedef struct _DISPATCHER_HEADER
+{
+ UCHAR Type;
+ UCHAR Absolute;
+ UCHAR Size;
+ UCHAR Inserted;
+ LONG SignalState;
+ LIST_ENTRY WaitListHead;
+} DISPATCHER_HEADER;
+
+struct _KDPC;
+
+typedef struct _KTIMER
+{
+ /*
+ * Pointers to maintain the linked list of activated timers
+ */
+ LIST_ENTRY entry;
+
+ /*
+ * Absolute expiration time in system time units
+ */
+ signed long long expire_time;
+
+ /*
+ * Optional dpc associated with the timer
+ */
+ struct _KDPC* dpc;
+
+ /*
+ * True if the timer is signaled
+ */
+ BOOLEAN signaled;
+
+ /*
+ * True if the timer is in the system timer queue
+ */
+ BOOLEAN running;
+
+ /*
+ * Type of the timer either Notification or Synchronization
+ */
+ TIMER_TYPE type;
+
+ /*
+ * Period of the timer in milliseconds (zero if once-only)
+ */
+ ULONG period;
+
+} KTIMER, *PKTIMER;
+
+struct _KSPIN_LOCK;
+
+typedef struct _KSPIN_LOCK
+{
+ KIRQL irql;
+} KSPIN_LOCK, *PKSPIN_LOCK;
+
+typedef struct _KDEVICE_QUEUE
+{
+ LIST_ENTRY ListHead;
+ BOOLEAN Busy;
+ KSPIN_LOCK Lock;
+} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
+
+#if RIGHT_DEFINITION_PROVIDED_ABOVE
#define _KTHREAD _ETHREAD
-typedef struct _ETHREAD
+typedef struct _KTHREAD
/*
* PURPOSE: Describes a thread of execution
*/
*/
hal_thread_state context;
+ /*
+ * PURPOSE: Timeout for the thread to be woken up
+ */
+ signed long long int wake_time;
+
} KTHREAD, *PKTHREAD, *PETHREAD;
-
-typedef struct _DISPATCHER_HEADER
-{
- UCHAR Type;
- UCHAR Absolute;
- UCHAR Size;
- UCHAR Inserted;
- LONG SignalState;
- LIST_ENTRY WaitListHead;
-} DISPATCHER_HEADER;
+#endif
+
typedef struct _KAPC
{
} KEVENT, *PKEVENT;
-typedef struct _KSPIN_LOCK
-{
- KIRQL irql;
-} KSPIN_LOCK, *PKSPIN_LOCK;
typedef VOID (*PDRIVER_ADD_DEVICE)(VOID);
} KDPC, *PKDPC;
-typedef struct _KDEVICE_QUEUE
-{
- LIST_ENTRY ListHead;
- BOOLEAN Busy;
- KSPIN_LOCK Lock;
-} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
typedef struct _KDEVICE_QUEUE_ENTRY
{
{
} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK;
-
-typedef struct _KTIMER
-{
- /*
- * Pointers to maintain the linked list of activated timers
- */
- LIST_ENTRY entry;
-
- /*
- * Absolute expiration time in system time units
- */
- unsigned long long expire_time;
-
- /*
- * Optional dpc associated with the timer
- */
- PKDPC dpc;
-
- /*
- * True if the timer is signaled
- */
- BOOLEAN signaled;
-
- /*
- * True if the timer is in the system timer queue
- */
- BOOLEAN running;
-
- /*
- * Type of the timer either Notification or Synchronization
- */
- TIMER_TYPE type;
-
- /*
- * Period of the timer in milliseconds (zero if once-only)
- */
- ULONG period;
-
-} KTIMER, *PKTIMER;
-
struct _KINTERRUPT;
typedef BOOLEAN (*PKSERVICE_ROUTINE)(struct _KINTERRUPT* Interrupt,
VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes);
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList);
+PVOID MmAllocateSection(ULONG Length);
#include <windows.h>
-#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
-#define NTKERNELAPI
-
- #define CTL_CODE(Dev, Func, Meth, Acc) ( ((Dev)<<16) | ((Acc)<<14) | ((Func)<<2) | (Meth))
-
-// IOCTL Parameter buffering methods
-#define METHOD_BUFFERED 0
-#define METHOD_IN_DIRECT 1
-#define METHOD_OUT_DIRECT 2
-#define METHOD_NEITHER 3
-
-// IOCTL File access type
-#define FILE_ANY_ACCESS 0
-#define FILE_READ_ACCESS 1
-#define FILE_WRITE_ACCESS 2
-
#define QUAD_PART(LI) (*(LONGLONG *)(&LI))
-enum {
- STATUS_NOT_SUPPORTED = 9999,
- STATUS_DISK_OPERATION_FAILED
-};
#define IO_DISK_INCREMENT 4
#define FILE_WORD_ALIGNMENT 0x0001
#define FILE_OPENED 0x0001
-
+
+#include <ddk/status.h>
+#include <ddk/ntdef.h>
#include <ddk/defines.h>
#include <ddk/types.h>
-#include <ddk/structs.h>
+#include <ddk/cfgtypes.h>
+#include <ddk/ketypes.h>
+#include <ddk/obtypes.h>
+#include <ddk/mmtypes.h>
+#include <ddk/iotypes.h>
+#include <ddk/extypes.h>
+#include <ddk/pstypes.h>
#include <ddk/setypes.h>
-
+#include <ddk/ioctrl.h>
#include <internal/hal/ddk.h>
#include <ddk/rtl.h>
struct _DIRECTORY_OBJECT;
+typedef ULONG ACCESS_STATE, *PACCESS_STATE;
+
typedef struct _OBJECT_HANDLE_INFORMATION {
ULONG HandleAttributes;
ACCESS_MASK GrantedAccess;
*/
ULONG HandleCount;
+ struct _DIRECTORY_OBJECT* Parent;
+
/*
* PURPOSE: Object type
* NOTE: This overlaps the first member of the object body
*/
CSHORT Size;
+
} OBJECT_HEADER, *POBJECT_HEADER;
/*
-typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
/*
* FUNCTION: Creates a thread which executes in kernel mode
NTSTATUS PsSuspendThread(VOID);
NTSTATUS PsWakeThread(PETHREAD Thread);
PETHREAD PsGetCurrentThread(VOID);
-PEPROCESS PsGetCurrentProcess(VOID);
+struct _EPROCESS* PsGetCurrentProcess(VOID);
#define __INCLUDE_DDK_PSTYPES_H
#include <kernel32/heap.h>
+#include <internal/hal.h>
-typedef ULONG THREADINFOCLASS;
+typedef NTSTATUS (*PKSTART_ROUTINE)(PVOID StartContext);
-typedef struct _CLIENT_ID
+typedef struct _STACK_INFORMATION
{
- HANDLE UniqueProcess;
- HANDLE UniqueThread;
-} CLIENT_ID, *PCLIENT_ID;
+ PVOID BaseAddress;
+ PVOID UpperAddress;
+} STACK_INFORMATION, *PSTACK_INFORMATION;
+
+typedef struct linux_sigcontext {
+ int sc_gs;
+ int sc_fs;
+ int sc_es;
+ int sc_ds;
+ int sc_edi;
+ int sc_esi;
+ int sc_ebp;
+ int sc_esp;
+ int sc_ebx;
+ int sc_edx;
+ int sc_ecx;
+ int sc_eax;
+ int sc_trapno;
+ int sc_err;
+ int sc_eip;
+ int sc_cs;
+ int sc_eflags;
+ int sc_esp_at_signal;
+ int sc_ss;
+ int sc_387;
+ int sc_mask;
+ int sc_cr2;
+} TRAP_FRAME, *PTRAP_FRAME;
+
+typedef ULONG THREADINFOCLASS;
-//typedef void* HEAP;
-typedef void* HANDLE_TABLE;
typedef void* ATOMTABLE;
typedef struct _pPebInfo {
- LPWSTR lpCommandLine;
- DWORD cb;
- HANDLE hStdInput; //18
- HANDLE hStdput;
- HANDLE hStdError;
- LPWSTR lpEnvironment;
- DWORD dwX;
- DWORD dwY;
- DWORD dwXSize;
- DWORD dwYSize;
- DWORD dwXCountChars;
- DWORD dwYCountChars;
- DWORD dwFillAttribute;
- DWORD dwFlags;
- DWORD wShowWindow;
- LPTSTR lpTitle;
- LPTSTR lpDesktop;
- LPTSTR reserved;
- DWORD cbReserved2;
- LPTSTR lpReserved1;
+ WCHAR* WindowTitle;
+ WCHAR* ImageFile;
+ WCHAR* CommandLine;
+ WCHAR* DllPath;
+// STARTUPINFOW StartupInfo;
} PEBINFO;
+typedef struct _LDR_ {
+ UCHAR Initialized;
+ UCHAR InInitializationOrderModuleList;
+ PVOID InLoadOrderModuleList;
+ PVOID InMemoryOrderModuleList;
+} LDR, *PLDR;
+
+
typedef struct _NT_PEB
{
-
+ UCHAR InheritedAddressSpace;
+ UCHAR ReadImageFileExecOptions;
+ UCHAR BeingDebugged;
LONG ImageBaseAddress;
- DWORD nActiveStdHandle;
- void *HeapIndex;
+ LDR Ldr;
DWORD dwTlsBits[2]; // tls in use bits
WORD NumberOfProcessors;
WORD NtGlobalFlag;
- DWORD dwCriticalSectionTime;
- DWORD dwHeapReserve;
- DWORD dwHeapCommit;
- DWORD dwHeapDecommitFreeBlockThreshold;
- DWORD dwNumberOfHeaps;
- DWORD dwMaxiumNumberOfHeaps;
- PEBINFO *pPebInfo;
- HEAP *pProcessHeap;
- HANDLE_TABLE htGDISharedHandleTable;
+ DWORD HeapReserve;
+ DWORD HeapCommit;
+ DWORD HeapDecommitFreeBlockThreshold;
+ DWORD NumberOfHeaps;
+ DWORD MaxiumNumberOfHeaps;
+ PEBINFO* PebInfo;
+ PHEAP ProcessHeap;
ATOMTABLE LocalAtomTable;
- CRITICAL_SECTION *pCriticalSection;
- WORD wMajorVersion;
- WORD wMinorVersion;
- WORD wBuildNumber;
- WORD wPlatformId;
-} NT_PEB, *PPEB;
+ LPCRITICAL_SECTION CriticalSection;
+ DWORD CriticalSectionTimeout;
+ WORD MajorVersion;
+ WORD MinorVersion;
+ WORD BuildNumber;
+ WORD PlatformId;
+} NT_PEB, *PNT_PEB;
+typedef struct _CLIENT_ID
+{
+ HANDLE UniqueProcess;
+ HANDLE UniqueThread;
+} CLIENT_ID, *PCLIENT_ID;
typedef struct _NT_TIB {
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
union {
PVOID FiberData;
ULONG Version;
- } s;
+ } Fib;
PVOID ArbitraryUserPointer;
struct _NT_TIB *Self;
} NT_TIB, *PNT_TIB;
{
NT_TIB Tib;
- DWORD dwProcessId;
- DWORD dwThreadId;
- HANDLE hRPC;
+ CLIENT_ID Cid;
+ HANDLE RPCHandle;
+ PVOID TlsData;
NT_PEB *pPeb;
- DWORD dwErrCode;
- WORD nMutexCount;
- LCID Locale;
- //HQUEUE MessageQueue
- DWORD dwTlsIndex ;
- LPVOID TlsData[512];
-
+ DWORD LastErrorCode;
+ NTSTATUS LastStatusValue;
+ DWORD LockCount;
+ UCHAR HardErrorMode;
} NT_TEB;
+typedef struct _KTHREAD
+{
+ DISPATCHER_HEADER DispatcherHeader;
+ TIME ElapsedTime;
+ TIME KernelTime;
+ TIME UserTime;
+ STACK_INFORMATION StackInformation;
+ PVOID ServiceDescriptorTable; // points to KeServiceDescriptorTable
+ KAFFINITY Affinity;
+ KPRIORITY CurrentPriority;
+ KPRIORITY BasePriority;
+ ULONG Quantum;
+ UCHAR ThreadState; //Thread state is a typeless enum, otherwise it should be const integer
+ ULONG FreezeCount;
+ ULONG SuspendCount;
+ PTRAP_FRAME TrapFrame;
+ PVOID *Tls;
+ KWAIT_BLOCK WaitBlock[4];
+ struct _KMUTANT* MutantList;
+ PLIST_ENTRY ApcList;
+ UCHAR KernelApcDisable;
+ KTIMER TimerBlock;
+ KDEVICE_QUEUE DeviceQueue;
+ NT_TEB* Teb;
+
+ /*
+ * PURPOSE: CPU state
+ * NOTE: I have temporarily added this to give somewhere to store
+ * cpu state when the thread isn't running
+ */
+ hal_thread_state Context;
+ LIST_ENTRY Entry;
+} KTHREAD, *PKTHREAD;
-typedef NT_TEB *PINITIAL_TEB;
-typedef struct _EPROCESS
-{
-} EPROCESS, *PEPROCESS;
+// According to documentation the stack should have a commited [ 1 page ] and
+// a reserved part [ 1 M ].
+
+typedef struct _INITIAL_TEB {
+ PVOID StackCommit;
+ PVOID StackReserved;
+} INITIAL_TEB, *PINITIAL_TEB;
+
-//typedef KTHREAD ETHREAD, *PETHREAD;
-#if ETHREAD_NOT_THE_SAME_AS_KTHREAD
-typedef struct _ETHREAD
+
+//ThreadState defines the current state of a thread
+//FIXME I am allready defined in psmgr.h as a enum
+/*
+enum
{
- EPROCESS* Process;
-} ETHREAD, *PETHREAD;
+ THREAD_STATE_INITIALIZED = 0,
+ THREAD_STATE_READY,
+ THREAD_STATE_RUNNING,
+ THREAD_STATE_STANDBY,
+ THREAD_STATE_TERMINATED,
+ THREAD_STATE_WAIT,
+ THREAD_STATE_TRANSITION,
+ THREAD_STATE_RESERVED
+};
+*/
+
+// wait reason only applies for threads in a wait state
+// part of this enum is double ????
/*
- * PURPOSE: Thread object
- */
-typedef struct
+typedef _KWAIT_REASON
{
- CSHORT Type;
- CSHORT Size;
-
- /*
- * PURPOSE: Entry in the linked list of threads
- */
- LIST_ENTRY Entry;
-
- /*
- * PURPOSE: Current state of the thread
- */
- ULONG State;
-
- /*
- * PURPOSE: Priority modifier of the thread
- */
- ULONG Priority;
-
- /*
- * PURPOSE: Pointer to our parent process
- */
-// PEPROCESS Parent;
-
- /*
- * PURPOSE: Handle of our parent process
- */
- HANDLE ParentHandle;
-
- /*
- * PURPOSE: Not currently used
- */
- ULONG AffinityMask;
+ WAIT_EXCECUTIVE1 = 0,
+ WAIT_FREE_PAGE1,
+ WAIT_PAGE_IN1,
+ WAIT_POOL_ALLOCATION1,
+ WAIT_EXECUTION_DELAY1,
+ WAIT_SUSPENDED_CONDITION1,
+ WAIT_USER_REQUEST1,
+ WAIT_EXCECUTIVE2,
+ WAIT_FREE_PAGE2,
+ WAIT_PAGE_IN2,
+ WAIT_POOL_ALLOCATION2,
+ WAIT_EXECUTION_DELAY2,
+ WAIT_SUSPENDED_CONDITION2,
+ WAIT_USER_REQUEST2,
+ WAIT_EVENT_PAIR_HIGH,
+ WAIT_EVENT_PAIR_LOW,
+ WAIT_LPC_RECEIVE,
+ WAIT_LPC_REPLY,
+ WAIT_VIRTUAL_MEMORY,
+ WAIT_PAGE_OUT
+} KWAIT_REASON;
+
+*/
+
+
+// TopLevelIrp can be one of the following values:
+// FIXME I belong somewhere else
+
+#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
+#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
+#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
+#define FSRTL_FAST_IO_TOP_LEVEL_IRP (0x04)
+#define FSRTL_MAX_TOP_LEVEL_IRP_FLAG (0x04)
+
+typedef struct _TOP_LEVEL_IRP
+{
+ PIRP TopLevelIrp;
+ ULONG TopLevelIrpConst;
+} TOP_LEVEL_IRP;
+
+typedef struct _ETHREAD {
+ KTHREAD Tcb;
+ TIME CreateTime;
+ TIME ExitTime;
+ NTSTATUS ExitStatus;
+ LIST_ENTRY PostBlockList;
+ LIST_ENTRY TerminationPortList;
+ ULONG ActiveTimerListLock;
+ PVOID ActiveTimerListHead;
+ CLIENT_ID Cid;
+ PLARGE_INTEGER LpcReplySemaphore;
+ PVOID LpcReplyMessage;
+ PLARGE_INTEGER LpcReplyMessageId;
+ PVOID ImpersonationInfo;
+ LIST_ENTRY IrpList; //
+ TOP_LEVEL_IRP TopLevelIrp;
+ ULONG ReadClusterSize;
+ UCHAR ForwardClusterOnly;
+ UCHAR DisablePageFaultClustering;
+ UCHAR DeadThread;
+ UCHAR HasTerminated;
+ ACCESS_MASK GrantedAccess;
+ struct _EPROCESS* ThreadsProcess;
+ PKSTART_ROUTINE StartAddress;
+ LPTHREAD_START_ROUTINE Win32StartAddress; // Should Specify a win32 start func
+ UCHAR LpcExitThreadCalled;
+ UCHAR HardErrorsAreDisabled;
+} ETHREAD, *PETHREAD;
+
+
+typedef struct _KPROCESS {
+ DISPATCHER_HEADER DispatcherHeader;
+ PVOID PageTableDirectory; // FIXME: I shoud point to a PTD
+ TIME ElapsedTime;
+ TIME KernelTime;
+ TIME UserTime;
+ LIST_ENTRY InOutSwap; // ??
+ KSPIN_LOCK SpinLock;
+ KAFFINITY Affinity;
+ ULONG StackCount;
+ KPRIORITY BasePriority;
+ ULONG DefaultThreadQuantum;
+ UCHAR ProcessState;
+ ULONG ThreadSeed;
+ UCHAR DisableBoost;
/*
- * PURPOSE: Saved thread context
+ * Added by David Welch (welch@mcmail.com)
*/
- hal_thread_state context;
-
-} THREAD_OBJECT, *PTHREAD_OBJECT;
-#endif
+ LIST_ENTRY MemoryAreaList;
+} KPROCESS, *PKPROCESS;
+
+typedef struct _EPROCESS
+{
+ KPROCESS Pcb;
+} EPROCESS, *PEPROCESS;
#endif /* __INCLUDE_DDK_PSTYPES_H */
+/*
+ * COPYRIGHT: See COPYING in the top level directory for details
+ * PROJECT: ReactOS kernel
+ * FILE: include/ddk/setypes.h
+ * PURPOSE: Security manager types
+ * REVISION HISTORY:
+ * ??/??/??: Created with empty stubs by David Welch
+ * 29/08/98: ACCESS_TOKEN definition from Boudewijn Dekker
+ */
typedef ULONG ACCESS_MODE, *PACCESS_MODE;
typedef struct _SECURITY_DESCRIPTOR_CONTEXT
{
} SECURITY_DESCRIPTOR_CONTEXT, *PSECURITY_DESCRIPTOR_CONTEXT;
+
+typedef struct _ACCESS_TOKEN {
+ TOKEN_SOURCE TokenSource;
+ LUID AuthenticationId;
+ LARGE_INTEGER ExpirationTime;
+ LUID ModifiedId;
+ ULONG UserAndGroupCount;
+ ULONG PrivilegeCount;
+ ULONG VariableLength;
+ ULONG DynamicCharged;
+ ULONG DynamicAvailable;
+ ULONG DefaultOwnerIndex;
+ PACL DefaultDacl;
+ TOKEN_TYPE TokenType;
+ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
+ UCHAR TokenFlags;
+ UCHAR TokenInUse;
+ UCHAR Unused[2];
+ PVOID ProxyData;
+ PVOID AuditData;
+ UCHAR VariablePart[0];
+} ACCESS_TOKEN, *PACCESS_TOKEN;
typedef ULONG KEY_INFORMATION_CLASS;
typedef ULONG FILE_INFORMATION_CLASS;
typedef ULONG KEY_VALUE_INFORMATION_CLASS;
-typedef ULONG PHYSICAL_ADDRESS;
+typedef LARGE_INTEGER PHYSICAL_ADDRESS;
typedef PHYSICAL_ADDRESS* PPHYSICAL_ADDRESS;
typedef ULONG WAIT_TYPE;
//typedef ULONG KINTERRUPT_MODE;
typedef USHORT CSHORT;
+
+typedef struct _TIME {
+ DWORD LowPart;
+ LONG HighPart;
+} TIME;
+
#endif
-
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* ??/??/??: Complete implementation by Boudewijn Dekker
* 13/07/98: Reorganised things a bit (David Welch)
* 04/08/98: Added some documentation (Boudewijn Dekker)
+ * 14/08/98: Added type TIME and change variable type from [1] to [0]
*/
#ifndef __DDK_ZW_H
SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
#endif
-
+
+
+
+/*
#if IOTYPES_DIDNT_DECLARE_THIS
typedef struct _IO_STATUS_BLOCK {
NTSTATUS Status;
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
#endif
-
-
-//typedef LARGE_INTEGER *PLARGE_INTEGER;
-
-//
+*/
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
#define EVENT_WRITE_ACCESS 2
+// file creation flags
+
+#define FILE_DIRECTORY_FILE 0x00000001
+#define FILE_WRITE_THROUGH 0x00000002
+#define FILE_SEQUENTIAL_ONLY 0x00000004
+#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
+
+#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
+#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
+#define FILE_NON_DIRECTORY_FILE 0x00000040
+#define FILE_CREATE_TREE_CONNECTION 0x00000080
+
+#define FILE_COMPLETE_IF_OPLOCKED 0x00000100
+#define FILE_NO_EA_KNOWLEDGE 0x00000200
+
+#define FILE_RANDOM_ACCESS 0x00000800
+
+#define FILE_DELETE_ON_CLOSE 0x00001000
+#define FILE_OPEN_BY_FILE_ID 0x00002000
+#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
+#define FILE_NO_COMPRESSION 0x00008000
+
+#define FILE_RESERVE_OPFILTER 0x00100000
+#define FILE_TRANSACTED_MODE 0x00200000
+#define FILE_OPEN_OFFLINE_FILE 0x00400000
+
+#define FILE_VALID_OPTION_FLAGS 0x007fffff
+#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
+#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
+#define FILE_VALID_SET_FLAGS 0x00001036
+
+
+// file disposition values
+
+
+#define FILE_SUPERSEDE 0x0000
+#define FILE_OPEN 0x0001
+#define FILE_CREATE 0x0002
+#define FILE_OPEN_IF 0x0003
+#define FILE_OVERWRITE 0x0004
+#define FILE_OVERWRITE_IF 0x0005
+#define FILE_MAXIMUM_DISPOSITION 0x0005
+
+
+
+
//process query / set information class
#define ProcessBasicInformation 0
#define MaxProcessInfoClass 22
// thread query / set information class
-
#define ThreadBasicInformation 0
#define ThreadTimes 1
#define ThreadPriority 2
#define MaxThreadInfoClass 15
+
// key query information class
#define KeyBasicInformation 0
// object handle information
-#define HandleInformation 0
-#define HandleName 1
-#define HandleTypeInformation 2
-#define HandleAllInformation 3
-#define HandleBasicInformation 4
+#define ObjectBasicInformation 0
+#define ObjectNameInformation 1
+#define ObjectTypeInformation 2
+#define ObjectAllInformation 3
+#define ObjectDataInformation 4
+
+// semaphore information
+
+#define SemaphoreBasicInformation 0
+
+// event information
+
+#define EventBasicInformation 0
+
// system information
+
#define SystemPerformanceInformation 5
#define SystemCacheInformation 21
#define SystemTimeAdjustmentInformation 28
// shutdown action
-typedef enum _SHUTDOWN_ACTION_ {
+typedef enum SHUTDOWN_ACTION_TAG {
ShutdownNoReboot,
ShutdownReboot,
ShutdownPowerOff
// object type access rights
-#define OBJECT_TYPE_CREATE 0x00000001
+#define OBJECT_TYPE_CREATE 0x0001
#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
#define SYMBOLIC_LINK_QUERY 0x0001
#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
-typedef struct _PROCESS_WS_WATCH_INFORMATION_
+typedef struct _PROCESS_WS_WATCH_INFORMATION
{
PVOID FaultingPc;
PVOID FaultingVa;
} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION;
-typedef struct _PROCESS_BASIC_INFORMATION_
+typedef struct _PROCESS_BASIC_INFORMATION
{
NTSTATUS ExitStatus;
- PPEB PebBaseAddress;
+ PNT_PEB PebBaseAddress;
KAFFINITY AffinityMask;
KPRIORITY BasePriority;
ULONG UniqueProcessId;
ULONG InheritedFromUniqueProcessId;
} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
-typedef struct _QUOTA_LIMITS_
+typedef struct _QUOTA_LIMITS
{
ULONG PagedPoolLimit;
ULONG NonPagedPoolLimit;
ULONG MinimumWorkingSetSize;
ULONG MaximumWorkingSetSize;
ULONG PagefileLimit;
- LARGE_INTEGER TimeLimit;
+ TIME TimeLimit;
} QUOTA_LIMITS, *PQUOTA_LIMITS;
-typedef struct _IO_COUNTERS_
+typedef struct _IO_COUNTERS
{
ULONG ReadOperationCount;
ULONG WriteOperationCount;
} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
-typedef struct _PROCESS_ACCESS_TOKEN_
+typedef struct _PROCESS_ACCESS_TOKEN
{
HANDLE Token;
HANDLE Thread;
} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
-typedef struct _KERNEL_USER_TIMES_
+typedef struct _KERNEL_USER_TIMES
{
- LARGE_INTEGER CreateTime;
- LARGE_INTEGER ExitTime;
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
+ TIME CreateTime;
+ TIME ExitTime;
+ TIME KernelTime;
+ TIME UserTime;
} KERNEL_USER_TIMES;
typedef KERNEL_USER_TIMES *PKERNEL_USER_TIMES;
+// thread information
+
+// incompatible with MS NT
+
+typedef struct _THREAD_BASIC_INFORMATION
+{
+ NTSTATUS ExitStatus;
+ PVOID TebBaseAddress;
+ KAFFINITY AffinityMask;
+ KPRIORITY BasePriority;
+ ULONG UniqueThreadId;
+} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
+
+// object information
-typedef struct _OBJECT_NAME_INFORMATION_
+typedef struct _OBJECT_NAME_INFORMATION
{
UNICODE_STRING Name;
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
-// section information
-
-// handle information
-
-//HandleBasicInformation HANDLE_BASIC_INFORMATION
-typedef struct _HANDLE_BASIC_INFORMATION_
+typedef struct _OBJECT_DATA_INFORMATION
{
BOOL bInheritHanlde;
BOOL bProtectFromClose;
-} HANDLE_BASIC_INFORMATION, *PHANDLE_BASIC_INFORMATION;
+} OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
-//HandleTypeInormation HANDLE_TYPE_INFORMATION
-typedef struct _HANDLE_TYPE_INFORMATION_ {
+
+typedef struct _OBJECT_TYPE_INFORMATION
+{
UNICODE_STRING Name;
UNICODE_STRING Type;
ULONG TotalHandles;
ULONG ReferenceCount;
-} HANDLE_TYPE_INFORMATION, *PHANDLE_TYPE_INFORMATION;
+} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION;
-typedef struct _SYSTEM_TIME_ADJUSTMENT_
+// system information
+
+typedef struct _SYSTEM_TIME_ADJUSTMENT
{
ULONG TimeAdjustment;
BOOL TimeAdjustmentDisabled;
} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
-
-#ifdef __STRUCTS_H_DIDNT_DEFINE_THIS_ALREADY
-typedef struct _SYSTEM_INFO_ {
+
+typedef struct _SYSTEM_CONFIGURATION_INFO {
union {
- DWORD dwOemId;
+ ULONG OemId;
struct {
- WORD wProcessorArchitecture;
- WORD wReserved;
- };
- };
- DWORD dwPageSize;
- LPVOID lpMinimumApplicationAddress;
- LPVOID lpMaximumApplicationAddress;
- DWORD dwActiveProcessorMask;
- DWORD dwNumberOfProcessors;
- DWORD dwProcessorType;
- DWORD dwAllocationGranularity;
- WORD wProcessorLevel;
- WORD wProcessorRevision;
-} SYSTEM_INFO;
-#endif
-
-typedef struct _SYSTEM_CACHE_INFORMATION_ {
+ WORD ProcessorArchitecture;
+ WORD Reserved;
+ } tag1;
+ } tag2;
+ ULONG PageSize;
+ PVOID MinimumApplicationAddress;
+ PVOID MaximumApplicationAddress;
+ ULONG ActiveProcessorMask;
+ ULONG NumberOfProcessors;
+ ULONG ProcessorType;
+ ULONG AllocationGranularity;
+ WORD ProcessorLevel;
+ WORD ProcessorRevision;
+} SYSTEM_CONFIGURATION_INFO, *PSYSTEM_CONFIGURATION_INFO;
+
+
+typedef struct _SYSTEM_CACHE_INFORMATION {
ULONG CurrentSize;
ULONG PeakSize;
ULONG PageFaultCount;
// file information
-typedef struct _FILE_BASIC_INFORMATION_
+typedef struct _FILE_BASIC_INFORMATION
{
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
+ TIME CreationTime;
+ TIME LastAccessTime;
+ TIME LastWriteTime;
+ TIME ChangeTime;
ULONG FileAttributes;
} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
-typedef struct _FILE_STANDARD_INFORMATION_
+typedef struct _FILE_STANDARD_INFORMATION
{
LARGE_INTEGER AllocationSize;
LARGE_INTEGER EndOfFile;
BOOLEAN Directory;
} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
-typedef struct _FILE_POSITION_INFORMATION_
+typedef struct _FILE_POSITION_INFORMATION
{
LARGE_INTEGER CurrentByteOffset;
} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
-typedef struct _FILE_ALIGNMENT_INFORMATION_
+typedef struct _FILE_ALIGNMENT_INFORMATION
{
ULONG AlignmentRequirement;
} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
-typedef struct _FILE_DISPOSITION_INFORMATION_
+typedef struct _FILE_DISPOSITION_INFORMATION
{
BOOLEAN DeleteFile;
} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
-typedef struct _FILE_END_OF_FILE_INFORMATION_
+typedef struct _FILE_END_OF_FILE_INFORMATION
{
LARGE_INTEGER EndOfFile;
} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
-typedef struct _FILE_NETWORK_OPEN_INFORMATION_ {
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
+typedef struct _FILE_NETWORK_OPEN_INFORMATION {
+ TIME CreationTime;
+ TIME LastAccessTime;
+ TIME LastWriteTime;
+ TIME ChangeTime;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER EndOfFile;
ULONG FileAttributes;
} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
-typedef struct _FILE_FULL_EA_INFORMATION_
+typedef struct _FILE_FULL_EA_INFORMATION
{
ULONG NextEntryOffset;
UCHAR Flags;
UCHAR EaNameLength;
USHORT EaValueLength;
CHAR *EaName;
-} FILE_FULL_EA_INFORMATION;
-typedef FILE_FULL_EA_INFORMATION *PFILE_FULL_EA_INFORMATION;
+} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
-typedef struct _FILE_EA_INFORMATION_ {
+typedef struct _FILE_EA_INFORMATION {
ULONG EaSize;
-} FILE_EA_INFORMATION;
+} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
-typedef struct _FILE_STREAM_INFORMATION_
-{
+
+typedef struct _FILE_GET_EA_INFORMATION {
+ ULONG NextEntryOffset;
+ UCHAR EaNameLength;
+ CHAR EaName[0];
+} FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
+
+typedef struct _FILE_STREAM_INFORMATION {
ULONG NextEntryOffset;
ULONG StreamNameLength;
LARGE_INTEGER StreamSize;
LARGE_INTEGER StreamAllocationSize;
- WCHAR StreamName[1];
+ WCHAR StreamName[0];
} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
+typedef struct _FILE_ALLOCATION_INFORMATION {
+ LARGE_INTEGER AllocationSize;
+} FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION;
-#ifdef __IO_TYPE_DIDNT_DEFINE_THIS_ALREADY
-typedef struct _IO_COMPLETION_CONTEXT
-{
- PVOID Port;
- ULONG Key;
-} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
-#endif
-
-typedef struct _FILE_ALLOCATION_INFORMATION_ {
- LARGE_INTEGER AllocationSize;
-} FILE_ALLOCATION_INFORMATION;
+typedef struct _FILE_NAME_INFORMATION {
+ ULONG FileNameLength;
+ WCHAR FileName[0];
+} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
-typedef struct _FILE_NAME_INFORMATION_ {
+typedef struct _FILE_NAMES_INFORMATION {
+ ULONG NextEntryOffset;
+ ULONG FileIndex;
ULONG FileNameLength;
- WCHAR FileName[1];
-} FILE_NAME_INFORMATION;
+ WCHAR FileName[0];
+} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
-typedef struct _FILE_RENAME_INFORMATION_ {
+
+typedef struct _FILE_RENAME_INFORMATION {
BOOLEAN Replace;
HANDLE RootDir;
ULONG FileNameLength;
- WCHAR FileName[1];
+ WCHAR FileName[0];
} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
-typedef struct _FILE_INTERNAL_INFORMATION_ {
+typedef struct _FILE_INTERNAL_INFORMATION {
LARGE_INTEGER IndexNumber;
-} FILE_INTERNAL_INFORMATION;
+} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
-typedef struct _FILE_ACCESS_INFORMATION_ {
+typedef struct _FILE_ACCESS_INFORMATION {
ACCESS_MASK AccessFlags;
-} FILE_ACCESS_INFORMATION;
+} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
-#ifdef __DEFINED_ABOVE
-typedef struct _FILE_POSITION_INFORMATION_ {
- LARGE_INTEGER CurrentByteOffset;
-} FILE_POSITION_INFORMATION;
-#endif
-typedef struct _FILE_MODE_INFORMATION_ {
+typedef struct _FILE_MODE_INFORMATION {
ULONG Mode;
-} FILE_MODE_INFORMATION;
-
-#ifdef __DEFINED_ABOVE
-typedef struct _FILE_ALIGNMENT_INFORMATION_ {
- ULONG AlignmentRequirement;
-} FILE_ALIGNMENT_INFORMATION;
-#endif
+} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
-typedef struct _FILE_COMPRESSION_INFORMATION_ {
+typedef struct _FILE_COMPRESSION_INFORMATION {
LARGE_INTEGER CompressedFileSize;
USHORT CompressionFormat;
UCHAR CompressionUnitShift;
UCHAR ChunkShift;
UCHAR ClusterShift;
UCHAR Reserved[3];
-} FILE_COMPRESSION_INFORMATION;
+} FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
typedef struct _FILE_ALL_INFORMATION {
FILE_BASIC_INFORMATION BasicInformation;
FILE_MODE_INFORMATION ModeInformation;
FILE_ALIGNMENT_INFORMATION AlignmentInformation;
FILE_NAME_INFORMATION NameInformation;
-} FILE_ALL_INFORMATION;
+} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION;
// file system information structures
-typedef struct _FILE_FS_DEVICE_INFORMATION_ {
+typedef struct _FILE_FS_DEVICE_INFORMATION {
DEVICE_TYPE DeviceType;
ULONG Characteristics;
-} FILE_FS_DEVICE_INFORMATION;
-typedef FILE_FS_DEVICE_INFORMATION *PFILE_FS_DEVICE_INFORMATION;
+} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
+
+
+/* device type can be one of the following values:
+
+ FILE_DEVICE_BEEP 0x00000001
+ FILE_DEVICE_CD_ROM 0x00000002
+ FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
+ FILE_DEVICE_CONTROLLER 0x00000004
+ FILE_DEVICE_DATALINK 0x00000005
+ FILE_DEVICE_DFS 0x00000006
+ FILE_DEVICE_DISK 0x00000007
+ FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
+ FILE_DEVICE_FILE_SYSTEM 0x00000009
+ FILE_DEVICE_INPORT_PORT 0x0000000a
+ FILE_DEVICE_KEYBOARD 0x0000000b
+ FILE_DEVICE_MAILSLOT 0x0000000c
+ FILE_DEVICE_MIDI_IN 0x0000000d
+ FILE_DEVICE_MIDI_OUT 0x0000000e
+ FILE_DEVICE_MOUSE 0x0000000f
+ FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
+ FILE_DEVICE_NAMED_PIPE 0x00000011
+ FILE_DEVICE_NETWORK 0x00000012
+ FILE_DEVICE_NETWORK_BROWSER 0x00000013
+ FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
+ FILE_DEVICE_NULL 0x00000015
+ FILE_DEVICE_PARALLEL_PORT 0x00000016
+ FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
+ FILE_DEVICE_PRINTER 0x00000018
+ FILE_DEVICE_SCANNER 0x00000019
+ FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
+ FILE_DEVICE_SERIAL_PORT 0x0000001b
+ FILE_DEVICE_SCREEN 0x0000001c
+ FILE_DEVICE_SOUND 0x0000001d
+ FILE_DEVICE_STREAMS 0x0000001e
+ FILE_DEVICE_TAPE 0x0000001f
+ FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
+ FILE_DEVICE_TRANSPORT 0x00000021
+ FILE_DEVICE_UNKNOWN 0x00000022
+ FILE_DEVICE_VIDEO 0x00000023
+ FILE_DEVICE_VIRTUAL_DISK 0x00000024
+ FILE_DEVICE_WAVE_IN 0x00000025
+ FILE_DEVICE_WAVE_OUT 0x00000026
+ FILE_DEVICE_8042_PORT 0x00000027
+ FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
+ FILE_DEVICE_BATTERY 0x00000029
+ FILE_DEVICE_BUS_EXTENDER 0x0000002a
+ FILE_DEVICE_MODEM 0x0000002b
+ FILE_DEVICE_VDM 0x0000002c
+ */
/*
characteristics is one of the following values:
FILE_VIRTUAL_VOLUME 0x00000040
*/
-typedef struct _FILE_FS_VOLUME_INFORMATION_ {
- LARGE_INTEGER VolumeCreationTime;
+typedef struct _FILE_FS_VOLUME_INFORMATION {
+ TIME VolumeCreationTime;
ULONG VolumeSerialNumber;
ULONG VolumeLabelLength;
BOOLEAN SupportsObjects;
- WCHAR VolumeLabel[1];
+ WCHAR VolumeLabel[0];
} FILE_FS_VOLUME_INFORMATION;
-typedef struct _FILE_FS_SIZE_INFORMATION_ {
+typedef struct _FILE_FS_SIZE_INFORMATION {
LARGE_INTEGER TotalAllocationUnits;
LARGE_INTEGER AvailableAllocationUnits;
ULONG SectorsPerAllocationUnit;
ULONG BytesPerSector;
-} FILE_FS_SIZE_INFORMATION;
+} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
-typedef struct _FILE_FS_ATTRIBUTE_INFORMATION_ {
+typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
ULONG FileSystemAttributes;
LONG MaximumComponentNameLength;
ULONG FileSystemNameLength;
- WCHAR FileSystemName[1];
+ WCHAR FileSystemName[0];
} FILE_FS_ATTRIBUTE_INFORMATION;
/*
FILE_VOLUME_QUOTAS 0x00000020
FILE_VOLUME_IS_COMPRESSED 0x00008000
*/
+typedef struct _FILE_FS_LABEL_INFORMATION {
+ ULONG VolumeLabelLength;
+ WCHAR VolumeLabel[0];
+} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION;
+// read file scatter / write file scatter
+//FIXME I am a win32 struct aswell
+
+typedef union _FILE_SEGMENT_ELEMENT {
+ PVOID Buffer;
+ ULONG Alignment;
+}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
// directory information
-typedef struct _OBJDIR_INFORMATION_ {
+typedef struct _OBJDIR_INFORMATION {
UNICODE_STRING ObjectName;
UNICODE_STRING ObjectTypeName; // Directory, Device ...
- UCHAR Data[1]; // variable size
+ UCHAR Data[0];
} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
+typedef struct _FILE_DIRECTORY_INFORMATION {
+ ULONG NextEntryOffset;
+ ULONG FileIndex;
+ TIME CreationTime;
+ TIME LastAccessTime;
+ TIME LastWriteTime;
+ TIME ChangeTime;
+ LARGE_INTEGER EndOfFile;
+ LARGE_INTEGER AllocationSize;
+ ULONG FileAttributes;
+ ULONG FileNameLength;
+ WCHAR FileName[0];
+} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
+
+typedef struct _FILE_FULL_DIRECTORY_INFORMATION {
+ ULONG NextEntryOffset;
+ ULONG FileIndex;
+ TIME CreationTime;
+ TIME LastAccessTime;
+ TIME LastWriteTime;
+ TIME ChangeTime;
+ LARGE_INTEGER EndOfFile;
+ LARGE_INTEGER AllocationSize;
+ ULONG FileAttributes;
+ ULONG FileNameLength;
+ ULONG EaSize;
+ WCHAR FileName[0];
+} FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION;
+
+
+typedef struct _FILE_BOTH_DIRECTORY_INFORMATION {
+ ULONG NextEntryOffset;
+ ULONG FileIndex;
+ TIME CreationTime;
+ TIME LastAccessTime;
+ TIME LastWriteTime;
+ TIME ChangeTime;
+ LARGE_INTEGER EndOfFile;
+ LARGE_INTEGER AllocationSize;
+ ULONG FileAttributes;
+ ULONG FileNameLength;
+ ULONG EaSize;
+ CHAR ShortNameLength;
+ WCHAR ShortName[12]; // 8.3 name
+ WCHAR FileName[0];
+} FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION;
+
+
/*
NotifyFilter / CompletionFilter:
FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
*/
-typedef struct _FILE_NOTIFY_INFORMATION_ {
+typedef struct _FILE_NOTIFY_INFORMATION {
ULONG NextEntryOffset;
ULONG Action;
ULONG FileNameLength;
- WCHAR FileName[1]; // variable size
+ WCHAR FileName[0];
} FILE_NOTIFY_INFORMATION;
*/
-//FIXME: I belong somewhere in windows.h
+//FIXME: I am a win32 object
typedef
VOID
(*PTIMERAPCROUTINE)(
// NtProcessStartup parameters
-typedef struct _ENVIRONMENT_INFORMATION_ {
+typedef struct _ENVIRONMENT_INFORMATION {
ULONG Unknown[21];
UNICODE_STRING CommandLine;
UNICODE_STRING ImageFile;
} ENVIRONMENT_INFORMATION, *PENVIRONMENT_INFORMATION;
-typedef struct _STARTUP_ARGUMENT_ {
+typedef struct _STARTUP_ARGUMENT {
ULONG Unknown[3];
PENVIRONMENT_INFORMATION Environment;
} STARTUP_ARGUMENT, *PSTARTUP_ARGUMENT;
#define FSCTL_GET_RETRIEVAL_POINTERS 0x90073
#define FSCTL_MOVE_FILE 0x90074
-typedef struct _MAPPING_PAIR_ {
+typedef struct _MAPPING_PAIR
+{
ULONGLONG Vcn;
ULONGLONG Lcn;
} MAPPING_PAIR, *PMAPPING_PAIR;
-typedef struct _GET_RETRIEVAL_DESCRIPTOR_ {
+typedef struct _GET_RETRIEVAL_DESCRIPTOR
+{
ULONG NumberOfPairs;
ULONGLONG StartVcn;
- MAPPING_PAIR Pair[1];
+ MAPPING_PAIR Pair[0];
} GET_RETRIEVAL_DESCRIPTOR, *PGET_RETRIEVAL_DESCRIPTOR;
-typedef struct _BITMAP_DESCRIPTOR_ {
+typedef struct _BITMAP_DESCRIPTOR
+{
ULONGLONG StartLcn;
ULONGLONG ClustersToEndOfVol;
- BYTE Map[1];
+ BYTE Map[0];
} BITMAP_DESCRIPTOR, *PBITMAP_DESCRIPTOR;
-typedef struct _MOVEFILE_DESCRIPTOR_ {
+typedef struct _MOVEFILE_DESCRIPTOR
+{
HANDLE FileHandle;
ULONG Reserved;
LARGE_INTEGER StartVcn;
} MOVEFILE_DESCRIPTOR, *PMOVEFILE_DESCRIPTOR;
+// semaphore information
+
+typedef struct _SEMAPHORE_BASIC_INFORMATION
+{
+ ULONG CurrentCount;
+ ULONG MaximumCount;
+} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION;
+
+// event information
+
+typedef struct _EVENT_BASIC_INFORMATION
+{
+ BOOL AutomaticReset;
+ BOOL Signaled;
+} EVENT_BASIC_INFORMATION, *PEVENT_INFORMATION;
+
/*
* FUNCTION: Adds an atom to the global atom table
* ARGUMENTS:
+ Atom (OUT) = Caller supplies storage for the resulting atom.
* AtomString = The string to add to the atom table.
* REMARKS: The arguments map to the win32 add GlobalAddAtom.
* RETURNS: Status
STDCALL
NtAddAtom(
OUT ATOM *Atom,
- IN PUNICODE_STRING pString
+ IN PUNICODE_STRING AtomString
);
/*
- * FUNCTION: Decrements a thread's resume count and places it in an alerted state.
+ * FUNCTION: Decrements a thread's suspend count and places it in an alerted
+ * state.
* ARGUMENTS:
* ThreadHandle = Handle to the thread that should be resumed
- * SuspendCount = The resulting resume count.
+ * SuspendCount = The resulting suspend count.
* REMARK:
- A thread is resumed if its resume count is 0
+ * A thread is resumed if its suspend count is 0
* RETURNS: Status
*/
NTSTATUS
IN HANDLE ThreadHandle,
OUT PULONG SuspendCount
);
+
/*
* FUNCTION: Puts the thread in a alerted state
* ARGUMENTS:
NtAlertThread(
IN HANDLE ThreadHandle
);
+
/*
* FUNCTION: Allocates a locally unique id
* ARGUMENTS:
* FUNCTION: Allocates a block of virtual memory in the process address space
* ARGUMENTS:
* ProcessHandle = The handle of the process which owns the virtual memory
- * BaseAddress = A pointer to the virtual memory allocated
- * StartAddress = (OPTIONAL) The requested start address
- * NumberOfBytesAllocated = The number of bytes to allocate
+ * BaseAddress = A pointer to the virtual memory allocated. If you supply a non zero
+ * value the system will try to allocate the memory at the address supplied. It rounds
+ * it down to a multiple if the page size.
+ * ZeroBits = (OPTIONAL) You can specify the number of high order bits that must be zero, ensuring that
+ * the memory will be allocated at a address below a certain value.
+ * RegionSize = The number of bytes to allocate
* AllocationType = Indicates the type of virtual memory you like to allocated,
* can be one of the values : MEM_COMMIT, MEM_RESERVE, MEM_RESET, MEM_TOP_DOWN
- * ProtectionType = Indicates the protection type of the pages allocated, can be a combination of
+ * Protect = Indicates the protection type of the pages allocated, can be a combination of
* PAGE_READONLY, PAGE_READWRITE, PAGE_EXECUTE_READ,
* PAGE_EXECUTE_READWRITE, PAGE_GUARD, PAGE_NOACCESS, PAGE_NOACCESS
* REMARKS:
NTSTATUS
STDCALL
NtAllocateVirtualMemory(
- IN HANDLE hProcess,
- OUT PVOID BaseAddress,
- IN ULONG StartAddress,
- IN ULONG NumberOfBytesAllocated,
+ IN HANDLE ProcessHandle,
+ OUT PVOID *BaseAddress,
+ IN ULONG ZeroBits,
+ IN ULONG RegionSize,
IN ULONG AllocationType,
- IN ULONG ProtectionType
+ IN ULONG Protect
);
/*
* FUNCTION: Cancels a IO request
* ARGUMENTS:
* FileHandle = Handle to the file
- * IoStatusBlock = Specifies the status of the io request when it was cancelled
+ * IoStatusBlock =
+
* REMARKS:
* This function maps to the win32 CancelIo.
* RETURNS: Status
* ARGUMENTS:
* Handle = Handle to the object
* REMARKS:
- This function maps to the win32 function CloseHandle.
+ * This function maps to the win32 function CloseHandle.
* RETURNS: Status
*/
* ARGUMENTS:
* Context = Specifies the processor context
* REMARKS
- NtContinue can be used to continue after a exception.
+ * NtContinue can be used to continue after a exception.
* RETURNS: Status
*/
//FIXME This function might need another parameter
IN BOOL ManualReset,
IN BOOL InitialState
);
+
+/*
+ * FUNCTION: Creates an eventpair object
+ * ARGUMENTS:
+ * EventPairHandle (OUT) = Caller supplied storage for the resulting handle
+ * DesiredAccess = Specifies access to the event
+ * ObjectAttribute = Initialized attributes for the object
+ */
+
+NTSTATUS
+STDCALL
+NtCreateEventPair(
+ OUT PHANDLE FileHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes
+ );
+
+
/*
* FUNCTION: Creates or opens a file, directory or device object.
* ARGUMENTS:
IN PUNICODE_STRING PageFileName,
IN ULONG MiniumSize,
IN ULONG MaxiumSize,
- OUT PULONG ActualSize
+ OUT PULONG ActualSize
);
/*
* FUNCTION: Creates a process.
* DesiredAccess = Specifies the allowed or desired access to the thread.
* ObjectAttributes = Initialized attributes for the object.
* ProcessHandle = Handle to the threads parent process.
- * ClientId = Caller supplies storage for process id and thread id.
+ * ClientId (OUT) = Caller supplies storage for returned process id and thread id.
* ThreadContext = Initial processor context for the thread.
* InitialTeb = Initial Thread Environment Block for the Thread.
* CreateSuspended = Specifies if the thread is ready for scheduling
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
IN HANDLE ProcessHandle,
- IN PCLIENT_ID ClientId,
+ OUT PCLIENT_ID ClientId,
IN PCONTEXT ThreadContext,
IN PINITIAL_TEB InitialTeb,
IN BOOLEAN CreateSuspended
/*
* FUNCTION: Deletes a file
* ARGUMENTS:
- * FileHandle = Handle to the file which should be deleted
+ * ObjectAttributes = Handle to the file which should be deleted
* REMARKS:
- * The function maps to the win32 DeleteFile
+ This system call is functionally equivalent to NtSetInformationFile
+ setting the disposition information.
+ * The function maps to the win32 DeleteFile.
* RETURNS: Status
*/
NTSTATUS
STDCALL
NtDeleteFile(
- IN HANDLE FileHandle
+ IN POBJECT_ATTRIBUTES ObjectAttributes
);
/*
* FUNCTION: Flushes chached file data to disk
* ARGUMENTS:
* FileHandle = Points to the file
+ IoStatusBlock = Caller must supply storage to receive the result of the flush
+ buffers operation. The information field is set to number of bytes
+ flushed to disk.
* RETURNS: Status
* REMARKS:
This funciton maps to the win32 FlushFileBuffers
NTSTATUS
STDCALL
NtFlushBuffersFile(
- IN HANDLE FileHandle
+ IN HANDLE FileHandle,
+ OUT PIO_STATUS_BLOCK IoStatusBlock
);
/*
* FUNCTION: Flushes a the processors instruction cache
* FUNCTION: Frees a range of virtual memory
* ARGUMENTS:
* ProcessHandle = Points to the process that allocated the virtual memory
- * BaseAddress = Points to the memory address
- * NumberOfBytesToFree = Limits the range to free,
- * NumberOfBytesFreed = Actual number of bytes freed
+ * BaseAddress = Points to the memory address, rounded down to a multiple of the pagesize
+ * RegionSize = Limits the range to free, rounded up to a multiple of the paging size
+ * FreeType = Can be one of the values: MEM_DECOMMIT, or MEM_RELEASE
* RETURNS: Status
*/
STDCALL
NtFreeVirtualMemory(
IN PHANDLE ProcessHandle,
- IN PVOID BaseAddress,
- IN ULONG NumberOfBytesToFree,
- OUT PULONG NumberOfBytesFreeed OPTIONAL
+ IN PVOID *BaseAddress,
+ IN ULONG RegionSize,
+ IN ULONG FreeType
);
/*
* FUNCTION: Loads a registry key.
* ARGUMENTS:
* KeyHandle = Handle to the registry key
- * ObjectAttributes = ???
+ ObjectAttributes = ???
* REMARK:
- * This procedure maps to the win32 procedure RegLoadKey
+ This procedure maps to the win32 procedure RegLoadKey
* RETURNS: Status
*/
NTSTATUS
* ApcContext = Argument to the callback
* IoStatusBlock (OUT) = Caller should supply storage for a structure containing
* the completion status and information about the requested lock operation.
- * ByteOffsetOfLock = Offset
- * LengthOfLock = Number of bytes to lock.
- * KeyOfLock =
- * DoNotWaitIfHeld =
- * IsExclusiveLock =
+ * ByteOffset = Offset
+ * Length = Number of bytes to lock.
+ * Key =
+ * FailImmediatedly =
+ * ExclusiveLock =
* REMARK:
- * This procedure maps to the win32 procedure LockFileEx
+ This procedure maps to the win32 procedure LockFileEx
* RETURNS: Status
*/
NTSTATUS
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN PLARGE_INTEGER ByteOffsetOfLock,
- IN PLARGE_INTEGER LengthOfLock,
- IN ULONG KeyOfLock,
- IN BOOLEAN DoNotWaitIfHeld,
- IN BOOLEAN IsExclusiveLock
+ IN PLARGE_INTEGER ByteOffset,
+ IN PLARGE_INTEGER Length,
+ IN ULONG Key,
+ IN BOOLEAN FailImmediatedly,
+ IN BOOLEAN ExclusiveLock
);
/*
* FUNCTION: Locks a range of virtual memory.
* NumberOfBytesLock = Offset to the upper boundary.
* NumberOfBytesLocked (OUT) = Number of bytes actually locked.
* REMARK:
- * This procedure maps to the win32 procedure VirtualLock
+ This procedure maps to the win32 procedure VirtualLock
* RETURNS: Status
*/
NTSTATUS
NtMakeTemporaryObject(
IN HANDLE Handle
);
-
-
/*
* FUNCTION: Maps a view of a section into the virtual address space of a
* process
* FUNCTION: Installs a notify for the change of a directory's contents
* ARGUMENTS:
* FileHandle = Handle to the directory
- * Event =
- * UserApcRoutine = Start address
- * UserApcContext = Delimits the range of virtual memory
+ Event =
+ * ApcRoutine = Start address
+ * ApcContext = Delimits the range of virtual memory
* for which the new access protection holds
* IoStatusBlock = The new access proctection for the pages
* Buffer = Caller supplies storage for resulting information --> FILE_NOTIFY_INFORMATION
* BufferSize = Size of the buffer
- * NotifyFilter = // might be completionfileter
- * WatchSubtree =
+ CompletionFilter = Can be one of the following values:
+ FILE_NOTIFY_CHANGE_FILE_NAME
+ FILE_NOTIFY_CHANGE_DIR_NAME
+ FILE_NOTIFY_CHANGE_NAME ( FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME )
+ FILE_NOTIFY_CHANGE_ATTRIBUTES
+ FILE_NOTIFY_CHANGE_SIZE
+ FILE_NOTIFY_CHANGE_LAST_WRITE
+ FILE_NOTIFY_CHANGE_LAST_ACCESS
+ FILE_NOTIFY_CHANGE_CREATION ( change of creation timestamp )
+ FILE_NOTIFY_CHANGE_EA
+ FILE_NOTIFY_CHANGE_SECURITY
+ FILE_NOTIFY_CHANGE_STREAM_NAME
+ FILE_NOTIFY_CHANGE_STREAM_SIZE
+ FILE_NOTIFY_CHANGE_STREAM_WRITE
+ WatchTree = If true the notify will be installed recursively on the targetdirectory and all subdirectories.
*
* REMARKS:
* The function maps to the win32 FindFirstChangeNotification, FindNextChangeNotification
NtNotifyChangeDirectoryFile(
IN HANDLE FileHandle,
IN HANDLE Event OPTIONAL,
- IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
- IN PVOID UserApcContext OPTIONAL,
+ IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+ IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID Buffer,
IN ULONG BufferSize,
- IN ULONG NotifyFilter,
- IN BOOL WatchSubtree
+ IN ULONG CompletionFilter,
+ IN BOOL WatchTree
+ );
+NTSTATUS
+STDCALL
+NtNotifyChangeKey(
+ IN HANDLE KeyHandle,
+ IN HANDLE Event,
+ IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+ IN PVOID ApcContext OPTIONAL,
+ OUT PIO_STATUS_BLOCK IoStatusBlock,
+ IN ULONG CompletionFilter,
+ IN BOOLEAN Asynchroneous,
+ OUT PVOID ChangeBuffer,
+ IN ULONG Length,
+ IN BOOLEAN WatchSubtree
);
-//NtNotifyChangeKey
/*
* FUNCTION: Opens an existing directory object
* ARGUMENTS:
* ObjectAttributes = Initialized attributes for the object
* IoStatusBlock =
* ShareAccess =
- * FileAttributes =
+ * OpenOptions =
* RETURNS: Status
*/
NTSTATUS
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG ShareAccess,
- IN ULONG FileAttributes
+ IN ULONG OpenOptions
);
-//--> NtOpenIoCompletion
+
+/*
+ * FUNCTION: Opens an existing io completion object
+ * ARGUMENTS:
+ * CompletionPort (OUT) = Caller supplied storage for the resulting handle
+ * DesiredAccess = Requested access to the io completion object
+ * ObjectAttributes = Initialized attributes for the object
+ * RETURNS: Status
+ */
+
+NTSTATUS
+STDCALL
+NtOpenIoCompletion(
+ OUT PHANDLE CompetionPort,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes
+ );
+
/*
* FUNCTION: Opens an existing key in the registry
* ARGUMENTS:
* KeyHandle (OUT) = Caller supplied storage for the resulting handle
* DesiredAccess = Requested access to the key
- * ObjectAttribute = Initialized attributes for the object
+ * ObjectAttributes = Initialized attributes for the object
* RETURNS: Status
*/
NTSTATUS
* ProcessHandle (OUT) = Caller supplied storage for the resulting handle
* DesiredAccess = Requested access to the process
* ObjectAttribute = Initialized attributes for the object
- * ClientId = storage for the process id and the thread id
+ * ClientId = Identifies the process id to open
* RETURNS: Status
*/
NTSTATUS
* ThreadHandle (OUT) = Caller supplied storage for the resulting handle
* DesiredAccess = Requested access to the thread
* ObjectAttribute = Initialized attributes for the object
+ * ClientId = Identifies the thread to open.
* RETURNS: Status
*/
NTSTATUS
NtOpenThread(
OUT PHANDLE ThreadHandle,
IN ACCESS_MASK DesiredAccess,
- IN POBJECT_ATTRIBUTES ObjectAttributes
+ IN POBJECT_ATTRIBUTES ObjectAttributes,
+ IN PCLIENT_ID ClientId
);
/*
* FUNCTION: Opens an existing timer
);
//-- NtQueryAttributesFile
-//-- NtQueryDirectoryFile
+
+// FileNameInformation - FILE_NAMES_INFORMATION
+
+NTSTATUS
+STDCALL
+NtQueryDirectoryFile(
+ IN HANDLE FileHandle,
+ IN HANDLE Event OPTIONAL,
+ IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
+ IN PVOID ApcContext OPTIONAL,
+ OUT PIO_STATUS_BLOCK IoStatusBlock,
+ OUT PVOID FileInformation,
+ IN ULONG Length,
+ IN FILE_INFORMATION_CLASS FileInformationClass,
+ IN BOOLEAN ReturnSingleEntry,
+ IN PUNICODE_STRING FileName OPTIONAL,
+ IN BOOLEAN RestartScan
+ );
+
/*
* FUNCTION: Query information about the content of a directory object
* ARGUMENTS:
OUT PULONG DataWritten OPTIONAL
);
-
-//-- NtQueryEaFile
+NTSTATUS
+STDCALL
+NtQueryEaFile(
+ IN HANDLE FileHandle,
+ OUT PIO_STATUS_BLOCK IoStatusBlock,
+ OUT PVOID Buffer,
+ IN ULONG Length,
+ IN BOOLEAN ReturnSingleEntry,
+ IN PVOID EaList OPTIONAL,
+ IN ULONG EaListLength,
+ IN PULONG EaIndex OPTIONAL,
+ IN BOOLEAN RestartScan
+ );
/*
* FUNCTION: Queries an event
* ARGUMENTS:
* EventHandle = Handle to the event
* EventInformationClass = Index of the information structure
+
+ EventBasicInformation EVENT_BASIC_INFORMATION
+
* EventInformation = Caller supplies storage for the information structure
* EventInformationLength = Size of the information structure
* ReturnLength = Data written
* Lenght = Size of the storage for the file information.
* FileInformationClass = Indicates which file information is queried
- FileDirectoryInformation
- FileFullDirectoryInformation
- FileBothDirectoryInformation
+ FileDirectoryInformation FILE_DIRECTORY_INFORMATION
+ FileFullDirectoryInformation FILE_FULL_DIRECTORY_INFORMATION
+ FileBothDirectoryInformation FILE_BOTH_DIRECTORY_INFORMATION
FileBasicInformation FILE_BASIC_INFORMATION
FileStandardInformation FILE_STANDARD_INFORMATION
FileInternalInformation FILE_INTERNAL_INFORMATION
FileNameInformation FILE_NAME_INFORMATION
FileRenameInformation FILE_RENAME_INFORMATION
FileLinkInformation
- FileNamesInformation
+ FileNamesInformation FILE_NAMES_INFORMATION
FileDispositionInformation FILE_DISPOSITION_INFORMATION
FilePositionInformation FILE_POSITION_INFORMATION
FileFullEaInformation FILE_FULL_EA_INFORMATION
ProcessVmCounters VM_COUNTERS
ProcessTimes KERNEL_USER_TIMES
ProcessBasePriority KPRIORITY
- ProcessBasePriority KPRIORITY
ProcessRaisePriority KPRIORITY
ProcessDebugPort HANDLE
ProcessExceptionPort HANDLE
ProcessUserModeIOPL (I/O Privilege Level)
ProcessEnableAlignmentFaultFixup BOOLEAN
ProcessPriorityClass ULONG
- ProcessWx86Information
+ ProcessWx86Information ULONG
ProcessHandleCount ULONG
ProcessAffinityMask ULONG
ProcessPooledQuotaLimits QUOTA_LIMITS
+
NTSTATUS
STDCALL
NtQueryInformationProcess(
OUT PULONG ReturnLength
);
+
+
/*
* FUNCTION: Queries the information of a thread object.
* ARGUMENTS:
* ThreadHandle = Handle to the thread object
* ThreadInformationClass = Index to a certain information structure
- ThreadBasicInformation
+ ThreadBasicInformation THREAD_BASIC_INFORMATION
ThreadTimes KERNEL_USER_TIMES
ThreadPriority KPRIORITY
ThreadBasePriority KPRIORITY
ThreadQuerySetWin32StartAddress
ThreadZeroTlsCell
ThreadPerformanceCount
- ThreadAmILastThread
- ThreadIdealProcessor
- ThreadPriorityBoost
+ ThreadAmILastThread BOOLEAN
+ ThreadIdealProcessor ULONG
+ ThreadPriorityBoost ULONG
MaxThreadInfoClass
IN ULONG ThreadInformationLength,
OUT PULONG ReturnLength
);
-// NtQueryInformationToken
-//-- NtQueryIoCompletion
+
+NTSTATUS
+STDCALL
+NtQueryIoCompletion(
+ IN HANDLE CompletionPort,
+ IN CINT CompletionInformationClass,
+ OUT PVOID CompletionInformation,
+ IN ULONG Length,
+ OUT PULONG ReturnLength
+ );
+
+
/*
* FUNCTION: Queries the information of a registry key object.
* ARGUMENTS:
IN ULONG Length,
OUT PULONG ResultLength
);
-//-- NtQueryMultipleValueKey
-//-- NtQueryMutant
+
+// preliminary guess
+
+NTSTATUS
+STDCALL
+NtQueryMultipleValueKey(
+ HANDLE KeyHandle,
+ PVALENT ListOfValuesToQuery,
+ ULONG NumberOfItems,
+ PVOID MultipleValueInformation,
+ ULONG Length,
+ PULONG ReturnLength
+);
+
+/*
+ * FUNCTION: Queries the information of a mutant object.
+ * ARGUMENTS:
+ MutantHandle = Handle to a mutant
+ MutantInformationClass = Index to a certain information structure
+ MutantInformation = Caller supplies storage for resulting information
+ Length = Size of the supplied storage
+ ResultLength = Bytes written
+ */
+NTSTATUS
+STDCALL
+NtQueryMutant(
+ IN HANDLE MutantHandle,
+ IN CINT MutantInformationClass,
+ OUT PVOID MutantInformation,
+ IN ULONG Length,
+ OUT PULONG ResultLength
+ );
+
/*
* FUNCTION: Queries the information of a object.
* ARGUMENTS:
ObjectHandle = Handle to a object
- HandleInformationClass = Index to a certain information structure
+ ObjectInformationClass = Index to a certain information structure
- HandleBasicInformation HANDLE_BASIC_INFORMATION
- HandleTypeInormation HANDLE_TYPE_INFORMATION
+ ObjectBasicInformation
+ ObjectTypeInformation OBJECT_TYPE_INFORMATION
+ ObjectNameInformation OBJECT_NAME_INFORMATION
+ ObjectDataInformation OBJECT_DATA_INFORMATION
- HandleInformation = Caller supplies storage for resulting information
+ ObjectInformation = Caller supplies storage for resulting information
Length = Size of the supplied storage
ResultLength = Bytes written
*/
STDCALL
NtQueryObject(
IN HANDLE ObjectHandle,
- IN CINT HandleInformationClass,
- OUT PVOID HandleInformationPtr,
+ IN CINT ObjectInformationClass,
+ OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
);
-//-- NtQuerySemaphore
+/*
+ * FUNCTION: Queries the information of a semaphore.
+ * ARGUMENTS:
+ * SemaphoreHandle = Handle to the semaphore object
+ * SemaphoreInformationClass = Index to a certain information structure
+
+ SemaphoreBasicInformation SEMAPHORE_BASIC_INFORMATION
+
+ * SemaphoreInformation = Caller supplies storage for the semaphore information structure
+ * Length = Size of the infomation structure
+ */
+
+NTSTATUS
+STDCALL
+NtQuerySemaphore(
+ HANDLE SemaphoreHandle,
+ CINT SemaphoreInformationClass,
+ OUT PVOID SemaphoreInformation,
+ ULONG Length,
+ PULONG ReturnLength
+ );
+
/*
* FUNCTION: Queries the information of a symbolic link object.
* ARGUMENTS:
/*
* FUNCTION: Queries the timer resolution
* ARGUMENTS:
- * MinimumResolution (OUT) = Caller should supply storage for the
- * resulting time.
- * Maximum Resolution (OUT) = Caller should supply storage for the
- * resulting time.
- * ActualResolution (OUT) = Caller should supply storage for the
- * resulting time.
+ * MinimumResolution (OUT) = Caller should supply storage for the resulting time.
+ Maximum Resolution (OUT) = Caller should supply storage for the resulting time.
+ ActualResolution (OUT) = Caller should supply storage for the resulting time.
* RETURNS: Status
*
- */
+*/
NTSTATUS
NtQueryTimerResolution (
OUT PULONG MinimumResolution,
- OUT PULONG MaximumResolution,
+ OUT PULONG MaximumResolution,
OUT PULONG ActualResolution
);
FSInformationClass = Index to a information structure
FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION
- FileFsLabelInformation
+ FileFsLabelInformation FILE_FS_LABEL_INFORMATION
FileFsSizeInformation FILE_FS_SIZE_INFORMATION
FileFsDeviceInformation FILE_FS_DEVICE_INFORMATION
FileFsAttributeInformation FILE_FS_ATTRIBUTE_INFORMATION
FileFsControlInformation
- FileFsQuotaQueryInformation
- FileFsQuotaSetInformation
+ FileFsQuotaQueryInformation --
+ FileFsQuotaSetInformation --
FileFsMaximumInformation
* RETURNS: Status
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
IN PVOID UserApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK UserIoStatusBlock,
- IN LARGE_INTEGER BufferDescription[],
+ IN FILE_SEGMENT_ELEMENT BufferDescription[],
IN ULONG BufferLength,
IN PLARGE_INTEGER ByteOffset,
IN PULONG Key OPTIONAL
/*
* FUNCTION: Releases a semaphore
* ARGUMENTS:
- * SemaphoreHandle =
+ * SemaphoreHandle = Handle to the semaphore object
* ReleaseCount =
* PreviousCount =
* RETURNS: Status
HANDLE EventHandle,
PULONG NumberOfWaitingThreads OPTIONAL
);
- //NtRestoreKey
+//Preliminary guess
+NTSTATUS
+STDCALL
+NtRestoreKey(
+ HANDLE KeyHandle,
+ HANDLE FileHandle,
+ ULONG RestoreFlags
+ );
/*
* FUNCTION: Decrements a thread's resume count
* ARGUMENTS:
IN HANDLE ThreadHandle,
IN PULONG SuspendCount
);
- //NtSaveKey
+/*
+ * FUNCTION: Writes the content of a registry key to ascii file
+ * ARGUMENTS:
+ * KeyHandle = Handle to the key
+ * FileHandle = Handle of the file
+ * REMARKS:
+ This function maps to the Win32 RegSaveKey.
+ * RETURNS: Status
+ */
+
+NTSTATUS
+STDCALL
+NtSaveKey(
+ IN HANDLE KeyHandle,
+ IN HANDLE FileHandle
+ );
/*
* FUNCTION: Sets the context of a specified thread.
* ARGUMENTS:
ULONG EaBufferSize
);
+//FIXME Shoud I have input EVENT_BASIC_INFORMATION ??
+
/*
- * FUNCTION: Set an event to a signalled state.
+ * FUNCTION: Sets the attributes of an event.
* ARGUMENTS:
* EventHandle = Handle to the event
* Count = The resulting count.
NTSTATUS
STDCALL
NtSetEvent(
- HANDLE EventHandle,
+ IN HANDLE EventHandle,
PULONG Count
);
+/*
+ * FUNCTION: Sets the high part of an event pair
+ * ARGUMENTS:
+ EventPair = Handle to the event pair
+ * RETURNS: Status
+*/
+
+NTSTATUS
+STDCALL
+NtSetHighEventPair(
+ IN HANDLE EventPair
+ );
+
+/*
+ * FUNCTION: Sets the high part of an event pair and wait for the low part
+ * ARGUMENTS:
+ EventPair = Handle to the event pair
+ * RETURNS: Status
+*/
+NTSTATUS
+STDCALL
+NtSetHighWaitLowEventPair(
+ IN HANDLE EventPair
+ );
+
/*
* FUNCTION: Sets the information of a file object.
* ARGUMENTS:
* IoStatusBlock = Caller supplies storage for extended information
* on the current operation.
* FileInformation = Storage for the new file information
- * Lenght = Size of the storage for the file information.
- * FileInformationClass = Indicates which file information is set
+ * Lenght = Size of the new file information.
+ * FileInformationClass = Indicates to a certain information structure
- FileNameInformation PUNICODE_STRING
+ FileNameInformation FILE_NAME_INFORMATION
FileRenameInformation FILE_RENAME_INFORMATION
FileStreamInformation FILE_STREAM_INFORMATION
* FileCompletionInformation IO_COMPLETION_CONTEXT
* RETURNS: Status
*/
+
NTSTATUS
STDCALL
NtSetInformationFile(
* FUNCTION: Sets the information of a registry key.
* ARGUMENTS:
* KeyHandle = Handle to the registry key
- * KeyInformationClass = Index to the a certain set of parameter to set.
+ * KeyInformationClass = Index to the a certain information structure.
Can be one of the following values:
* KeyWriteTimeInformation KEY_WRITE_TIME_INFORMATION
- KeyInformation = Storage for the new key information
- * KeyInformationLength = Size of the storage allocated for the key information
+ KeyInformation = Storage for the new information
+ * KeyInformationLength = Size of the information strucure
* RETURNS: Status
*/
* FUNCTION: Changes a set of object specific parameters
* ARGUMENTS:
* ObjectHandle =
- * HandleInformationClass = Index to the set of parameters to change.
+ * ObjectInformationClass = Index to the set of parameters to change.
- HandleInformation
- HandleName
- HandleTypeInformation
- HandleAllInformation
- HandleBasicInformation
+
+ ObjectBasicInformation
+ ObjectTypeInformation OBJECT_TYPE_INFORMATION
+ ObjectAllInformation
+ ObjectDataInformation OBJECT_DATA_INFORMATION
+ ObjectNameInformation OBJECT_NAME_INFORMATION
- * HandleInformation = Caller supplies storage for parameters to set.
+ * ObjectInformation = Caller supplies storage for parameters to set.
* Length = Size of the storage supplied
* RETURNS: Status
*/
STDCALL
NtSetInformationObject(
IN HANDLE ObjectHandle,
- IN CINT HandleInformationClass,
- IN PVOID HandleInformationPtr,
+ IN CINT ObjectInformationClass,
+ IN PVOID ObjectInformation,
IN ULONG Length
);
* ProcessBasicInformation PROCESS_BASIC_INFORMATION
* ProcessQuotaLimits QUOTA_LIMITS
* ProcessBasePriority KPRIORITY
- * ProcessRaisePriority KPRIORITY
+ * ProcessRaisePriority KPRIORITY
* ProcessDebugPort HANDLE
* ProcessExceptionPort HANDLE
* ProcessAccessToken PROCESS_ACCESS_TOKEN
* ProcessDefaultHardErrorMode ULONG
* ProcessPriorityClass ULONG
- * ProcessAffinityMask KAFFINITY
+ * ProcessAffinityMask KAFFINITY //??
*
* ProcessInformation = Caller supplies storage for information to set.
* ProcessInformationLength = Size of the information structure
* Can be one of the following values:
*
* ThreadBasicInformation THREAD_BASIC_INFORMATION
- * ThreadPriority KPRIORITY
+ * ThreadPriority KPRIORITY //???
* ThreadBasePriority KPRIORITY
- * ThreadAffinityMask KAFFINITY
+ * ThreadAffinityMask KAFFINITY //??
+ * ThreadImpersonationToken ACCESS_TOKEN
* ThreadIdealProcessor ULONG
* ThreadPriorityBoost ULONG
*
IN ULONG ThreadInformationLength
);
//FIXME: Are the arguments correct
+// Might be a ordinary set function
/*
- * FUNCTION: Sets a io completion
+ * FUNCTION: Sets an io completion
* ARGUMENTS:
* CompletionPort =
* CompletionKey =
OUT PULONG NumberOfBytesTransferred
);
//FIXME: Should I have more parameters ?
-
-typedef struct
- {
- } LDT_ENTR, *PLDT_ENTR;
-
/*
* FUNCTION: Initializes the Local Descriptor Table
* ARGUMENTS:
- * ProcessHandle =
- * LdtEntry =
+ ProcessHandle =
+ LdtEntry =
* RETURNS: Status
- */
+*/
NTSTATUS
STDCALL
NtSetLdtEntries(
HANDLE ProcessHandle,
- PLDT_ENTR LdtEntry
+ PVOID LdtEntry // LDT_ENTR
+ );
+
+/*
+ * FUNCTION: Sets the low part of an event pair
+ * ARGUMENTS:
+ EventPair = Handle to the event pair
+ * RETURNS: Status
+*/
+
+NTSTATUS
+STDCALL
+NtSetLowEventPair(
+ HANDLE EventPair
+ );
+
+/*
+ * FUNCTION: Sets the low part of an event pair and wait for the high part
+ * ARGUMENTS:
+ EventPair = Handle to the event pair
+ * RETURNS: Status
+*/
+NTSTATUS
+STDCALL
+NtSetLowWaitHighEventPair(
+ HANDLE EventPair
);
//FIXME: Should Value be a void pointer or a pointer to a unicode string ?
* FUNCTION: Increments a thread's resume count
* ARGUMENTS:
* ThreadHandle = Handle to the thread that should be resumed
- * SuspendCount = The resulting suspend count.
+ * PreviousSuspendCount = The resulting/previous suspend count.
* REMARK:
* A thread will be suspended if its suspend count is greater than 0. This procedure maps to
* the win32 SuspendThread function. ( documentation about the the suspend count can be found here aswell )
* FileHandle = Handle to the file
* IoStatusBlock = Caller should supply storage for a structure containing
* the completion status and information about the requested unlock operation.
- * StartAddress = StartAddress of the range of bytes to unlock
- * NumberOfBytesToUnlock = Number of bytes to unlock.
- * NumberOfBytesUnlocked (OUT) = Number of bytes actually unlocked.
+ The information field is set to the number of bytes unlocked.
+ * ByteOffset = Offset to start the range of bytes to unlock
+ * Length = Number of bytes to unlock.
+ * Key =
* REMARK:
This procedure maps to the win32 procedure UnlockFileEx
* RETURNS: Status
NtUnlockFile(
IN HANDLE FileHandle,
OUT IO_STATUS_BLOCK IoStatusBlock,
- IN LARGE_INTEGER StartAddress,
- IN LARGE_INTEGER NumberOfBytesToUnlock,
- OUT PLARGE_INTEGER NumberOfBytesUnlocked OPTIONAL
+ IN LARGE_INTEGER ByteOffset,
+ IN LARGE_INTEGER Lenght,
+ OUT PULONG Key OPTIONAL
);
/*
STDCALL
NtWaitForMultipleObjects (
IN ULONG Count,
- IN PHANDLE Object[],
+ IN PHANDLE Object[0],
IN CINT WaitType,
IN BOOLEAN Alertable,
IN PLARGE_INTEGER Time
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
- IN LARGE_INTEGER BufferDescription[],
+ IN FILE_SEGMENT_ELEMENT BufferDescription[],
IN ULONG BufferLength,
IN PLARGE_INTEGER ByteOffset,
IN PULONG Key OPTIONAL
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
-#define UNIMPLEMENTED do {printk("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
+#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
#ifndef NDEBUG
-#define DPRINT(fmt,args...) do { printk("(%s:%d) ",__FILE__,__LINE__); printk(fmt,args); } while(0);
-//#define assert(x) if (!(x)) {printk("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
-#define assert(x) if (!(x)) {printk("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
-#define CHECKPOINT printk("%s:%d\n",__FILE__,__LINE__)
+#define DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
+//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
+#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
+#define CHECKPOINT DbgPrint("%s:%d\n",__FILE__,__LINE__)
#else
#define DPRINT(fmt,args...)
#define assert(x)
#ifndef __INTERNAL_HAL_PAGE_H
#define __INTERNAL_HAL_PAGE_H
-#include <internal/kernel.h>
+#include <ddk/ntddk.h>
#define PAGESIZE (4096)
#define PA_READ (1<<0)
#define PA_WRITE ((1<<0)+(1<<1))
#define PA_EXECUTE PA_READ
+#define PA_PCD (1<<4)
+#define PA_PWT (1<<3)
/*
* Page attributes
unsigned int page_dir=0;
__asm__("movl %%cr3,%0\n\t"
: "=r" (page_dir));
-// printk("page_dir %x %x\n",page_dir,physical_to_linear(page_dir));
return((unsigned int *)physical_to_linear(page_dir));
}
-/*
- * Various useful prototypes
- */
-
-#ifndef __KERNEL_H
-#define __KERNEL_H
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-
-#include <internal/linkage.h>
-#include <stdarg.h>
-
-/*
- * Use these to place a function in a specific section of the executable
- */
-#define PLACE_IN_SECTION(s) __attribute__((section (s)))
-#define INIT_FUNCTION (PLACE_IN_SECTION("init"))
-#define PAGE_LOCKED_FUNCTION (PLACE_IN_SECTION("pagelk"))
-#define PAGE_UNLOCKED_FUNCTION (PLACE_IN_SECTION("pagepo"))
-
-/*
- * Maximum size of the kmalloc area (this is totally arbitary)
- */
-#define NONPAGED_POOL_SIZE (4*1024*1024)
-
-VOID KiInterruptDispatch(unsigned int irq);
-VOID KiDispatchInterrupt(unsigned int irq);
-VOID KeTimerInterrupt(VOID);
-
-/*
- * Defines a descriptor as it appears in the processor tables
- */
-typedef struct
-{
- unsigned int a;
- unsigned int b;
-} descriptor;
-
-extern descriptor idt[256];
-extern descriptor gdt[256];
-
-/*
- * printf style functions
- */
-asmlinkage void printk(const char* fmt, ...);
-int vsprintf(char *buf, const char *fmt, va_list args);
-int sprintf(char* buf, const char* fmt, ...);
-
-typedef struct
-{
- /*
- * Magic value (useless really)
- */
- unsigned int magic;
-
- /*
- * Cursor position
- */
- unsigned int cursorx;
- unsigned int cursory;
-
- /*
- * Number of files (including the kernel) loaded
- */
- unsigned int nr_files;
-
- /*
- * Range of physical memory being used by the system
- */
- unsigned int start_mem;
- unsigned int end_mem;
-
- /*
- * List of module lengths (terminated by a 0)
- */
- unsigned int module_length[64];
-} boot_param;
-
-
-/*
- * Initalization functions (called once by main())
- */
-void MmInitalize(boot_param* bp);
-void InitalizeExceptions(void);
-void InitalizeIRQ(void);
-void InitializeTimer(void);
-void InitConsole(boot_param* bp);
-void KeInitDpc(void);
-void HalInit(boot_param* bp);
-void IoInit(void);
-void ObjNamespcInit(void);
-void PsMgrInit(void);
-void KeInitializeBugCheck(void);
-VOID KeInitializeDispatcher(VOID);
-void TstBegin(void);
-void KeCalibrateTimerLoop(void);
-
-/*
- * FUNCTION: Called to execute queued dpcs
- */
-void KeDrainDpcQueue(void);
-
-void KeExpireTimers(void);
-
-typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
-asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
-
-#endif
+#include <internal/ntoskrnl.h>
* Higher level memory managment definitions
*/
-#ifndef __MM_H
-#define __MM_H
+#ifndef __INCLUDE_INTERNAL_MM_H
+#define __INCLUDE_INTERNAL_MM_H
#define PAGE_SYSTEM (0x80000000)
#include <internal/linkage.h>
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
#include <windows.h>
-typedef struct _memory_area
-/*
- * PURPOSE: Describes an area of virtual memory
- */
+/* TYPES *********************************************************************/
+
+enum
+{
+ MEMORY_AREA_INVALID,
+ MEMORY_AREA_SECTION_VIEW,
+ MEMORY_AREA_CONTINUOUS_MEMORY,
+ MEMORY_AREA_NO_CACHE,
+ MEMORY_AREA_IO_MAPPING,
+ MEMORY_AREA_SYSTEM,
+ MEMORY_AREA_MDL_MAPPING,
+};
+
+typedef struct
{
- /*
- * Access protection
- */
- unsigned int access;
-
- /*
- * Memory region base
- */
- unsigned int base;
-
- /*
- * Memory region length
- */
- unsigned int length;
-
- /*
- * Memory type (Mapped file, mapped from an executable or private)
- */
- unsigned int type;
-
- /*
- * Memory region state (committed, reserved or free)
- */
- unsigned int state;
-
- /*
- * Original access protection
- */
- unsigned int initial_access;
-
- /*
- * Used to maintain the linked list of memory areas
- */
- struct _memory_area* previous;
- struct _memory_area* next;
-
- /*
- * True the region is locked
- */
- BOOL lock;
-
- /*
- * FUNCTION: Decommits all the pages in the regions
- */
- void (*free)(struct _memory_area* marea);
-
- /*
- * FUNCTION: Handles a page fault by loading the required page
- * RECEIVES:
- * marea = the memory area
- * address = the relative address of the page to load
- * RETURNS:
- * TRUE = the access should be restarted
- * FALSE = the access was illegal and an exception should
- * be generated
- * NOTES: This function is guarrented to be called within the context
- * of the thread which required a page to be loaded
- */
- BOOL (*load_page)(struct _memory_area* marea, unsigned int address);
-} memory_area;
+ FILE_OBJECT* File;
+} SECTION_OBJECT;
+typedef struct
+{
+ ULONG Type;
+ ULONG BaseAddress;
+ ULONG Length;
+ ULONG Attributes;
+ LIST_ENTRY Entry;
+ union
+ {
+ SECTION_OBJECT* Section;
+ } d;
+} MEMORY_AREA;
+
+
+NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
+ ULONG Type,
+ PULONG BaseAddress,
+ ULONG Length,
+ ULONG Attributes,
+ MEMORY_AREA** Result);
+MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address);
+NTSTATUS MmInitMemoryAreas(VOID);
+VOID ExInitNonPagedPool(ULONG BaseAddress);
+NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
+ ULONG Length,
+ BOOLEAN FreePages);
+VOID MmDumpMemoryAreas(VOID);
/*
* FUNCTION: Gets a page with a restricted max physical address (i.e.
void VirtualInit(boot_param* bp);
-/*
- * FUNCTION: Returns the first memory area starting in the region or the last
- * one before the start of the region
- * ARGUMENTS:
- * list_head = Head of the list of memory areas to search
- * base = base address of the region
- * length = length of the region
- * RETURNS: A pointer to the area found or
- * NULL if the region was before the first region on the list
- */
-memory_area* find_first_marea(memory_area* list_head, unsigned int base,
- unsigned int length);
-
-/*
- * Head of the list of system memory areas
- */
-extern memory_area* system_memory_area_list_head;
-
-/*
- * Head of the list of user memory areas (this should be per process)
- */
-extern memory_area* memory_area_list_head;
-
#endif
* PURPOSE: Head of the list of our subdirectories
*/
LIST_ENTRY head;
+ KSPIN_LOCK Lock;
} DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
#ifndef __INCLUDE_INTERNAL_PSMGR_H
#define __INCLUDE_INTERNAL_PSMGR_H
-#include <internal/hal/hal.h>
+#include <internal/hal.h>
+
+extern EPROCESS SystemProcess;
+extern HANDLE SystemProcessHandle;
void PsInitThreadManagment(void);
+VOID PsInitIdleThread(VOID);
/*
* PURPOSE: Thread states
#ifndef __VERSION_H
#define __VERSION_H
-#define KERNEL_VERSION "0.0.9"
+#define KERNEL_VERSION "0.0.10"
#define KERNEL_MAJOR_VERSION 0
#define KERNEL_MINOR_VERSION 0
-#define KERNEL_PATCH_LEVEL 9
+#define KERNEL_PATCH_LEVEL 10
#endif
HEAP_BLOCK Start __attribute__((aligned (8)));
} HEAP, *PHEAP;
-PHEAP __ProcessHeap;
+//PHEAP __ProcessHeap;
#endif /* __INCLUDE_KERNEL32_HEAP_H */
extern "C" {
#endif
-wchar_t * ___wcstok;
+//wchar_t * ___wcstok = NULL;
extern wchar_t * wcscpy(wchar_t *,const wchar_t *);
extern wchar_t * wcsncpy(wchar_t *,const wchar_t *, __kernel_size_t);
extern wchar_t * wcscat(wchar_t *, const wchar_t *);
; Move onto the next position in prepartion for a future read
;
movzx eax,word [size_div_4k]
- inc eax
mov bx,[size_mod_4k]
cmp bx,0
- je l20
- inc eax
+ je l20
+ inc eax
l20:
- shl eax,12
+ shl eax,0ch
add [next_load_base],eax
push fs
#
# Device driver rules
#
+ide: dummy
+ make -C services/ide
parallel: dummy
make -C services/parallel
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/debug.h>
/*
* PURPOSE: Queue of items waiting to be processed at normal priority
*/
-WORK_QUEUE normal_work_queue;
+WORK_QUEUE normal_work_queue = {0,};
#define WAIT_INTERVAL (0)
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/mm.h>
#include <internal/string.h>
#include <internal/hal/page.h>
{
continue;
}
- printk("BIOS32 detected at %x\n",i);
+ DbgPrint("BIOS32 detected at %x\n",i);
bios32_indirect.address = service_entry->entry;
bios32_detected=TRUE;
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/hal/x86/bus.c
+ * PURPOSE: Bus functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/hal/x86/dma.c
+ * FILE: ntoskrnl/hal/x86/dma.c
* PURPOSE: DMA functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/hal/x86/exp.c
+ * FILE: ntoskrnl/hal/x86/exp.c
* PURPOSE: Handling exceptions
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISION HISTORY:
/* INCLUDES *****************************************************************/
#include <windows.h>
-
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
+#include <internal/ke.h>
#include <internal/hal/segment.h>
#include <internal/hal/page.h>
+#define NDEBUG
+#include <internal/debug.h>
+
/* GLOBALS *****************************************************************/
+typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
+asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
+
extern descriptor idt[256];
static exception_hook* exception_hooks[256]={NULL,};
unsigned int i;
unsigned int* stack;
+ __asm__("cli\n\t");
+
/*
* Activate any hook for the exception
*/
*/
printk("Exception: %d(%x)\n",type,error_code&0xffff);
printk("CS:EIP %x:%x\n",cs&0xffff,eip);
+ for(;;);
printk("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
printk("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
printk("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
return(0);
}
-asmlinkage void InitalizeExceptions(void)
+asmlinkage void KeInitExceptions(void)
/*
* FUNCTION: Initalize CPU exception handling
*/
{
int i;
+ DPRINT("KeInitExceptions()\n",0);
+
set_interrupt_gate(0,(int)exception_handler0);
set_interrupt_gate(1,(int)exception_handler1);
set_interrupt_gate(2,(int)exception_handler2);
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/hal/hal.h>
+#include <internal/ntoskrnl.h>
+#include <internal/ke.h>
+#include <internal/hal.h>
/* FUNCTIONS ***************************************************************/
VOID HalInit(boot_param* bp)
{
- InitalizeExceptions();
- InitalizeIRQ();
+ KeInitExceptions();
+ KeInitIRQ();
+ KeLowerIrql(DISPATCH_LEVEL);
/*
* Probe for a BIOS32 extension
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: mkernel/hal/x86/irq.c
+ * FILE: ntoskrnl/hal/x86/irq.c
* PURPOSE: IRQ handling
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
#include <ddk/ntddk.h>
#include <internal/stddef.h>
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
+#include <internal/ke.h>
#include <internal/bitops.h>
#include <internal/linkage.h>
#include <internal/string.h>
* be accessed at any irq level.
*/
static LIST_ENTRY isr_table[NR_IRQS]={{NULL,NULL},};
-static PKSPIN_LOCK isr_lock[NR_IRQS];
-static KSPIN_LOCK isr_table_lock;
+static PKSPIN_LOCK isr_lock[NR_IRQS] = {NULL,};
+static KSPIN_LOCK isr_table_lock = {0,};
/* FUNCTIONS ****************************************************************/
#define PRESENT (0x8000)
#define I486_INTERRUPT_GATE (0xe00)
-asmlinkage void KiInterruptDispatch(unsigned int irq)
+asmlinkage VOID KiInterruptDispatch(ULONG irq)
/*
* FUNCTION: Calls the irq specific handler for an irq
* ARGUMENTS:
* Notify the rest of the kernel of the raised irq level
*/
old_level = KeGetCurrentIrql();
- DPRINT("old_level %d\n",old_level);
+// DPRINT("old_level %d\n",old_level);
KeSetCurrentIrql(HIGH_LEVEL - irq);
/*
if (irq==0)
{
- KeTimerInterrupt();
+ KiTimerInterrupt();
}
else
{
- DPRINT("KiInterruptDispatch(irq %x)\n",irq);
- /*
- * Iterate the list until one of the isr tells us its device interrupted
- */
- current = isr_table[irq].Flink;
- isr = CONTAINING_RECORD(current,KINTERRUPT,Entry);
- DPRINT("current %x isr %x\n",current,isr);
- while (current!=NULL && !isr->ServiceRoutine(isr,isr->ServiceContext))
- {
- current = current->Flink;
- isr = CONTAINING_RECORD(current,KINTERRUPT,Entry);
- DPRINT("current %x isr %x\n",current,isr);
- }
+ DPRINT("KiInterruptDispatch(irq %x)\n",irq);
+ /*
+ * Iterate the list until one of the isr tells us its device interrupted
+ */
+ current = isr_table[irq].Flink;
+ isr = CONTAINING_RECORD(current,KINTERRUPT,Entry);
+ DPRINT("current %x isr %x\n",current,isr);
+ while (current!=(&isr_table[irq]) &&
+ !isr->ServiceRoutine(isr,isr->ServiceContext))
+ {
+ current = current->Flink;
+ isr = CONTAINING_RECORD(current,KINTERRUPT,Entry);
+ DPRINT("current %x isr %x\n",current,isr);
+ }
}
/*
KeSetCurrentIrql(old_level);
}
-void InitalizeIRQ(void)
+void KeInitIRQ(void)
{
int i;
+ DPRINT("KeInitIrq()\n",0);
+
/*
* First mask off all interrupts from pic
*/
}
}
+static VOID KeDumpIrqList(VOID)
+{
+ PKINTERRUPT current;
+ PLIST_ENTRY current_entry;
+ unsigned int i;
+
+ for (i=0;i<NR_IRQS;i++)
+ {
+ DPRINT("For irq %x ",i);
+ current_entry = isr_table[i].Flink;
+ current = CONTAINING_RECORD(current,KINTERRUPT,Entry);
+ while (current_entry!=(&isr_table[i]))
+ {
+ DPRINT("Isr %x ",current);
+ current_entry = current_entry->Flink;
+ current = CONTAINING_RECORD(current_entry,KINTERRUPT,Entry);
+ }
+ DPRINT("\n",0);
+ }
+}
+
NTSTATUS IoConnectInterrupt(PKINTERRUPT* InterruptObject,
PKSERVICE_ROUTINE ServiceRoutine,
PVOID ServiceContext,
ASSERT_IRQL(PASSIVE_LEVEL);
+ DPRINT("IoConnectInterrupt(Vector %x)\n",Vector);
+
/*
* Check the parameters
*/
*/
KeReleaseSpinLock(&isr_table_lock,oldlvl);
+ KeDumpIrqList();
+
return(STATUS_SUCCESS);
}
KeRaiseIrql(InterruptObject->SynchLevel,&oldlvl);
KeAcquireSpinLockAtDpcLevel(InterruptObject->IrqLock);
- RemoveEntryFromList(&isr_table[InterruptObject->Vector],
- &InterruptObject->Entry);
+ RemoveEntryList(&InterruptObject->Entry);
KeReleaseSpinLockFromDpcLevel(InterruptObject->IrqLock);
KeLowerIrql(oldlvl);
}
// OldIrql);
if (NewIrql < CurrentIrql)
{
- printk("%s:%d\n",__FILE__,__LINE__);
+ DbgPrint("%s:%d\n",__FILE__,__LINE__);
for(;;);
}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
-#include <internal/mm.h>
-#include <internal/string.h>
-#include <internal/hal/page.h>
/* FUNCTIONS *****************************************************************/
* true
*/
{
- printk("Assuming ISA bus\n");
+ DbgPrint("Assuming ISA bus\n");
/*
* Probe for plug and play support
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES ***************************************************************/
-#include <internal/kernel.h>
#include <internal/hal/page.h>
#include <internal/mm.h>
#include <internal/string.h>
* FUNCTION: Returns the physical address corresponding to a virtual address
*/
{
+ PHYSICAL_ADDRESS p;
DPRINT("get_page_physical_address(vaddr %x)\n",vaddr);
- return(PAGE_MASK(*get_page_entry((unsigned int)vaddr)));
+ p.HighPart = 0;
+ p.LowPart = PAGE_MASK(*get_page_entry((unsigned int)vaddr));
+ return(p);
}
BOOL is_page_present(unsigned int vaddr)
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
-#include <internal/mm.h>
-#include <internal/string.h>
-#include <internal/hal/page.h>
/* FUNCTIONS **************************************************************/
{
if (Hal_bios32_is_service_present(PCI_SERVICE))
{
- printk("Detected PCI service\n");
+ DbgPrint("Detected PCI service\n");
return(TRUE);
}
return(FALSE);
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/hal/x86/printk.c
+ * FILE: ntoskrnl/hal/x86/printk.c
* PURPOSE: Writing to the console
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
#include <internal/string.h>
#include <internal/hal/page.h>
#include <internal/hal/io.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/hal/x86/sysinfo.c
+ * PURPOSE: Getting system information
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/hal/x86/thread.c
+ * FILE: ntoskrnl/hal/x86/thread.c
* PURPOSE: HAL multitasking functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISION HISTORY:
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
#include <internal/psmgr.h>
#include <internal/string.h>
-#include <internal/hal/hal.h>
+#include <internal/hal.h>
#include <internal/hal/segment.h>
#include <internal/hal/page.h>
#define FIRST_TSS_SELECTOR (KERNEL_DS + 0x8)
#define FIRST_TSS_OFFSET (FIRST_TSS_SELECTOR / 8)
+static char null_ldt[8]={0,};
+static unsigned int null_ldt_sel=0;
+static PKTHREAD FirstThread=NULL;
+
/* FUNCTIONS **************************************************************/
void HalTaskSwitch(PKTHREAD thread)
* again
*/
{
+ DPRINT("Scheduling thread %x\n",thread->Context.nr);
+ DPRINT("previous task %x reserved1 %x esp0 %x ss0 %x\n",
+ thread->Context.previous_task,thread->Context.reserved1,
+ thread->Context.esp0,thread->Context.ss0);
+ DPRINT("reserved2 %x esp1 %x ss1 %x reserved3 %x esp2 %x ss2 %x\n",
+ thread->Context.reserved2,thread->Context.esp1,thread->Context.ss1,
+ thread->Context.reserved3,thread->Context.esp2,thread->Context.ss2);
+ DPRINT("reserved4 %x cr3 %x eip %x eflags %x eax %x\n",
+ thread->Context.reserved4,thread->Context.cr3,thread->Context.eip,
+ thread->Context.eflags,thread->Context.eax);
+ DPRINT("ecx %x edx %x ebx %x esp %x ebp %x esi %x\n",
+ thread->Context.ecx,thread->Context.edx,thread->Context.ebx,
+ thread->Context.esp,thread->Context.ebp,thread->Context.esi);
+ DPRINT("edi %x es %x reserved5 %x cs %x reserved6 %x\n",
+ thread->Context.edi,thread->Context.es,thread->Context.reserved5,
+ thread->Context.cs,thread->Context.reserved6);
+ DPRINT("ss %x reserved7 %x ds %x reserved8 %x fs %x\n",
+ thread->Context.ss,thread->Context.reserved7,thread->Context.ds,
+ thread->Context.reserved8,thread->Context.fs);
+ DPRINT("reserved9 %x gs %x reserved10 %x ldt %x reserved11 %x\n",
+ thread->Context.reserved9,thread->Context.gs,
+ thread->Context.reserved10,thread->Context.ldt,
+ thread->Context.reserved11);
+ DPRINT("trap %x iomap_base %x nr %x io_bitmap[0] %x\n",
+ thread->Context.trap,thread->Context.iomap_base,
+ thread->Context.nr,thread->Context.io_bitmap[0]);
__asm__("pushfl\n\t"
"cli\n\t"
"ljmp %0\n\t"
"popfl\n\t"
: /* No outputs */
- : "m" (*(((unsigned char *)(&(thread->context.nr)))-4) )
+ : "m" (*(((unsigned char *)(&(thread->Context.nr)))-4) )
: "ax","dx");
+// set_breakpoint(0,&(FirstThread->Context.gs),HBP_READWRITE,HBP_DWORD);
}
static unsigned int allocate_tss_descriptor(void)
*/
{
NTSTATUS ret;
- DPRINT("begin_thread %x %x\n",fn,start_context);
+// DPRINT("begin_thread %x %x\n",fn,start_context);
KeLowerIrql(PASSIVE_LEVEL);
ret = fn(start_context);
PsTerminateSystemThread(ret);
{
unsigned int desc = allocate_tss_descriptor();
unsigned int length = sizeof(hal_thread_state) - 1;
- unsigned int base = (unsigned int)(&(thread->context));
+ unsigned int base = (unsigned int)(&(thread->Context));
unsigned int* kernel_stack = ExAllocatePool(NonPagedPool,4096);
+ DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
+ thread,fn,StartContext);
+
/*
* Make sure
*/
/*
* Initialize the thread context
*/
- memset(&thread->context,0,sizeof(hal_thread_state));
- thread->context.ldt = 0;
- thread->context.eflags = (1<<1)+(1<<9);
- thread->context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
- thread->context.esp0 = &kernel_stack[1021];
- thread->context.ss0 = KERNEL_DS;
- thread->context.esp = &kernel_stack[1021];
- thread->context.ss = KERNEL_DS;
- thread->context.cs = KERNEL_CS;
- thread->context.eip = (unsigned long)begin_thread;
- thread->context.io_bitmap[0] = 0xff;
- thread->context.cr3 = ((unsigned int)get_page_directory()) - IDMAP_BASE;
- thread->context.ds = KERNEL_DS;
- thread->context.es = KERNEL_DS;
- thread->context.fs = KERNEL_DS;
- thread->context.gs = KERNEL_DS;
- thread->context.nr = desc * 8;
+ memset(&thread->Context,0,sizeof(hal_thread_state));
+ thread->Context.ldt = null_ldt_sel;
+ thread->Context.eflags = (1<<1)+(1<<9);
+ thread->Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
+ thread->Context.esp0 = &kernel_stack[1021];
+ thread->Context.ss0 = KERNEL_DS;
+ thread->Context.esp = &kernel_stack[1021];
+ thread->Context.ss = KERNEL_DS;
+ thread->Context.cs = KERNEL_CS;
+ thread->Context.eip = (unsigned long)begin_thread;
+ thread->Context.io_bitmap[0] = 0xff;
+ thread->Context.cr3 = ((unsigned int)get_page_directory()) - IDMAP_BASE;
+ thread->Context.ds = KERNEL_DS;
+ thread->Context.es = KERNEL_DS;
+ thread->Context.fs = KERNEL_DS;
+ thread->Context.gs = KERNEL_DS;
+ thread->Context.nr = desc * 8;
+ DPRINT("Allocated %x\n",desc*8);
+
return(TRUE);
}
* initial thread
*/
{
+ unsigned int base;
+ unsigned int length;
+ unsigned int desc;
+
+ memset(null_ldt,0,sizeof(null_ldt));
+ desc = allocate_tss_descriptor();
+ base = (unsigned int)&null_ldt;
+ length = sizeof(null_ldt) - 1;
+ gdt[desc].a = (length & 0xffff) | ((base & 0xffff) << 16);
+ gdt[desc].b = ((base & 0xff0000)>>16) | 0x8200 | (length & 0xf0000)
+ | (base & 0xff000000);
+ null_ldt_sel = desc*8;
+
/*
* Initialize the thread context
*/
HalInitTask(thread,NULL,NULL);
-
+
/*
* Load the task register
*/
__asm__("ltr %%ax"
: /* no output */
- : "a" (FIRST_TSS_OFFSET*8));
+ : "a" (thread->Context.nr));
+ FirstThread = thread;
}
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/io/arc.c
+ * PURPOSE: arc names
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#define NDEBUG
/* GLOBALS *******************************************************************/
-static KSPIN_LOCK CancelSpinLock;
+static KSPIN_LOCK CancelSpinLock = {0,};
/* FUNCTIONS *****************************************************************/
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/objmgr.h>
#include <internal/iomgr.h>
#include <internal/string.h>
ULONG CreateOptions,
PVOID EaBuffer,
ULONG EaLength)
+/*
+ * FUNCTION: Either causes a new file or directory to be created, or it opens
+ * an existing file, device, directory or volume, giving the caller a handle
+ * for the file object. This handle can be used by subsequent calls to
+ * manipulate data within the file or the file object's state of attributes.
+ * ARGUMENTS:
+ * FileHandle (OUT) = Points to a variable which receives the file
+ * handle on return
+ * DesiredAccess = Desired access to the file
+ * ObjectAttributes = Structure describing the file
+ * IoStatusBlock (OUT) = Receives information about the operation on
+ * return
+ * AllocationSize = Initial size of the file in bytes
+ * FileAttributes = Attributes to create the file with
+ * ShareAccess = Type of shared access the caller would like to the file
+ * CreateDisposition = Specifies what to do, depending on whether the
+ * file already existings
+ * CreateOptions = Options for creating a new file
+ * EaBuffer = Undocumented
+ * EaLength = Undocumented
+ * RETURNS: Status
+ */
{
UNIMPLEMENTED;
}
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG OpenOptions)
+/*
+ * FUNCTION: Opens a file (simpler than ZwCreateFile)
+ * ARGUMENTS:
+ * FileHandle (OUT) = Variable that receives the file handle on return
+ * DesiredAccess = Access desired by the caller to the file
+ * ObjectAttributes = Structue describing the file to be opened
+ * IoStatusBlock (OUT) = Receives details about the result of the
+ * operation
+ * ShareAccess = Type of shared access the caller requires
+ * OpenOptions = Options for the file open
+ * RETURNS: Status
+ * NOTE: Undocumented
+ */
{
PVOID Object;
NTSTATUS Status;
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/iomgr.h>
#include <internal/objmgr.h>
#include <internal/string.h>
-//#define NDEBUG
+#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS ***************************************************************/
DriverObject=ExAllocatePool(NonPagedPool,sizeof(DRIVER_OBJECT));
if (DriverObject==NULL)
{
- printk("%s:%d\n",__FILE__,__LINE__);
+ DbgPrint("%s:%d\n",__FILE__,__LINE__);
return(STATUS_INSUFFICIENT_RESOURCES);
}
memset(DriverObject,sizeof(DRIVER_OBJECT),0);
dev->DeviceType=DeviceType;
dev->StackSize=1;
dev->AlignmentRequirement=1;
+ KeInitializeDeviceQueue(&dev->DeviceQueue);
*DeviceObject=dev;
DPRINT("dev->DriverObject %x\n",dev->DriverObject);
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/io/dpc.c
+ * PURPOSE: io manager dpc functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/iomgr/drvlck.c
+ * FILE: ntoskrnl/io/drvlck.c
* PURPOSE: Managing driver managing
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/io/errlog.c
+ * PURPOSE: Error logging
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/io/file.c
+ * FILE: ntoskrnl/io/file.c
* PURPOSE: Graceful system shutdown if a bug is detected
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* GLOBALS ******************************************************************/
-static KSPIN_LOCK FileSystemListLock;
-static LIST_ENTRY FileSystemListHead;
+static KSPIN_LOCK FileSystemListLock = {0,};
+static LIST_ENTRY FileSystemListHead = {NULL,NULL};
/* FUNCTIONS *****************************************************************/
current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
if (current->DeviceObject == DeviceObject)
{
- RemoveEntryFromList(&FileSystemListHead,current_entry);
+ RemoveEntryList(current_entry);
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
return;
}
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/objmgr.h>
+#define NDEBUG
+#include <internal/debug.h>
+
/* GLOBALS *******************************************************************/
OBJECT_TYPE DeviceObjectType = {{0,0,NULL},
/*
* Register iomgr types
*/
+ CHECKPOINT;
RtlInitAnsiString(&astring,"Device");
+ CHECKPOINT;
RtlAnsiStringToUnicodeString(&DeviceObjectType.TypeName,&astring,TRUE);
+ CHECKPOINT;
ObRegisterType(OBJTYP_DEVICE,&DeviceObjectType);
-
+ CHECKPOINT;
RtlInitAnsiString(&astring,"File");
RtlAnsiStringToUnicodeString(&FileObjectType.TypeName,&astring,TRUE);
ObRegisterType(OBJTYP_FILE,&FileObjectType);
-
+ CHECKPOINT;
/*
* Create the device directory
*/
RtlInitAnsiString(&astring,"\\Device");
+ CHECKPOINT;
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
+ CHECKPOINT;
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
+ CHECKPOINT;
ZwCreateDirectoryObject(&handle,0,&attr);
-
+ CHECKPOINT;
IoInitCancelHandling();
IoInitSymbolicLinkImplementation();
}
/* INCLUDES ****************************************************************/
#include <internal/string.h>
-#include <internal/kernel.h>
#include <ddk/ntddk.h>
#define NDEBUG
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <internal/hal/page.h>
#include <ddk/ntddk.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
-PEPROCESS IoGetCurrentProcess()
+struct _EPROCESS* IoGetCurrentProcess()
{
return(PsGetCurrentProcess());
}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
+
+#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
PIRP Irp;
KIRQL oldirql;
+ DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n",
+ DeviceObject,Cancelable);
+
entry = KeRemoveDeviceQueue(&DeviceObject->DeviceQueue);
if (entry!=NULL)
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/iomgr.h>
#include <internal/string.h>
#include <internal/objmgr.h>
/* FUNCTIONS ***************************************************************/
NTSTATUS ZwReadFile(HANDLE FileHandle,
- HANDLE Event,
+ HANDLE EventHandle,
PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock,
PFILE_OBJECT FileObject = (PFILE_OBJECT)hdr;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
-
+ KEVENT Event;
+
if (hdr==NULL)
{
return(STATUS_INVALID_HANDLE);
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
+ KeInitializeEvent(&Event,NotificationEvent,FALSE);
+ Irp->UserEvent=&Event;
StackPtr = IoGetNextIrpStackLocation(Irp);
DPRINT("StackPtr %x\n",StackPtr);
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
IoCallDriver(FileObject->DeviceObject,Irp);
- memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
+ KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
+ if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
+ {
+ memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
+ }
return(STATUS_SUCCESS);
}
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/string.h>
{
PLIST_ENTRY current_entry;
PKAPC current;
+ PKTHREAD CurrentThread=KeGetCurrentThread();
- current_entry = KeGetCurrentThread()->ApcQueueHead.Flink;
- while (current_entry!=NULL)
+ while ((current_entry=RemoveHeadList(CurrentThread->ApcList))!=NULL)
{
current = CONTAINING_RECORD(current_entry,KAPC,ApcListEntry);
current->NormalRoutine(current->NormalContext,
}
}
-VOID KeInitializeApc(PKAPC Apc, PKNORMAL_ROUTINE NormalRoutine,
- PVOID NormalContext,
- PKTHREAD TargetThread)
+VOID KeInitializeApc(PKAPC Apc,
+ PKTHREAD Thread,
+ UCHAR StateIndex,
+ PKKERNEL_ROUTINE KernelRoutine,
+ PKRUNDOWN_ROUTINE RundownRoutine,
+ PKNORMAL_ROUTINE NormalRoutine,
+ UCHAR Mode,
+ PVOID Context)
{
memset(Apc,0,sizeof(KAPC));
- Apc->Thread = TargetThread;
+ Apc->Thread = Thread;
+ Apc->ApcListEntry.Flink=NULL;
+ Apc->ApcListEntry.Blink=NULL;
+ Apc->KernelRoutine=KernelRoutine;
+ Apc->RundownRoutine=RundownRoutine;
Apc->NormalRoutine=NormalRoutine;
- Apc->NormalContext=NormalContext;
+ Apc->NormalContext=Context;
Apc->Inserted=FALSE;
+ Apc->ApcStateIndex=StateIndex;
+ Apc->ApcMode=Mode;
}
-BOOLEAN KeInsertQueueApc(PKAPC Apc)
+void KeInsertQueueApc(PKAPC Apc, PVOID SystemArgument1,
+ PVOID SystemArgument2, UCHAR Mode)
{
+ Apc->SystemArgument1=SystemArgument1;
+ Apc->SystemArgument2=SystemArgument2;
+ Apc->ApcMode=Mode;
if (Apc->Inserted)
{
- return(FALSE);
+ return;
}
Apc->Inserted=TRUE;
- InsertTailList(&Apc->Thread->ApcQueueHead,&Apc->ApcListEntry);
- return(TRUE);
+ InsertTailList(Apc->Thread->ApcList,&Apc->ApcListEntry);
+ return;
}
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
CallbackRecord->CallbackRoutine=CallbackRoutine;
}
-asmlinkage VOID KeBugCheckEx(ULONG BugCheckCode,
- ULONG BugCheckParameter1,
- ULONG BugCheckParameter2,
- ULONG BugCheckParameter3,
- ULONG BugCheckParameter4)
+VOID KeBugCheckEx(ULONG BugCheckCode,
+ ULONG BugCheckParameter1,
+ ULONG BugCheckParameter2,
+ ULONG BugCheckParameter3,
+ ULONG BugCheckParameter4)
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
* RETURNS: Doesn't
*/
{
- printk("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode,
+ DbgPrint("Bug detected (code %x param %x %x %x %x)\n",BugCheckCode,
BugCheckParameter1,BugCheckParameter2,BugCheckParameter3,
BugCheckParameter4);
for(;;);
}
-asmlinkage VOID KeBugCheck(ULONG BugCheckCode)
+VOID KeBugCheck(ULONG BugCheckCode)
/*
* FUNCTION: Brings the system down in a controlled manner when an
* inconsistency that might otherwise cause corruption has been detected
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: mkernel/kernel/catch.c
+ * FILE: ntoskrnl/ke/catch.c
* PURPOSE: Exception handling
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
/* FUNCTIONS ****************************************************************/
VOID ExRaiseStatus(NTSTATUS Status)
{
- printk("ExRaiseStatus(%d)\n",Status);
+ DbgPrint("ExRaiseStatus(%d)\n",Status);
for(;;);
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/critical.c
+ * FILE: ntoskrnl/ke/critical.c
* PURPOSE: Implement critical regions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: mkernel/kernel/dispatch.c
+ * FILE: ntoskrnl/ke/dispatch.c
* PURPOSE: Handles a dispatch interrupt
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
+#include <internal/ke.h>
/* FUNCTIONS ****************************************************************/
-void KiDispatchInterrupt(unsigned int irq)
+VOID KiDispatchInterrupt(ULONG irq)
/*
* FUNCTION: Called after an irq when the interrupted processor was at a lower
* level than DISPATCH_LEVEL
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: mkernel/kernel/dpc.cc
+ * FILE: ntoskrnl/ke/dpc.c
* PURPOSE: Handle DPCs (Delayed Procedure Calls)
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
*/
/*
- * NOTE: See also the higher level support routines in mkernel/iomgr/iodpc.cc
+ * NOTE: See also the higher level support routines in ntoskrnl/io/dpc.c
*/
/* INCLUDES ***************************************************************/
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
+#define NDEBUG
+#include <internal/debug.h>
/* TYPES *******************************************************************/
/* GLOBALS ******************************************************************/
-LIST_ENTRY DpcQueueHead;
+static LIST_ENTRY DpcQueueHead={NULL,NULL};
+static KSPIN_LOCK DpcQueueLock={0,};
/* FUNCTIONS ****************************************************************/
* FUNCTION: Called to execute queued dpcs
*/
{
- PLIST_ENTRY current_entry = ExInterlockedRemoveHeadList(&DpcQueueHead,NULL);
- PKDPC current = CONTAINING_RECORD(¤t_entry,KDPC,DpcListEntry);
+ PLIST_ENTRY current_entry;
+ PKDPC current;
- while (current_entry!=NULL)
+
+ KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
+ current_entry = RemoveHeadList(&DpcQueueHead);
+ current = CONTAINING_RECORD(current_entry,KDPC,DpcListEntry);
+ while (current_entry!=(&DpcQueueHead))
{
+ CHECKPOINT;
current->DeferredRoutine(current,current->DeferredContext,
current->SystemArgument1,
current->SystemArgument2);
- current_entry = ExInterlockedRemoveHeadList(&DpcQueueHead,NULL);
+ current->Lock=FALSE;
+ current_entry = RemoveHeadList(&DpcQueueHead);
current = CONTAINING_RECORD(¤t_entry,KDPC,DpcListEntry);
}
+ KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
+// DPRINT("Finished KeDrainDpcQueue()\n",0);
}
BOOLEAN KeRemoveQueueDpc(PKDPC Dpc)
{
return(FALSE);
}
- ExInterlockedRemoveEntryList(&DpcQueueHead,&Dpc->DpcListEntry,NULL);
+ RemoveEntryList(&Dpc->DpcListEntry);
Dpc->Lock=0;
+ return(TRUE);
}
BOOLEAN KeInsertQueueDpc(PKDPC dpc, PVOID SystemArgument1,
* FALSE otherwise
*/
{
+ DPRINT("KeInsertQueueDpc()\n",0);
+ assert(KeGetCurrentIrql()==DISPATCH_LEVEL);
+
dpc->Number=0;
dpc->Importance=Medium;
dpc->SystemArgument1=SystemArgument1;
{
return(FALSE);
}
- ExInterlockedInsertHeadList(&DpcQueueHead,&dpc->DpcListEntry,NULL);
+ KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
+ InsertHeadList(&DpcQueueHead,&dpc->DpcListEntry);
+ KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
dpc->Lock=1;
+ DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);
+ DPRINT("Leaving KeInsertQueueDpc()\n",0);
return(TRUE);
}
/*
* Last error code (this should be per process)
*/
-DWORD error_code;
+DWORD error_code = 0;
/* FUNCTIONS ***************************************************************/
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/event.c
- * PURPOSE: Implements event
+ * PURPOSE: Implements events
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/wait.h>
-
#include <ddk/ntddk.h>
+#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS ****************************************************************/
VOID KeClearEvent(PKEVENT Event)
{
- Event->Header.SignalState=FALSE; // (??) Is this atomic
+ Event->Header.SignalState=FALSE;
}
VOID KeInitializeEvent(PKEVENT Event, EVENT_TYPE Type, BOOLEAN State)
{
- Event->Header.Type = Type;
- Event->Header.Absolute = 0;
- Event->Header.Inserted = 0;
- Event->Header.Size = sizeof(KEVENT) / sizeof(ULONG);
- Event->Header.SignalState = State;
+ KeInitializeDispatcherHeader(&(Event->Header),Type,
+ sizeof(Event)/sizeof(ULONG),State);
InitializeListHead(&(Event->Header.WaitListHead));
}
LONG KeSetEvent(PKEVENT Event, KPRIORITY Increment, BOOLEAN Wait)
{
int ret;
- KIRQL oldlvl;
-
- KeAcquireSpinLock(&DispatcherDatabaseLock,&oldlvl);
- ret = InterlockedExchange(&(Event->Header.SignalState),1);
+
+ DPRINT("KeSetEvent(Event %x, Wait %x)\n",Event,Wait);
+ KeAcquireDispatcherDatabaseLock(Wait);
+// ret = InterlockedExchange(&(Event->Header.SignalState),1);
+ Event->Header.SignalState=1;
KeDispatcherObjectWake((DISPATCHER_HEADER *)Event);
- KeReleaseSpinLock(&DispatcherDatabaseLock,oldlvl);
+ KeReleaseDispatcherDatabaseLock(Wait);
}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
+#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
}
current=DeviceQueue->ListHead.Flink;
- while (current!=NULL)
+ while (current!=(&DeviceQueue->ListHead))
{
entry = CONTAINING_RECORD(current,KDEVICE_QUEUE_ENTRY,Entry);
if (entry->Key < SortKey)
entry = CONTAINING_RECORD(current,KDEVICE_QUEUE_ENTRY,Entry);
if (entry->Key < SortKey || current->Flink == NULL)
{
- RemoveEntryFromList(&DeviceQueue->ListHead,current);
+ RemoveEntryList(current);
KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl);
return(entry);
}
PLIST_ENTRY list_entry;
PKDEVICE_QUEUE_ENTRY entry;
+ DPRINT("KeRemoveDeviceQueue(DeviceQueue %x)\n",DeviceQueue);
+
assert_irql(DISPATCH_LEVEL);
assert(DeviceQueue!=NULL);
assert(DeviceQueue->Busy);
KeAcquireSpinLock(&DeviceQueue->Lock,&oldlvl);
list_entry = RemoveHeadList(&DeviceQueue->ListHead);
- if (list_entry==NULL)
+ if (list_entry==(&DeviceQueue->ListHead))
{
DeviceQueue->Busy=FALSE;
KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl);
/* INCLUDES *****************************************************************/
#include <windows.h>
-#include <coff.h>
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
#include <internal/version.h>
#include <internal/mm.h>
#include <internal/string.h>
: "ax");
}
+extern int edata;
+extern int end;
+
asmlinkage void _main(boot_param* _bp)
/*
* FUNCTION: Called by the boot loader to start the kernel
{
unsigned int i;
unsigned int start;
+ unsigned int start1;
+ boot_param bp;
+
+// memset((void *)&edata,0,((int)&end)-((int)&edata));
/*
* Copy the parameters to a local buffer because lowmem will go away
*/
- boot_param bp;
memcpy(&bp,_bp,sizeof(bp));
/*
printk("Starting ReactOS "KERNEL_VERSION"\n");
+ start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
+ DPRINT("MmGetPhysicalAddress(start) = %x\n",MmGetPhysicalAddress(start));
+ DPRINT("bp.module_length[0] %x PAGE_ROUND_UP(bp.module_length[0]) %x\n",
+ bp.module_length[0],PAGE_ROUND_UP(bp.module_length[0]));
+ start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
+ DPRINT("bp.module_length[1] %x PAGE_ROUND_UP(bp.module_length[1]) %x\n",
+ bp.module_length[1],PAGE_ROUND_UP(bp.module_length[1]));
+
+ DPRINT("start %x *start %x\n",start,*((unsigned int *)start));
+ DPRINT("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
+
+
/*
* Initalize various critical subsystems
*/
HalInit(&bp);
+// set_breakpoint(0,start,HBP_READWRITE,HBP_DWORD);
MmInitalize(&bp);
- KeInitDpc();
- KeInitializeBugCheck();
- KeInitializeDispatcher();
- InitializeTimer();
-
- /*
- * Allow interrupts
- */
- KeLowerIrql(PASSIVE_LEVEL);
-
- KeCalibrateTimerLoop();
- ObjNamespcInit();
- PsMgrInit();
- IoInit();
+ CHECKPOINT;
+ KeInit();
+ CHECKPOINT;
+ ObInit();
+ CHECKPOINT;
+ PsInit();
+ CHECKPOINT;
+ IoInit();
+ CHECKPOINT;
/*
- * Initalize loaded modules
+ * Initalize services loaded at boot time
*/
DPRINT("%d files loaded\n",bp.nr_files);
-
- start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]) +
- PAGESIZE;
+ start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
for (i=1;i<bp.nr_files;i++)
{
- DPRINT("start %x length %d\n",start,bp.module_length[i]);
- process_boot_module(start);
- start=start+PAGE_ROUND_UP(bp.module_length[i])+PAGESIZE;
+ DPRINT("start %x *start %x\n",start,*((unsigned int *)start));
+ CHECKPOINT;
+ process_boot_module(start);
+ CHECKPOINT;
+ start=start+PAGE_ROUND_UP(bp.module_length[i]);
}
-
/*
- * Enter shell
+ * Test various features of the kernel
*/
TstBegin();
#include <ddk/ntddk.h>
#include <internal/iomgr.h>
-#include <internal/kernel.h>
#include <internal/symbol.h>
#include <internal/string.h>
#include <internal/mm.h>
val = get_kernel_symbol_addr(name);
if (val==0)
{
- printk("Undefined symbol %s in module\n",name);
+ DbgPrint("Undefined symbol %s in module\n",name);
return(0);
}
// DPRINT("REL32 value %x name %s\n",val,name);
break;
default:
- printk("Unknown relocation type %x at %d in module\n",
+ DbgPrint("Unknown relocation type %x at %d in module\n",
reloc->r_type,j);
return(0);
}
PDRIVER_INITIALIZE func;
int i;
+ DPRINT("process_boot_module(start %x)\n",start);
DPRINT("n = %x\n",*((unsigned int *)start));
-
mod=(module *)ExAllocatePool(NonPagedPool,sizeof(module));
DPRINT("magic %x\n",((FILHDR *)start)->f_magic);
if (I386BADMAG(hdr))
{
- printk("(%s:%d) Module has bad magic value (%x)\n",__FILE__,
+ DbgPrint("(%s:%d) Module has bad magic value (%x)\n",__FILE__,
__LINE__,hdr.f_magic);
return(0);
}
}
}
- mod->base = (unsigned int)VirtualAlloc((LPVOID)0,mod->size,MEM_COMMIT,
- PAGE_SYSTEM + PAGE_EXECUTE_READWRITE);
+ CHECKPOINT;
+ mod->base = (unsigned int)MmAllocateSection(mod->size);
if (mod->base == 0)
{
- printk("Failed to allocated section for module\n");
+ DbgPrint("Failed to alloc section for module\n");
return(0);
}
-
+ CHECKPOINT;
/*
* Adjust section vaddrs for allocated area
if (!found_entry)
{
- printk("No module entry point defined\n");
+ DbgPrint("No module entry point defined\n");
return(0);
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/mutex.c
+ * FILE: ntoskrnl/ke/mutex.c
* PURPOSE: Implements mutex
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/sem.c
+ * FILE: ntoskrnl/ke/sem.c
* PURPOSE: Implements kernel semaphores
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
+#include <internal/ke.h>
#include <internal/debug.h>
LONG Count,
LONG Limit)
{
- UNIMPLEMENTED;
+ KeInitializeDispatcherHeader(&Semaphore->Header,SemaphoreType,
+ sizeof(KSEMAPHORE)/sizeof(ULONG),
+ Count);
+ Semaphore->Limit=Limit;
}
LONG KeReadStateSemaphore(PKSEMAPHORE Semaphore)
{
- UNIMPLEMENTED;
+ return(Semaphore->Header.SignalState);
}
LONG KeReleaseSemaphore(PKSEMAPHORE Semaphore,
LONG Adjustment,
BOOLEAN Wait)
{
- UNIMPLEMENTED;
}
/* INCLUDES ***************************************************************/
#include <limits.h>
-
-#include <internal/stddef.h>
-#include <internal/kernel.h>
-#include <internal/mm.h>
-#include <internal/hal/page.h>
-#include <internal/string.h>
#include <ddk/ntddk.h>
+#define NDEBUG
#include <internal/debug.h>
/* TYPES *****************************************************************/
* PURPOSE: List of timers
*/
static LIST_ENTRY timer_list_head = {NULL,NULL};
-static KSPIN_LOCK timer_list_lock;
+static KSPIN_LOCK timer_list_lock = {0,};
#define MICROSECONDS_TO_CALIBRATE (1000000)
loops_per_microsecond = (loops_per_microsecond * MICROSECONDS_TO_CALIBRATE)
/ (nr_ticks*MICROSECONDS_PER_TICK);
- printk("nr_ticks %d\n",nr_ticks);
- printk("loops_per_microsecond %d\n",loops_per_microsecond);
- printk("Processor speed (approx) %d\n",
- (6*loops_per_microsecond)/1000);
+ DbgPrint("nr_ticks %d\n",nr_ticks);
+ DbgPrint("loops_per_microsecond %d\n",loops_per_microsecond);
+ DbgPrint("Processor speed (approx) %d\n",
+ (6*loops_per_microsecond)/1000);
if (nr_ticks == (TICKS_PER_SECOND_APPROX * MICROSECONDS_TO_CALIBRATE)
/ MICROSECONDS_IN_A_SECOND)
{
- printk("Testing loop\n");
+ DbgPrint("Testing loop\n");
KeStallExecutionProcessor(10000);
- printk("Finished loop\n");
+ DbgPrint("Finished loop\n");
return;
}
}
}
+NTSTATUS KeAddThreadTimeout(PKTHREAD Thread, PLARGE_INTEGER Interval)
+{
+ KeInitializeTimer(&(Thread->TimerBlock));
+ KeSetTimer(&(Thread->TimerBlock),*Interval,NULL);
+}
+
NTSTATUS KeDelayExecutionThread(KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Interval)
+/*
+ * FUNCTION: Puts the current thread into an alertable or nonalertable
+ * wait state for a given internal
+ * ARGUMENTS:
+ * WaitMode = Processor mode in which the caller is waiting
+ * Altertable = Specifies if the wait is alertable
+ * Interval = Specifies the interval to wait
+ * RETURNS: Status
+ */
{
- UNIMPLEMENTED;
+ PKTHREAD CurrentThread = KeGetCurrentThread();
+ KeAddThreadTimeout(CurrentThread,Interval);
+ return(KeWaitForSingleObject(&(CurrentThread->TimerBlock),Executive,
+ KernelMode,Alertable,NULL));
}
VOID KeStallExecutionProcessor(ULONG MicroSeconds)
if (Timer->expire_time < 0)
{
Timer->expire_time = system_time - Timer->expire_time;
- Timer->signaled = FALSE;
}
+ Timer->signaled = FALSE;
if (Timer->running)
{
KeReleaseSpinLock(&timer_list_lock,oldlvl);
{
return(FALSE);
}
- RemoveEntryFromList(&timer_list_head,&Timer->entry);
+ RemoveEntryList(&Timer->entry);
KeReleaseSpinLock(&timer_list_lock,oldlvl);
return(TRUE);
}
}
else
{
- RemoveEntryFromList(&timer_list_head,¤t->entry);
+ RemoveEntryList(¤t->entry);
current->running=FALSE;
}
}
KeAcquireSpinLock(&timer_list_lock,&oldlvl);
- while (current_entry!=NULL)
+ while (current_entry!=(&timer_list_head))
{
if (system_time == current->expire_time)
{
KeReleaseSpinLock(&timer_list_lock,oldlvl);
}
-VOID KeTimerInterrupt(VOID)
+VOID KiTimerInterrupt(VOID)
/*
* FUNCTION: Handles a timer interrupt
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS project
- * FILE: ntoskrnl/ps/wait.c
+ * FILE: ntoskrnl/ke/wait.c
* PURPOSE: Manages non-busy waiting
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISION HISTORY:
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
-#include <internal/wait.h>
+#include <internal/ke.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS ******************************************************************/
-KSPIN_LOCK DispatcherDatabaseLock;
-BOOLEAN WaitSet;
+static KSPIN_LOCK DispatcherDatabaseLock = {0,};
+static BOOLEAN WaitSet = FALSE;
+static KIRQL oldlvl = PASSIVE_LEVEL;
+static PKTHREAD Owner = NULL;
/* FUNCTIONS *****************************************************************/
-VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr)
+VOID KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header,
+ ULONG Type,
+ ULONG Size,
+ ULONG SignalState)
+{
+ Header->Type = Type;
+ Header->Absolute = 0;
+ Header->Inserted = 0;
+ Header->Size = Size;
+ Header->SignalState = SignalState;
+ InitializeListHead(&(Header->WaitListHead));
+}
+
+VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait)
+/*
+ * PURPOSE: Acquires the dispatcher database lock for the caller
+ */
+{
+ DPRINT("KeAcquireDispatcherDatabaseLock(Wait %x)\n",Wait);
+ if (WaitSet && Owner == KeGetCurrentThread())
+ {
+ return;
+ }
+ KeAcquireSpinLock(&DispatcherDatabaseLock,&oldlvl);
+ WaitSet = Wait;
+ Owner = KeGetCurrentThread();
+}
+
+VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait)
+{
+ DPRINT("KeReleaseDispatcherDatabaseLock(Wait %x)\n",Wait);
+ assert(Wait==WaitSet);
+ if (!Wait)
+ {
+ Owner = NULL;
+ KeReleaseSpinLock(&DispatcherDatabaseLock,oldlvl);
+ }
+}
+
+VOID KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
{
PKWAIT_BLOCK current;
PLIST_ENTRY current_entry;
- DPRINT("Entering KeDispatcherObjectWake(hdr %x)\n",hdr);
- DPRINT("hdr->WaitListHead %x hdr->WaitListHead.Flink %x\n",
- &hdr->WaitListHead,hdr->WaitListHead.Flink);
- while ((current_entry=RemoveHeadList(&hdr->WaitListHead))!=NULL)
+ while (!IsListEmpty(&(hdr->WaitListHead)))
{
+ current_entry = RemoveHeadList(&hdr->WaitListHead);
current = CONTAINING_RECORD(current_entry,KWAIT_BLOCK,
WaitListEntry);
DPRINT("Waking %x\n",current->Thread);
- PsWakeThread(current->Thread);
+ PsWakeThread((PETHREAD)current->Thread);
};
}
+
+BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr)
+{
+ PKWAIT_BLOCK current;
+ PLIST_ENTRY current_entry;
+
+ DPRINT("KeDispatcherObjectWakeOn(hdr %x)\n",hdr);
+ DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
+ hdr->WaitListHead.Flink,hdr->WaitListHead.Blink);
+ if (IsListEmpty(&(hdr->WaitListHead)))
+ {
+ return(FALSE);
+ }
+ current_entry=RemoveHeadList(&(hdr->WaitListHead));
+ current = CONTAINING_RECORD(current_entry,KWAIT_BLOCK,
+ WaitListEntry);
+ DPRINT("current_entry %x current %x\n",current_entry,current);
+ DPRINT("Waking %x\n",current->Thread);
+ PsWakeThread((PETHREAD)current->Thread);
+ return(TRUE);
+}
+
+VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr)
+{
+
+ DPRINT("Entering KeDispatcherObjectWake(hdr %x)\n",hdr);
+// DPRINT("hdr->WaitListHead %x hdr->WaitListHead.Flink %x\n",
+// &hdr->WaitListHead,hdr->WaitListHead.Flink);
+ if (hdr->Type==NotificationEvent)
+ {
+ KeDispatcherObjectWakeAll(hdr);
+ }
+ if (hdr->Type==SynchronizationEvent)
+ {
+ if (KeDispatcherObjectWakeOne(hdr))
+ {
+ hdr->SignalState=FALSE;
+ }
+ }
+}
NTSTATUS KeWaitForSingleObject(PVOID Object,
KPROCESSOR_MODE WaitMode,
BOOLEAN Alertable,
PLARGE_INTEGER Timeout)
+/*
+ * FUNCTION: Puts the current thread into a wait state until the
+ * given dispatcher object is set to signalled
+ * ARGUMENTS:
+ * Object = Object to wait on
+ * WaitReason = Reason for the wait (debugging aid)
+ * WaitMode = Can be KernelMode or UserMode, if UserMode then
+ * user-mode APCs can be delivered and the thread's
+ * stack can be paged out
+ * Altertable = Specifies if the wait is a alertable
+ * Timeout = Optional timeout value
+ * RETURNS: Status
+ */
{
DISPATCHER_HEADER* hdr = (DISPATCHER_HEADER *)Object;
KWAIT_BLOCK blk;
+ KIRQL oldlvl;
DPRINT("Entering KeWaitForSingleObject(Object %x)\n",Object);
+
+ KeAcquireDispatcherDatabaseLock(FALSE);
+
+ if (hdr->SignalState)
+ {
+ hdr->SignalState=FALSE;
+ KeReleaseDispatcherDatabaseLock(FALSE);
+ return(STATUS_SUCCESS);
+ }
+
+ if (Timeout!=NULL)
+ {
+ KeAddThreadTimeout(KeGetCurrentThread(),Timeout);
+ }
blk.Object=Object;
blk.Thread=KeGetCurrentThread();
- InsertTailList(&hdr->WaitListHead,&blk.WaitListEntry);
+ blk.WaitKey = WaitReason; // Assumed
+ blk.WaitType = WaitMode; // Assumed
+ blk.NextWaitBlock = NULL;
+ InsertTailList(&(hdr->WaitListHead),&(blk.WaitListEntry));
+// DPRINT("hdr->WaitListHead.Flink %x hdr->WaitListHead.Blink %x\n",
+// hdr->WaitListHead.Flink,hdr->WaitListHead.Blink);
+ KeReleaseDispatcherDatabaseLock(FALSE);
PsSuspendThread();
+ return(STATUS_SUCCESS);
}
NTSTATUS KeWaitForMultipleObjects(ULONG Count,
NTSTATUS LdrLoadDriver(PUNICODE_STRING FileName)
/*
- * FUNCTION: Loads a PE executable into the current process
+ * FUNCTION: Loads a PE executable into the kernel
* ARGUMENTS:
* FileName = Driver to load
* RETURNS: Status
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: mkernel/mm/freelist.cc
+ * FILE: ntoskrnl/mm/freelist.c
* PURPOSE: Handle the list of free physical pages
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
#include <internal/stddef.h>
#include <internal/hal/page.h>
#include <internal/mm.h>
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
#include <internal/bitops.h>
#include <ddk/ntddk.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/mm/iospace.c
+ * PURPOSE: Mapping io space
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
* FUNCTION: Unlocks the physical pages described by a given MDL
* ARGUMENTS:
* MemoryDescriptorList = MDL describing the buffer to be unlocked
+ * NOTES: The memory described by the specified MDL must have been locked
+ * previously by a call to MmProbeAndLockPages. As the pages unlocked, the
+ * MDL is updated
*/
{
UNIMPLEMENTED;
}
PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
+/*
+ * FUNCTION: Maps the physical pages described by a given MDL
+ * ARGUMENTS:
+ * Mdl = Points to an MDL updated by MmProbeAndLockPages
+ * AccessMode = Specifies the access mode in which to map the MDL
+ * RETURNS: The base virtual address that maps the locked pages for the
+ * range described by the MDL
+ */
{
PVOID base;
unsigned int i;
ULONG* mdl_pages=NULL;
+ MEMORY_AREA* Result;
DPRINT("Mdl->ByteCount %x\n",Mdl->ByteCount);
DPRINT("PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE) %x\n",
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
- base = VirtualAlloc((LPVOID)0,Mdl->ByteCount,MEM_COMMIT,
- PAGE_SYSTEM + PAGE_EXECUTE_READWRITE);
+ MmCreateMemoryArea(KernelMode,
+ MEMORY_AREA_MDL_MAPPING,
+ &base,
+ Mdl->ByteCount,
+ 0,
+ &Result);
mdl_pages = (ULONG *)(Mdl + 1);
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE); i++)
{
}
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
+/*
+ * FUNCTION: Releases a mapping set up by a preceding call to MmMapLockedPages
+ * ARGUMENTS:
+ * BaseAddress = Base virtual address to which the pages were mapped
+ * MemoryDescriptorList = MDL describing the mapped pages
+ */
{
- UNIMPLEMENTED;
+ (void)MmFreeMemoryArea(BaseAddress,MemoryDescriptorList->ByteCount,FALSE);
}
VOID MmPrepareMdlForReuse(PMDL Mdl)
{
ULONG* mdl_pages=NULL;
int i;
- memory_area* marea;
+ MEMORY_AREA* marea;
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
DPRINT("StartVa %x\n",Mdl->StartVa);
- if (Mdl->StartVa > KERNEL_BASE)
- {
- marea=find_first_marea(system_memory_area_list_head,
- (ULONG)Mdl->StartVa,
- Mdl->ByteCount);
- }
- else
- {
- marea=find_first_marea(memory_area_list_head,
- (ULONG)Mdl->StartVa,
- Mdl->ByteCount);
- }
-
+ marea = MmOpenMemoryAreaByAddress((ULONG)Mdl->StartVa);
DPRINT("marea %x\n",marea);
/*
* Check the area is valid
*/
- if (marea==NULL || (marea->base+marea->length) < ((ULONG)Mdl->StartVa))
+ if (marea==NULL )
{
printk("Area is invalid\n");
ExRaiseStatus(STATUS_INVALID_PARAMETER);
/*
* Check the permissions
*/
+ #if 0
switch(Operation)
{
case IoReadAccess:
__FUNCTION__);
KeBugCheck(UNEXPECTED_KERNEL_MODE_TRAP);
}
+ #endif
/*
* Lock the memory area
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);i++)
{
- if (!is_page_present(PAGE_ROUND_DOWN(Mdl->StartVa) + (i*PAGESIZE)))
- {
- marea->load_page(marea,PAGE_ROUND_DOWN(Mdl->StartVa) + (i*PAGESIZE)
- - marea->base);
- }
mdl_pages[i]=MmGetPhysicalAddress((PVOID)(PAGE_ROUND_DOWN(Mdl->StartVa)
- +(i*PAGESIZE)));
+ +(i*PAGESIZE))).LowPart;
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
DPRINT("&mdl_pages[i] %x\n",&mdl_pages[i]);
}
for (va=0; va<Mdl->Size; va++)
{
((PULONG)(Mdl + 1))[va] = MmGetPhysicalAddress(
- Mdl->StartVa+ (va * PAGESIZE));
+ Mdl->StartVa+ (va * PAGESIZE)).LowPart;
}
Mdl->MappedSystemVa = Mdl->StartVa;
}
/*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
- * FILE: mm/mm.c
+ * FILE: ntoskrnl/mm/mm.c
* PURPOSE: kernel memory managment functions
* PROGRAMMER: David Welch
* UPDATE HISTORY:
#include <internal/stddef.h>
#include <internal/mm.h>
#include <internal/string.h>
-#include <internal/kernel.h>
-#include <internal/pool.h>
+#include <internal/ntoskrnl.h>
#include <internal/bitops.h>
#include <internal/string.h>
/* INCLUDES ****************************************************************/
+#include <internal/string.h>
#include <internal/stddef.h>
#include <internal/mm.h>
#include <internal/hal/page.h>
#include <internal/pool.h>
#include <internal/bitops.h>
-#include <internal/kernel.h>
+#include <internal/ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h>
/*
* Memory managment initalized symbol for the base of the pool
*/
-extern unsigned int kernel_pool_base;
+unsigned int kernel_pool_base = 0;
/*
* Pointer to the first block in the free list
/* FUNCTIONS ***************************************************************/
+VOID ExInitNonPagedPool(ULONG BaseAddress)
+{
+ kernel_pool_base=BaseAddress;
+}
+
static void validate_free_list(void)
/*
* FUNCTION: Validate the integrity of the list of free blocks
static PVOID ExAllocateNonPagedPool(ULONG type, ULONG size)
{
block_hdr* current=NULL;
+ void* block;
DPRINT("kmalloc(size %d)\n",size);
validate_kernel_pool();
if (current->size>=size)
{
DPRINT("found block %x of size %d\n",current,size);
- return(take_block(current,size));
+ block=take_block(current,size);
+ memset(block,0,size);
+ return(block);
}
current=current->next;
}
/*
* Otherwise create a new block
*/
- return(block_to_address(grow_kernel_pool(size)));
+ block=block_to_address(grow_kernel_pool(size));
+ memset(block,0,size);
+ return(block);
}
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes)
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
+#include <internal/mm.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
+NTSTATUS STDCALL ZwCreateSection(OUT PHANDLE SectionHandle,
+ IN ACCESS_MASK DesiredAccess,
+ IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
+ IN PLARGE_INTEGER MaximumSize OPTIONAL,
+ IN ULONG SectionPageProtection OPTIONAL,
+ IN ULONG AllocationAttributes,
+ IN HANDLE FileHandle OPTIONAL)
+/*
+ * FUNCTION: Creates a section object.
+ * ARGUMENTS:
+ * SectionHandle (OUT) = Caller supplied storage for the resulting
+ * handle
+ * DesiredAccess = Specifies the desired access to the section can be a
+ * combination of STANDARD_RIGHTS_REQUIRED |
+ * SECTION_QUERY | SECTION_MAP_WRITE |
+ * SECTION_MAP_READ | SECTION_MAP_EXECUTE.
+ * ObjectAttribute = Initialized attributes for the object can be used
+ * to create a named section
+ * MaxiumSize = Maximizes the size of the memory section. Must be
+ * non-NULL for a page-file backed section.
+ * If value specified for a mapped file and the file is
+ * not large enough, file will be extended.
+ * SectionPageProtection = Can be a combination of PAGE_READONLY |
+ * PAGE_READWRITE | PAGE_WRITEONLY |
+ * PAGE_WRITECOPY.
+ * AllocationAttributes = can be a combination of SEC_IMAGE |
+ * SEC_RESERVE
+ * FileHandle = Handle to a file to create a section mapped to a file
+ * instead of a memory backed section.
+ * RETURNS: Status
+ */
+{
+}
+
NTSTATUS ZwOpenSection(PHANDLE SectionHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes)
* These two are statically declared because mm is initalized before the
* memory pool
*/
-static memory_area kernel_text_desc;
-static memory_area kernel_data_desc;
-static memory_area kernel_param_desc;
-static memory_area kernel_pool_desc;
-
-/*
- * Head of the list of system memory areas
- */
-memory_area* system_memory_area_list_head=&kernel_text_desc;
-
-/*
- * Head of the list of user memory areas (this should be per process)
- */
-memory_area* memory_area_list_head=NULL;
-
-/*
- * The base address of the kmalloc region
- */
-unsigned int kernel_pool_base = 0;
-
+static MEMORY_AREA* kernel_text_desc = NULL;
+static MEMORY_AREA* kernel_data_desc = NULL;
+static MEMORY_AREA* kernel_param_desc = NULL;
+static MEMORY_AREA* kernel_pool_desc = NULL;
/* FUNCTIONS ****************************************************************/
*/
{
unsigned int kernel_len = bp->end_mem - bp->start_mem;
+ ULONG BaseAddress;
+ ULONG Length;
+ ULONG ParamLength = kernel_len;
DPRINT("VirtualInit() %x\n",bp);
- /*
- * Setup the system area descriptor list
- */
- kernel_text_desc.base = KERNEL_BASE;
- kernel_text_desc.length = ((ULONG)&etext) - KERNEL_BASE;
- kernel_text_desc.previous = NULL;
- kernel_text_desc.next = &kernel_data_desc;
- kernel_text_desc.load_page=NULL;
- kernel_text_desc.access = PAGE_EXECUTE_READ;
-
- kernel_data_desc.base = PAGE_ROUND_UP(((ULONG)&etext));
- kernel_data_desc.length = ((ULONG)&end) - kernel_text_desc.base;
- kernel_data_desc.previous = &kernel_text_desc;
- kernel_data_desc.next = &kernel_param_desc;
- kernel_data_desc.load_page=NULL;
- kernel_data_desc.access = PAGE_READWRITE;
+ MmInitMemoryAreas();
+ ExInitNonPagedPool(KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE);
- kernel_param_desc.base = PAGE_ROUND_UP(((ULONG)&end));
- kernel_param_desc.length = kernel_len - (kernel_data_desc.length +
- kernel_text_desc.length);
- kernel_param_desc.previous = &kernel_data_desc;
- kernel_param_desc.next = &kernel_pool_desc;
- kernel_param_desc.load_page=NULL;
/*
- * The kmalloc area starts one page after the kernel area
+ * Setup the system area descriptor list
*/
- kernel_pool_desc.base = KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE;
- kernel_pool_desc.length = NONPAGED_POOL_SIZE;
- kernel_pool_desc.previous = &kernel_param_desc;
- kernel_pool_desc.next = NULL;
- kernel_pool_desc.load_page=NULL;
-
- kernel_pool_base = kernel_pool_desc.base;
- DPRINT("kmalloc_region_base %x\n",kernel_pool_base);
+ BaseAddress = KERNEL_BASE;
+ Length = ((ULONG)&etext) - KERNEL_BASE;
+ ParamLength = ParamLength - Length;
+ MmCreateMemoryArea(KernelMode,MEMORY_AREA_SYSTEM,&BaseAddress,
+ Length,0,&kernel_text_desc);
+
+ Length = ((ULONG)&end) - ((ULONG)&etext);
+ ParamLength = ParamLength - Length;
+ DPRINT("Length %x\n",Length);
+ BaseAddress = PAGE_ROUND_UP(((ULONG)&etext));
+ MmCreateMemoryArea(KernelMode,
+ MEMORY_AREA_SYSTEM,
+ &BaseAddress,
+ Length,
+ 0,
+ &kernel_data_desc);
+
+
+ BaseAddress = PAGE_ROUND_UP(((ULONG)&end));
+ Length = ParamLength;
+ MmCreateMemoryArea(KernelMode,MEMORY_AREA_SYSTEM,&BaseAddress,
+ Length,0,&kernel_param_desc);
+
+ BaseAddress = KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE;
+ Length = NONPAGED_POOL_SIZE;
+ MmCreateMemoryArea(KernelMode,MEMORY_AREA_SYSTEM,&BaseAddress,
+ Length,0,&kernel_pool_desc);
+
+ MmDumpMemoryAreas();
+ CHECKPOINT;
}
-
-memory_area* find_first_marea(memory_area* list_head, unsigned int base,
- unsigned int length)
-/*
- * FUNCTION: Returns the first memory area starting in the region or the last
- * one before the start of the region
- * ARGUMENTS:
- * list_head = Head of the list of memory areas to search
- * base = base address of the region
- * length = length of the region
- * RETURNS: A pointer to the area found or
- * NULL if the region was before the first region on the list
- */
+NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea, ULONG Address)
{
- memory_area* current=list_head;
- for (;;)
- {
- if (current==NULL)
- {
-// printk("current is null\n");
- return(NULL);
- }
-// printk("current %x current->base %x\n",current,current->base);
- if (current->base == base && length==0)
- {
- return(current);
- }
-
- if (current->base >= base)
- {
- if (current->base < (base+length))
- {
- return(current);
- }
- else
- {
- return(current->previous);
- }
- }
- if (current->next==NULL)
- {
- return(current);
- }
- current=current->next;
- }
- return(NULL);
+ set_page(Address,0x7,get_free_page());
+ return(STATUS_SUCCESS);
}
asmlinkage int page_fault_handler(unsigned int edi,
* FUNCTION: Handle a page fault
*/
{
- memory_area* marea=NULL;
-
+ KPROCESSOR_MODE FaultMode;
+ MEMORY_AREA* MemoryArea;
+
/*
* Get the address for the page fault
*/
unsigned int cr2;
__asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
DPRINT("Page fault at address %x with eip %x\n",cr2,eip);
+ for(;;);
cr2 = PAGE_ROUND_DOWN(cr2);
+ assert_irql(DISPATCH_LEVEL);
+
/*
* Find the memory area for the faulting address
*/
printk("%s:%d\n",__FILE__,__LINE__);
return(0);
}
- marea=find_first_marea(system_memory_area_list_head,cr2,
- PAGESIZE);
+ FaultMode = UserMode;
}
else
{
- marea=find_first_marea(memory_area_list_head,cr2,
- PAGESIZE);
+ FaultMode = KernelMode;
}
- /*
- * If the access was to an invalid area of memory raise an exception
- */
- if (marea==NULL || marea->load_page==NULL)
+ MemoryArea = MmOpenMemoryAreaByAddress(cr2);
+ if (MemoryArea==NULL)
{
printk("%s:%d\n",__FILE__,__LINE__);
return(0);
}
- /*
- * Check the access was within the area
- */
- if (cr2 > (marea->base + marea->length) || cr2 < marea->base)
+ switch (MemoryArea->Type)
{
- DPRINT("base was %x length %x\n",marea->base,marea->length);
- DPRINT("%s:%d\n",__FILE__,__LINE__);
+ case MEMORY_AREA_SYSTEM:
return(0);
- }
-
- /*
- * Call the region specific page fault handler
- */
- return(marea->load_page(marea,cr2 - marea->base));
-}
-
-
-
-static LPVOID allocate_marea(DWORD dwSize, DWORD flAllocationType,
- DWORD flProtect, memory_area** list_head,
- unsigned int last_addr,
- BOOL (*fn)(memory_area* marea,
- unsigned int address))
-/*
- * FUNCTION:
- */
-{
- memory_area* current=*list_head;
- memory_area* previous;
- memory_area* ndesc=NULL;
-
- previous=current;
- while (current!=NULL)
- {
- last_addr = PAGE_ROUND_UP(current->base + current->length);
- previous=current;
- current=current->next;
- }
- ndesc = ExAllocatePool(NonPagedPool,sizeof(memory_area));
- ndesc->access=flProtect;
- ndesc->state=flAllocationType;
- ndesc->lock=FALSE;
- ndesc->base=last_addr+PAGESIZE;
- ndesc->length=dwSize;
- ndesc->previous=previous;
- if (previous!=NULL)
- {
- ndesc->next=previous->next;
- previous->next=ndesc;
- if (previous->next!=NULL)
- {
- previous->next->previous=ndesc;
- }
- }
- else
- {
- *list_head=ndesc;
- ndesc->next=NULL;
- ndesc->previous=NULL;
- }
- ndesc->load_page=fn;
- DPRINT("VirtualAlloc() returning %x\n",ndesc->base);
- return((LPVOID)ndesc->base);
-}
-
-void commit_region_free(memory_area* marea)
-/*
- * FUNCTION: Decommits the region
- */
-{
- int i;
- for (i=0;i<marea->length;i=i+PAGESIZE)
- {
- if (is_page_present(marea->base+marea->length))
- {
- free_page(MmGetPhysicalAddress(marea->base+marea->length),1);
- }
- }
-}
-
-BOOL commit_region_load_page(memory_area* marea, unsigned int address)
-/*
- * FUNCTION: Handles a page fault on a committed region of memory
- * ARGUMENTS:
- * marea = memory area
- * address = address of faulting access
- * RETURNS: TRUE if the page was loaded
- * FALSE if an exception should be generated
- */
-{
- set_page(marea->base+address,0x7,get_free_page());
- return(TRUE);
-}
-
-asmlinkage LPVOID STDCALL VirtualAlloc(LPVOID lpAddress, DWORD dwSize,
- DWORD flAllocationType,
- DWORD flProtect)
-{
-/*
- * FUNCTION: Create a memory area
- * ARGUMENTS:
- * lpAddress = the base address of the area or NULL if the system
- * decides the base
- * dwSize = the size of the area
- * flAllocationType = the type of allocation
- * MEM_COMMIT = accessible
- * MEM_RESERVE = not accessible but can't be allocated
- * flProtect = what protection to give the area
- * RETURNS: The base address of the block
- */
- DPRINT("VirtualAlloc() lpAddress %x dwSize %x flAllocationType %x ",
- lpAddress,dwSize,flAllocationType);
- DPRINT("flProtect %x\n",flProtect);
-
- if (lpAddress==NULL)
- {
- /*
- * We decide the address
- */
- if (flProtect & PAGE_SYSTEM)
- {
- return(allocate_marea(dwSize,flAllocationType,
- flProtect,&system_memory_area_list_head,
- KERNEL_BASE,commit_region_load_page));
- }
- else
- {
- return(allocate_marea(dwSize,flAllocationType,
- flProtect,&memory_area_list_head,PAGESIZE,
- commit_region_load_page));
- }
- }
- else
- {
- memory_area* marea=NULL;
- if (lpAddress < ((PVOID)KERNEL_BASE))
- {
- marea=find_first_marea(memory_area_list_head,
- (unsigned int)lpAddress,dwSize);
- }
- else
- {
- marea=find_first_marea(system_memory_area_list_head,
- (unsigned int)lpAddress,dwSize);
- }
-
- /*
- * Check someone hasn't already allocated that area
- */
- if (marea!=NULL && marea->base <= (unsigned int)lpAddress &&
- (marea->base + marea->length) > (unsigned int)lpAddress)
- {
- SetLastError(ERROR_INVALID_DATA);
- return(0);
- }
-
- /*
- * Grab the area
- */
- }
-}
-
-BOOL WINAPI VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, DWORD dwSize,
- DWORD dwFreeType)
-/*
- * FUNCTION: Releases, decommits or both a region of memory within the
- * virtual address of a specified process
- * ARGUMENTS:
- * hProcess = Process to act on
- * lpAddress = starting virtual address to free
- * dwSize = Size in bytes of the memory region to free
- * dwFreeType = Type of free operation
- * RETURNS: On success non-zero
- * On failure zero
- * NOTE: This tries to optimize for the most common case which is for
- * regions to be decommitted in large chunks. If a process alternatedly
- * decommitted every other page in a region this function would be extremely
- * inefficent.
- */
-{
- memory_area* marea = NULL;
-
- /*
- * Check our permissions for hProcess here
- */
-
- /*
- * Get the list of memory areas corresponding to hProcess here
- */
-
- /*
- * Do the business
- */
- if (dwFreeType==MEM_RELEASE)
- {
- if (dwSize!=0)
- {
- SetLastError(ERROR_INVALID_BLOCK_LENGTH);
- return(0);
- }
-
- marea = find_first_marea(memory_area_list_head,(unsigned int)lpAddress,
- 1);
- if (marea==NULL || marea->base!=((int)lpAddress))
- {
- SetLastError(ERROR_INVALID_BLOCK);
- return(0);
- }
-
- /*
- * Ask the memory area to destroy itself
- */
- marea->free(marea);
-
- /*
- * Change the area attributes
- */
- marea->access=PAGE_NOACCESS;
- marea->state=MEM_FREE;
- marea->type=MEM_PRIVATE;
- }
- else
- {
+ case MEMORY_AREA_SECTION_VIEW:
+ return(MmSectionHandleFault(MemoryArea,cr2));
}
+ return(0);
}
-BOOL WINAPI VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress,
- DWORD dwSize, DWORD flNewProtect, PDWORD lpflOldProtect)
-/*
- * FUNCTION:
- */
-{
-}
-
-DWORD WINAPI VirtualQueryEx(HANDLE hProcess, LPCVOID lpAddress,
- PMEMORY_BASIC_INFORMATION lpBuffer, DWORD dwLength)
-/*
- * FUNCTION: Provides information about a range of pages within the virtual
- * address space of a specified process.
- * ARGUMENTS:
- * hProcess = Handle of process
- * lpAddress = Address of region
- * lpBuffer = Buffer to store information
- * dwLength = length of region
- * RETURNS: The number of bytes transferred into the buffer
- */
-{
- /*
- * Find the memory area
- */
- memory_area* marea = find_first_marea(memory_area_list_head,
- (unsigned int) lpAddress,
- dwLength);
-
- /*
- * Check it exists
- */
- if (marea==NULL || marea->base!=((int)lpAddress))
- {
- SetLastError(0);
- return(0);
- }
-
- lpBuffer->BaseAddress = (void *)lpAddress;
- lpBuffer->AllocationBase = (void *)marea->base;
- lpBuffer->AllocationProtect = marea->initial_access;
- lpBuffer->RegionSize = marea->length;
- lpBuffer->State = marea->state;
- lpBuffer->Protect = marea->access;
- lpBuffer->Type = marea->type;
-
- return(sizeof(MEMORY_BASIC_INFORMATION));
-}
BOOLEAN MmIsNonPagedSystemAddressValid(PVOID VirtualAddress)
{
* allow byte granular access?
*/
{
- memory_area* marea;
-
- if (VirtualAddress >= (PVOID)KERNEL_BASE)
- {
- marea = find_first_marea(system_memory_area_list_head,
- (unsigned int)VirtualAddress,1);
- }
- else
- {
- marea = find_first_marea(memory_area_list_head,
- (unsigned int)VirtualAddress,1);
- }
-
- if (marea==NULL)
- {
- return(FALSE);
- }
-
- if (marea->access == PAGE_NOACCESS || marea->access & PAGE_GUARD ||
- marea->state == MEM_FREE || marea->state == MEM_RESERVE)
- {
- return(FALSE);
- }
-
- return(TRUE);
+ UNIMPLEMENTED;
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: mkernel/mm/zone.c
+ * FILE: ntoskrnl/mm/zone.c
* PURPOSE: Implements zone buffers
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
/* INCLUDES ****************************************************************/
#include <ddk/ntddk.h>
-#include <internal/mm.h>
-#include <internal/kernel.h>
/* FUNCTIONS ***************************************************************/
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/string.h>
-#include <internal/pool.h>
#define NDEBUG
#include <internal/debug.h>
* PURPOSE: Head of the list of handle blocks
*/
LIST_ENTRY handle_list_head = {NULL,NULL};
-KSPIN_LOCK handle_list_lock;
+KSPIN_LOCK handle_list_lock = {0};
/* FUNCTIONS ***************************************************************/
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/string.h>
-#include <internal/kernel.h>
#define NDEBUG
#include <internal/debug.h>
0,
ULONG_MAX,
ULONG_MAX,
- sizeof(DEVICE_OBJECT),
+ sizeof(DIRECTORY_OBJECT),
0,
NULL,
NULL,
NULL,
};
+
static struct
{
OBJECT_HEADER hdr;
// DIRECTORY_OBJECT directory;
LIST_ENTRY head;
-} namespc_root;
+ KSPIN_LOCK Lock;
+} namespc_root = {{0,},};
/* FUNCTIONS **************************************************************/
NTSTATUS ZwOpenDirectoryObject(PHANDLE DirectoryHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes)
+/*
+ * FUNCTION: Opens a namespace directory object
+ * ARGUMENTS:
+ * DirectoryHandle (OUT) = Variable which receives the directory handle
+ * DesiredAccess = Desired access to the directory
+ * ObjectAttributes = Structure describing the directory
+ * RETURNS: Status
+ * NOTES: Undocumented
+ */
{
PVOID Object;
NTSTATUS Status;
IN BOOLEAN IgnoreInputIndex,
IN OUT PULONG ObjectIndex,
OUT PULONG DataWritten OPTIONAL)
+/*
+ * FUNCTION: Reads information from a namespace directory
+ * ARGUMENTS:
+ * DirObjInformation (OUT) = Buffer to hold the data read
+ * BufferLength = Size of the buffer in bytes
+ * GetNextIndex = If TRUE then set ObjectIndex to the index of the
+ * next object
+ * If FALSE then set ObjectIndex to the number of
+ * objects in the directory
+ * IgnoreInputIndex = If TRUE start reading at index 0
+ * If FALSE start reading at the index specified
+ * by object index
+ * ObjectIndex = Zero based index into the directory, interpretation
+ * depends on IgnoreInputIndex and GetNextIndex
+ * DataWritten (OUT) = Caller supplied storage for the number of bytes
+ * written (or NULL)
+ * RETURNS: Status
+ */
{
POBJECT_HEADER hdr = ObGetObjectByHandle(DirObjHandle);
PDIRECTORY_OBJECT dir = (PDIRECTORY_OBJECT)(HEADER_TO_BODY(hdr));
+ ULONG EntriesToRead;
PLIST_ENTRY current_entry;
POBJECT_HEADER current;
- PWSTR outbuffer = (PWSTR)(ObjectIndex);
+ ULONG i=0;
+ ULONG EntriesToSkip;
+
+ assert_irql(PASSIVE_LEVEL);
+
+ EntriesToRead = BufferLength / sizeof(OBJDIR_INFORMATION);
+ *DataWritten = 0;
current_entry = dir->head.Flink;
- while (current_entry!=NULL)
+
+ /*
+ * Optionally, skip over some entries at the start of the directory
+ */
+ if (!IgnoreInputIndex)
+ {
+ EntriesToSkip = *ObjectIndex;
+ while ( i<EntriesToSkip && current_entry!=NULL)
+ {
+ current_entry = current_entry->Flink;
+ }
+ }
+
+ /*
+ * Read the maximum entries possible into the buffer
+ */
+ while ( i<EntriesToRead && current_entry!=NULL)
{
current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,entry);
- if (BufferLength < wstrlen(current->name.Buffer))
- {
- return(STATUS_SUCCESS);
- }
- BufferLength = BufferLength - wstrlen(current->name.Buffer);
-// wcscpy(outbuffer,current->name.Buffer);
- outbuffer = outbuffer + wstrlen(current->name.Buffer);
+ RtlCopyUnicodeString(&DirObjInformation[i].ObjectName,
+ &(current->name));
+ i++;
current_entry = current_entry->Flink;
+ (*DataWritten) = (*DataWritten) + sizeof(OBJDIR_INFORMATION);
+ }
+
+ /*
+ * Optionally, count the number of entries in the directory
+ */
+ if (!GetNextIndex)
+ {
+ *ObjectIndex=i;
+ }
+ else
+ {
+ while ( current_entry!=NULL )
+ {
+ current_entry=current_entry->Flink;
+ i++;
+ }
+ *ObjectIndex=i;
}
return(STATUS_SUCCESS);
}
+NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
+ ULONG Attributes,
+ PACCESS_STATE PassedAccessState,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_TYPE ObjectType,
+ KPROCESSOR_MODE Accessmode,
+ PVOID ParseContext,
+ PVOID* ObjectPtr)
+{
+ UNIMPLEMENTED;
+}
+
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* Object)
{
return(STATUS_SUCCESS);
}
-void ObjNamespcInit(void)
+void ObInit(void)
/*
* FUNCTION: Initialize the object manager namespace
*/
* Initialize the object body
*/
InitializeListHead(&dir->head);
-
+ KeInitializeSpinLock(&(dir->Lock));
+
return(STATUS_SUCCESS);
}
}
if (name[0]=='.'&&name[1]=='.'&&name[2]==0)
{
- UNIMPLEMENTED;
- return(NULL);
+ return(BODY_TO_HEADER(BODY_TO_HEADER(dir)->Parent));
}
- while (current!=NULL)
+ while (current!=(&((PDIRECTORY_OBJECT)dir)->head))
{
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,entry);
if ( wcscmp(current_obj->name.Buffer, name)==0)
if (string[0]!='\\')
{
- printk("(%s:%d) Non absolute pathname passed to %s\n",__FILE__,
+ DbgPrint("(%s:%d) Non absolute pathname passed to %s\n",__FILE__,
__LINE__,__FUNCTION__);
return(NULL);
}
*/
if (current_dir->Type!=OBJTYP_DIRECTORY)
{
- printk("(%s:%d) Bad path component\n",__FILE__,
+ DbgPrint("(%s:%d) Bad path component\n",__FILE__,
__LINE__);
ExFreePool(string);
return(NULL);
current_hdr=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current);
if (current_hdr==NULL)
{
- printk("(%s:%d) Path component not found\n",__FILE__,
+ DbgPrint("(%s:%d) Path component not found\n",__FILE__,
__LINE__);
ExFreePool(string);
return(NULL);
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
-#include <internal/kernel.h>
#include <wstring.h>
#define NDEBUG
name=name+1;
}
- parent = ObLookupObject(ObjectAttributes->RootDirectory,path);
+ hdr->Parent = ObLookupObject(ObjectAttributes->RootDirectory,path);
/*
* Initialize the object header
*/
ObInitializeObjectHeader(Type,name,hdr);
- ObCreateEntry(parent,hdr);
+ ObCreateEntry(hdr->Parent,hdr);
DPRINT("Handle %x\n",Handle);
*Handle = ObAddHandle(HEADER_TO_BODY(hdr));
{
POBJECT_HEADER Object;
- DPRINT("ObReferenceObjectByPointer(%x %x)\n",ObjectBody,Object);
+ DPRINT("ObReferenceObjectByPointer(%x)\n",ObjectBody);
Object = BODY_TO_HEADER(ObjectBody);
Object->RefCount++;
PVOID ObjectBody;
ASSERT_IRQL(PASSIVE_LEVEL);
- assert(HandleInformation==NULL);
+ assert(HandleInformationPtr==NULL);
assert(Object!=NULL);
assert(Handle!=NULL);
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/psmgr/process.c
+ * FILE: ntoskrnl/ps/process.c
* PURPOSE: Process managment
* PROGRAMMER: David Welch (welch@mcmail.com)
* REVISION HISTORY:
/* INCLUDES ******************************************************************/
-#include <internal/kernel.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
+/* GLOBALS ******************************************************************/
+
+EPROCESS SystemProcess = {{0},};
+HANDLE SystemProcessHandle = NULL;
+
/* FUNCTIONS *****************************************************************/
-PEPROCESS PsGetCurrentProcess(VOID)
+PKPROCESS KeGetCurrentProcess(VOID)
+{
+ return(NULL);
+// return(&(PsGetCurrentProcess()->Pcb));
+}
+
+struct _EPROCESS* PsGetCurrentProcess(VOID)
/*
* FUNCTION: Returns a pointer to the current process
*/
{
- return(PsGetCurrentThread()->Process);
+ return(PsGetCurrentThread()->ThreadsProcess);
}
/* FUNCTIONS ***************************************************************/
-VOID PsMgrInit(VOID)
+VOID PsInit(VOID)
{
ObjInitializeHandleTable(NULL);
PsInitThreadManagment();
+ PsInitIdleThread();
}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
+#include <internal/ke.h>
#include <internal/objmgr.h>
#include <internal/string.h>
-#include <internal/hal/hal.h>
+#include <internal/hal.h>
#include <internal/psmgr.h>
#define NDEBUG
0,
ULONG_MAX,
ULONG_MAX,
- sizeof(KTHREAD),
+ sizeof(ETHREAD),
0,
NULL,
NULL,
NULL,
};
-
#define NR_THREAD_PRIORITY_LEVELS (32)
-static KSPIN_LOCK ThreadListLock;
+static KSPIN_LOCK ThreadListLock = {0,};
/*
* PURPOSE: List of all threads currently active
*/
-static LIST_ENTRY ThreadListHead;
+static LIST_ENTRY ThreadListHead = {NULL,NULL};
/*
* PURPOSE: List of threads associated with each priority level
*/
-static LIST_ENTRY PriorityListHead[NR_THREAD_PRIORITY_LEVELS];
+static LIST_ENTRY PriorityListHead[NR_THREAD_PRIORITY_LEVELS]={{NULL,NULL},};
static BOOLEAN DoneInitYet = FALSE;
-static PKTHREAD CurrentThread;
+static PETHREAD CurrentThread = NULL;
static ULONG NextThreadUniqueId = 0;
PKTHREAD KeGetCurrentThread(VOID)
{
- return(CurrentThread);
+ return((PKTHREAD)CurrentThread);
}
PETHREAD PsGetCurrentThread(VOID)
* If this was an involuntary reschedule then the current thread will still
* be eligible to run later
*/
- if (CurrentThread->State==THREAD_STATE_RUNNING)
+ if (CurrentThread->Tcb.ThreadState==THREAD_STATE_RUNNING)
{
- CurrentThread->State=THREAD_STATE_RUNNABLE;
+ CurrentThread->Tcb.ThreadState=THREAD_STATE_RUNNABLE;
}
/*
current = CONTAINING_RECORD(ThreadListHead.Flink,KTHREAD,Entry);
current_entry = ThreadListHead.Flink;
- while (current_entry!=NULL)
+ while (current_entry!=(&ThreadListHead))
{
- DPRINT("Scanning %x\n",current);
- DPRINT("State %x Runnable %x\n",current->State,THREAD_STATE_RUNNABLE);
- if (current->State == THREAD_STATE_RUNNABLE &&
- current !=CurrentThread)
+ DPRINT("Scanning %x ",current);
+ DPRINT("State %x Runnable %x\n",current->ThreadState,
+ THREAD_STATE_RUNNABLE);
+ if (current->ThreadState == THREAD_STATE_RUNNABLE &&
+ current != (PKTHREAD)CurrentThread)
{
DPRINT("Scheduling this one %x\n",current);
CurrentThread = current;
- CurrentThread->State = THREAD_STATE_RUNNING;
+ CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
KeReleaseSpinLock(&ThreadListLock,irql);
HalTaskSwitch(current);
return;
* If there are no other threads then continue with the current one if
* possible
*/
- if (CurrentThread->State == THREAD_STATE_RUNNABLE)
+ if (CurrentThread->Tcb.ThreadState == THREAD_STATE_RUNNABLE)
{
return;
}
* FUNCTION: Initialize thread managment
*/
{
- PKTHREAD first_thread;
+ PETHREAD first_thread;
InitializeListHead(&ThreadListHead);
KeInitializeSpinLock(&ThreadListLock);
ObRegisterType(OBJTYP_THREAD,&ThreadObjectType);
- first_thread = ExAllocatePool(NonPagedPool,sizeof(KTHREAD));
- first_thread->State = THREAD_STATE_RUNNING;
- HalInitFirstTask(first_thread);
- ExInterlockedInsertHeadList(&ThreadListHead,&first_thread->Entry,
+ first_thread = ExAllocatePool(NonPagedPool,sizeof(ETHREAD));
+ first_thread->Tcb.ThreadState = THREAD_STATE_RUNNING;
+ HalInitFirstTask((PKTHREAD)first_thread);
+ ExInterlockedInsertHeadList(&ThreadListHead,&first_thread->Tcb.Entry,
&ThreadListLock);
CurrentThread = first_thread;
DoneInitYet = TRUE;
}
-NTSTATUS PsWakeThread(PKTHREAD Thread)
+NTSTATUS PsWakeThread(PETHREAD Thread)
{
- Thread->State = THREAD_STATE_RUNNABLE;
+ Thread->Tcb.ThreadState = THREAD_STATE_RUNNABLE;
+ return(STATUS_SUCCESS);
}
NTSTATUS PsSuspendThread(VOID)
* NOTE: When we return from PsDispatchThread the spinlock will be
* released
*/
- CurrentThread->State = THREAD_STATE_SUSPENDED;
+ CurrentThread->Tcb.ThreadState = THREAD_STATE_SUSPENDED;
PsDispatchThread();
+ return(STATUS_SUCCESS);
}
-NTSTATUS PsCreateThread(HANDLE Parent,
- LPSECURITY_ATTRIBUTES lpThreadAttributes,
- PVOID Stack,
- LPTHREAD_START_ROUTINE lpStartAddress,
- LPVOID Parameter,
- DWORD dwCreationFlags,
- LPDWORD lpThreadId,
- PHANDLE ThreadHandle)
-/*
- * FUNCTION: Creates a thread
- * ARGUMENTS:
- * Parent = Parent process (or NULL for current)
- * lpThreadAttributes = Security descriptor for the new thread
- * Stack = Caller allocated stack
- * lpStartAddress = Entry point for the thread
- * Parameter = Parameter to be passed to the entrypoint
- * dwCreationFlags = Flags for creation
- * lpThreadId = Pointer which receives thread identifier
- * ThreadHandle = Variable which receives handle
- * RETURNS: Status
- */
-{
-
-}
+
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
/*
DPRINT("terminating %x\n",CurrentThread);
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
- CurrentThread->State = THREAD_STATE_TERMINATED;
- ExInterlockedRemoveEntryList(&ThreadListHead,&CurrentThread->Entry,
- &ThreadListLock);
+ CurrentThread->Tcb.ThreadState = THREAD_STATE_TERMINATED;
+ RemoveEntryList(&CurrentThread->Tcb.Entry);
PsDispatchThread();
for(;;);
}
+NTSTATUS NtCreateThread(PHANDLE ThreadHandle,
+ ACCESS_MASK DesiredAccess,
+ POBJECT_ATTRIBUTES ObjectAttributes,
+ HANDLE ProcessHandle,
+ PCLIENT_ID Client,
+ PCONTEXT ThreadContext,
+ PINITIAL_TEB InitialTeb,
+ BOOLEAN CreateSuspended)
+{
+}
+
NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
* RETURNS: Success or failure status
*/
{
- PKTHREAD thread;
+ PETHREAD thread;
ULONG ThreadId;
ULONG ProcessId;
thread = ObGenericCreateObject(ThreadHandle,0,NULL,OBJTYP_THREAD);
-
+ DPRINT("Allocating thread %x\n",thread);
- thread->State=THREAD_STATE_RUNNABLE;
- thread->Priority=0;
-// thread->Process=ObjGetObjectByHandle(ProcessHandle);
- thread->ProcessHandle=ProcessHandle;
- HalInitTask(thread,StartRoutine,StartContext);
-
-// ThreadId = InterlockedIncrement(&NextThreadUniqueId);
- if (ClientId != NULL)
+ thread->Tcb.ThreadState=THREAD_STATE_RUNNABLE;
+ thread->Tcb.BasePriority=0;
+ thread->Tcb.CurrentPriority=0;
+ thread->Tcb.ApcList=ExAllocatePool(NonPagedPool,sizeof(LIST_ENTRY));
+ InitializeListHead(thread->Tcb.ApcList);
+ HalInitTask(&(thread->Tcb),StartRoutine,StartContext);
+ InitializeListHead(&(thread->IrpList));
+ thread->Cid.UniqueThread=NextThreadUniqueId++;
+// thread->Cid.ThreadId=InterlockedIncrement(&NextThreadUniqueId);
+ if (ClientId!=NULL)
{
- ClientId->UniqueThread = ThreadId;
+ *ClientId=thread->Cid;
}
- ExInterlockedInsertHeadList(&ThreadListHead,&thread->Entry,
+ if (ProcessHandle!=NULL)
+ {
+ thread->ThreadsProcess=ObGetObjectByHandle(ProcessHandle);
+ }
+ else
+ {
+ thread->ThreadsProcess=&SystemProcess;
+ }
+ thread->StartAddress=StartRoutine;
+
+
+ ExInterlockedInsertHeadList(&ThreadListHead,&thread->Tcb.Entry,
&ThreadListLock);
- InitializeListHead(&thread->ApcQueueHead);
return(STATUS_SUCCESS);
}
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *************************************************************/
-VOID RemoveEntryList(PLIST_ENTRY Entry)
+BOOLEAN IsListEmpty(PLIST_ENTRY ListHead)
/*
- * FUNCTION: Resets the links for an entry from a double linked list
+ * FUNCTION: Determines if a list is empty
* ARGUMENTS:
- * Entry = Entry to reset
- * NOTE: This isn't the same as ExInterlockedRemoveEntryList
+ * ListHead = Head of the list
+ * RETURNS: True if there are no entries in the list
*/
{
- if (Entry->Blink!=NULL)
- {
- Entry->Blink->Flink=Entry->Flink;
- }
- if (Entry->Flink!=NULL)
- {
- Entry->Flink->Blink=Entry->Blink;
- }
+ return(ListHead->Flink==ListHead);
+}
+
+VOID RemoveEntryList(PLIST_ENTRY ListEntry)
+{
+ PLIST_ENTRY OldFlink;
+ PLIST_ENTRY OldBlink;
+ DPRINT("RemoveEntryList(ListEntry %x)\n",ListEntry);
+ OldFlink=ListEntry->Flink;
+ OldBlink=ListEntry->Blink;
+ DPRINT("OldFlink %x OldBlink %x\n",OldFlink,OldBlink);
+ OldFlink->Blink=OldBlink;
+ OldBlink->Flink=OldFlink;
}
PLIST_ENTRY RemoveTailList(PLIST_ENTRY ListHead)
* RETURNS: The removed entry
*/
{
- PLIST_ENTRY entry = ListHead->Blink;
- if (ListHead->Blink == ListHead->Flink)
- {
- ListHead->Flink = NULL;
- }
- if (entry!=NULL)
- {
- ListHead->Blink = entry->Blink;
- }
- return(entry);
-}
-
-VOID ExInterlockedRemoveEntryList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry,
- PKSPIN_LOCK Lock)
-{
- KIRQL oldlvl;
- KeAcquireSpinLock(Lock,&oldlvl);
- if (ListHead->Flink == Entry && ListHead->Blink == Entry)
- {
- ListHead->Flink = ListHead->Blink = NULL;
- Entry->Flink = Entry->Blink = NULL;
- KeReleaseSpinLock(Lock,oldlvl);
- return;
- }
- if (ListHead->Flink == Entry)
- {
- ListHead->Flink=Entry->Flink;
- Entry->Flink = Entry->Blink = NULL;
- KeReleaseSpinLock(Lock,oldlvl);
- return;
- }
- if (ListHead->Blink == Entry)
- {
- ListHead->Blink = Entry->Blink;
- Entry->Flink = Entry->Blink = NULL;
- KeReleaseSpinLock(Lock,oldlvl);
- return;
- }
- Entry->Flink->Blink = Entry->Blink;
- Entry->Blink->Flink = Entry->Flink;
- Entry->Flink = Entry->Blink = NULL;
- KeReleaseSpinLock(Lock,oldlvl);
+ PLIST_ENTRY Old = ListHead->Blink;
+ RemoveEntryList(ListHead->Blink);
+ return(Old);
}
PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead)
-{
- PLIST_ENTRY Old;
-
+{
+ PLIST_ENTRY Old = ListHead->Flink;
DPRINT("RemoveHeadList(ListHead %x)\n",ListHead);
- DPRINT("Flink %x Blink %x\n",ListHead->Flink,ListHead->Blink);
-
- Old = ListHead->Flink;
-
- if (ListHead->Flink==NULL)
- {
- return(NULL);
- }
-
- DPRINT("ListHead->Flink->Flink %x\n",ListHead->Flink->Flink);
- ListHead->Flink=ListHead->Flink->Flink;
- if (ListHead->Flink!=NULL)
- {
- DPRINT("ListHead->Flink->Blink %x\n",ListHead->Flink->Blink);
- ListHead->Flink->Blink=NULL;
- }
+ RemoveEntryList(ListHead->Flink);
return(Old);
}
-VOID RemoveEntryFromList(PLIST_ENTRY ListHead, PLIST_ENTRY Entry)
-{
- if (ListHead->Flink == Entry && ListHead->Blink == Entry)
- {
- ListHead->Flink = ListHead->Blink = NULL;
- Entry->Flink = Entry->Blink = NULL;
- return;
- }
- if (ListHead->Flink == Entry)
- {
- ListHead->Flink=Entry->Flink;
- Entry->Flink = Entry->Blink = NULL;
- return;
- }
- if (ListHead->Blink == Entry)
- {
- ListHead->Blink = Entry->Blink;
- Entry->Flink = Entry->Blink = NULL;
- return;
- }
- Entry->Flink->Blink = Entry->Blink;
- Entry->Blink->Flink = Entry->Flink;
- Entry->Flink = Entry->Blink = NULL;
-}
-
-
-
-
VOID InitializeListHead(PLIST_ENTRY ListHead)
/*
* FUNCTION: Initializes a double linked list
* ListHead = Caller supplied storage for the head of the list
*/
{
- ListHead->Blink=NULL;
- ListHead->Flink=NULL;
+ ListHead->Flink = ListHead->Blink = ListHead;
}
VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListEntry)
* Entry = Entry to insert
*/
{
- assert(ListHead!=NULL);
- assert(ListEntry!=NULL);
- if (ListHead->Blink==NULL)
- {
- ListEntry->Blink = ListEntry->Flink = NULL;
- ListHead->Blink = ListHead->Flink = ListEntry;
- }
- else
- {
- ListEntry->Blink = ListHead->Blink;
- ListEntry->Flink = NULL;
- ListHead->Blink->Flink = ListEntry;
- ListHead->Blink = ListEntry;
- }
+ PLIST_ENTRY Blink;
+
+ Blink = ListHead->Blink;
+ ListEntry->Flink=ListHead;
+ ListEntry->Blink=Blink;
+ Blink->Flink=ListEntry;
+ ListHead->Blink=ListEntry;
}
VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY ListEntry)
{
- /*
- * Insert the entry
- */
- ListEntry->Blink=NULL;
- ListEntry->Flink=ListHead->Flink;
+ PLIST_ENTRY OldFlink;
- if (ListHead->Flink==NULL)
- {
- assert(ListHead->Blink==NULL);
- ListHead->Blink = ListHead->Flink = ListEntry;
- }
- else
- {
- ListHead->Flink->Blink = ListEntry;
- ListHead->Flink = ListEntry;
- }
+ OldFlink = ListHead->Flink;
+ ListEntry->Flink = OldFlink;
+ ListEntry->Blink = ListHead;
+ OldFlink->Blink = ListEntry;
+ ListHead->Flink = ListEntry;
}
PLIST_ENTRY ExInterlockedInsertTailList(PLIST_ENTRY ListHead,
PLIST_ENTRY ListEntry,
PKSPIN_LOCK Lock)
{
- PLIST_ENTRY Old = NULL;
+ PLIST_ENTRY Old;
KIRQL oldlvl;
- /*
- * Lock the spinlock
- */
KeAcquireSpinLock(Lock,&oldlvl);
- DPRINT("oldlvl %x\n",oldlvl);
- /*
- * Insert the entry
- */
- Old = ListHead->Flink;
- InsertTailList(ListHead,ListEntry);
-
- /*
- * Unlock the spinlock
- */
+ if (IsListEmpty(ListHead))
+ {
+ Old = NULL;
+ }
+ else
+ {
+ Old = ListHead->Blink;
+ }
+ InsertTailList(ListHead,ListEntry);
KeReleaseSpinLock(Lock,oldlvl);
return(Old);
* RETURNS: The previous head of the list
*/
{
- PLIST_ENTRY old = NULL;
+ PLIST_ENTRY Old;
KIRQL oldlvl;
-
- /*
- * Block on the spinlock here
- */
+
KeAcquireSpinLock(Lock,&oldlvl);
-
- /*
- * Insert the entry
- */
- old=ListHead->Flink;
- InsertHeadList(ListHead,ListEntry);
-
- /*
- * Release spin lock
- */
+ if (IsListEmpty(ListHead))
+ {
+ Old = NULL;
+ }
+ else
+ {
+ Old = ListHead->Flink;
+ }
+ InsertHeadList(ListHead,ListEntry);
KeReleaseSpinLock(Lock,oldlvl);
- return(old);
+ return(Old);
}
-BOOLEAN IsListEmpty(PLIST_ENTRY ListHead)
+
+PLIST_ENTRY ExInterlockedRemoveHeadList(PLIST_ENTRY Head,
+ PKSPIN_LOCK Lock)
/*
- * FUNCTION: Determines if a list is emptry
+ * FUNCTION: Removes the head of a double linked list
* ARGUMENTS:
- * ListHead = Head of the list
- * RETURNS: True if there are no entries in the list
+ * Head = List head
+ * Lock = Lock for synchronizing access to the list
+ * RETURNS: The removed entry
*/
{
- return(ListHead->Flink==NULL);
+ PLIST_ENTRY ret;
+ KIRQL oldlvl;
+
+ KeAcquireSpinLock(Lock,&oldlvl);
+ if (IsListEmpty(Head))
+ {
+ ret = NULL;
+ }
+ else
+ {
+ ret = RemoveHeadList(Head);
+ }
+ KeReleaseSpinLock(Lock,oldlvl);
+ return(ret);
}
-PLIST_ENTRY ExInterlockedRemoveHeadList(PLIST_ENTRY Head,
+PLIST_ENTRY ExInterlockedRemoveTailList(PLIST_ENTRY Head,
PKSPIN_LOCK Lock)
/*
- * FUNCTION: Removes the head of a double linked list
+ * FUNCTION: Removes the tail of a double linked list
* ARGUMENTS:
* Head = List head
* Lock = Lock for synchronizing access to the list
{
PLIST_ENTRY ret;
KIRQL oldlvl;
-
+
KeAcquireSpinLock(Lock,&oldlvl);
- ret = RemoveHeadList(Head);
+ if (IsListEmpty(Head))
+ {
+ ret = NULL;
+ }
+ else
+ {
+ ret = RemoveTailList(Head);
+ }
KeReleaseSpinLock(Lock,oldlvl);
return(ret);
}
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.cc
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/rtl/lookas.c
+ * PURPOSE: Lookaside lists
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: kernel/rtl/mem.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * PURPOSE: Memory functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <internal/string.h>
#include <ddk/ntddk.h>
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/debug.h>
* RETURNS: The removed entry
*/
{
- PSINGLE_LIST_ENTRY entry = ListHead->Next;
- if (entry==NULL)
+ PSINGLE_LIST_ENTRY ListEntry = ListHead->Next;
+ if (ListEntry!=NULL)
{
- return(NULL);
+ ListHead->Next = ListEntry->Next;
}
- ListHead->Next = ListHead->Next->Next;
- return(entry);
+ return(ListEntry);
}
PSINGLE_LIST_ENTRY ExInterlockedPopEntryList(PSINGLE_LIST_ENTRY ListHead,
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: kernel/base/bug.c
- * PURPOSE: Graceful system shutdown if a bug is detected
+ * FILE: ntoskrnl/rtl/unalign.c
+ * PURPOSE: Unaligned stores and loads
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* Created 22/05/98
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <internal/debug.h>
#include <ddk/ntddk.h>
#include <internal/string.h>
-#include <internal/kernel.h>
+#include <internal/ke.h>
#include <internal/ctype.h>
#define NDEBUG
#include <stdarg.h>
-#include <internal/kernel.h>
#include <internal/debug.h>
#include <internal/ctype.h>
#include <internal/string.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: ntoskrnl/ke/wstring.c
+ * FILE: ntoskrnl/rtl/wstring.c
* PURPOSE: Wide string functions
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
/* INCLUDES *****************************************************************/
-#include <internal/kernel.h>
-#include <internal/linkage.h>
#include <ddk/ntddk.h>
#include <wstring.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
-
#include <internal/debug.h>
/* FUNCTIONS ***************************************************************/
#include <windows.h>
#include <ddk/ntddk.h>
-#include <internal/kernel.h>
#include <internal/string.h>
#define NDEBUG
/* GLOBALS ******************************************************************/
-static KEVENT event;
+static KEVENT event = {};
+//static KEVENT event2;
/* FUNCTIONS ****************************************************************/
NTSTATUS TstFirstThread(PVOID start)
{
printk("Beginning Thread A\n");
- KeClearEvent(&event);
- KeSetEvent(&event,IO_NO_INCREMENT,TRUE);
+ for (;;)
+ {
+ KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
+ printk("AAA ");
+ KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
+ }
}
NTSTATUS TstSecondThread(PVOID start)
{
- printk("Beginning Thread B\n");
- KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
- printk("Ending Thread B\n");
+ printk("Beginning Thread B\n");
+ for (;;)
+ {
+ KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
+ KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
+ printk("BBB ");
+ }
}
NTSTATUS TstThreadSupport()
HANDLE th1, th2;
KeInitializeEvent(&event,SynchronizationEvent,FALSE);
-// PsCreateSystemThread(&th1,0,NULL,NULL,NULL,TstFirstThread,NULL);
- KeClearEvent(&event);
+ PsCreateSystemThread(&th1,0,NULL,NULL,NULL,TstFirstThread,NULL);
PsCreateSystemThread(&th2,0,NULL,NULL,NULL,TstSecondThread,NULL);
+ printk("Ending main thread\n");
for(;;);
}
void TstKeyboardRead()
{
- KEY_EVENT_RECORD key;
+ OBJECT_ATTRIBUTES attr;
HANDLE hfile;
+ ANSI_STRING afilename;
+ UNICODE_STRING ufilename;
+ KEY_EVENT_RECORD key[2];
-// hfile = CreateFile("\\Device\\Keyboard",0,0,0,0,0,0);
- if (hfile == NULL)
+ DbgPrint("Opening keyboard\n");
+ RtlInitAnsiString(&afilename,"\\Device\\Keyboard");
+ RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
+ InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
+ ZwOpenFile(&hfile,0,&attr,NULL,0,0);
+ if (hfile==NULL)
{
- printk("Failed to open keyboard\n");
- return;
+ DbgPrint("Failed to open keyboard\n");
+ return;
}
- for (;;)
+ for(;;)
{
-// ReadFile(hfile,&key,sizeof(KEY_EVENT_RECORD),NULL,NULL);
- printk("%c",key.AsciiChar);
- for(;;);
+ ZwReadFile(hfile,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &key[0],
+ sizeof(KEY_EVENT_RECORD)*2,
+ 0,
+ 0);
+ DbgPrint("%c",key[0].AsciiChar);
+// DbgPrint("%c",key[1].AsciiChar);
}
-}
+ }
+
+
void TstBegin()
{
- TstGeneralWrite();
+// TstGeneralWrite();
+// TstThreadSupport();
+ TstKeyboardRead();
}