Compare commits

...

9 Commits

Author SHA1 Message Date
The ReactOS Team
efb17a2783 This commit was manufactured by cvs2svn to create tag 'krnl0011'.
svn path=/tags/krnl0011/; revision=41
1998-09-13 15:55:55 +00:00
Rex Jolliff
5c1b8a026c Import of KRNL0011
svn path=/branches/ros/; revision=39
1998-09-13 15:55:55 +00:00
The ReactOS Team
02b00d9c04 This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=38
1998-09-13 15:55:55 +00:00
Rex Jolliff
935b7c2953 upgrade to krnl0010
svn path=/branches/ros/; revision=30
1998-09-05 17:34:23 +00:00
The ReactOS Team
1b7327da76 This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=29
1998-09-05 17:34:23 +00:00
Rex Jolliff
f77c44657c Import of KRNL0009
svn path=/branches/ros/; revision=21
1998-08-28 23:24:42 +00:00
The ReactOS Team
df0328b7cc This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=20
1998-08-28 23:24:42 +00:00
Rex Jolliff
94c8483b04 A much Needed Update
svn path=/branches/ros/; revision=10
1998-08-25 04:27:41 +00:00
The ReactOS Team
fc7e59ce74 This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=9
1998-08-25 04:27:41 +00:00
63 changed files with 2261 additions and 2400 deletions

View File

@@ -215,6 +215,7 @@ enum
FILE_DEVICE_WAVE_IN,
FILE_DEVICE_WAVE_OUT,
FILE_DEVICE_8042_PORT,
FILE_DEVICE_FILE_SYSTEM,
/*
* Values beyond this are reserved for ISVs
@@ -298,4 +299,9 @@ enum
FILE_DOES_NOT_EXIST,
};
#define IRP_MN_USER_FS_REQUEST 0x00
#define IRP_MN_MOUNT_VOLUME 0x01
#define IRP_MN_VERIFY_VOLUME 0x02
#define IRP_MN_LOAD_FILE_SYSTEM 0x03
#endif

View File

@@ -521,3 +521,5 @@ IN ULONG Length,
OUT PVOID FileInformation,
OUT PULONG ReturnedLength
);
VOID IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject);
PDEVICE_OBJECT IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject);

View File

@@ -75,51 +75,38 @@ typedef struct _IO_TIMER
KDPC dpc;
} IO_TIMER, *PIO_TIMER;
typedef struct _IO_SECURITY_CONTEXT
{
PSECURITY_QUALITY_OF_SERVICE SecurityQos;
PACCESS_STATE AccessState;
ACCESS_MASK DesiredAccess;
ULONG FullCreateOptions;
} IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
/*
* PURPOSE: IRP stack location
*/
typedef struct _IO_STACK_LOCATION
{
/*
* Type of request
*/
UCHAR MajorFunction;
/*
* Further information about request type
*/
UCHAR MinorFunction;
/*
*
*/
UCHAR Flags;
/*
* FUNCTION: Various flags including for the io completion routine
*/
UCHAR MinorFunction;
UCHAR Flags;
UCHAR Control;
/*
* Parameters for request
*/
union
{
struct
{
/*
* Number of bytes to be transferrred
*/
PIO_SECURITY_CONTEXT SecurityContext;
ULONG Options;
USHORT FileAttributes;
USHORT ShareAccess;
ULONG EaLength;
} Create;
struct
{
ULONG Length;
/*
* Possibly used to sort incoming request (to be documented)
*/
ULONG Key;
/*
* Optional starting offset for read
*/
LARGE_INTEGER ByteOffset;
} Read;
struct
@@ -135,26 +122,18 @@ typedef struct _IO_STACK_LOCATION
ULONG IoControlCode;
PVOID Type3InputBuffer;
} DeviceIoControl;
struct
{
struct _VPB* Vpb;
struct _DEVICE_OBJECT* DeviceObject;
} Mount;
} Parameters;
/*
* PURPOSE: Completion routine
* NOTE: If this is the nth stack location (where the 1st is passed to the
* highest level driver) then this is the completion routine set by
* the (n-1)th driver
*/
PIO_COMPLETION_ROUTINE CompletionRoutine;
PVOID CompletionContext;
/*
* Driver created device object representing the target device
*/
struct _DEVICE_OBJECT* DeviceObject;
/*
* File object (if any) associated with DeviceObject
*/
struct _FILE_OBJECT* FileObject;
} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
@@ -295,10 +274,15 @@ typedef struct _IRP
KAPC Apc;
ULONG CompletionKey;
} Tail;
ULONG CurrentLocation;
CHAR StackCount;
CHAR CurrentLocation;
IO_STACK_LOCATION Stack[1];
} IRP, *PIRP;
#define VPB_MOUNTED 0x00000001
#define VPB_LOCKED 0x00000002
#define VPB_PERSISTENT 0x00000004
#define VPB_REMOVE_PENDING 0x00000008
typedef struct _VPB
{
@@ -377,9 +361,6 @@ typedef struct _DRIVER_EXTENSION
typedef struct _DRIVER_OBJECT
{
/*
* PURPOSE: Magic values for debugging
*/
CSHORT Type;
CSHORT Size;
PDEVICE_OBJECT DeviceObject;

View File

@@ -37,10 +37,10 @@ extern "C"
#include <ddk/ketypes.h>
#include <ddk/obtypes.h>
#include <ddk/mmtypes.h>
#include <ddk/setypes.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>

View File

@@ -44,4 +44,4 @@ NTSTATUS ObReferenceObjectByPointer(PVOID Object,
KPROCESSOR_MODE AccessMode);
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* Object);
PVOID* Object, PWSTR* UnparsedSection);

View File

@@ -9,6 +9,7 @@ typedef struct _OBJECT_HANDLE_INFORMATION {
struct _OBJECT;
typedef struct _OBJECT_TYPE
{
/*
@@ -132,15 +133,11 @@ typedef struct _OBJECT
} OBJECT_HEADER, *POBJECT_HEADER;
/*
* PURPOSE: Defines an object
*/
typedef struct _OBJECT_ATTRIBUTES
{
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
SECURITY_DESCRIPTOR *SecurityDescriptor;
SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;

View File

@@ -153,6 +153,8 @@ LONG RtlCompareString(PSTRING String1, PSTRING String2,
LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN BaseInsensitive);
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
@@ -165,12 +167,27 @@ NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
NTSTATUS RtlDeleteRegistryValue(ULONG RelativeTo,
PWSTR Path,
PWSTR ValueName);
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
LONG Multiplier);
ULONG RtlEnlargedUnsignedDivide(ULARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlEnlargedUnsignedMultiply(ULONG Multiplicand,
ULONG Multiplier);
BOOLEAN RtlEqualString(PSTRING String1,
PSTRING String2,
BOOLEAN CaseInSensitive);
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN CaseInSensitive);
LARGE_INTEGER RtlExtendedIntegerMultiply(LARGE_INTEGER Multiplicand,
LONG Multiplier);
LARGE_INTEGER RtlExtendedLargeIntegerDivide(LARGE_INTEGER Dividend,
ULONG Divisor,
PULONG Remainder);
LARGE_INTEGER RtlExtendedMagicDivide(LARGE_INTEGER Dividend,
LARGE_INTEGER MagicDivisor,
CCHAR ShiftCount);
VOID RtlFillMemory(PVOID Destination, ULONG Length, UCHAR Fill);
VOID RtlFreeAnsiString(PANSI_STRING AnsiString);
VOID RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
@@ -182,8 +199,13 @@ VOID RtlInitUnicodeString(PUNICODE_STRING DestinationString,
NTSTATUS RtlIntegerToUnicodeString(ULONG Value,
ULONG Base,
PUNICODE_STRING String);
LARGE_INTEGER RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
LARGE_INTEGER Addend2);
VOID RtlLargeIntegerAnd(PLARGE_INTEGER Result,
LARGE_INTEGER Source,
LARGE_INTEGER Mask);
/** LARGE_INTEGER Functions *******************************************/
/* MISSING FUNCTIONS GO HERE */
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
LARGE_INTEGER RtlEnlargedIntegerMultiply(LONG Multiplicand,
@@ -240,8 +262,6 @@ LARGE_INTEGER RtlLargeIntegerShiftRight(LARGE_INTEGER LargeInteger,
LARGE_INTEGER RtlLargeIntegerSubtract(LARGE_INTEGER Minuend,
LARGE_INTEGER Subtrahend);
/* MISSING FUNCTIONS GO HERE */
ULONG RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
VOID RtlMoveMemory(PVOID Destination, CONST VOID* Source, ULONG Length);
NTSTATUS RtlQueryRegistryValues(ULONG RelativeTo,

View File

@@ -8,7 +8,11 @@
* 29/08/98: ACCESS_TOKEN definition from Boudewijn Dekker
*/
#ifndef __INCLUDE_DDK_SETYPES_H
#define __INCLUDE_DDK_SETYPES_H
typedef ULONG ACCESS_MODE, *PACCESS_MODE;
typedef SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE;
typedef struct _SECURITY_SUBJECT_CONTEXT
{
@@ -39,3 +43,5 @@ typedef struct _ACCESS_TOKEN {
PVOID AuditData;
UCHAR VariablePart[0];
} ACCESS_TOKEN, *PACCESS_TOKEN;
#endif

View File

@@ -153,7 +153,12 @@ enum
// STATUS_WRONG_VOLUME,
STATUS_FS_DRIVER_REQUIRED,
STATUS_NOT_SUPPORTED = 9999,
STATUS_DISK_OPERATION_FAILED
STATUS_DISK_OPERATION_FAILED,
/*
* Reactos codes
*/
STATUS_FS_QUERY_REQUIRED,
};
#endif /* __INCLUDE_DDK_STATUS_H */

View File

@@ -1,14 +0,0 @@
/* SYSTEM STRUCTURES ******************************************************/
#include <internal/hal/hal.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>
typedef struct _ADAPTER_OBJECT
{
} ADAPTER_OBJECT, *PADAPTER_OBJECT;

View File

@@ -16,6 +16,13 @@
#include <windows.h>
typedef struct _OBJDIR_INFORMATION {
UNICODE_STRING ObjectName;
UNICODE_STRING ObjectTypeName; // Directory, Device ...
UCHAR Data[0];
} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
/*
* FUNCTION: Closes an object handle
* ARGUMENTS:
@@ -177,6 +184,14 @@ NTSTATUS ZwOpenKey(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
NTSTATUS ZwOpenSection(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes);
NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
OUT POBJDIR_INFORMATION DirObjInformation,
IN ULONG BufferLength,
IN BOOLEAN GetNextIndex,
IN BOOLEAN IgnoreInputIndex,
IN OUT PULONG ObjectIndex,
OUT PULONG DataWritten OPTIONAL);
/*
* FUNCTION: Returns information about an open file
* ARGUMENTS:
@@ -196,29 +211,20 @@ NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
NTSTATUS ZwReadFile(HANDLE FileHandle,
HANDLE EventHandle,
PIO_APC_ROUTINE ApcRoutine,
PVOID ApcContext,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER ByteOffset,
PULONG Key);
#if KERNEL_SUPPORTS_OBJECT_ATTRIBUTES_CORRECTLY
typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
SECURITY_DESCRIPTOR *SecurityDescriptor;
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
*/
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
@@ -879,12 +885,6 @@ typedef union _FILE_SEGMENT_ELEMENT {
// directory information
typedef struct _OBJDIR_INFORMATION {
UNICODE_STRING ObjectName;
UNICODE_STRING ObjectTypeName; // Directory, Device ...
UCHAR Data[0];
} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
typedef struct _FILE_DIRECTORY_INFORMATION {
ULONG NextEntryOffset;

View File

@@ -16,6 +16,13 @@
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
#ifndef NDEBUG
#define DPRINT1(x) DbgPrint(x)
#else
#define DPRINT1(x)
#endif
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
#ifndef NDEBUG

View File

@@ -1,4 +1,4 @@
/* $Id: dma.h,v 1.3 1998/08/25 04:48:36 rex Exp $
/* $Id: dma.h,v 1.1.1.2 1998/08/25 04:27:32 rex Exp $
* linux/include/asm/dma.h: Defines for using and allocating dma channels.
* Written by Hennus Bergman, 1992.
* High DMA channel support & info by Hannu Savolainen

View File

@@ -1,71 +0,0 @@
/*
*
*/
#ifndef __INTERNAL_HAL_HAL_H
#define __INTERNAL_HAL_HAL_H
typedef struct
{
unsigned short previous_task;
unsigned short reserved1;
unsigned long esp0;
unsigned short ss0;
unsigned short reserved2;
unsigned long esp1;
unsigned short ss1;
unsigned short reserved3;
unsigned long esp2;
unsigned short ss2;
unsigned short reserved4;
unsigned long cr3;
unsigned long eip;
unsigned long eflags;
unsigned long eax;
unsigned long ecx;
unsigned long edx;
unsigned long ebx;
unsigned long esp;
unsigned long ebp;
unsigned long esi;
unsigned long edi;
unsigned short es;
unsigned short reserved5;
unsigned short cs;
unsigned short reserved6;
unsigned short ss;
unsigned short reserved7;
unsigned short ds;
unsigned short reserved8;
unsigned short fs;
unsigned short reserved9;
unsigned short gs;
unsigned short reserved10;
unsigned short ldt;
unsigned short reserved11;
unsigned short trap;
unsigned short iomap_base;
unsigned short nr;
unsigned char io_bitmap[1];
} hal_thread_state;
/*
* FUNCTION: Probes for a PCI bus
* RETURNS: True if found
*/
BOOL HalPciProbe(void);
/*
* FUNCTION: Probes for a BIOS32 extension
*/
VOID Hal_bios32_probe(VOID);
/*
* FUNCTION: Determines if a a bios32 service is present
*/
BOOLEAN Hal_bios32_is_service_present(ULONG service);
#endif /* __INTERNAL_HAL_HAL_H */

View File

@@ -1,27 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/iomgr.h
* PURPOSE: Internal io manager declarations
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 28/05/97: Created
*/
#ifndef __INCLUDE_INTERNAL_IOMGR_H
#define __INCLUDE_INTERNAL_IOMGR_H
#include <ddk/ntddk.h>
/*
* FUNCTION: Called to initalize a loaded driver
* ARGUMENTS:
* entry = pointer to the driver initialization routine
* RETURNS: Success or failure
*/
NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry);
VOID IoInitCancelHandling(VOID);
VOID IoInitSymbolicLinkImplementation(VOID);
#endif

View File

@@ -26,6 +26,8 @@ enum
typedef struct
{
CSHORT Type;
CSHORT Size;
FILE_OBJECT* File;
} SECTION_OBJECT;
@@ -36,10 +38,15 @@ typedef struct
ULONG Length;
ULONG Attributes;
LIST_ENTRY Entry;
ULONG LockCount;
union
{
SECTION_OBJECT* Section;
} d;
struct
{
SECTION_OBJECT* Section;
ULONG ViewOffset;
} SectionData;
} Data;
} MEMORY_AREA;
@@ -85,16 +92,6 @@ asmlinkage unsigned int get_free_page(void);
*/
asmlinkage void free_page(unsigned int physical_base, unsigned int nr);
/*
* FUNCTION: Returns the physical address mapped by a given virtual address
* ARGUMENTS:
* vaddr = virtual address to query
* RETURNS: The physical address if present in memory
* Zero if paged out or invalid
* NOTE: This doesn't do any synchronization
*/
unsigned int get_page_physical_address(unsigned int vaddr);
void mark_page_not_writable(unsigned int vaddr);
void VirtualInit(boot_param* bp);

View File

@@ -8,7 +8,8 @@ typedef struct
/*
*
*/
{
{
unsigned int nsyms;
unsigned int text_base;
unsigned int data_base;
unsigned int bss_base;

View File

@@ -1,91 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/objmgr.h
* PURPOSE: Object manager definitions
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
#ifndef __INCLUDE_INTERNAL_OBJMGR_H
#define __INCLUDE_INTERNAL_OBJMGR_H
#include <ddk/types.h>
typedef struct
{
CSHORT Type;
CSHORT Size;
} COMMON_BODY_HEADER, *PCOMMON_BODY_HEADER;
typedef struct _DIRECTORY_OBJECT
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Head of the list of our subdirectories
*/
LIST_ENTRY head;
KSPIN_LOCK Lock;
} DIRECTORY_OBJECT, *PDIRECTORY_OBJECT;
/*
* Enumeration of object types
*/
enum
{
OBJTYP_INVALID,
OBJTYP_TYPE,
OBJTYP_DIRECTORY,
OBJTYP_SYMLNK,
OBJTYP_DEVICE,
OBJTYP_THREAD,
OBJTYP_FILE,
OBJTYP_MAX,
};
BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object);
VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
POBJECT_HEADER obj);
/*
* FUNCTION: Get the size of an object
* ARGUMENTS:
* Type = Object type
* RETURNS: The size in bytes
*/
ULONG ObSizeOf(CSHORT Type);
HANDLE ObAddHandle(PVOID obj);
PVOID ObLookupObject(HANDLE rooth, PWSTR _string);
PVOID ObGetObjectByHandle(HANDLE h);
PVOID ObGenericCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
CSHORT Type);
/*
* FUNCTION: Creates an entry within a directory
* ARGUMENTS:
* parent = Parent directory
* object = Header of the object to add
*/
VOID ObCreateEntry(PDIRECTORY_OBJECT parent, POBJECT_HEADER object);
extern inline POBJECT_HEADER BODY_TO_HEADER(PVOID body)
{
PCOMMON_BODY_HEADER chdr = (PCOMMON_BODY_HEADER)body;
return(CONTAINING_RECORD((&(chdr->Type)),OBJECT_HEADER,Type));
}
extern inline PVOID HEADER_TO_BODY(POBJECT_HEADER obj)
{
return(((void *)obj)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER));
}
#define OBJECT_ALLOC_SIZE(type) (ObSizeOf(type)+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */

View File

@@ -1,52 +0,0 @@
#ifndef __INCLUDE_INTERNAL_PSMGR_H
#define __INCLUDE_INTERNAL_PSMGR_H
#include <internal/hal.h>
extern EPROCESS SystemProcess;
extern HANDLE SystemProcessHandle;
void PsInitThreadManagment(void);
VOID PsInitIdleThread(VOID);
/*
* PURPOSE: Thread states
*/
enum
{
/*
* PURPOSE: Don't touch
*/
THREAD_STATE_INVALID,
/*
* PURPOSE: Waiting to be dispatched
*/
THREAD_STATE_RUNNABLE,
/*
* PURPOSE: Currently running
*/
THREAD_STATE_RUNNING,
/*
* PURPOSE: Doesn't want to run
*/
THREAD_STATE_SUSPENDED,
/*
* Waiting to be freed
*/
THREAD_STATE_TERMINATED,
};
/*
* Functions the HAL must provide
*/
void HalInitFirstTask(PKTHREAD thread);
BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
PVOID StartContext);
void HalTaskSwitch(PKTHREAD thread);
#endif

View File

@@ -9,9 +9,9 @@
#ifndef __VERSION_H
#define __VERSION_H
#define KERNEL_VERSION "0.0.10"
#define KERNEL_VERSION "0.0.11"
#define KERNEL_MAJOR_VERSION 0
#define KERNEL_MINOR_VERSION 0
#define KERNEL_PATCH_LEVEL 10
#define KERNEL_PATCH_LEVEL 11
#endif

View File

@@ -1,2 +0,0 @@
extern KSPIN_LOCK DispatcherDatabaseLock;
extern BOOLEAN WaitSet;

BIN
reactos/lib/ntdll/genntdll Normal file

Binary file not shown.

View File

@@ -27,12 +27,9 @@
;
; $Logfile: C:/dos-c/src/boot/boot.asv $
;
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.asm,v 1.3 1998/08/25 04:37:43 rex Exp $
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.asm,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
;
; $Log: boot.asm,v $
; Revision 1.3 1998/08/25 04:37:43 rex
; new release cleanup
;
; Revision 1.1.1.2 1998/08/25 04:27:38 rex
; A much Needed Update
;
@@ -289,3 +286,6 @@ filename db "KERNEL BIN"
sign dw 0aa55h

View File

@@ -0,0 +1,640 @@
1 ;
2 ; File:
3 ; boot.asm
4 ; Description:
5 ; DOS-C boot
6 ;
7 ; Copyright (c) 1997;
8 ; Svante Frey
9 ; All Rights Reserved
10 ;
11 ; This file is part of DOS-C.
12 ;
13 ; DOS-C is free software; you can redistribute it and/or
14 ; modify it under the terms of the GNU General Public License
15 ; as published by the Free Software Foundation; either version
16 ; 2, or (at your option) any later version.
17 ;
18 ; DOS-C is distributed in the hope that it will be useful, but
19 ; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
21 ; the GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public
24 ; License along with DOS-C; see the file COPYING. If not,
25 ; write to the Free Software Foundation, 675 Mass Ave,
26 ; Cambridge, MA 02139, USA.
27 ;
28 ; $Logfile: C:/dos-c/src/boot/boot.asv $
29 ;
30 ; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.lst,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
31 ;
32 ; $Log: boot.lst,v $
32 ; Revision 1.1.1.2 1998/08/25 04:27:38 rex
32 ; A much Needed Update
32 ;
33 ;
34 ; Rev 1.5 10 Jan 1997 4:58:06 patv
35 ; Corrected copyright
36 ;
37 ; Rev 1.4 10 Jan 1997 4:52:50 patv
38 ; Re-written to support C drive and eliminate restrictions on IPL.SYS
39 ;
40 ; Rev 1.3 29 Aug 1996 13:06:50 patv
41 ; Bug fixes for v0.91b
42 ;
43 ; Rev 1.2 01 Sep 1995 17:56:44 patv
44 ; First GPL release.
45 ;
46 ; Rev 1.1 30 Jul 1995 20:37:38 patv
47 ; Initialized stack before use.
48 ;
49 ; Rev 1.0 02 Jul 1995 10:57:52 patv
50 ; Initial revision.
51 ;
52
53 section .text
54
55 org 0
56 00000000 E93D00 Entry: jmp real_start
57
58 ; bp is initialized to 7c00h
59 %define oem [bp+3]
60 %define bytesPerSector [bp+0bh]
61 %define sectPerCluster [bp+0dh]
62 %define resSectors [bp+0eh]
63 %define nFats [bp+10h]
64 %define nRootDir [bp+11h]
65 %define nSectors [bp+13h]
66 %define MID [bp+15h]
67 %define sectPerFat [bp+16h]
68 %define sectPerTrack [bp+18h]
69 %define nHeads [bp+1ah]
70 %define nHidden [bp+1ch]
71 %define nHidden_hi [bp+1eh]
72 %define nSectorHuge [bp+20h]
73 %define drive [bp+24h]
74 %define extBoot [bp+26h]
75 %define volid [bp+27h]
76 %define vollabel [bp+2bh]
77 %define filesys 36h
78
79 LOADSEG equ 2000h
80
81 FATBUF equ 4000h ; offset of temporary buffer for FAT
82 ; chain
83 RETRYCOUNT equ 5 ; number of retries on disk errors
84
85 ; Some extra variables that are created on the stack frame
86
87 %define fat_start [bp-4] ; first FAT sector
88 %define fat_start_hi [bp-2]
89 %define root_dir_start [bp-8] ; first root directory sector
90 %define root_dir_start_hi [bp-6]
91 %define data_start [bp-12] ; first data sector
92 %define data_start_hi [bp-10]
93
94 ;
95 ; Include macros for filesystem access
96 ;
97 %include "boot.inc"
98 <1> ; To save space, functions that are just called once are
99 <1> ; implemented as macros instead. Four bytes are saved by
100 <1> ; avoiding the call / ret instructions.
101 <1>
102 <1>
103 <1> ; FINDFILE: Searches for the file in the root directory.
104 <1> ;
105 <1> ; Returns:
106 <1> ;
107 <1> ; If file not found: CF set
108 <1> ;
109 <1> ; If file found: CF clear
110 <1> ; AX = first cluster of file
111 <1>
112 <1>
113 <1> %macro FINDFILE 0
114 <1> ; First, read the whole root directory
115 <1> ; into the temporary buffer.
116 <1>
117 <1> mov ax, word root_dir_start
118 <1> mov dx, word root_dir_start_hi
119 <1> mov di, nRootDir
120 <1> xor bx, bx
121 <1> mov es, tempbuf
122 <1> call readDisk
123 <1> jc ffDone
124 <1>
125 <1> xor di, di
126 <1>
127 <1> next_entry: mov cx, 11
128 <1> mov si, filename+7c00h
129 <1> push di
130 <1> repe cmpsb
131 <1> pop di
132 <1> mov ax, [es:di+1ah] ; get cluster number from directory entry
133 <1> clc
134 <1> je ffDone
135 <1>
136 <1> add di, 20h ; go to next directory entry
137 <1> cmp byte [es:di], 0 ; if the first byte of the name is 0,
138 <1> jnz next_entry ; there is no more files in the directory
139 <1>
140 <1> stc
141 <1> ffDone:
142 <1> %endmacro
143 <1>
144 <1> ; GETDRIVEPARMS: Calculate start of some disk areas.
145 <1>
146 <1> %macro GETDRIVEPARMS 0
147 <1> mov si, word nHidden
148 <1> mov di, word nHidden_hi
149 <1> add si, word resSectors
150 <1> adc di, 0 ; DI:SI = first FAT sector
151 <1>
152 <1> mov word fat_start, si
153 <1> mov word fat_start_hi, di
154 <1>
155 <1> mov al, nFats
156 <1> xor ah, ah
157 <1> mul word sectPerFat ; DX:AX = total number of FAT sectors
158 <1>
159 <1> add si, ax
160 <1> adc di, dx ; DI:SI = first root directory sector
161 <1> mov word root_dir_start, si
162 <1> mov word root_dir_start_hi, di
163 <1>
164 <1> ; Calculate how many sectors the root directory occupies.
165 <1> mov bx, bytesPerSector
166 <1> mov cl, 5 ; divide BX by 32
167 <1> shr bx, cl ; BX = directory entries per sector
168 <1>
169 <1> mov ax, nRootDir
170 <1> xor dx, dx
171 <1> div bx
172 <1>
173 <1> mov nRootDir, ax ; AX = sectors per root directory
174 <1>
175 <1> add si, ax
176 <1> adc di, 0 ; DI:SI = first data sector
177 <1>
178 <1> mov data_start, si
179 <1> mov data_start_hi, di
180 <1> %endmacro
181 <1>
182 <1> ; GETFATCHAIN:
183 <1> ;
184 <1> ; Reads the FAT chain and stores it in a temporary buffer in the first
185 <1> ; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers,
186 <1> ; ending with 0.
187 <1> ;
188 <1> ; The file must fit in conventional memory, so it can't be larger than
189 <1> ; 640 kb. The sector size must be at least 512 bytes, so the FAT chain
190 <1> ; can't be larger than around 3 kb.
191 <1> ;
192 <1> ; Call with: AX = first cluster in chain
193 <1> ;
194 <1> ; Returns: CF clear on success, set on error
195 <1>
196 <1> %macro GETFATCHAIN 0
197 <1> push ax ; store first cluster number
198 <1>
199 <1> ; Load the complete FAT into memory. The FAT can't be larger
200 <1> ; than 128 kb, so it should fit in the temporary buffer.
201 <1>
202 <1> mov es, tempbuf
203 <1> xor bx, bx
204 <1> mov di, sectPerFat
205 <1> mov ax, word fat_start
206 <1> mov dx, word fat_start_hi
207 <1> call readDisk
208 <1> pop ax ; restore first cluster number
209 <1> jc boot_error
210 <1>
211 <1> ; Set ES:DI to the temporary storage for the FAT chain.
212 <1> push ds
213 <1> push es
214 <1> pop ds
215 <1> pop es
216 <1> mov di, FATBUF
217 <1>
218 <1> next_clust: stosw ; store cluster number
219 <1> mov si, ax ; SI = cluster number
220 <1> cmp byte extBoot, 29h
221 <1> jne fat_12
222 <1> cmp byte [bp+filesys+4], '6' ; check for FAT-16 system
223 <1> je fat_16
224 <1>
225 <1> ; This is a FAT-12 disk.
226 <1>
227 <1> fat_12: add si, si ; multiply cluster number by 3...
228 <1> add si, ax
229 <1> shr si, 1 ; ...and divide by 2
230 <1> lodsw
231 <1>
232 <1> ; If the cluster number was even, the cluster value is now in
233 <1> ; bits 0-11 of AX. If the cluster number was odd, the cluster
234 <1> ; value is in bits 4-15, and must be shifted right 4 bits. If
235 <1> ; the number was odd, CF was set in the last shift instruction.
236 <1>
237 <1> jnc fat_even
238 <1> mov cl, 4
239 <1> shr ax, cl ; shift the cluster number
240 <1>
241 <1> fat_even: and ah, 0fh ; mask off the highest 4 bits
242 <1> cmp ax, 0fffh ; check for EOF
243 <1> jmp short next_test
244 <1>
245 <1> ; This is a FAT-16 disk. The maximal size of a 16-bit FAT
246 <1> ; is 128 kb, so it may not fit within a single 64 kb segment.
247 <1>
248 <1> fat_16: mov dx, tempbuf
249 <1> add si, si ; multiply cluster number by two
250 <1> jnc first_half ; if overflow...
251 <1> add dh, 10h ; ...add 64 kb to segment value
252 <1>
253 <1> first_half: mov ds, dx ; DS:SI = pointer to next cluster
254 <1> lodsw ; AX = next cluster
255 <1>
256 <1> cmp ax, 0fff8h ; >= FFF8 = 16-bit EOF
257 <1> next_test: jb next_clust ; continue if not EOF
258 <1>
259 <1> finished: ; Mark end of FAT chain with 0, so we have a single
260 <1> ; EOF marker for both FAT-12 and FAT-16 systems.
261 <1>
262 <1> xor ax, ax
263 <1> stosw
264 <1> fatError:
265 <1> %endmacro
266 <1>
267 <1>
268 <1> ; loadFile: Loads the file into memory, one cluster at a time.
269 <1>
270 <1> %macro LOADFILE 0
271 <1> mov es, tempbuf ; set ES:BX to load address
272 <1> xor bx, bx
273 <1>
274 <1> mov si, FATBUF ; set DS:SI to the FAT chain
275 <1> push cs
276 <1> pop ds
277 <1>
278 <1> next_cluster: lodsw ; AX = next cluster to read
279 <1> or ax, ax ; if EOF...
280 <1> je boot_success ; ...boot was successful
281 <1>
282 <1> dec ax ; cluster numbers start with 2
283 <1> dec ax
284 <1>
285 <1> mov di, word sectPerCluster
286 <1> and di, 0ffh ; DI = sectors per cluster
287 <1> mul di
288 <1> add ax, data_start
289 <1> adc dx, data_start_hi ; DX:AX = first sector to read
290 <1> call readDisk
291 <1> jnc next_cluster
292 <1>
293 <1> %endmacro
294
295 ;
296 ;
297 ;
298 00000003 00<rept> TIMES 3eh-($-$$) DB 0
299
300 %define tempbuf [bp+3eh]
301 0000003E 0020 load_seg dw LOADSEG
302
303 00000040 FA real_start: cli
304 00000041 FC cld
305 00000042 8CC8 mov ax, cs
306 00000044 8ED0 mov ss, ax ; initialize stack
307 00000046 BD007C mov bp, 7c00h
308 00000049 8D66E0 lea sp, [bp-20h]
309 0000004C FB sti
310
311 0000004D 8EC0 mov es, ax
312 0000004F 8ED8 mov ds, ax
313 00000051 885624 mov drive, dl ; BIOS passes drive number in DL
314
315 GETDRIVEPARMS
316 00000054 8B761C <1> mov si, word nHidden
317 00000057 8B7E1E <1> mov di, word nHidden_hi
318 0000005A 03760E <1> add si, word resSectors
319 0000005D 81D70000 <1> adc di, 0
320 <1>
321 00000061 8976FC <1> mov word fat_start, si
322 00000064 897EFE <1> mov word fat_start_hi, di
323 <1>
324 00000067 8A4610 <1> mov al, nFats
325 0000006A 30E4 <1> xor ah, ah
326 0000006C F76616 <1> mul word sectPerFat
327 <1>
328 0000006F 01C6 <1> add si, ax
329 00000071 11D7 <1> adc di, dx
330 00000073 8976F8 <1> mov word root_dir_start, si
331 00000076 897EFA <1> mov word root_dir_start_hi, di
332 <1>
333 <1>
334 00000079 8B5E0B <1> mov bx, bytesPerSector
335 0000007C B105 <1> mov cl, 5
336 0000007E D3EB <1> shr bx, cl
337 <1>
338 00000080 8B4611 <1> mov ax, nRootDir
339 00000083 31D2 <1> xor dx, dx
340 00000085 F7F3 <1> div bx
341 <1>
342 00000087 894611 <1> mov nRootDir, ax
343 <1>
344 0000008A 01C6 <1> add si, ax
345 0000008C 81D70000 <1> adc di, 0
346 <1>
347 00000090 8976F4 <1> mov data_start, si
348 00000093 897EF6 <1> mov data_start_hi, di
349
350 FINDFILE ; locate file in root directory
351 <1>
352 <1>
353 <1>
354 00000096 8B46F8 <1> mov ax, word root_dir_start
355 00000099 8B56FA <1> mov dx, word root_dir_start_hi
356 0000009C 8B7E11 <1> mov di, nRootDir
357 0000009F 31DB <1> xor bx, bx
358 000000A1 8E463E <1> mov es, tempbuf
359 000000A4 E8B900 <1> call readDisk
360 000000A7 721E <1> jc ffDone
361 <1>
362 000000A9 31FF <1> xor di, di
363 <1>
364 000000AB B90B00 <1> next_entry: mov cx, 11
365 000000AE BE[F17D] <1> mov si, filename+7c00h
366 000000B1 57 <1> push di
367 000000B2 F3A6 <1> repe cmpsb
368 000000B4 5F <1> pop di
369 000000B5 268B451A <1> mov ax, [es:di+1ah]
370 000000B9 F8 <1> clc
371 000000BA 740B <1> je ffDone
372 <1>
373 000000BC 81C72000 <1> add di, 20h
374 000000C0 26803D00 <1> cmp byte [es:di], 0
375 000000C4 75E5 <1> jnz next_entry
376 <1>
377 000000C6 F9 <1> stc
378 <1> ffDone:
379 000000C7 727A jc boot_error ; fail if not found
380
381 GETFATCHAIN ; read FAT chain
382 000000C9 50 <1> push ax
383 <1>
384 <1>
385 <1>
386 <1>
387 000000CA 8E463E <1> mov es, tempbuf
388 000000CD 31DB <1> xor bx, bx
389 000000CF 8B7E16 <1> mov di, sectPerFat
390 000000D2 8B46FC <1> mov ax, word fat_start
391 000000D5 8B56FE <1> mov dx, word fat_start_hi
392 000000D8 E88500 <1> call readDisk
393 000000DB 58 <1> pop ax
394 000000DC 7265 <1> jc boot_error
395 <1>
396 <1>
397 000000DE 1E <1> push ds
398 000000DF 06 <1> push es
399 000000E0 1F <1> pop ds
400 000000E1 07 <1> pop es
401 000000E2 BF0040 <1> mov di, FATBUF
402 <1>
403 000000E5 AB <1> next_clust: stosw
404 000000E6 89C6 <1> mov si, ax
405 000000E8 807E2629 <1> cmp byte extBoot, 29h
406 000000EC 7506 <1> jne fat_12
407 000000EE 807E3A36 <1> cmp byte [bp+filesys+4], '6'
408 000000F2 7415 <1> je fat_16
409 <1>
410 <1>
411 <1>
412 000000F4 01F6 <1> fat_12: add si, si
413 000000F6 01C6 <1> add si, ax
414 000000F8 D1EE <1> shr si, 1
415 000000FA AD <1> lodsw
416 <1>
417 <1>
418 <1>
419 <1>
420 <1>
421 <1>
422 000000FB 7304 <1> jnc fat_even
423 000000FD B104 <1> mov cl, 4
424 000000FF D3E8 <1> shr ax, cl
425 <1>
426 00000101 80E40F <1> fat_even: and ah, 0fh
427 00000104 3DFF0F <1> cmp ax, 0fffh
428 00000107 EB10 <1> jmp short next_test
429 <1>
430 <1>
431 <1>
432 <1>
433 00000109 8B563E <1> fat_16: mov dx, tempbuf
434 0000010C 01F6 <1> add si, si
435 0000010E 7303 <1> jnc first_half
436 00000110 80C610 <1> add dh, 10h
437 <1>
438 00000113 8EDA <1> first_half: mov ds, dx
439 00000115 AD <1> lodsw
440 <1>
441 00000116 3DF8FF <1> cmp ax, 0fff8h
442 00000119 72CA <1> next_test: jb next_clust
443 <1>
444 <1> finished:
445 <1>
446 <1>
447 0000011B 31C0 <1> xor ax, ax
448 0000011D AB <1> stosw
449 <1> fatError:
450 LOADFILE ; load file (jumps to boot_sucess if successful)
451 0000011E 8E463E <1> mov es, tempbuf
452 00000121 31DB <1> xor bx, bx
453 <1>
454 00000123 BE0040 <1> mov si, FATBUF
455 00000126 0E <1> push cs
456 00000127 1F <1> pop ds
457 <1>
458 00000128 AD <1> next_cluster: lodsw
459 00000129 09C0 <1> or ax, ax
460 0000012B 742B <1> je boot_success
461 <1>
462 0000012D 48 <1> dec ax
463 0000012E 48 <1> dec ax
464 <1>
465 0000012F 8B7E0D <1> mov di, word sectPerCluster
466 00000132 81E7FF00 <1> and di, 0ffh
467 00000136 F7E7 <1> mul di
468 00000138 0346F4 <1> add ax, data_start
469 0000013B 1356F6 <1> adc dx, data_start_hi
470 0000013E E81F00 <1> call readDisk
471 00000141 73E5 <1> jnc next_cluster
472 <1>
473
474 00000143 B90A00 boot_error: mov cx, ERRMSGLEN
475 00000146 BE[E77D] mov si, errmsg+7c00h
476
477 00000149 AC next_char: lodsb ; print error message
478 0000014A B40E mov ah, 0eh
479 0000014C 30FF xor bh, bh
480 0000014E CD10 int 10h
481 00000150 E2F7 loop next_char
482
483 00000152 30E4 xor ah, ah
484 00000154 CD16 int 16h ; wait for keystroke
485 00000156 CD19 int 19h ; invoke bootstrap loader
486
487 00000158 8A5624 boot_success: mov dl, drive
488
489 0000015B EA db 0eah ; far jump to LOADSEG:0000
490 0000015C 0000 dw 0
491 0000015E 0020 dw LOADSEG
492
493
494 ; readDisk: Reads a number of sectors into memory.
495 ;
496 ; Call with: DX:AX = 32-bit DOS sector number
497 ; DI = number of sectors to read
498 ; ES:BX = destination buffer
499 ; ES must be 64k aligned (1000h, 2000h etc).
500 ;
501 ; Returns: CF set on error
502 ; ES:BX points one byte after the last byte read.
503
504 readDisk:
505 00000160 56 push si
506 00000161 52 read_next: push dx
507 00000162 50 push ax
508
509 ;
510 ; translate sector number to BIOS parameters
511 ;
512
513 ;
514 ; abs = sector offset in track
515 ; + head * sectPerTrack offset in cylinder
516 ; + track * sectPerTrack * nHeads offset in platter
517 ;
518 ; t1 = abs / sectPerTrack (ax has t1)
519 ; sector = abs mod sectPerTrack (cx has sector)
520 ;
521 00000163 F77618 div word sectPerTrack
522 00000166 89D1 mov cx, dx
523
524 ;
525 ; t1 = head + track * nHeads
526 ;
527 ; track = t1 / nHeads (ax has track)
528 ; head = t1 mod nHeads (dl has head)
529 ;
530 00000168 31D2 xor dx, dx
531 0000016A F7761A div word nHeads
532
533 ; the following manipulations are necessary in order to
534 ; properly place parameters into registers.
535 ; ch = cylinder number low 8 bits
536 ; cl = 7-6: cylinder high two bits
537 ; 5-0: sector
538 0000016D 88D6 mov dh, dl ; save head into dh for bios
539 0000016F D0CC ror ah, 1 ; move track high bits into
540 00000171 D0CC ror ah, 1 ; bits 7-6 (assumes top = 0)
541 00000173 86C4 xchg al, ah ; swap for later
542 00000175 8A5618 mov dl, byte sectPerTrack
543 00000178 28CA sub dl, cl
544 0000017A FEC1 inc cl ; sector offset from 1
545 0000017C 09C1 or cx, ax ; merge cylinder into sector
546 0000017E 88D0 mov al, dl ; al has # of sectors left
547
548 ; Calculate how many sectors can be transfered in this read
549 ; due to dma boundary conditions.
550 00000180 52 push dx
551
552 00000181 89FE mov si, di ; temp register save
553 ; this computes remaining bytes because of modulo 65536
554 ; nature of dma boundary condition
555 00000183 89D8 mov ax, bx ; get offset pointer
556 00000185 F7D8 neg ax ; and convert to bytes
557 00000187 740B jz ax_min_1 ; started at seg:0, skip ahead
558
559 00000189 31D2 xor dx, dx ; convert to sectors
560 0000018B F7760B div word bytesPerSector
561
562 0000018E 39F8 cmp ax, di ; check remainder vs. asked
563 00000190 7202 jb ax_min_1 ; less, skip ahead
564 00000192 89C6 mov si, ax ; transfer only what we can
565
566 00000194 5A ax_min_1: pop dx
567
568 ; Check that request sectors do not exceed track boundary
569 00000195 8B7618 mov si, sectPerTrack
570 00000198 46 inc si
571 00000199 89C8 mov ax, cx ; get the sector/cyl byte
572 0000019B 253F00 and ax, 03fh ; and mask out sector
573 0000019E 29C6 sub si, ax ; si has how many we can read
574 000001A0 89F8 mov ax, di
575 000001A2 39FE cmp si, di ; see if asked <= available
576 000001A4 7D02 jge ax_min_2
577 000001A6 89F0 mov ax, si ; get what can be xfered
578
579 000001A8 BE0500 ax_min_2: mov si, RETRYCOUNT
580 000001AB B402 mov ah, 2
581 000001AD 8A5624 mov dl, drive
582
583 000001B0 50 retry: push ax
584 000001B1 CD13 int 13h
585 000001B3 58 pop ax
586 000001B4 7310 jnc read_ok
587 000001B6 50 push ax
588 000001B7 31C0 xor ax, ax ; reset the drive
589 000001B9 CD13 int 13h
590 000001BB 58 pop ax
591 000001BC 4E dec si
592 000001BD 75F1 jnz retry
593 000001BF F9 stc
594 000001C0 58 pop ax
595 000001C1 5A pop dx
596 000001C2 5E pop si
597 000001C3 C3 ret
598
599 000001C4 EB9B read_next_jmp: jmp short read_next
600 000001C6 30E4 read_ok: xor ah, ah
601 000001C8 89C6 mov si, ax ; AX = SI = number of sectors read
602 000001CA F7660B mul word bytesPerSector ; AX = number of bytes read
603 000001CD 01C3 add bx, ax ; add number of bytes read to BX
604 000001CF 7307 jnc no_incr_es ; if overflow...
605
606 000001D1 8CC0 mov ax, es
607 000001D3 80C410 add ah, 10h ; ...add 1000h to ES
608 000001D6 8EC0 mov es, ax
609
610 000001D8 58 no_incr_es: pop ax
611 000001D9 5A pop dx ; DX:AX = last sector number
612
613 000001DA 01F0 add ax, si
614 000001DC 81D20000 adc dx, 0 ; DX:AX = next sector to read
615 000001E0 29F7 sub di, si ; if there is anything left to read,
616 000001E2 7FE0 jg read_next_jmp ; continue
617
618 000001E4 F8 clc
619 000001E5 5E pop si
620 000001E6 C3 ret
621
622 000001E7 426F6F74206572726F- errmsg db "Boot error"
623 000001F0 72
624 ERRMSGLEN equ $ - errmsg
625
626
627 ;filename db "OSLDR BIN"
628 000001F1 4B45524E454C202042- filename db "KERNEL BIN"
629 000001FA 494E
630
631 000001FC 00<rept> TIMES 510-($-$$) DB 0
632 000001FE 55AA sign dw 0aa55h
633
634
635
636
637

View File

@@ -1,12 +1,9 @@
#
# makefile for DOS-C boot
#
# $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.mak,v 1.3 1998/08/25 04:39:40 rex Exp $
# $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/boot.mak,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
#
# $Log: boot.mak,v $
# Revision 1.3 1998/08/25 04:39:40 rex
# Release cleanup
#
# Revision 1.1.1.2 1998/08/25 04:27:38 rex
# A much Needed Update
#
@@ -56,4 +53,3 @@ clean:
del *.las
del *.obj
del *.exe

View File

@@ -27,12 +27,9 @@
;
; $Logfile: C:/dos-c/src/boot/boot.asv $
;
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/bootbk.asm,v 1.3 1998/08/25 04:40:47 rex Exp $
; $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/loaders/boot/Attic/bootbk.asm,v 1.1.1.2 1998/08/25 04:27:38 rex Exp $
;
; $Log: bootbk.asm,v $
; Revision 1.3 1998/08/25 04:40:47 rex
; Release cleanup
;
; Revision 1.1.1.2 1998/08/25 04:27:38 rex
; A much Needed Update
;
@@ -293,3 +290,5 @@ TEXT ENDS
end

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -5,9 +5,9 @@
#
# Select your host
#
#HOST = djgpp-linux
HOST = djgpp-linux
#HOST = mingw32-linux
HOST = djgpp-msdos
#HOST = djgpp-msdos
#HOST = mingw32-windows
include rules.mak
@@ -30,13 +30,20 @@ LOADERS = dos
#
# Select the device drivers and filesystems you want
#
KERNEL_SERVICES = parallel keyboard null mouse serial sound test ide ide-test
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test minix
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES)
#
# Device driver rules
#
sdisk: dummy
make -C services/sdisk
minix: dummy
make -C services/fs/minix
ide-test: dummy
make -C services/ide-test
@@ -67,12 +74,6 @@ serial: dummy
sound: dummy
make -C services/sound
ide: dummy
make -C services/ide
ide-test: dummy
make -C services/ide-test
#
# Kernel loaders
#

View File

@@ -158,6 +158,7 @@ IoRaiseHardError
IoRaiseInformationalHardError
IoReadPartitionTable
IoRegisterDriverReinitialization
IoRegisterFileSystem
IoRegisterShutdownNotification
IoReleaseCancelSpinLock
IoRemoveShareAccess
@@ -375,3 +376,4 @@ ZwSetValueKey
ZwUnmapViewOfSection
ZwWriteFile
sprintf
wcschr

View File

@@ -137,7 +137,7 @@ asmlinkage void exception_handler(unsigned int edi,
*/
printk("Exception: %d(%x)\n",type,error_code&0xffff);
printk("CS:EIP %x:%x\n",cs&0xffff,eip);
for(;;);
// 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);

View File

@@ -20,6 +20,8 @@
/* GLOBALS ******************************************************************/
#define BOCHS_LOGGER_PORT (0x3ed)
/*
* PURPOSE: Current cursor position
*/
@@ -120,7 +122,9 @@ static void putchar(char c)
char* address;
int offset;
int i;
outb_p(BOCHS_LOGGER_PORT,c);
switch(c)
{
case '\n':
@@ -268,7 +272,7 @@ ULONG DbgPrint(PCH Format, ...)
: "m" (eflags));
}
void InitConsole(boot_param* bp)
void HalInitConsole(boot_param* bp)
/*
* FUNCTION: Initalize the console
* ARGUMENTS:

View File

@@ -13,7 +13,7 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ntoskrnl.h>
#include <internal/psmgr.h>
#include <internal/ps.h>
#include <internal/string.h>
#include <internal/hal.h>
#include <internal/hal/segment.h>

View File

@@ -12,9 +12,10 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/iomgr.h>
#include <internal/ob.h>
#include <internal/io.h>
#include <internal/string.h>
#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
@@ -48,7 +49,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
* 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
* file already exists
* CreateOptions = Options for creating a new file
* EaBuffer = Undocumented
* EaLength = Undocumented
@@ -85,47 +86,112 @@ NTSTATUS ZwOpenFile(PHANDLE FileHandle,
PDEVICE_OBJECT DeviceObject;
PFILE_OBJECT FileObject;
PIO_STACK_LOCATION StackLoc;
PWSTR Remainder;
DPRINT("ZwOpenFile(FileHandle %x, ObjectAttributes %x, "
"ObjectAttributes->ObjectName->Buffer %w)\n",FileHandle,
ObjectAttributes,ObjectAttributes->ObjectName->Buffer);
assert_irql(PASSIVE_LEVEL);
*FileHandle=0;
Status = ObOpenObjectByName(ObjectAttributes,&Object);
DPRINT("Object %x Status %x\n",Object,Status);
if (!NT_SUCCESS(Status))
{
return(Status);
}
DeviceObject = (PDEVICE_OBJECT)Object;
FileObject = ObGenericCreateObject(FileHandle,0,NULL,OBJTYP_FILE);
DPRINT("FileObject %x DeviceObject %x\n",FileObject,DeviceObject);
memset(FileObject,0,sizeof(FILE_OBJECT));
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Remainder);
if (Status != STATUS_SUCCESS && Status != STATUS_FS_QUERY_REQUIRED)
{
DPRINT("%s() = Failed to find object\n",__FUNCTION__);
ObDeleteHandle(*FileHandle);
*FileHandle=0;
ExFreePool(FileObject);
return(STATUS_UNSUCCESSFUL);
}
DeviceObject = (PDEVICE_OBJECT)Object;
DeviceObject = IoGetAttachedDevice(DeviceObject);
DPRINT("DeviceObject %x\n",DeviceObject);
if (Status == STATUS_SUCCESS)
{
CHECKPOINT;
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
ObjectAttributes->Length);
RtlCopyUnicodeString(&(FileObject->FileName),
ObjectAttributes->ObjectName);
}
else
{
CHECKPOINT;
if (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM &&
DeviceObject->DeviceType != FILE_DEVICE_DISK)
{
ObDeleteHandle(*FileHandle);
*FileHandle=0;
ExFreePool(FileObject);
return(STATUS_UNSUCCESSFUL);
}
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
{
Status = IoTryToMountStorageDevice(DeviceObject);
if (Status!=STATUS_SUCCESS)
{
ObDeleteHandle(*FileHandle);
*FileHandle=0;
ExFreePool(FileObject);
return(Status);
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
}
DPRINT("Remainder %w\n",Remainder);
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
wstrlen(Remainder));
RtlInitUnicodeString(&(FileObject->FileName),Remainder);
DPRINT("FileObject->FileName.Buffer %x %w\n",
FileObject->FileName.Buffer,FileObject->FileName.Buffer);
}
CHECKPOINT;
FileObject->DeviceObject=DeviceObject;
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
FileObject->Vpb=DeviceObject->Vpb;
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
if (Irp==NULL)
{
ObDeleteHandle(*FileHandle);
*FileHandle=0;
ExFreePool(FileObject);
return(STATUS_UNSUCCESSFUL);
}
StackLoc = IoGetNextIrpStackLocation(Irp);
DPRINT("StackLoc %x\n",StackLoc);
StackLoc->MajorFunction = IRP_MJ_CREATE;
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
StackLoc->DeviceObject = DeviceObject;
StackLoc->FileObject=FileObject;
DPRINT("DeviceObject %x\n",DeviceObject);
DPRINT("DeviceObject->DriverObject %x\n",DeviceObject->DriverObject);
IoCallDriver(DeviceObject,Irp);
Status = IoCallDriver(DeviceObject,Irp);
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = IoStatusBlock->Status;
}
return(STATUS_SUCCESS);
if (Status!=STATUS_SUCCESS)
{
ObDeleteHandle(*FileHandle);
*FileHandle=0;
ExFreePool(FileObject);
}
return(Status);
}

View File

@@ -12,8 +12,8 @@
#include <ddk/ntddk.h>
#include <internal/iomgr.h>
#include <internal/objmgr.h>
#include <internal/io.h>
#include <internal/ob.h>
#include <internal/string.h>
#define NDEBUG
@@ -60,10 +60,31 @@ VOID IoDetachDevice(PDEVICE_OBJECT TargetDevice)
UNIMPLEMENTED;
}
PDEVICE_OBJECT IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
{
PDEVICE_OBJECT Current = DeviceObject;
DPRINT("IoGetAttachDevice(DeviceObject %x)\n",DeviceObject);
while (Current->AttachedDevice!=NULL)
{
Current = Current->AttachedDevice;
DPRINT("Current %x\n",Current);
}
return(Current);
}
PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
PDEVICE_OBJECT TargetDevice)
{
UNIMPLEMENTED;
PDEVICE_OBJECT AttachedDevice = IoGetAttachedDevice(TargetDevice);
DPRINT("IoAttachDeviceToDeviceStack(SourceDevice %x, TargetDevice %x)\n",
SourceDevice,TargetDevice);
AttachedDevice->AttachedDevice = SourceDevice;
SourceDevice->StackSize = AttachedDevice->StackSize + 1;
return(AttachedDevice);
}
VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
@@ -153,11 +174,25 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
OBJECT_ATTRIBUTES dev_attr;
HANDLE devh;
DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject,
DeviceName->Buffer);
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
if (DeviceName!=NULL)
{
DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject,
DeviceName->Buffer);
}
else
{
DPRINT("IoCreateDevice(DriverObject %x)\n",DriverObject);
}
if (DeviceName!=NULL)
{
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
}
else
{
dev = ObGenericCreateObject(&devh,0,NULL,OBJTYP_DEVICE);
}
*DeviceObject=NULL;
@@ -191,11 +226,17 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
return(STATUS_INSUFFICIENT_RESOURCES);
}
dev->AttachedDevice=NULL;
dev->DeviceType=DeviceType;
dev->StackSize=1;
dev->AlignmentRequirement=1;
KeInitializeDeviceQueue(&dev->DeviceQueue);
if (dev->DeviceType==FILE_DEVICE_DISK)
{
IoAttachVpb(dev);
}
*DeviceObject=dev;
DPRINT("dev->DriverObject %x\n",dev->DriverObject);

View File

@@ -11,7 +11,9 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/io.h>
#define NDEBUG
#include <internal/debug.h>
/* TYPES *******************************************************************/
@@ -35,9 +37,30 @@ VOID IoInitFileSystemImplementation(VOID)
KeInitializeSpinLock(&FileSystemListLock);
}
NTSTATUS IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject)
NTSTATUS IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject,
PDEVICE_OBJECT DeviceToMount)
{
UNIMPLEMENTED;
PIRP Irp;
KEVENT Event;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
DPRINT("IoAskFileSystemToMountDevice(DeviceObject %x, DeviceToMount %x)\n",
DeviceObject,DeviceToMount);
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoBuildFilesystemControlRequest(IRP_MN_MOUNT_VOLUME,
DeviceObject,
&Event,
&IoStatusBlock,
DeviceToMount);
Status = IoCallDriver(DeviceObject,Irp);
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = IoStatusBlock.Status;
}
return(Status);
}
NTSTATUS IoAskFileSystemToLoad(PDEVICE_OBJECT DeviceObject)
@@ -58,12 +81,15 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject)
FILE_SYSTEM_OBJECT* current;
NTSTATUS Status;
DPRINT("IoTryToMountStorageDevice(DeviceObject %x)\n",DeviceObject);
KeAcquireSpinLock(&FileSystemListLock,&oldlvl);
current_entry = FileSystemListHead.Flink;
while (current_entry!=NULL)
while (current_entry!=(&FileSystemListHead))
{
current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
Status = IoAskFileSystemToMountDevice(DeviceObject);
Status = IoAskFileSystemToMountDevice(current->DeviceObject,
DeviceObject);
switch (Status)
{
case STATUS_FS_DRIVER_REQUIRED:
@@ -90,6 +116,8 @@ VOID IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
{
FILE_SYSTEM_OBJECT* fs;
DPRINT("IoRegisterFileSystem(DeviceObject %x)\n",DeviceObject);
fs=ExAllocatePool(NonPagedPool,sizeof(FILE_SYSTEM_OBJECT));
assert(fs!=NULL);
@@ -103,10 +131,12 @@ VOID IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
KIRQL oldlvl;
PLIST_ENTRY current_entry;
FILE_SYSTEM_OBJECT* current;
DPRINT("IoUnregisterFileSystem(DeviceObject %x)\n",DeviceObject);
KeAcquireSpinLock(&FileSystemListLock,&oldlvl);
current_entry = FileSystemListHead.Flink;
while (current_entry!=NULL)
while (current_entry!=(&FileSystemListHead))
{
current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
if (current->DeviceObject == DeviceObject)

View File

@@ -12,7 +12,7 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/ob.h>
#define NDEBUG
#include <internal/debug.h>
@@ -66,28 +66,28 @@ VOID IoInit(VOID)
/*
* 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;
RtlInitAnsiString(&astring,"\\??");
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
ZwCreateDirectoryObject(&handle,0,&attr);
IoInitCancelHandling();
IoInitSymbolicLinkImplementation();
IoInitFileSystemImplementation();
}

View File

@@ -32,7 +32,7 @@
#include <internal/string.h>
#include <ddk/ntddk.h>
//#define NDEBUG
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS ****************************************************************/
@@ -82,177 +82,6 @@ VOID IoMarkIrpPending(PIRP Irp)
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
}
PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER StartingOffset,
PIO_STATUS_BLOCK IoStatusBlock)
/*
* FUNCTION: Allocates and sets up an IRP to be sent to lower level drivers
* ARGUMENTS:
* MajorFunction = One of IRP_MJ_READ, IRP_MJ_WRITE,
* IRP_MJ_FLUSH_BUFFERS or IRP_MJ_SHUTDOWN
* DeviceObject = Device object to send the irp to
* Buffer = Buffer into which data will be read or written
* Length = Length in bytes of the irp to be allocated
* StartingOffset = Starting offset on the device
* IoStatusBlock (OUT) = Storage for the result of the operation
* RETURNS: The IRP allocated on success, or
* NULL on failure
*/
{
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
if (Irp==NULL)
{
return(NULL);
}
Irp->UserBuffer = (LPVOID)Buffer;
if (DeviceObject->Flags&DO_BUFFERED_IO)
{
DPRINT("Doing buffer i/o\n",0);
Irp->AssociatedIrp.SystemBuffer = (PVOID)
ExAllocatePool(NonPagedPool,Length);
if (Irp->AssociatedIrp.SystemBuffer==NULL)
{
return(NULL);
}
Irp->UserBuffer = NULL;
}
if (DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT("Doing direct i/o\n",0);
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
Irp->UserIosb = IoStatusBlock;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->Parameters.Write.Length = Length;
if (StartingOffset!=NULL)
{
StackPtr->Parameters.Write.ByteOffset.LowPart =
StartingOffset->LowPart;
StackPtr->Parameters.Write.ByteOffset.HighPart =
StartingOffset->HighPart;
}
else
{
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
}
return(Irp);
}
PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
PDEVICE_OBJECT DeviceObject,
PVOID InputBuffer,
ULONG InputBufferLength,
PVOID OutputBuffer,
ULONG OutputBufferLength,
BOOLEAN InternalDeviceIoControl,
PKEVENT Event,
PIO_STATUS_BLOCK IoStatusBlock)
{
UNIMPLEMENTED;
}
PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
ULONG Length,
PLARGE_INTEGER StartingOffset,
PKEVENT Event,
PIO_STATUS_BLOCK IoStatusBlock)
/*
* FUNCTION: Allocates and builds an IRP to be sent synchronously to lower
* level driver(s)
* ARGUMENTS:
* MajorFunction = Major function code, one of IRP_MJ_READ,
* IRP_MJ_WRITE, IRP_MJ_FLUSH_BUFFERS, IRP_MJ_SHUTDOWN
* DeviceObject = Target device object
* Buffer = Buffer containing data for a read or write
* Length = Length in bytes of the information to be transferred
* StartingOffset = Offset to begin the read/write from
* Event (OUT) = Will be set when the operation is complete
* IoStatusBlock (OUT) = Set to the status of the operation
* RETURNS: The IRP allocated on success, or
* NULL on failure
*/
{
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
if (Irp==NULL)
{
return(NULL);
}
Irp->UserBuffer = (LPVOID)Buffer;
if (DeviceObject->Flags&DO_BUFFERED_IO)
{
DPRINT("Doing buffer i/o\n",0);
Irp->AssociatedIrp.SystemBuffer = (PVOID)
ExAllocatePool(NonPagedPool,Length);
if (Irp->AssociatedIrp.SystemBuffer==NULL)
{
return(NULL);
}
Irp->UserBuffer = NULL;
}
if (DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT("Doing direct i/o\n",0);
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
Irp->UserIosb = IoStatusBlock;
Irp->UserEvent = Event;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->Parameters.Write.Length = Length;
if (StartingOffset!=NULL)
{
StackPtr->Parameters.Write.ByteOffset.LowPart =
StartingOffset->LowPart;
StackPtr->Parameters.Write.ByteOffset.HighPart =
StartingOffset->HighPart;
}
else
{
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
}
return(Irp);
}
USHORT IoSizeOfIrp(CCHAR StackSize)
/*
* FUNCTION: Determines the size of an IRP
@@ -275,6 +104,7 @@ VOID IoInitializeIrp(PIRP Irp, USHORT PacketSize, CCHAR StackSize)
{
assert(Irp!=NULL);
memset(Irp,0,PacketSize);
Irp->StackCount=StackSize;
Irp->CurrentLocation=StackSize;
Irp->Tail.Overlay.CurrentStackLocation=IoGetCurrentIrpStackLocation(Irp);
}
@@ -358,6 +188,7 @@ PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
return(NULL);
}
Irp->StackCount=StackSize;
Irp->CurrentLocation=StackSize;
DPRINT("Irp %x Irp->StackPtr %d\n",Irp,Irp->CurrentLocation);
@@ -399,15 +230,11 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
* thread making the request
*/
{
unsigned int i=0;
unsigned int stack_size;
unsigned int i;
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
Irp,PriorityBoost);
DPRINT("Irp->Stack[i].DeviceObject->StackSize %x\n",
Irp->Stack[i].DeviceObject->StackSize);
stack_size = Irp->Stack[i].DeviceObject->StackSize;
for (i=0;i<stack_size;i++)
for (i=0;i<Irp->StackCount;i++)
{
if (Irp->Stack[i].CompletionRoutine!=NULL)
{
@@ -420,12 +247,4 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
{
KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
}
if (Irp->UserIosb!=NULL)
{
*Irp->UserIosb=Irp->IoStatus;
}
/*
* If the
*/
}

View File

@@ -38,12 +38,7 @@ VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
if (entry!=NULL)
{
Irp = CONTAINING_RECORD(entry,IRP,Tail.Overlay.DeviceQueueEntry);
DeviceObject->CurrentIrp = Irp;
DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp);
}
else
{
DeviceObject->CurrentIrp = NULL;
}
}
@@ -68,13 +63,9 @@ VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable)
if (entry!=NULL)
{
Irp = CONTAINING_RECORD(entry,IRP,Tail.Overlay.DeviceQueueEntry);
DeviceObject->CurrentIrp = Irp;
DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp);
}
else
{
DeviceObject->CurrentIrp = NULL;
}
}
VOID IoStartPacket(PDEVICE_OBJECT DeviceObject,
@@ -118,7 +109,6 @@ VOID IoStartPacket(PDEVICE_OBJECT DeviceObject,
if (!stat)
{
DeviceObject->CurrentIrp = Irp;
DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp);
}
}

View File

@@ -12,21 +12,50 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/iomgr.h>
#include <internal/io.h>
#include <internal/string.h>
#include <internal/objmgr.h>
#include <internal/ob.h>
#define NDEBUG
#include <internal/debug.h>
#ifndef NDEBUG
#define DPRINT1(x) printk(x)
#else
#define DPRINT1(x)
#endif
/* FUNCTIONS ***************************************************************/
static VOID IoSecondStageCompletion(PIRP Irp,
BOOLEAN FromDevice,
PDEVICE_OBJECT DeviceObject,
ULONG Length,
PVOID Buffer)
/*
* FUNCTION: Performs the second stage of irp completion for read/write irps
* ARGUMENTS:
* Irp = Irp to completion
* FromDevice = True if the operation transfered data from the device
*/
{
if (Irp->UserIosb!=NULL)
{
*Irp->UserIosb=Irp->IoStatus;
}
if (DeviceObject->Flags & DO_BUFFERED_IO && FromDevice)
{
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
}
if (DeviceObject->Flags & DO_DIRECT_IO)
{
if (Irp->MdlAddress->MappedSystemVa!=NULL)
{
MmUnmapLockedPages(Irp->MdlAddress->MappedSystemVa,
Irp->MdlAddress);
}
MmUnlockPages(Irp->MdlAddress);
ExFreePool(Irp->MdlAddress);
}
IoFreeIrp(Irp);
}
NTSTATUS ZwReadFile(HANDLE FileHandle,
HANDLE EventHandle,
PIO_APC_ROUTINE ApcRoutine,
@@ -37,89 +66,55 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
PLARGE_INTEGER ByteOffset,
PULONG Key)
{
NTSTATUS Status;
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(FileHandle);
PFILE_OBJECT FileObject = (PFILE_OBJECT)hdr;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
NTSTATUS Status;
DPRINT("ZwReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
"IoStatusBlock %x)\n",
FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
if (hdr==NULL)
{
DPRINT("%s() = STATUS_INVALID_HANDLE\n",__FUNCTION__);
return(STATUS_INVALID_HANDLE);
}
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize,TRUE);
if (Irp==NULL)
if (ByteOffset==NULL)
{
return(STATUS_UNSUCCESSFUL);
ByteOffset = &(FileObject->CurrentByteOffset);
}
Irp->UserBuffer = (LPVOID)Buffer;
if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
{
DPRINT1("Doing buffer i/o\n");
Irp->AssociatedIrp.SystemBuffer = (PVOID)
ExAllocatePool(NonPagedPool,Length);
if (Irp->AssociatedIrp.SystemBuffer==NULL)
{
return(STATUS_UNSUCCESSFUL);
}
Irp->UserBuffer = NULL;
}
if (FileObject->DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT1("Doing direct i/o\n");
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp->UserEvent=&Event;
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
FileObject->DeviceObject,
Buffer,
Length,
ByteOffset,
&Event,
IoStatusBlock);
StackPtr = IoGetNextIrpStackLocation(Irp);
DPRINT("StackPtr %x\n",StackPtr);
StackPtr->MajorFunction = IRP_MJ_READ;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = FileObject->DeviceObject;
StackPtr->FileObject = FileObject;
StackPtr->Parameters.Read.Length = Length;
if (ByteOffset!=NULL)
{
StackPtr->Parameters.Read.ByteOffset.LowPart = ByteOffset->LowPart;
StackPtr->Parameters.Read.ByteOffset.HighPart = ByteOffset->HighPart;
}
else
{
StackPtr->Parameters.Read.ByteOffset.LowPart = 0;
StackPtr->Parameters.Read.ByteOffset.HighPart = 0;
}
if (Key!=NULL)
{
StackPtr->Parameters.Read.Key = *Key;
}
else
{
StackPtr->Parameters.Read.Key = 0;
}
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
Status = IoCallDriver(FileObject->DeviceObject,Irp);
if (NT_SUCCESS(Status))
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = Irp->IoStatus.Status;
if (NT_SUCCESS(Status))
{
if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
{
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
}
}
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = Irp->IoStatus.Status;
}
if (!NT_SUCCESS(Status))
{
return(Status);
}
FileObject->CurrentByteOffset.LowPart =
FileObject->CurrentByteOffset.LowPart + Length;
if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
{
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
}
return(Status);
}
@@ -134,11 +129,11 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
PLARGE_INTEGER ByteOffset,
PULONG Key)
{
NTSTATUS Status;
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(FileHandle);
PFILE_OBJECT FileObject = (PFILE_OBJECT)hdr;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
NTSTATUS Status;
if (hdr==NULL)
{
@@ -204,6 +199,11 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
Status = IoCallDriver(FileObject->DeviceObject,Irp);
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = IoStatusBlock->Status;
}
return(Status);
}

View File

@@ -11,22 +11,27 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/ob.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS ******************************************************************/
typedef struct
{
PVOID Target;
} SYMBOLIC_LINK_OBJECT;
CSHORT Type;
CSHORT Size;
UNICODE_STRING TargetName;
OBJECT_ATTRIBUTES Target;
} SYMLNK_OBJECT, *PSYMLNK_OBJECT;
OBJECT_TYPE SymlinkObjectType = {{NULL,0,0},
0,
0,
ULONG_MAX,
ULONG_MAX,
sizeof(SYMBOLIC_LINK_OBJECT),
sizeof(SYMLNK_OBJECT),
0,
NULL,
NULL,
@@ -40,9 +45,65 @@ OBJECT_TYPE SymlinkObjectType = {{NULL,0,0},
/* FUNCTIONS *****************************************************************/
NTSTATUS ZwOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes)
{
NTSTATUS Status;
PVOID Object;
PWSTR Ignored;
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Ignored);
if (!NT_SUCCESS(Status))
{
return(Status);
}
*LinkHandle = ObAddHandle(Object);
return(STATUS_SUCCESS);
}
NTSTATUS ZwQuerySymbolicLinkObject(IN HANDLE LinkHandle,
IN OUT PUNICODE_STRING LinkTarget,
OUT PULONG ReturnedLength OPTIONAL)
{
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(LinkHandle);
PSYMLNK_OBJECT SymlinkObject = (PSYMLNK_OBJECT)hdr;
if (hdr==NULL)
{
return(STATUS_INVALID_HANDLE);
}
RtlCopyUnicodeString(LinkTarget,SymlinkObject->Target.ObjectName);
if (ReturnedLength!=NULL)
{
*ReturnedLength=SymlinkObject->Target.Length;
}
return(STATUS_SUCCESS);
}
POBJECT IoOpenSymlink(POBJECT _Symlink)
{
PVOID Result;
PSYMLNK_OBJECT Symlink = (PSYMLNK_OBJECT)_Symlink;
PWSTR Ignored;
DPRINT("IoOpenSymlink(_Symlink %x)\n",Symlink);
DPRINT("Target %w\n",Symlink->Target.ObjectName->Buffer);
ObOpenObjectByName(&(Symlink->Target),&Result,&Ignored);
return(Result);
}
VOID IoInitSymbolicLinkImplementation(VOID)
{
ANSI_STRING astring;
RtlInitAnsiString(&astring,"Symbolic Link");
RtlAnsiStringToUnicodeString(&SymlinkObjectType.TypeName,&astring,TRUE);
ObRegisterType(OBJTYP_SYMLNK,&SymlinkObjectType);
}
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
@@ -54,7 +115,31 @@ NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
PUNICODE_STRING DeviceName)
{
UNIMPLEMENTED;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE SymbolicLinkHandle;
PSYMLNK_OBJECT SymbolicLink;
PUNICODE_STRING TargetName;
DPRINT("IoCreateSymbolicLink(SymbolicLinkName %w, DeviceName %w)\n",
SymbolicLinkName->Buffer,DeviceName->Buffer);
InitializeObjectAttributes(&ObjectAttributes,SymbolicLinkName,0,NULL,NULL);
SymbolicLink = ObGenericCreateObject(&SymbolicLinkHandle,0,
&ObjectAttributes,OBJTYP_SYMLNK);
if (SymbolicLink == NULL)
{
return(STATUS_UNSUCCESSFUL);
}
SymbolicLink->TargetName.Buffer = ExAllocatePool(NonPagedPool,
((wstrlen(DeviceName->Buffer)+1)*2));
SymbolicLink->TargetName.MaximumLength = wstrlen(DeviceName->Buffer);
SymbolicLink->TargetName.Length = 0;
RtlCopyUnicodeString(&(SymbolicLink->TargetName),DeviceName);
DPRINT("DeviceName %w\n",SymbolicLink->TargetName.Buffer);
InitializeObjectAttributes(&(SymbolicLink->Target),
&(SymbolicLink->TargetName),0,NULL,NULL);
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
return(STATUS_SUCCESS);
}
NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING DeviceName)

View File

@@ -159,6 +159,7 @@ void IoRaiseHardError(void);
void IoRaiseInformationalHardError(void);
void IoReadPartitionTable(void);
void IoRegisterDriverReinitialization(void);
void IoRegisterFileSystem(void);
void IoRegisterShutdownNotification(void);
void IoReleaseCancelSpinLock(void);
void IoRemoveShareAccess(void);
@@ -376,6 +377,7 @@ void ZwSetValueKey(void);
void ZwUnmapViewOfSection(void);
void ZwWriteFile(void);
void sprintf(void);
void wcschr(void);
#ifdef __cplusplus
}
#endif
@@ -531,6 +533,7 @@ export symbol_table[]={
{"_IoRaiseInformationalHardError",(unsigned int)IoRaiseInformationalHardError},
{"_IoReadPartitionTable",(unsigned int)IoReadPartitionTable},
{"_IoRegisterDriverReinitialization",(unsigned int)IoRegisterDriverReinitialization},
{"_IoRegisterFileSystem",(unsigned int)IoRegisterFileSystem},
{"_IoRegisterShutdownNotification",(unsigned int)IoRegisterShutdownNotification},
{"_IoReleaseCancelSpinLock",(unsigned int)IoReleaseCancelSpinLock},
{"_IoRemoveShareAccess",(unsigned int)IoRemoveShareAccess},
@@ -748,5 +751,6 @@ export symbol_table[]={
{"_ZwUnmapViewOfSection",(unsigned int)ZwUnmapViewOfSection},
{"_ZwWriteFile",(unsigned int)ZwWriteFile},
{"_sprintf",(unsigned int)sprintf},
{"_wcschr",(unsigned int)wcschr},
{NULL,NULL},
};

View File

@@ -22,7 +22,7 @@
#include <internal/hal/page.h>
#include <internal/hal/segment.h>
//#define NDEBUG
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS ****************************************************************/
@@ -122,16 +122,21 @@ asmlinkage void _main(boot_param* _bp)
/*
* Copy the parameters to a local buffer because lowmem will go away
*/
memcpy(&bp,_bp,sizeof(bp));
memcpy(&bp,_bp,sizeof(boot_param));
/*
* Initalize the console (before printing anything)
*/
InitConsole(&bp);
HalInitConsole(&bp);
DbgPrint("Starting ReactOS "KERNEL_VERSION"\n");
printk("Starting ReactOS "KERNEL_VERSION"\n");
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
if (start <= ((int)&end))
{
DbgPrint("Kernel booted incorrectly, aborting\n");
for(;;);
}
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]));
@@ -147,7 +152,6 @@ asmlinkage void _main(boot_param* _bp)
* Initalize various critical subsystems
*/
HalInit(&bp);
// set_breakpoint(0,start,HBP_READWRITE,HBP_DWORD);
MmInitalize(&bp);
CHECKPOINT;
KeInit();
@@ -165,12 +169,12 @@ asmlinkage void _main(boot_param* _bp)
DPRINT("%d files loaded\n",bp.nr_files);
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
start1 = start+PAGE_ROUND_UP(bp.module_length[1]);
// DbgPrint("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
for (i=1;i<bp.nr_files;i++)
{
DPRINT("start %x *start %x\n",start,*((unsigned int *)start));
CHECKPOINT;
process_boot_module(start);
CHECKPOINT;
// DbgPrint("start1 %x *start1 %x\n",start1,*((unsigned int *)start1));
start=start+PAGE_ROUND_UP(bp.module_length[i]);
}

View File

@@ -15,13 +15,13 @@
#include <ddk/ntddk.h>
#include <internal/iomgr.h>
#include <internal/io.h>
#include <internal/symbol.h>
#include <internal/string.h>
#include <internal/mm.h>
#include <internal/module.h>
//#define NDEBUG
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS **************************************************************/
@@ -67,6 +67,27 @@ static void get_symbol_name(module* mod, unsigned int i, char* name)
}
}
static unsigned int get_symbol_value_by_name(module* mod, char* sname,
unsigned int idx)
{
unsigned int i;
char name[255];
DPRINT("get_symbol_value_by_name(sname %s, idx %x)\n",sname,idx);
for (i=0; i<mod->nsyms; i++)
{
get_symbol_name(mod,i,name);
// DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value);
if (strcmp(name,sname)==0)
{
DPRINT("Returning %x\n",mod->sym_list[i].e_value);
return(mod->sym_list[i].e_value);
}
}
return(0);
}
static unsigned int get_symbol_value(module* mod, unsigned int i)
/*
* FUNCTION: Get the value of a module defined symbol
@@ -119,17 +140,32 @@ static int do_reloc32_reloc(module* mod, SCNHDR* scn, RELOC* reloc)
val = get_kernel_symbol_addr(name);
if (val==0)
{
DbgPrint("Undefined symbol %s in module\n",name);
return(0);
val = get_symbol_value_by_name(mod,name,reloc->r_symndx);
if (val==0)
{
DbgPrint("Undefined symbol %s in module\n",name);
return(0);
}
loc=(unsigned int *)(mod->base+reloc->r_vaddr);
DPRINT("old %x ",*loc);
// (*loc) = (*loc) + val + mod->base - scn->s_vaddr;
(*loc) = (*loc);
DPRINT("mod->base %x scn->s_vaddr %x\n",mod->base,scn->s_vaddr);
DPRINT("new %x\n",*loc);
}
// DPRINT("REL32 value %x name %s\n",val,name);
// printk("value %x\n",val);
else
{
DPRINT("REL32 value %x name %s\n",val,name);
DPRINT("value %x\n",val);
loc=(unsigned int *)(mod->base+reloc->r_vaddr);
// printk("old %x ",*loc);
DPRINT("old %x ",*loc);
DPRINT("mod->base %x scn->s_vaddr %x\n",mod->base,scn->s_vaddr);
(*loc) = (*loc) + val - mod->base + scn->s_vaddr;
// printk("new %x\n",*loc);
DPRINT("new %x\n",*loc);
}
return(1);
}
@@ -238,6 +274,7 @@ BOOLEAN process_boot_module(unsigned int start)
mod=(module *)ExAllocatePool(NonPagedPool,sizeof(module));
DPRINT("magic %x\n",((FILHDR *)start)->f_magic);
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
memcpy(&hdr,(void *)start,FILHSZ);
@@ -258,6 +295,7 @@ BOOLEAN process_boot_module(unsigned int start)
mod->scn_list = (SCNHDR *)(start+FILHSZ+hdr.f_opthdr);
mod->size=0;
mod->raw_data_off = start;
mod->nsyms = hdr.f_nsyms;
/*
* Determine the length of the module
@@ -288,7 +326,9 @@ BOOLEAN process_boot_module(unsigned int start)
}
CHECKPOINT;
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
mod->base = (unsigned int)MmAllocateSection(mod->size);
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
if (mod->base == 0)
{
DbgPrint("Failed to alloc section for module\n");

View File

@@ -26,7 +26,7 @@ IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
io/shutdown.o io/fdisk.o io/cancel.o io/error.o io/arc.o \
io/dpc.o io/symlink.o io/adapter.o io/cntrller.o io/mdl.o \
io/resource.o io/event.o io/process.o io/file.o io/ioctrl.o \
io/fs.o
io/fs.o io/vpb.o io/buildirp.o
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
@@ -39,7 +39,7 @@ SE_OBJECTS = se/semgr.o
CFG_OBJECTS = cfg/registry.o
TST_OBJECTS = tst/test.o
TST_OBJECTS = tst/test.o tst/sshell.o tst/readline.o
DBG_OBJECTS = dbg/brkpoint.o
@@ -48,7 +48,7 @@ LDR_OBJECTS = ldr/loader.o
OBJECTS = $(HAL_OBJECTS) $(KE_OBJECTS) $(RTL_OBJECTS) $(MM_OBJECTS) \
$(IO_OBJECTS) $(OB_OBJECTS) $(PS_OBJECTS) $(EX_OBJECTS) \
$(SE_OBJECTS) $(CFG_OBJECTS) $(TST_OBJECTS) $(DBG_OBJECTS)
utils/export/export$(EXE_POSTFIX): utils/export/export.c
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)

View File

@@ -1,30 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: kernel/mm/cont.c
* PURPOSE: Manages continuous memory
* 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>
/* FUNCTIONS *****************************************************************/
PVOID MmAllocateContiguousMemory(ULONG NumberOfBytes,
PHYSICAL_ADDRESS HighestAcceptableAddress)
{
UNIMPLEMENTED;
}
VOID MmFreeContiguousMemory(PVOID BaseAddress)
{
UNIMPLEMENTED;
}

View File

@@ -32,7 +32,6 @@ VOID MmDumpMemoryAreas(VOID)
ULONG i;
current_entry = ListHead->Flink;
i=0;
while (current_entry!=ListHead)
{
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
@@ -41,14 +40,7 @@ VOID MmDumpMemoryAreas(VOID)
current->BaseAddress+current->Length,current->Attributes,
current->Entry.Flink);
current_entry = current_entry->Flink;
i++;
if (i>6)
{
CHECKPOINT;
for(;;);
}
}
CHECKPOINT;
}
VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
@@ -88,8 +80,12 @@ static PLIST_ENTRY MmGetRelatedListHead(ULONG BaseAddress)
}
else
{
PKPROCESS CurrentProcess = KeGetCurrentProcess();
return(&(CurrentProcess->MemoryAreaList));
PEPROCESS CurrentProcess = PsGetCurrentProcess();
if (CurrentProcess==NULL)
{
return(NULL);
}
return(&(CurrentProcess->Pcb.MemoryAreaList));
}
}
@@ -99,6 +95,16 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
PLIST_ENTRY current_entry;
MEMORY_AREA* current;
MmDumpMemoryAreas();
DPRINT("MmInternalOpenMemoryAreaByAddress(ListHead %x, Address %x)\n",
ListHead,Address);
if (ListHead==NULL)
{
return(NULL);
}
current_entry = ListHead->Flink;
while (current_entry!=ListHead)
{
@@ -307,14 +313,14 @@ static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
DPRINT("Base %x Gap %x\n",current->BaseAddress,Gap);
if (Gap >= Length)
{
return(current->BaseAddress + current->Length);
return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
}
current_entry = current_entry->Flink;
}
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
//DbgPrint("current %x returning %x\n",current,current->BaseAddress+
// current->Length);
return(current->BaseAddress + current->Length);
return(current->BaseAddress + PAGE_ROUND_UP(current->Length));
}
NTSTATUS MmInitMemoryAreas(VOID)

View File

@@ -44,7 +44,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
* range described by the MDL
*/
{
PVOID base;
PVOID base = NULL;
unsigned int i;
ULONG* mdl_pages=NULL;
MEMORY_AREA* Result;
@@ -59,6 +59,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
Mdl->ByteCount,
0,
&Result);
CHECKPOINT;
mdl_pages = (ULONG *)(Mdl + 1);
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE); i++)
{

View File

@@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: kernel/mm/cont.c
* PURPOSE: Manages non-cached memory
* 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>
/* FUNCTIONS *****************************************************************/
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes)
{
UNIMPLEMENTED;
}
VOID MmFreeNonCachedMemory(PVOID BaseAddress, ULONG NumberOfBytes)
{
UNIMPLEMENTED;
}

View File

@@ -39,7 +39,7 @@ PVOID MmAllocateSection(ULONG Length)
{
return(NULL);
}
CHECKPOINT;
DPRINT("Result %x\n",Result);
Attributes = PA_WRITE | PA_READ | PA_EXECUTE | PA_SYSTEM;
for (i=0;i<=(Length/PAGESIZE);i++)
{

View File

@@ -59,12 +59,12 @@ void VirtualInit(boot_param* bp)
* Setup the system area descriptor list
*/
BaseAddress = KERNEL_BASE;
Length = ((ULONG)&etext) - KERNEL_BASE;
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
ParamLength = ParamLength - Length;
MmCreateMemoryArea(KernelMode,MEMORY_AREA_SYSTEM,&BaseAddress,
Length,0,&kernel_text_desc);
Length = ((ULONG)&end) - ((ULONG)&etext);
Length = PAGE_ROUND_UP(((ULONG)&end)) - PAGE_ROUND_UP(((ULONG)&etext));
ParamLength = ParamLength - Length;
DPRINT("Length %x\n",Length);
BaseAddress = PAGE_ROUND_UP(((ULONG)&etext));
@@ -113,18 +113,26 @@ asmlinkage int page_fault_handler(unsigned int edi,
{
KPROCESSOR_MODE FaultMode;
MEMORY_AREA* MemoryArea;
KIRQL oldlvl;
ULONG stat;
/*
* 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(;;);
DbgPrint("Page fault at address %x with eip %x\n",cr2,eip);
cr2 = PAGE_ROUND_DOWN(cr2);
assert_irql(DISPATCH_LEVEL);
if (KeGetCurrentIrql()!=PASSIVE_LEVEL)
{
DbgPrint("Recursive page fault detected\n");
KeBugCheck(0);
for(;;);
}
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
/*
* Find the memory area for the faulting address
@@ -156,12 +164,21 @@ asmlinkage int page_fault_handler(unsigned int edi,
switch (MemoryArea->Type)
{
case MEMORY_AREA_SYSTEM:
return(0);
stat = 0;
break;
case MEMORY_AREA_SECTION_VIEW:
return(MmSectionHandleFault(MemoryArea,cr2));
stat = MmSectionHandleFault(MemoryArea,cr2);
default:
stat = 0;
break;
}
return(0);
if (stat)
{
KeLowerIrql(oldlvl);
}
return(stat);
}

View File

@@ -12,7 +12,7 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/ob.h>
#include <internal/string.h>
#define NDEBUG
@@ -26,7 +26,7 @@
typedef struct
{
PVOID obj;
} HANDLE_REP;
} HANDLE_REP, *PHANDLE_REP;
#define HANDLE_BLOCK_ENTRIES ((PAGESIZE-sizeof(LIST_ENTRY))/sizeof(HANDLE_REP))
@@ -89,10 +89,33 @@ VOID ObjInitializeHandleTable(HANDLE parent)
* parent = Parent process (or NULL if this is the first process)
*/
{
DPRINT("ObjInitializeHandleTable(parent %x)\n",parent);
InitializeListHead(&handle_list_head);
KeInitializeSpinLock(&handle_list_lock);
}
static PHANDLE_REP ObTranslateHandle(HANDLE* h)
{
PLIST_ENTRY current = handle_list_head.Flink;
unsigned int handle = ((unsigned int)h) - 1;
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
HANDLE_BLOCK* blk = NULL;
unsigned int i;
for (i=0;i<count;i++)
{
current = current->Flink;
if (current==(&handle_list_head))
{
return(NULL);
}
}
blk = (HANDLE_BLOCK *)current;
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
}
PVOID ObGetObjectByHandle(HANDLE h)
/*
* FUNCTION: Translate a handle to the corresponding object
@@ -101,23 +124,20 @@ PVOID ObGetObjectByHandle(HANDLE h)
* RETURNS: The object
*/
{
LIST_ENTRY* current = handle_list_head.Flink;
unsigned int handle = ((unsigned int)h) - 1;
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
HANDLE_BLOCK* blk = NULL;
unsigned int i;
DPRINT("ObGetObjectByHandle(h %x)\n",h);
for (i=0;i<count;i++)
if (h==NULL)
{
current = current->Flink;
if (current==NULL)
{
return(NULL);
}
return(NULL);
}
blk = (HANDLE_BLOCK *)current;
return(blk->handles[handle%HANDLE_BLOCK_ENTRIES].obj);
return(ObTranslateHandle(h)->obj);
}
VOID ObDeleteHandle(HANDLE Handle)
{
PHANDLE_REP Rep = ObTranslateHandle(Handle);
Rep->obj=NULL;
}
HANDLE ObAddHandle(PVOID obj)
@@ -134,13 +154,13 @@ HANDLE ObAddHandle(PVOID obj)
unsigned int i;
HANDLE_BLOCK* new_blk = NULL;
DPRINT("ObAddHandle(obj %)\n",obj);
DPRINT("ObAddHandle(obj %x)\n",obj);
/*
* Scan through the currently allocated handle blocks looking for a free
* slot
*/
while (current!=NULL)
while (current!=(&handle_list_head))
{
HANDLE_BLOCK* blk = (HANDLE_BLOCK *)current;

View File

@@ -13,7 +13,8 @@
#include <windows.h>
#include <wstring.h>
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/ob.h>
#include <internal/io.h>
#include <internal/string.h>
#define NDEBUG
@@ -64,19 +65,23 @@ NTSTATUS ZwOpenDirectoryObject(PHANDLE DirectoryHandle,
{
PVOID Object;
NTSTATUS Status;
PWSTR Ignored;
Status = ObOpenObjectByName(ObjectAttributes,&Object);
*DirectoryHandle = 0;
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Ignored);
if (!NT_SUCCESS(Status))
{
return(Status);
}
if (BODY_TO_HEADER(Object)->Type!=OBJTYP_DIRECTORY)
{
{
return(STATUS_UNSUCCESSFUL);
}
*DirectoryHandle = ObAddHandle(Object);
CHECKPOINT;
return(STATUS_SUCCESS);
}
@@ -106,19 +111,24 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
* RETURNS: Status
*/
{
POBJECT_HEADER hdr = ObGetObjectByHandle(DirObjHandle);
PDIRECTORY_OBJECT dir = (PDIRECTORY_OBJECT)(HEADER_TO_BODY(hdr));
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(DirObjHandle);
PDIRECTORY_OBJECT dir = (PDIRECTORY_OBJECT)hdr;
ULONG EntriesToRead;
PLIST_ENTRY current_entry;
POBJECT_HEADER current;
ULONG i=0;
ULONG EntriesToSkip;
DPRINT("ZwQueryDirectoryObject(DirObjHandle %x)\n",DirObjHandle);
DPRINT("dir %x namespc_root %x\n",dir,HEADER_TO_BODY(&(namespc_root.hdr)));
assert_irql(PASSIVE_LEVEL);
EntriesToRead = BufferLength / sizeof(OBJDIR_INFORMATION);
*DataWritten = 0;
DPRINT("EntriesToRead %d\n",EntriesToRead);
current_entry = dir->head.Flink;
/*
@@ -126,6 +136,8 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
*/
if (!IgnoreInputIndex)
{
CHECKPOINT;
EntriesToSkip = *ObjectIndex;
while ( i<EntriesToSkip && current_entry!=NULL)
{
@@ -133,29 +145,40 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
}
}
DPRINT("DirObjInformation %x\n",DirObjInformation);
/*
* Read the maximum entries possible into the buffer
*/
while ( i<EntriesToRead && current_entry!=NULL)
while ( i<EntriesToRead && current_entry!=(&(dir->head)))
{
current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,entry);
DPRINT("Scanning %w\n",current->name.Buffer);
DirObjInformation[i].ObjectName.Buffer =
ExAllocatePool(NonPagedPool,current->name.Length);
DirObjInformation[i].ObjectName.Length = current->name.Length;
DirObjInformation[i].ObjectName.MaximumLength = current->name.Length;
DPRINT("DirObjInformation[i].ObjectName.Buffer %x\n",
DirObjInformation[i].ObjectName.Buffer);
RtlCopyUnicodeString(&DirObjInformation[i].ObjectName,
&(current->name));
i++;
current_entry = current_entry->Flink;
(*DataWritten) = (*DataWritten) + sizeof(OBJDIR_INFORMATION);
CHECKPOINT;
}
CHECKPOINT;
/*
* Optionally, count the number of entries in the directory
*/
if (!GetNextIndex)
if (GetNextIndex)
{
*ObjectIndex=i;
}
else
{
while ( current_entry!=NULL )
while ( current_entry!=(&(dir->head)) )
{
current_entry=current_entry->Flink;
i++;
@@ -179,22 +202,22 @@ NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
}
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* Object)
PVOID* Object, PWSTR* UnparsedSection)
{
NTSTATUS Status;
DPRINT("ObOpenObjectByName(ObjectAttributes %x, Object %x)\n",
ObjectAttributes,Object);
DPRINT("ObjectAttributes = {ObjectName %x ObjectName->Buffer %w}\n",
ObjectAttributes->ObjectName,ObjectAttributes->ObjectName->Buffer);
*Object = ObLookupObject(ObjectAttributes->RootDirectory,
ObjectAttributes->ObjectName->Buffer);
*Object = NULL;
Status = ObLookupObject(ObjectAttributes->RootDirectory,
ObjectAttributes->ObjectName->Buffer,
Object,
UnparsedSection);
DPRINT("*Object %x\n",*Object);
if ((*Object)==NULL)
{
return(STATUS_NO_SUCH_FILE);
}
return(STATUS_SUCCESS);
return(Status);
}
void ObInit(void)
@@ -284,30 +307,34 @@ static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name)
* NULL otherwise
*/
{
LIST_ENTRY* current = ((PDIRECTORY_OBJECT)dir)->head.Flink;
LIST_ENTRY* current = dir->head.Flink;
POBJECT_HEADER current_obj;
DPRINT("ObDirLookup(dir %x, name %w)\n",dir,name);
if (name[0]==0)
{
return(BODY_TO_HEADER(dir));
return(dir);
}
if (name[0]=='.'&&name[1]==0)
{
return(BODY_TO_HEADER(dir));
return(dir);
}
if (name[0]=='.'&&name[1]=='.'&&name[2]==0)
{
return(BODY_TO_HEADER(BODY_TO_HEADER(dir)->Parent));
return(BODY_TO_HEADER(dir)->Parent);
}
while (current!=(&((PDIRECTORY_OBJECT)dir)->head))
while (current!=(&(dir->head)))
{
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,entry);
DPRINT("Scanning %w\n",current_obj->name.Buffer);
if ( wcscmp(current_obj->name.Buffer, name)==0)
{
return(current_obj);
return(HEADER_TO_BODY(current_obj));
}
current = current->Flink;
}
DPRINT("%s() = NULL\n",__FUNCTION__);
return(NULL);
}
@@ -323,11 +350,6 @@ VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
{
DPRINT("ObjCreateEntry(%x,%x,%x,%w)\n",parent,Object,Object->name.Buffer,
Object->name.Buffer);
DPRINT("root type %d\n",namespc_root.hdr.Type);
DPRINT("%x\n",&(namespc_root.hdr.Type));
DPRINT("type %x\n",&(parent->Type));
DPRINT("type %x\n",&(BODY_TO_HEADER(parent)->Type));
DPRINT("type %d\n",parent->Type);
assert(parent->Type == OBJTYP_DIRECTORY);
/*
@@ -336,7 +358,8 @@ VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
InsertTailList(&parent->head,&Object->entry);
}
PVOID ObLookupObject(HANDLE rooth, PWSTR string)
NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
PWSTR* UnparsedSection)
/*
* FUNCTION: Lookup an object within the system namespc
* ARGUMENTS:
@@ -349,17 +372,23 @@ PVOID ObLookupObject(HANDLE rooth, PWSTR string)
PWSTR current;
PWSTR next;
PDIRECTORY_OBJECT current_dir = NULL;
POBJECT_HEADER current_hdr;
NTSTATUS Status;
DPRINT("root %x string %w\n",rooth,string);
DPRINT("ObLookupObject(rootdir %x, string %x, string %w, Object %x, "
"UnparsedSection %x)\n",rootdir,string,string,Object,
UnparsedSection);
if (rooth==NULL)
*UnparsedSection = NULL;
*Object = NULL;
if (rootdir==NULL)
{
current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
}
else
{
ObReferenceObjectByHandle(rooth,DIRECTORY_TRAVERSE,NULL,
ObReferenceObjectByHandle(rootdir,DIRECTORY_TRAVERSE,NULL,
UserMode,(PVOID*)&current_dir,NULL);
}
@@ -368,74 +397,90 @@ PVOID ObLookupObject(HANDLE rooth, PWSTR string)
*/
if (string[0]==0)
{
DPRINT("current_dir %x\n",current_dir);
DPRINT("type %d\n",current_dir->Type);
return(current_dir);
*Object=current_dir;
return(STATUS_SUCCESS);
}
DPRINT("string = %w\n",string);
if (string[0]!='\\')
{
DbgPrint("(%s:%d) Non absolute pathname passed to %s\n",__FILE__,
__LINE__,__FUNCTION__);
return(NULL);
return(STATUS_UNSUCCESSFUL);
}
current = string+1;
DPRINT("current %w\n",current);
next = wcschr(string+1,'\\');
if (next!=NULL)
{
*next=0;
}
DPRINT("next %x\n",next);
next = &string[0];
current = next+1;
while (next!=NULL)
{
DPRINT("Scanning %w next %w current %x\n",current,next+1,
current_dir);
/*
* Check the current object is a directory
*/
if (current_dir->Type!=OBJTYP_DIRECTORY)
{
DbgPrint("(%s:%d) Bad path component\n",__FILE__,
__LINE__);
ExFreePool(string);
return(NULL);
}
/*
* Lookup the next component of the path in the directory
*/
current_hdr=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current);
if (current_hdr==NULL)
{
DbgPrint("(%s:%d) Path component not found\n",__FILE__,
__LINE__);
ExFreePool(string);
return(NULL);
}
current_dir = HEADER_TO_BODY(current_hdr);
while (next!=NULL && current_dir->Type==OBJTYP_DIRECTORY)
{
*next = '\\';
current = next+1;
next = wcschr(next+1,'\\');
if (next!=NULL)
{
*next=0;
}
DPRINT("current %w current[5] %x next %x ",current,current[5],next);
if (next!=NULL)
{
DPRINT("(next+1) %w",next+1);
}
DPRINT("\n",0);
current_dir=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current);
if (current_dir==NULL)
{
DbgPrint("(%s:%d) Path component not found\n",__FILE__,
__LINE__);
ExFreePool(string);
return(STATUS_UNSUCCESSFUL);
}
DPRINT("current_dir %x\n",current_dir);
DPRINT("current_dir->Type %d OBJTYP_SYMLNK %d OBJTYP_DIRECTORY %d\n",
current_dir->Type,OBJTYP_SYMLNK,OBJTYP_DIRECTORY);
DPRINT("&(current_dir->Type) %x\n",&(current_dir->Type));
if (current_dir->Type==OBJTYP_SYMLNK)
{
current_dir = IoOpenSymlink(current_dir);
}
}
DPRINT("next %x\n",next);
DPRINT("current %x current %w\n",current,current);
if (next==NULL)
{
if (current_dir==NULL)
{
Status = STATUS_UNSUCCESSFUL;
}
else
{
Status = STATUS_SUCCESS;
}
}
else
{
CHECKPOINT;
*next = '\\';
*UnparsedSection = next;
switch(current_dir->Type)
{
case OBJTYP_DEVICE:
CHECKPOINT;
Status = STATUS_FS_QUERY_REQUIRED;
break;
default:
current_dir = NULL;
Status = STATUS_UNSUCCESSFUL;
break;
}
}
CHECKPOINT;
*Object = current_dir;
DPRINT("current_dir %x current %x\n",current_dir,current);
DPRINT("current %w\n",current);
current_hdr = ObDirLookup(current_dir,current);
if (current_hdr==NULL)
{
return(NULL);
}
DPRINT("Returning %x %x\n",current_hdr,HEADER_TO_BODY(current_hdr));
return(HEADER_TO_BODY(current_hdr));
return(Status);
}

View File

@@ -11,7 +11,7 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/objmgr.h>
#include <internal/ob.h>
#include <wstring.h>
#define NDEBUG
@@ -41,9 +41,10 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
PWSTR path;
PWSTR name;
PDIRECTORY_OBJECT parent;
PWSTR Ignored;
DPRINT("ObGenericCreateObject(Handle %x, DesiredAccess %x,"
"ObjectAttributes %x, Type %x)\n",Handle,DesiredAccess,ObjectAttributes,
"ObjectAttributes %x, Type %d)\n",Handle,DesiredAccess,ObjectAttributes,
Type);
/*
@@ -96,8 +97,9 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
name=name+1;
}
hdr->Parent = ObLookupObject(ObjectAttributes->RootDirectory,path);
ObLookupObject(ObjectAttributes->RootDirectory,path,
&hdr->Parent,&Ignored);
/*
* Initialize the object header
*/
@@ -168,6 +170,9 @@ VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
RtlInitUnicodeString(&obj->name,name);
DPRINT("name %w\n",obj->name.Buffer);
}
DPRINT("obj->Type %d\n",obj->Type);
DPRINT("obj %x\n",obj);
DPRINT("&(obj->Type) %x\n",&(obj->Type));
}

View File

@@ -12,6 +12,7 @@
#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS ******************************************************************/
@@ -21,10 +22,14 @@ HANDLE SystemProcessHandle = NULL;
/* FUNCTIONS *****************************************************************/
VOID PsInitProcessManagment(VOID)
{
InitializeListHead(&(SystemProcess.Pcb.MemoryAreaList));
}
PKPROCESS KeGetCurrentProcess(VOID)
{
return(NULL);
// return(&(PsGetCurrentProcess()->Pcb));
return(&(PsGetCurrentProcess()->Pcb));
}
struct _EPROCESS* PsGetCurrentProcess(VOID)
@@ -32,6 +37,7 @@ struct _EPROCESS* PsGetCurrentProcess(VOID)
* FUNCTION: Returns a pointer to the current process
*/
{
DPRINT("PsGetCurrentProcess() = %x\n",PsGetCurrentThread()->ThreadsProcess);
return(PsGetCurrentThread()->ThreadsProcess);
}

View File

@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: kernel/psmgr/psmgr.c
* FILE: ntoskrnl/ps/psmgr.c
* PURPOSE: Process managment
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
@@ -10,13 +10,14 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/psmgr.h>
#include <internal/ps.h>
/* FUNCTIONS ***************************************************************/
VOID PsInit(VOID)
{
ObjInitializeHandleTable(NULL);
PsInitProcessManagment();
PsInitThreadManagment();
PsInitIdleThread();
}

View File

@@ -21,10 +21,10 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/objmgr.h>
#include <internal/ob.h>
#include <internal/string.h>
#include <internal/hal.h>
#include <internal/psmgr.h>
#include <internal/ps.h>
#define NDEBUG
#include <internal/debug.h>
@@ -150,7 +150,7 @@ void PsDispatchThread(void)
if (current->ThreadState == THREAD_STATE_RUNNABLE &&
current != (PKTHREAD)CurrentThread)
{
DPRINT("Scheduling this one %x\n",current);
DPRINT("Scheduling this one %x\n",current);
CurrentThread = current;
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
KeReleaseSpinLock(&ThreadListLock,irql);

View File

@@ -22,6 +22,15 @@
#define Aa_Difference 'A'-'a';
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest,
PUNICODE_STRING Src)
{
if (Dest==NULL)
{
Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
}
}
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
{
UNIMPLEMENTED;
@@ -44,7 +53,7 @@ NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
unsigned long i;
if(AllocateDestinationString==TRUE) {
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
DestinationString->Buffer=ExAllocatePool(NonPagedPool, (SourceString->Length+1)*2);
DestinationString->MaximumLength=SourceString->Length;
};

View File

@@ -1,529 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/rtl/unicode.c
* PURPOSE: String functions
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
* UPDATE HISTORY:
* Created 10/08/98
* Fixed bugs 21/08/98
*/
#include <base.h>
#include <internal/string.h>
#include <ddk/ntddk.h>
#include <internal/ctype.h>
#include <internal/kernel.h>
#include <internal/debug.h>
#define Aa_Difference 'A'-'a';
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
{
UNIMPLEMENTED;
}
WCHAR wtoupper(WCHAR c)
{
if((c>='a') && (c<='z')) return c+Aa_Difference;
return c;
};
unsigned long wstrlen(PWSTR s)
{
WCHAR c=' ';
unsigned int len=0;
while(c!=0) {
c=*s;
s++;
len++;
};
s-=len;
return len-1;
};
ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
{
return AnsiString->Length*2;
};
NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PANSI_STRING SourceString, IN BOOLEAN AllocateDestinationString)
{
unsigned long i;
if(AllocateDestinationString==TRUE) {
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
DestinationString->MaximumLength=SourceString->Length;
};
DestinationString->Length=SourceString->Length;
memset(DestinationString->Buffer, 0, SourceString->Length*2);
for (i=0; i<SourceString->Length; i++)
{
*DestinationString->Buffer=*SourceString->Buffer;
SourceString->Buffer++;
DestinationString->Buffer++;
};
*DestinationString->Buffer=0;
SourceString->Buffer-=SourceString->Length;
DestinationString->Buffer-=SourceString->Length;
return STATUS_SUCCESS;
};
NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
IN PUNICODE_STRING Source)
{
unsigned long i;
if(Destination->MaximumLength-Destination->Length-Source->Length<0)
return STATUS_BUFFER_TOO_SMALL;
Destination->Buffer+=Destination->Length;
for(i=0; i<Source->Length; i++) {
*Destination->Buffer=*Source->Buffer;
Destination->Buffer++;
Source->Buffer++;
};
*Destination->Buffer=0;
Destination->Buffer-=(Destination->Length+Source->Length);
Source->Buffer-=Source->Length;
Destination->Length+=Source->Length;
return STATUS_SUCCESS;
};
NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
IN PWSTR Source)
{
unsigned long i, slen=wstrlen(Source);
if(Destination->MaximumLength-Destination->Length-slen<0)
return STATUS_BUFFER_TOO_SMALL;
Destination->Buffer+=Destination->Length;
for(i=0; i<slen; i++) {
*Destination->Buffer=*Source;
Destination->Buffer++;
Source++;
};
*Destination->Buffer=0;
Destination->Buffer-=(Destination->Length+slen);
Source-=slen;
Destination->Length+=slen;
return STATUS_SUCCESS;
};
NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
{
*Value=simple_strtoul((const char *)String, NULL, Base);
};
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
{
unsigned long i;
char c1, c2;
if(String1->Length!=String2->Length) return String1->Length-String2->Length;
for(i=0; i<String1->Length; i++) {
if(CaseInsensitive==TRUE) {
c1=toupper(*String1->Buffer);
c2=toupper(*String2->Buffer);
} else {
c1=*String1->Buffer;
c2=*String2->Buffer;
};
if(c1!=c2) {
String1->Buffer-=i;
String2->Buffer-=i;
return c1-c2;
};
String1->Buffer++;
String2->Buffer++;
};
String1->Buffer-=i;
String2->Buffer-=i;
return 0;
};
LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
BOOLEAN CaseInsensitive)
{
unsigned long i;
WCHAR wc1, wc2;
if(String1->Length!=String2->Length) return
String1->Length-String2->Length;
for(i=0; i<String1->Length; i++) {
if(CaseInsensitive==TRUE) {
wc1=wtoupper(*String1->Buffer);
wc2=wtoupper(*String2->Buffer);
} else {
wc1=*String1->Buffer;
wc2=*String2->Buffer;
};
if(wc1!=wc2) {
String1->Buffer-=i;
String2->Buffer-=i;
return wc1-wc2;
};
String1->Buffer++;
String2->Buffer++;
};
String1->Buffer-=i;
String2->Buffer-=i;
return 0;
};
VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
{
unsigned long copylen, i;
if(SourceString==NULL) {
DestinationString->Length=0;
} else {
if(SourceString->Length<DestinationString->MaximumLength) {
copylen=SourceString->Length;
} else {
copylen=DestinationString->MaximumLength;
};
for(i=0; i<copylen; i++)
{
*DestinationString->Buffer=*SourceString->Buffer;
DestinationString->Buffer++;
SourceString->Buffer++;
};
*DestinationString->Buffer=0;
DestinationString->Buffer-=copylen;
SourceString->Buffer-=copylen;
};
};
VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString)
{
unsigned long copylen, i;
if(SourceString==NULL) {
DestinationString->Length=0;
} else {
if(SourceString->Length<DestinationString->MaximumLength) {
copylen=SourceString->Length;
} else {
copylen=DestinationString->MaximumLength;
};
for(i=0; i<copylen; i++)
{
*DestinationString->Buffer=*SourceString->Buffer;
DestinationString->Buffer++;
SourceString->Buffer++;
};
*DestinationString->Buffer=0;
DestinationString->Buffer-=copylen;
SourceString->Buffer-=copylen;
};
};
BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
{
unsigned long s1l=String1->Length;
unsigned long s2l=String2->Length;
unsigned long i;
char c1, c2;
if(s1l!=s2l) return FALSE;
for(i=0; i<s1l; i++) {
c1=*String1->Buffer;
c2=*String2->Buffer;
if(CaseInsensitive==TRUE) {
c1=toupper(c1);
c2=toupper(c2);
};
if(c1!=c2) {
String1->Buffer-=i;
String2->Buffer-=i;
return FALSE;
};
String1->Buffer++;
String2->Buffer++;
};
String1->Buffer-=i;
String2->Buffer-=i;
return TRUE;
};
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
BOOLEAN CaseInsensitive)
{
unsigned long s1l=String1->Length;
unsigned long s2l=String2->Length;
unsigned long i;
char wc1, wc2;
if(s1l!=s2l) return FALSE;
for(i=0; i<s1l; i++) {
if(CaseInsensitive==TRUE) {
wc1=wtoupper(*String1->Buffer);
wc2=wtoupper(*String2->Buffer);
} else {
wc1=*String1->Buffer;
wc2=*String2->Buffer;
};
if(wc1!=wc2) {
String1->Buffer-=i;
String2->Buffer-=i;
return FALSE;
};
String1->Buffer++;
String2->Buffer++;
};
String1->Buffer-=i;
String2->Buffer-=i;
return TRUE;
};
VOID RtlFreeAnsiString(IN PANSI_STRING AnsiString)
{
ExFreePool(AnsiString->Buffer);
};
VOID RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
{
ExFreePool(UnicodeString->Buffer);
};
VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
IN PCSZ SourceString)
{
unsigned long DestSize;
if(SourceString==NULL) {
DestinationString->Length=0;
DestinationString->MaximumLength=0;
} else {
DestSize=strlen((const char *)SourceString);
DestinationString->Length=DestSize;
DestinationString->MaximumLength=DestSize+1;
};
DestinationString->Buffer=(PCHAR)SourceString;
};
VOID RtlInitString(IN OUT PSTRING DestinationString,
IN PCSZ SourceString)
{
DestinationString->Length=strlen((char *)SourceString);
DestinationString->MaximumLength=strlen((char *)SourceString)+1;
DestinationString->Buffer=SourceString;
};
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString)
{
unsigned long i, DestSize;
UNICODE_STRING Dest=*DestinationString;
if(SourceString==NULL) {
DestinationString->Length=0;
DestinationString->MaximumLength=0;
DestinationString->Buffer=NULL;
} else {
DestSize=wstrlen((PWSTR)SourceString);
DestinationString->Length=DestSize;
DestinationString->MaximumLength=DestSize+1;
DestinationString->Buffer=(PWSTR)SourceString;
};
};
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String)
{
char *str;
unsigned long len, i;
str=ExAllocatePool(NonPagedPool, 1024);
if(Base==16) {
sprintf(str, "%x", Value);
} else
if(Base==8) {
sprintf(str, "%o", Value);
} else
if(Base==2) {
sprintf(str, "%b", Value);
} else {
sprintf(str, "%u", Value);
};
len=strlen(str);
if(String->MaximumLength<len) return STATUS_INVALID_PARAMETER;
for(i=0; i<len; i++) {
*String->Buffer=*str;
String->Buffer++;
str++;
};
*String->Buffer=0;
String->Buffer-=len;
String->Length=len;
str-=len;
ExFreePool(str);
return STATUS_SUCCESS;
};
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
unsigned long i;
if(AllocateDestinationString==TRUE) {
// Causes excetion 14(0) in _Validate_Free_List
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length+1);
DestinationString->MaximumLength=SourceString->Length+1;
};
DestinationString->Length=SourceString->Length;
for(i=0; i<SourceString->Length; i++) {
*DestinationString->Buffer=*SourceString->Buffer;
DestinationString->Buffer++;
SourceString->Buffer++;
};
*DestinationString->Buffer=0;
DestinationString->Buffer-=SourceString->Length;
SourceString->Buffer-=SourceString->Length;
return STATUS_SUCCESS;
};
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
OUT PULONG Value)
{
char *str;
unsigned long i, lenmin=0;
BOOLEAN addneg=FALSE;
str=ExAllocatePool(NonPagedPool, String->Length+1);
for(i=0; i<String->Length; i++) {
*str=*String->Buffer;
if(*str=='b') { Base=2; lenmin++; } else
if(*str=='o') { Base=8; lenmin++; } else
if(*str=='d') { Base=10; lenmin++; } else
if(*str=='x') { Base=16; lenmin++; } else
if(*str=='+') { lenmin++; } else
if(*str=='-') { addneg=TRUE; lenmin++; } else
if((*str>'1') && (Base==2)) {
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
if(((*str>'7') || (*str<'0')) && (Base==8)) {
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
if(((*str>'9') || (*str<'0')) && (Base==10)) {
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
if((((*str>'9') || (*str<'0')) ||
((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
{
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
str++;
String->Buffer++;
};
*str=0;
String->Buffer-=String->Length;
str-=(String->Length-lenmin);
if(addneg==TRUE) {
*Value=simple_strtoul(str, NULL, Base)*-1;
} else
*Value=simple_strtoul(str, NULL, Base);
ExFreePool(str);
};
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
unsigned long i;
if(AllocateDestinationString==TRUE) {
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
DestinationString->Length=SourceString->Length;
DestinationString->MaximumLength=SourceString->Length+1;
};
for(i=0; i<SourceString->Length; i++) {
*DestinationString->Buffer=wtoupper(*SourceString->Buffer);
DestinationString->Buffer++;
SourceString->Buffer++;
};
*DestinationString->Buffer=0;
DestinationString->Buffer-=SourceString->Length;
SourceString->Buffer-=SourceString->Length;
return STATUS_SUCCESS;
};
VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
IN PSTRING SourceString)
{
unsigned long i, len;
if(SourceString->Length>DestinationString->MaximumLength) {
len=DestinationString->MaximumLength;
} else {
len=SourceString->Length;
};
for(i=0; i<len; i++) {
*DestinationString->Buffer=toupper(*SourceString->Buffer);
DestinationString->Buffer++;
SourceString->Buffer++;
};
*DestinationString->Buffer=0;
DestinationString->Buffer-=len;
SourceString->Buffer-=len;
};

View File

@@ -222,10 +222,25 @@ int vsprintf(char *buf, const char *fmt, va_list args)
case 'w':
sw = va_arg(args,short int *);
// DPRINT("L %x\n",sw);
while ((*sw)!=0)
if (sw==NULL)
{
*str++ = (char)(*sw++);
// CHECKPOINT;
s = "<NULL>";
while ((*s)!=0)
{
*str++ = *s++;
}
// CHECKPOINT;
// DbgPrint("str %x\n",str);
}
else
{
while ((*sw)!=0)
{
*str++ = (char)(*sw++);
}
}
// CHECKPOINT;
continue;
case 's':

View File

@@ -18,16 +18,15 @@
#define NDEBUG
#include <internal/debug.h>
#include <in.h>
int ShellChangeDir(char* args);
int ShellListDir(char* args);
VOID TstReadLineInit(VOID);
VOID TstReadLine(ULONG Length, PCHAR Buffer);
/* GLOBALS ******************************************************************/
static HANDLE CurrentDirHandle;
static UNICODE_STRING CurrentDirName;
static HANDLE KeyboardHandle;
static HANDLE CurrentDirHandle = NULL;
static UNICODE_STRING CurrentDirName = {NULL,0,0};
typedef struct
{
@@ -50,22 +49,28 @@ int ShellChangeDir(char* args)
int ShellListDir(char* args)
{
OBJDIR_INFORMATION DirObj[50];
ULONG Idx;
ULONG Length;
ULONG i;
ZwQueryDirectoryObject(CurrentDirHandle,
&(DirObj[0]),
sizeof(DirObj),
TRUE,
TRUE,
&Idx,
&Length);
for (i=0;i<(Length/sizeof(OBJDIR_INFORMATION));i++)
{
DbgPrint("Scanning %w\n",DirObj[i].ObjectName.Buffer);
}
}
VOID ShellDisplayPrompt()
{
printk("%w# ",CurrentDirName->Buffer);
}
VOID ShellGetCommand(char* cmd)
{
do
{
ZwReadFile(hfile,NULL,NULL,NULL,NULL,cmd,1,0,0);
printk("%c",*cmd);
cmd++;
} while((*cmd)!='\n');
*cmd=0;
printk("%w# ",CurrentDirName.Buffer);
}
VOID ShellProcessCommand(char* cmd)
@@ -88,6 +93,7 @@ NTSTATUS TstShell(VOID)
OBJECT_ATTRIBUTES attr;
char cmd[255];
RtlInitAnsiString(&astr,"\\");
RtlAnsiStringToUnicodeString(&CurrentDirName,&astr,TRUE);
@@ -95,17 +101,14 @@ NTSTATUS TstShell(VOID)
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenDirectoryObject(&CurrentDirHandle,0,&attr);
RtlInitAnsiString(&afilename,"\\Device\\Keyboard");
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenFile(&KeyboardHandle,0,&attr,NULL,0,0);
TstReadLineInit();
for(;;)
{
ShellDisplayPrompt();
ShellGetCommand(cmd);
TstReadLine(255,cmd);
ShellProcessCommand(cmd);
}
}

View File

@@ -14,7 +14,7 @@
#include <ddk/ntddk.h>
#include <internal/string.h>
#define NDEBUG
//#define NDEBUG
#include <internal/debug.h>
#include <in.h>
@@ -23,14 +23,17 @@
static KEVENT event = {};
//static KEVENT event2;
NTSTATUS TstShell(VOID);
/* FUNCTIONS ****************************************************************/
/*
NTSTATUS TstPlaySound(void)
NTSTATUS TstPlaySound(VOID)
{
HANDLE hfile;
// * Open the parallel port
/*
* Open the parallel port
*/
printk("Opening Waveout\n");
// hfile = CreateFile("\\Device\\WaveOut",0,0,0,0,0,0);
if (hfile == NULL)
@@ -45,23 +48,31 @@ NTSTATUS TstPlaySound(void)
NTSTATUS TstFirstThread(PVOID start)
{
int i;
printk("Beginning Thread A\n");
for (;;)
// for (i=0;i<10;i++)
{
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
printk("AAA ");
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
for (i=0;i<10000;i++);
}
}
NTSTATUS TstSecondThread(PVOID start)
{
int i;
printk("Beginning Thread B\n");
for (;;)
for(;;)
// for (i=0;i<10;i++)
{
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
printk("BBB ");
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
for (i=0;i<100000;i++);
}
}
@@ -69,23 +80,23 @@ NTSTATUS TstThreadSupport()
{
HANDLE th1, th2;
KeInitializeEvent(&event,SynchronizationEvent,FALSE);
KeInitializeEvent(&event,SynchronizationEvent,TRUE);
PsCreateSystemThread(&th1,0,NULL,NULL,NULL,TstFirstThread,NULL);
PsCreateSystemThread(&th2,0,NULL,NULL,NULL,TstSecondThread,NULL);
printk("Ending main thread\n");
for(;;);
}
void TstGeneralWrite()
void TstGeneralWrite(VOID)
{
OBJECT_ATTRIBUTES attr;
HANDLE hfile;
char buf[256];
char buf[512];
ANSI_STRING afilename;
UNICODE_STRING ufilename;
DbgPrint("Opening test device\n");
RtlInitAnsiString(&afilename,"\\Device\\Test");
RtlInitAnsiString(&afilename,"\\Device\\SDisk");
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
@@ -94,19 +105,19 @@ void TstGeneralWrite()
DbgPrint("Failed to open test device\n");
return;
}
strcpy(buf,"hello world");
ZwWriteFile(hfile,
ZwReadFile(hfile,
NULL,
NULL,
NULL,
NULL,
buf,
strlen(buf),
512,
0,
0);
DbgPrint("buf %s\n",buf);
}
/*
void TstParallelPortWrite()
void TstParallelPortWrite(VOID)
{
HANDLE hfile;
@@ -117,9 +128,9 @@ void TstParallelPortWrite()
DbgPrint("Failed to open parallel port\n");
}
// WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
}
}
void TstKeyboardRead()
void TstKeyboardRead(VOID)
{
OBJECT_ATTRIBUTES attr;
HANDLE hfile;
@@ -152,228 +163,52 @@ void TstKeyboardRead()
// DbgPrint("%c",key[1].AsciiChar);
}
}
*/
/* IDE TEST STUFF ***********************************************************/
typedef struct _BOOT_PARAMETERS {
WORD BytesBerSector;
BYTE SectorsPerAllocationUnit;
WORD ReservedSectorCount;
BYTE FATCount;
WORD RootDirEntryCount;
WORD TotalSectorCount;
BYTE MediaDescriptor;
WORD SectorsPerFAT;
WORD SectorsPerTrack;
WORD HeadCount;
DWORD HiddenSectorCount;
DWORD TotalSectorsInLogicalVolume;
} __attribute__ ((packed)) BOOT_PARAMETERS, __attribute__ ((packed)) *PBOOT_PARAMETERS;
typedef struct _BOOT_BLOCK {
char JumpInstruction[3];
char OEMName[8];
BOOT_PARAMETERS BootParameters;
BYTE DriveNumber;
BYTE Reserved1;
BYTE ExtBootSignatureRecord;
DWORD BinaryVolumeID;
char VolumeLabel[11];
char Reserved2[8];
char Bootstrap[512 - 61];
} __attribute__ ((packed)) BOOT_BLOCK, __attribute__ ((packed)) *PBOOT_BLOCK;
typedef struct _ROOT_DIR_ENTRY {
char Filename[8];
char Extension[3];
char FileAttribute;
char Reserved1[10];
WORD ModifiedTime;
WORD ModifiedDate;
WORD StartingCluster;
DWORD FileSize;
} __attribute__ ((packed)) ROOT_DIR_ENTRY;
#define ENTRIES_PER_BLOCK (512 / sizeof(ROOT_DIR_ENTRY))
void TstIDERead(void)
void TstFileRead(VOID)
{
BOOLEAN TestFailed;
int Entry, i;
HANDLE FileHandle;
NTSTATUS Status;
LARGE_INTEGER BlockOffset;
ANSI_STRING AnsiDeviceName;
UNICODE_STRING UnicodeDeviceName;
OBJECT_ATTRIBUTES ObjectAttributes;
char SectorBuffer[512];
PBOOT_BLOCK BootBlock;
ROOT_DIR_ENTRY DirectoryBlock[ENTRIES_PER_BLOCK];
OBJECT_ATTRIBUTES attr;
HANDLE hfile;
ANSI_STRING afilename;
UNICODE_STRING ufilename;
char ch;
IO_STATUS_BLOCK IoStatusBlock;
DbgPrint("Opening file\n");
RtlInitAnsiString(&afilename,"\\??\\C:\\my_other_directory\\..\\"
"my_valid_directory\\apc.txt");
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
if (hfile==NULL)
{
DbgPrint("Failed to open file\n");
return;
}
while (1)
{
// CHECKPOINT;
ZwReadFile(hfile,
NULL,
NULL,
NULL,
&IoStatusBlock,
&ch,
1,
NULL,
NULL);
DbgPrint("%c",ch);
}
CHECKPOINT;
}
DbgPrint("IDE Read Test\n");
TestFailed = FALSE;
/* open the first partition */
DbgPrint("Opening Partition1\n");
RtlInitAnsiString(&AnsiDeviceName, "\\Device\\HardDrive0\\Partition0");
RtlAnsiStringToUnicodeString(&UnicodeDeviceName, &AnsiDeviceName, TRUE);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeDeviceName,
0,
NULL,
NULL);
Status = ZwOpenFile(&FileHandle, 0, &ObjectAttributes, NULL, 0, 0);
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to open partition1\n");
TestFailed = TRUE;
}
/* Read the boot block */
if (!TestFailed)
{
DbgPrint("Reading boot block from Partition1\n");
RtlZeroMemory(SectorBuffer, sizeof(SectorBuffer));
DbgPrint("addr %x\n", SectorBuffer);
Status = ZwReadFile(FileHandle,
NULL,
NULL,
NULL,
NULL,
SectorBuffer,
sizeof(SectorBuffer),
0,
0);
if (Status != STATUS_SUCCESS /* !NT_SUCCESS(Status) */)
{
DbgPrint("Failed to read book block from partition1 status:%x\n", Status);
TestFailed = TRUE;
}
}
/* %%% Check for valid boot block signature */
/* Spew info about boot block */
if (!TestFailed)
{
for (i = 0; i < 64; i++)
{
if (!(i % 16))
{
DbgPrint("\n%04d: ", i);
}
DbgPrint("%02x ", (unsigned char)SectorBuffer[i]);
}
DbgPrint("\n");
BootBlock = (PBOOT_BLOCK) SectorBuffer;
DbgPrint("boot block on Partition1:\n");
DbgPrint(" OEM Name: %.8s Bytes/Sector:%d Sectors/Cluster:%d\n",
BootBlock->OEMName,
BootBlock->BootParameters.BytesBerSector,
BootBlock->BootParameters.SectorsPerAllocationUnit);
DbgPrint(" ReservedSectors:%d FATs:%d RootDirEntries:%d\n",
BootBlock->BootParameters.ReservedSectorCount,
BootBlock->BootParameters.FATCount,
BootBlock->BootParameters.RootDirEntryCount);
DbgPrint(" TotalSectors:%d MediaDescriptor:%d Sectors/FAT:%d\n",
BootBlock->BootParameters.TotalSectorCount,
BootBlock->BootParameters.MediaDescriptor,
BootBlock->BootParameters.SectorsPerFAT);
DbgPrint(" Sectors/Track:%d Heads:%d HiddenSectors:%d\n",
BootBlock->BootParameters.SectorsPerTrack,
BootBlock->BootParameters.HeadCount,
BootBlock->BootParameters.HiddenSectorCount);
DbgPrint(" VolumeLabel:%.11s\n", BootBlock->VolumeLabel);
}
for(;;);
/* Read the first root directory block */
if (!TestFailed)
{
DbgPrint("Reading rootdir block from Partition1\n");
BlockOffset.HighPart = 0;
BlockOffset.LowPart = BootBlock->BootParameters.ReservedSectorCount * 512 +
BootBlock->BootParameters.FATCount *
BootBlock->BootParameters.SectorsPerFAT * 512;
Status = ZwReadFile(FileHandle,
NULL,
NULL,
NULL,
NULL,
DirectoryBlock,
sizeof(DirectoryBlock),
&BlockOffset,
0);
if (Status != STATUS_SUCCESS /* !NT_SUCCESS(Status) */)
{
DbgPrint("Failed to read root directory block from partition1\n");
TestFailed = TRUE;
}
}
/* Print the contents */
if (!TestFailed)
{
for (Entry = 0; Entry < ENTRIES_PER_BLOCK; Entry++)
{
switch (DirectoryBlock[Entry].Filename[0])
{
case 0x00:
DbgPrint("End of Directory.\n");
Entry = ENTRIES_PER_BLOCK;
break;
case 0x05:
DbgPrint(" FILE: %c%.7s.%.3s ATTR:%x Time:%04x Date:%04x offset:%d size:%d\n",
0xe5,
&DirectoryBlock[Entry].Filename[1],
DirectoryBlock[Entry].Extension,
DirectoryBlock[Entry].FileAttribute,
DirectoryBlock[Entry].ModifiedTime,
DirectoryBlock[Entry].ModifiedDate,
DirectoryBlock[Entry].StartingCluster,
DirectoryBlock[Entry].FileSize);
break;
case 0x2e:
DbgPrint(" ALIAS: %.8s ATTR:%x Time:%04x Date:%04x offset:%d size:%d\n",
&DirectoryBlock[Entry].Filename[1],
DirectoryBlock[Entry].FileAttribute,
DirectoryBlock[Entry].ModifiedTime,
DirectoryBlock[Entry].ModifiedDate,
DirectoryBlock[Entry].StartingCluster,
DirectoryBlock[Entry].FileSize);
break;
case 0xe5:
break;
default:
DbgPrint(" FILE: %.8s.%.3s ATTR:%x Time:%04x Date:%04x offset:%d size:%d\n",
&DirectoryBlock[Entry].Filename[1],
DirectoryBlock[Entry].Extension,
DirectoryBlock[Entry].FileAttribute,
DirectoryBlock[Entry].ModifiedTime,
DirectoryBlock[Entry].ModifiedDate,
DirectoryBlock[Entry].StartingCluster,
DirectoryBlock[Entry].FileSize);
break;
}
}
}
if (FileHandle != NULL)
{
ZwClose(FileHandle);
}
}
void TstBegin()
{
TstFileRead();
// TstGeneralWrite();
// TstThreadSupport();
// TstKeyboardRead();
TstIDERead();
// TstShell();
}

View File

@@ -45,7 +45,7 @@ endif
DEFINES = -DCHECKED_BUILD -DWIN32_LEAN_AND_MEAN -DDBG
CC = $(PREFIX)gcc
NATIVE_CC = gcc
CFLAGS = -O2 -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
CFLAGS = -O2 -I../../../include -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
CXXFLAGS = $(CFLAGS)
NASM = nasm
NFLAGS = -i../include/ -f$(NASM_FORMAT)