Compare commits

...

11 Commits

Author SHA1 Message Date
The ReactOS Team
b9855717d2 This commit was manufactured by cvs2svn to create tag 'krnl0012'.
svn path=/tags/krnl0012/; revision=54
1998-10-05 04:01:30 +00:00
Rex Jolliff
95f1659d23 import of v12
svn path=/branches/ros/; revision=52
1998-10-05 04:01:30 +00:00
The ReactOS Team
0927cf2cfa This commit was manufactured by cvs2svn to create branch 'ros'.
svn path=/branches/ros/; revision=51
1998-10-05 04:01:30 +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
156 changed files with 8855 additions and 9141 deletions

View File

@@ -1 +1 @@
loaders\dos\loadros ntoskrnl\kimage.bin %1 %2 %3 %4
loaders\dos\loadros ntoskrnl\kimage.bin services\dd\ide\ide.o services\fs\vfat\vfatfsd.o services\dd\keyboard\keyboard.o %2 %3 %4

View File

@@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -20,8 +20,5 @@ IoInitializeDpc
IoInitializeTimer
IoStartTimer
IoStopTimer
Partially implemented
IoCreateDevice
IoCallDriver

View File

@@ -1,31 +0,0 @@
* Kernel things implemented [exceptions in brackets]
Spinlocks [Uniprocessor only]
IRQ levels [Not APC_LEVEL or WAKE_LEVEL, uniprocessor only]
ISRs [Partial, uniprocessor only]
Timers [Untested]
DPCs [Untested]
Objects [Partial]
Namespace [Partial]
Handle tables [One process only]
Threads [Some initial work]
RTL list functions [All except sequenced lists]
Zones [Untested]
Memory pool [Working but semantics partially incompatiable]
Device objects [Some but no support for layering]
IRP [Partial]
Memory sections [Partial, no file mappings]
PCI interface [Probes but no support]
CreateFile API [Device only]
ReadFile/WriteFile API [Device only]
MDL functions [Untested]
* Kernel things unimplemented (partial)
Add support for source level debugging to Bochs
Support for remote debugging
Process managment
Dispatcher objects (Mutex, Semaphore etc)
Investigate user and kernel mode APCs
Asynchronous I/O
Optimization

View File

@@ -15,7 +15,7 @@
#define NDEBUG
#include <internal/debug.h>
#include "minix_fs.h"
#include "minix.h"
/* FUNCTIONS ***************************************************************/
@@ -34,6 +34,7 @@ BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
DPRINT("MinixReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject,DiskSector,Buffer);
sectorNumber.HighPart = 0;
sectorNumber.LowPart = DiskSector * BLOCKSIZE;
KeInitializeEvent(&event, NotificationEvent, FALSE);
@@ -82,3 +83,51 @@ BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
ExFreePool(mbr);
return TRUE;
}
BOOLEAN MinixWriteSector(IN PDEVICE_OBJECT pDeviceObject,
IN ULONG DiskSector,
IN UCHAR* Buffer)
{
LARGE_INTEGER sectorNumber;
PIRP irp;
IO_STATUS_BLOCK ioStatus;
KEVENT event;
NTSTATUS status;
ULONG sectorSize;
DPRINT("MinixWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject,DiskSector,Buffer);
sectorNumber.LowPart = DiskSector * BLOCKSIZE;
KeInitializeEvent(&event, NotificationEvent, FALSE);
sectorSize = BLOCKSIZE;
irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
pDeviceObject,
Buffer,
sectorSize,
&sectorNumber,
&event,
&ioStatus );
status = IoCallDriver(pDeviceObject,
irp);
if (status == STATUS_PENDING) {
KeWaitForSingleObject(&event,
Suspended,
KernelMode,
FALSE,
NULL);
status = ioStatus.Status;
}
if (!NT_SUCCESS(status)) {
return FALSE;
}
return TRUE;
}

View File

@@ -1,2 +1,9 @@
all: minix.o blockdev.o
$(LD) -r minix.o blockdev.o -o minixfsd.o
OBJECTS = block.o rw.o inode.o dir.o mount.o blockdev.o
all: minix.o
minix.o: $(OBJECTS)
$(LD) -r $(OBJECTS) -o minix.o
WIN32_LEAN_AND_MEAN = yes
include ../../../rules.mak

View File

@@ -1,454 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: services/fs/minix/minix.c
* PURPOSE: Minix FSD
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
*/
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/string.h>
#include <wstring.h>
#define NDEBUG
#include <internal/debug.h>
#include "minix_fs.h"
/* GLOBALS ******************************************************************/
static PDRIVER_OBJECT DriverObject;
typedef struct
{
PDEVICE_OBJECT AttachedDevice;
struct minix_inode root_inode;
char superblock_buf[BLOCKSIZE];
struct minix_super_block* sb;
} MINIX_DEVICE_EXTENSION;
/* FUNCTIONS ****************************************************************/
static unsigned int MinixGetIndirectBlock(struct minix_inode* inode,
unsigned char* buffer, int blk)
{
unsigned short int* buf = (unsigned short int *)buffer;
return(buf[blk]);
}
static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
struct minix_inode* inode,
int blk)
{
int block;
char* buffer;
DPRINT("MinixGetBlock(inode %x, blk %d)\n",inode,blk);
if (blk < 7)
{
block = inode->i_zone[blk];
return(block);
}
blk = blk - 7;
buffer = ExAllocatePool(NonPagedPool,1024);
if (blk < 512)
{
block = inode->i_zone[7];
MinixReadSector(DeviceObject,block,buffer);
block = MinixGetIndirectBlock(inode,buffer,blk);
ExFreePool(buffer);
return(block);
}
blk = blk - 512;
block = inode->i_zone[8];
MinixReadSector(DeviceObject,block,buffer);
block = MinixGetIndirectBlock(inode,buffer,(blk>>9)&511);
MinixReadSector(DeviceObject,block,buffer);
block = MinixGetIndirectBlock(inode,buffer,blk&511);
ExFreePool(buffer);
return(block);
}
NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
struct minix_inode* inode,
int blk,
PVOID buffer)
{
unsigned int block;
DPRINT("MinixReadBlock(inode %x, blk %d, buffer %x)\n",inode,blk,buffer);
block = MinixGetBlock(DeviceObject,inode,blk);
DPRINT("block %d\n",block);
return(MinixReadSector(DeviceObject,block,buffer));
}
VOID MinixMount(PDEVICE_OBJECT DeviceToMount)
{
PDEVICE_OBJECT DeviceObject;
MINIX_DEVICE_EXTENSION* DeviceExt;
IoCreateDevice(DriverObject,
sizeof(MINIX_DEVICE_EXTENSION),
NULL,
FILE_DEVICE_FILE_SYSTEM,
0,
FALSE,
&DeviceObject);
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
DeviceExt = DeviceObject->DeviceExtension;
MinixReadSector(DeviceToMount,1,DeviceExt->superblock_buf);
DeviceExt->sb = (struct minix_super_block *)(DeviceExt->superblock_buf);
DeviceExt->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
DeviceToMount);
}
NTSTATUS MinixFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PVPB vpb = Stack->Parameters.Mount.Vpb;
PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
NTSTATUS Status;
char* superblock_buf;
struct minix_super_block* sb;
DbgPrint("MinixFileSystemControl(DeviceObject %x, Irp %x)\n",DeviceObject,
Irp);
DPRINT("DeviceToMount %x\n",DeviceToMount);
superblock_buf = ExAllocatePool(NonPagedPool,BLOCKSIZE);
DPRINT("MinixReadSector %x\n",MinixReadSector);
MinixReadSector(DeviceToMount,1,superblock_buf);
sb = (struct minix_super_block *)superblock_buf;
DPRINT("Magic %x\n",sb->s_magic);
DPRINT("Imap blocks %x\n",sb->s_imap_blocks);
DPRINT("Zmap blocks %x\n",sb->s_zmap_blocks);
if (sb->s_magic==MINIX_SUPER_MAGIC2)
{
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
MinixMount(DeviceToMount);
Status = STATUS_SUCCESS;
}
else
{
DPRINT("%s() = STATUS_UNRECOGNIZED_VOLUME\n",__FUNCTION__);
Status = STATUS_UNRECOGNIZED_VOLUME;
}
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}
NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
MINIX_DEVICE_EXTENSION* DeviceExt,
ULONG ino,
struct minix_inode* result)
{
int block;
char* buffer;
struct minix_inode* inodes;
DPRINT("MinixReadInode(ino %x, result %x)\n",ino,result);
buffer = ExAllocatePool(NonPagedPool,1024);
inodes = (struct minix_inode *)buffer;
block = 2 + DeviceExt->sb->s_imap_blocks + DeviceExt->sb->s_zmap_blocks
+ ((ino-1) / MINIX_INODES_PER_BLOCK);
DPRINT("Reading block %x offset %x\n",block,block*BLOCKSIZE);
DPRINT("Index %x\n",(ino-1)%MINIX_INODES_PER_BLOCK);
MinixReadSector(DeviceObject,block,buffer);
memcpy(result,&inodes[(ino-1)%MINIX_INODES_PER_BLOCK],
sizeof(struct minix_inode));
DPRINT("result->i_uid %x\n",result->i_uid);
DPRINT("result->i_size %x\n",result->i_size);
return(STATUS_SUCCESS);
}
BOOLEAN MinixCompareUnicodeStringToAnsi(PCH AnsiStr, PWCHAR UnicodeStr,
ULONG MaxLen)
{
unsigned int i = 0;
while (i<MaxLen)
{
if ((*AnsiStr)!=(*UnicodeStr))
{
return(FALSE);
}
if ((*AnsiStr)==0 && (*UnicodeStr)==0)
{
return(TRUE);
}
AnsiStr++;
UnicodeStr++;
i++;
}
return(TRUE);
}
ULONG MinixDirLookup(PDEVICE_OBJECT DeviceObject,
struct minix_inode* dir,
PWCHAR Name)
{
char* buffer;
struct minix_dir_entry* entry;
unsigned int offset;
unsigned int i;
unsigned int inode;
buffer=ExAllocatePool(NonPagedPool,BLOCKSIZE);
for (i=0;i<(dir->i_size/MINIX_DIR_ENTRY_SIZE);i++)
{
offset = i*MINIX_DIR_ENTRY_SIZE;
if ((offset%BLOCKSIZE)==0)
{
MinixReadBlock(DeviceObject,
dir,
offset/BLOCKSIZE,
buffer);
}
entry = (struct minix_dir_entry *)&buffer[offset%BLOCKSIZE];
DPRINT("Inode %x Name %.30s\n",entry->inode,entry->name);
if (MinixCompareUnicodeStringToAnsi(entry->name,Name,30))
{
inode = entry->inode;
ExFreePool(buffer);
DPRINT("MinixDirLookup() = %d\n",inode);
return(inode);
}
}
ExFreePool(buffer);
DPRINT("MinixDirLookup() = %d\n",0);
return(0);
}
NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
MINIX_DEVICE_EXTENSION* DeviceExt,
PWSTR DeviceName,
struct minix_inode* result)
{
PWSTR current;
PWSTR next;
PWSTR string = DeviceName;
struct minix_inode current_dir;
unsigned int current_ino;
DbgPrint("MinixOpen(DeviceObject %x, DeviceName %w, result %x)\n",
DeviceObject,DeviceName,result);
DPRINT("DeviceName %x\n",DeviceName);
next = &string[0];
current = next+1;
current_ino = MINIX_ROOT_INO;
while (next!=NULL && current_ino!=0)
{
MinixReadInode(DeviceObject,DeviceExt,current_ino,&current_dir);
DPRINT("current %w next %x\n",current,next);
*next = '\\';
current = next+1;
next = wcschr(next+1,'\\');
if (next!=NULL)
{
*next=0;
}
current_ino = MinixDirLookup(DeviceObject,&current_dir,current);
}
if (next==NULL && current_ino!=0)
{
MinixReadInode(DeviceObject,DeviceExt,current_ino,&current_dir);
}
memcpy(result,&current_dir,sizeof(struct minix_inode));
DPRINT("MinxOpen() = STATUS_SUCCESS\n",0);
return(STATUS_SUCCESS);
}
NTSTATUS MinixWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
DPRINT("MinixWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
Irp->IoStatus.Information = 0;
return(STATUS_UNSUCCESSFUL);
}
NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
ULONG Length;
PVOID Buffer;
ULONG Offset;
ULONG CurrentOffset;
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT FileObject = Stack->FileObject;
MINIX_DEVICE_EXTENSION* DeviceExt = DeviceObject->DeviceExtension;
struct minix_inode* inode = (struct minix_inode *)FileObject->FsContext;
PVOID TempBuffer;
unsigned int i;
DPRINT("MinixRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
Length = Stack->Parameters.Read.Length;
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
Offset = Stack->Parameters.Read.ByteOffset.LowPart;
TempBuffer = ExAllocatePool(NonPagedPool,BLOCKSIZE);
DPRINT("Length %x Buffer %x Offset %x\n",Length,Buffer,Offset);
CurrentOffset=Offset;
if ((Offset%BLOCKSIZE)!=0)
{
CHECKPOINT;
CurrentOffset = Offset - (Offset%BLOCKSIZE);
MinixReadBlock(DeviceExt->AttachedDevice,inode,
CurrentOffset/BLOCKSIZE,
TempBuffer);
memcpy(Buffer,TempBuffer+(Offset%BLOCKSIZE),
min(BLOCKSIZE - (Offset%BLOCKSIZE),Length));
DPRINT("(BLOCKSIZE - (Offset%BLOCKSIZE)) %d\n",
(BLOCKSIZE - (Offset%BLOCKSIZE)));
DPRINT("Length %d\n",Length);
CurrentOffset = CurrentOffset + BLOCKSIZE;
Buffer = Buffer + BLOCKSIZE - (Offset%BLOCKSIZE);
Length = Length - min(BLOCKSIZE - (Offset%BLOCKSIZE),Length);
DPRINT("CurrentOffset %d Buffer %x Length %d\n",CurrentOffset,Buffer,
Length);
}
for (i=0;i<(Length/BLOCKSIZE);i++)
{
CHECKPOINT;
MinixReadBlock(DeviceExt->AttachedDevice,inode,
CurrentOffset/BLOCKSIZE,Buffer);
CurrentOffset = CurrentOffset + BLOCKSIZE;
Buffer = Buffer + BLOCKSIZE;
Length = Length - BLOCKSIZE;
}
if (Length > 0)
{
CHECKPOINT;
MinixReadBlock(DeviceExt->AttachedDevice,inode,
CurrentOffset/BLOCKSIZE,
TempBuffer);
memcpy(Buffer,TempBuffer,Length);
}
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = Length;
return(STATUS_SUCCESS);
}
NTSTATUS MinixClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT FileObject = Stack->FileObject;
DPRINT("MinixClose(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
ExFreePool(FileObject->FsContext);
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(STATUS_SUCCESS);
}
NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT FileObject = Stack->FileObject;
NTSTATUS Status;
struct minix_inode* result;
MINIX_DEVICE_EXTENSION* DeviceExt;
DPRINT("MinixCreate(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
DPRINT("Opening file %x %w\n",FileObject->FileName.Buffer,
FileObject->FileName.Buffer);
DPRINT("FileObject->FileName.Buffer %x\n",
FileObject->FileName.Buffer);
DeviceExt = (MINIX_DEVICE_EXTENSION *)DeviceObject->DeviceExtension;
result = ExAllocatePool(NonPagedPool,sizeof(struct minix_inode));
DPRINT("result %x\n",result);
Status = MinixOpen(DeviceExt->AttachedDevice,DeviceExt,
FileObject->FileName.Buffer,result);
if (Status==STATUS_SUCCESS)
{
FileObject->FsContext=result;
}
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}
NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
PUNICODE_STRING RegistryPath)
/*
* FUNCTION: Called by the system to initalize the driver
* ARGUMENTS:
* DriverObject = object describing this driver
* RegistryPath = path to our configuration entries
* RETURNS: Success or failure
*/
{
PDEVICE_OBJECT DeviceObject;
NTSTATUS ret;
UNICODE_STRING ustr;
ANSI_STRING astr;
DbgPrint("Minix FSD 0.0.1\n");
DriverObject = _DriverObject;
RtlInitAnsiString(&astr,"\\Device\\Minix");
RtlAnsiStringToUnicodeString(&ustr,&astr,TRUE);
ret = IoCreateDevice(DriverObject,0,&ustr,
FILE_DEVICE_PARALLEL_PORT,0,FALSE,&DeviceObject);
if (ret!=STATUS_SUCCESS)
{
return(ret);
}
DeviceObject->Flags=0;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = MinixWrite;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
MinixFileSystemControl;
DriverObject->DriverUnload = NULL;
IoRegisterFileSystem(DeviceObject);
return(STATUS_SUCCESS);
}

View File

@@ -1,80 +0,0 @@
#define MINIX_ROOT_INO 1
/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
#define MINIX_LINK_MAX 250
#define MINIX_I_MAP_SLOTS 8
#define MINIX_Z_MAP_SLOTS 64
#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
#define MINIX_VALID_FS 0x0001 /* Clean fs. */
#define MINIX_ERROR_FS 0x0002 /* fs has errors. */
#define MINIX_INODES_PER_BLOCK ((BLOCKSIZE)/(sizeof (struct minix_inode)))
#define MINIX2_INODES_PER_BLOCK ((BLOCKSIZE)/(sizeof (struct minix2_inode)))
#define MINIX_V1 0x0001 /* original minix fs */
#define MINIX_V2 0x0002 /* minix V2 fs */
/*
* This is the original minix inode layout on disk.
* Note the 8-bit gid and atime and ctime.
*/
struct minix_inode {
unsigned short int i_mode;
unsigned short int i_uid;
unsigned long i_size;
unsigned long i_time;
unsigned char i_gid;
unsigned char i_nlinks;
unsigned short int i_zone[9];
};
/*
* The new minix inode has all the time entries, as well as
* long block numbers and a third indirect block (7+1+1+1
* instead of 7+1+1). Also, some previously 8-bit values are
* now 16-bit. The inode is now 64 bytes instead of 32.
*/
struct minix2_inode {
unsigned short int i_mode;
unsigned short int i_nlinks;
unsigned short int i_uid;
unsigned short int i_gid;
unsigned long i_size;
unsigned long i_atime;
unsigned long i_mtime;
unsigned long i_ctime;
unsigned long i_zone[10];
};
/*
* minix super-block data on disk
*/
struct minix_super_block {
unsigned short int s_ninodes;
unsigned short int s_nzones;
unsigned short int s_imap_blocks;
unsigned short int s_zmap_blocks;
unsigned short int s_firstdatazone;
unsigned short int s_log_zone_size;
unsigned long s_max_size;
unsigned short int s_magic;
unsigned short int s_state;
unsigned long s_zones;
};
struct minix_dir_entry {
unsigned short int inode;
char name[0];
};
#define MINIX_DIR_ENTRY_SIZE (sizeof(struct minix_dir_entry)+30)
BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
IN ULONG DiskSector,
IN UCHAR* Buffer);
#define BLOCKSIZE (1024)

View File

@@ -1,11 +0,0 @@
These are a selection of services for the ReactOS kernel. They include
parallel = parallel port driver
serial = serial port driver
mouse = mouse driver
null = null device driver
ide = IDE (hard disk) driver
keyboard = keyboard driver
loop = Allows accessing a file as a block device
scramdisk = Filesystem encryption driver
event = Sample driver demonstrating notifying a user thread using an event

View File

@@ -43,9 +43,127 @@ extern "C" {
#endif
#endif /* !NULL */
/*
* Definitions needed for the ddk includes (we miss out win32 only stuff to
* cut down on the compile time)
*/
typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef unsigned short WCHAR;
typedef unsigned short WORD;
typedef int WINBOOL;
typedef unsigned char BOOLEAN;
typedef unsigned int DWORD; /* was unsigned long */
typedef unsigned short *LPWSTR;
typedef unsigned short *PWSTR;
typedef unsigned char *PUCHAR;
typedef unsigned int *PUINT;
typedef unsigned long *PULONG;
typedef unsigned short *PUSHORT;
typedef void *PVOID;
typedef unsigned char BYTE;
typedef void *LPVOID;
/* Check VOID before defining CHAR, SHORT, and LONG */
#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
#endif
typedef CHAR *PCHAR;
typedef CHAR *PCH;
typedef void *HANDLE;
typedef char CCHAR;
typedef enum _SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation
} SECURITY_IMPERSONATION_LEVEL;
typedef enum tagTOKEN_TYPE {
TokenPrimary = 1,
TokenImpersonation
} TOKEN_TYPE;
#define FALSE 0
#define TRUE 1
typedef const unsigned short *PCWSTR;
typedef char* PCSZ;
#define CONST const
#ifdef i386
#define STDCALL __attribute__ ((stdcall))
#define CDECL __attribute((cdecl))
#define CALLBACK WINAPI
#define PASCAL WINAPI
#else
#define STDCALL
#define CDECL
#define CALLBACK
#define PASCAL
#endif
#define WINAPI STDCALL
#define APIENTRY STDCALL
#define WINGDIAPI
typedef BYTE *PBOOLEAN;
typedef HANDLE *PHANDLE;
typedef DWORD CALLBACK (*PTHREAD_START_ROUTINE) (LPVOID);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
typedef unsigned short ATOM;
#ifdef UNICODE
typedef unsigned short *LPTCH;
typedef unsigned short *LPTSTR;
#else
typedef char *LPTCH;
typedef char *LPTSTR;
#endif /* UNICODE */
typedef long *PLONG;
typedef unsigned short *PWCHAR;
typedef char *LPSTR;
typedef double LONGLONG, *PLONGLONG;
typedef enum _MEDIA_TYPE {
Unknown,
F5_1Pt2_512,
F3_1Pt44_512,
F3_2Pt88_512,
F3_20Pt8_512,
F3_720_512,
F5_360_512,
F5_320_512,
F5_320_1024,
F5_180_512,
F5_160_512,
RemovableMedia,
FixedMedia
} MEDIA_TYPE;
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef WIN32_LEAN_AND_MEAN
#ifndef RC_INVOKED
/* typedef ACMDRIVERENUMCB;
@@ -58,30 +176,15 @@ typedef ACMFORMATENUMCB;
typedef ACMFORMATTAGENUMCB;
typedef APPLET_PROC;
*/
typedef unsigned short ATOM;
/* Changed from BOOL to WINBOOL to avoid Objective-C conflict */
typedef int WINBOOL;
typedef unsigned char BOOLEAN;
typedef unsigned char BYTE;
typedef unsigned long CALTYPE;
typedef unsigned long CALID;
typedef char CCHAR;
typedef unsigned long COLORREF;
#define CONST const
/* Check VOID before defining CHAR, SHORT, and LONG */
#ifndef VOID
#define VOID void
typedef char CHAR;
typedef short SHORT;
typedef long LONG;
#endif
/*
typedef CTRYID;
typedef DLGPROC;
*/
typedef unsigned int DWORD; /* was unsigned long */
typedef double DWORDLONG, *PDWORDLONG;
/*
typedef EDITWORDBREAKPROC;
@@ -92,7 +195,6 @@ typedef ENUMRESTYPEPROC;
*/
typedef float FLOAT;
/* typedef GLOBALHANDLE; */
typedef void *HANDLE;
typedef HANDLE HACCEL;
typedef HANDLE HBITMAP;
typedef HANDLE HBRUSH;
@@ -138,7 +240,6 @@ typedef unsigned short LANGID;
typedef DWORD LCID;
typedef DWORD LCTYPE;
/* typedef LOCALHANDLE */
typedef double LONGLONG, *PLONGLONG;
typedef unsigned short *LP;
typedef long LPARAM;
typedef WINBOOL *LPBOOL;
@@ -147,7 +248,6 @@ typedef CONST CHAR *LPCCH;
typedef CHAR *LPCH;
typedef COLORREF *LPCOLORREF;
typedef const char *LPCSTR;
typedef char* PCSZ;
#ifdef UNICODE
typedef const unsigned short *LPCTSTR;
@@ -163,41 +263,23 @@ typedef HANDLE *LPHANDLE;
/* typedef LPHANDLER_FUNCTION; */
typedef int *LPINT;
typedef long *LPLONG;
typedef char *LPSTR;
#ifdef UNICODE
typedef unsigned short *LPTCH;
typedef unsigned short *LPTSTR;
#else
typedef char *LPTCH;
typedef char *LPTSTR;
#endif /* UNICODE */
typedef long LRESULT;
typedef void *LPVOID;
typedef const void *LPCVOID;
typedef unsigned short *LPWCH;
typedef unsigned short *LPWORD;
typedef unsigned short *LPWSTR;
typedef unsigned short *PWSTR;
/* typedef NPSTR; */
typedef unsigned short *NWPSTR;
typedef WINBOOL *PWINBOOL;
typedef BYTE *PBOOLEAN;
typedef BYTE *PBYTE;
typedef const CHAR *PCCH;
typedef CHAR *PCH;
typedef CHAR *PCHAR;
typedef const char *PCSTR;
typedef const unsigned short *PCWCH;
typedef const unsigned short *PCWSTR;
typedef DWORD *PDWORD;
typedef float *PFLOAT;
typedef HANDLE *PHANDLE;
/* typedef PHKEY; */
typedef int *PINT;
/* typedef LCID *PLCID; */
typedef long *PLONG;
typedef short *PSHORT;
/* typedef PSID; */
typedef char *PSTR;
@@ -215,13 +297,7 @@ typedef char *PTCHAR;
typedef char *PTSTR;
#endif /* UNICODE */
typedef unsigned char *PUCHAR;
typedef unsigned int *PUINT;
typedef unsigned long *PULONG;
typedef unsigned short *PUSHORT;
typedef void *PVOID;
typedef unsigned short *PWCH;
typedef unsigned short *PWCHAR;
typedef unsigned short *PWORD;
/*
typedef PWSTR;
@@ -246,30 +322,10 @@ typedef char TCHAR;
typedef BYTE BCHAR;
#endif /* UNICODE */
typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef unsigned short WCHAR;
typedef unsigned short WORD;
typedef unsigned int WPARAM;
/* typedef YIELDPROC; */
/* Only use __stdcall under WIN32 compiler */
#ifdef i386
#define STDCALL __attribute__ ((stdcall))
#define CDECL __attribute((cdecl))
#define CALLBACK WINAPI
#define PASCAL WINAPI
#else
#define STDCALL
#define CDECL
#define CALLBACK
#define PASCAL
#endif
#define WINAPI STDCALL
#define APIENTRY STDCALL
#define WINGDIAPI
#define _export
@@ -281,21 +337,6 @@ typedef enum _ACL_INFORMATION_CLASS {
AclSizeInformation
} ACL_INFORMATION_CLASS;
typedef enum _MEDIA_TYPE {
Unknown,
F5_1Pt2_512,
F3_1Pt44_512,
F3_2Pt88_512,
F3_20Pt8_512,
F3_720_512,
F5_360_512,
F5_320_512,
F5_320_1024,
F5_180_512,
F5_160_512,
RemovableMedia,
FixedMedia
} MEDIA_TYPE;
#define RASCS_DONE 0x2000
#define RASCS_PAUSED 0x1000
@@ -339,14 +380,7 @@ typedef enum _RASPROJECTION {
RASP_PppIpx = 0x802B,
RASP_PppIp = 0x8021
} RASPROJECTION ;
typedef enum _SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation
} SECURITY_IMPERSONATION_LEVEL;
typedef enum _SID_NAME_USE {
SidTypeUser = 1,
SidTypeGroup,
@@ -370,12 +404,7 @@ typedef enum _TOKEN_INFORMATION_CLASS {
TokenImpersonationLevel,
TokenStatistics
} TOKEN_INFORMATION_CLASS;
typedef enum tagTOKEN_TYPE {
TokenPrimary = 1,
TokenImpersonation
} TOKEN_TYPE;
#endif /* ! defined (RC_INVOKED) */
/*
@@ -421,13 +450,6 @@ typedef enum tagTOKEN_TYPE {
#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
#define MAKEWPARAM(l, h) ((WPARAM) MAKELONG(l, h))
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define PALETTEINDEX(i) ((COLORREF) (0x01000000 | (DWORD) (WORD) (i)))
#define PALETTERGB(r, g, b) (0x02000000 | RGB(r, g, b))
@@ -451,8 +473,6 @@ typedef enum tagTOKEN_TYPE {
typedef int CALLBACK (*BFFCALLBACK) (HWND, UINT, LPARAM, LPARAM);
typedef UINT CALLBACK (*LPCCHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPCFHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef DWORD CALLBACK (*PTHREAD_START_ROUTINE) (LPVOID);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
typedef DWORD CALLBACK (*EDITSTREAMCALLBACK) (DWORD, LPBYTE, LONG, LONG);
typedef UINT CALLBACK (*LPFRHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
typedef UINT CALLBACK (*LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
@@ -565,6 +585,8 @@ typedef DWORD CCSTYLEFLAGA, *PCCSTYLEFLAGA, *LPCCSTYLEFLAGA;
#endif /* ! defined (RC_INVOKED) */
#endif /* WIN32_LEAN_AND_MEAN */
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -94,3 +94,59 @@ PLIST_ENTRY ExInterlockedInsertHeadList(PLIST_ENTRY ListHead,
VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
WORK_QUEUE_TYPE QueueType);
VOID ExRaiseStatus(NTSTATUS Status);
VOID ExReinitializeResourceLite(PERESOURCE Resource);
VOID ExReleaseFastMutex(PFAST_MUTEX Mutex);
VOID ExReleaseFastMutexUnsafe(PFAST_MUTEX Mutex);
VOID ExReleaseResource(PERESOURCE Resource);
VOID ExReleaseResourceForThread(PERESOURCE Resource,
ERESOURCE_THREAD ResourceThreadId);
VOID ExReleaseResourceForThreadLite(PERESOURCE Resource,
ERESOURCE_THREAD ResourceThreadId);
VOID ExSystemTimeToLocalTime(PLARGE_INTEGER SystemTime,
PLARGE_INTEGER LocalTime);
BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex);
BOOLEAN ExTryToAcquireResourceExclusiveLite(PERESOURCE Resource);
PVOID InterlockedCompareExchange(PVOID* Destination,
PVOID Exchange,
PVOID Comperand);
LONG InterlockedDecrement(PLONG Addend);
LONG InterlockedExchange(PLONG Target, LONG Value);
LONG InterlockedExchangeAdd(PLONG Addend, LONG Value);
LONG InterlockedIncrement(PLONG Addend);
PVOID ExInterlockedAllocateFromZone(PZONE_HEADER Zone, PKSPIN_LOCK Lock);
PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,
PKSPIN_LOCK Lock);
NTSTATUS ExInterlockedExtendZone(PZONE_HEADER Zone, PVOID Segment,
ULONG SegmentSize, PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPopEntryList(PSINGLE_LIST_ENTRY ListHead,
PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPushEntryList(PSINGLE_LIST_ENTRY ListHead,
PSINGLE_LIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPushEntrySList(PSLIST_HEADER ListHead,
PSINGLE_LIST_ENTRY ListEntry,
PKSPIN_LOCK Lock);
PSINGLE_LIST_ENTRY ExInterlockedPopEntrySList(PSLIST_HEADER ListHead,
PKSPIN_LOCK Lock);
BOOLEAN ExIsFullZone(PZONE_HEADER Zone);
BOOLEAN ExIsObjectInFirstZoneSegment(PZONE_HEADER Zone, PVOID Object);
VOID ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime,
PLARGE_INTEGER SystemTime);
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
unsigned int ExHookException(exception_hook fn, unsigned int exp);
INTERLOCKED_RESULT ExInterlockedDecrementLong(PLONG Addend,
PKSPIN_LOCK Lock);
ULONG ExInterlockedExchangeUlong(PULONG Target,
ULONG Value,
PKSPIN_LOCK Lock);
INTERLOCKED_RESULT ExInterlockedIncrementLong(PLONG Addend,
PKSPIN_LOCK Lock);
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource);
BOOLEAN ExIsResourceAcquiredSharedLite(PERESOURCE Resource);
USHORT ExQueryDepthSListHead(PSLIST_HEADER SListHead);

View File

@@ -51,76 +51,20 @@ enum
*/
enum
{
/*
* Read any data from the actual backing media
*/
IRP_NOCACHE,
/*
* The I/O operation is performing paging
*/
IRP_PAGING_IO,
/*
* The IRP is for a mount operation
*/
IRP_MOUNT_COMPLETION,
/*
* The API expects synchronous behaviour
*/
IRP_SYNCHRONOUS_API,
/*
* The IRP is associated with a larger operation
*/
IRP_ASSOCIATED_IRP,
/*
* The AssociatedIrp.SystemBuffer field is valid
*/
IRP_BUFFERED_IO,
/*
* The system buffer was allocated from pool and should be deallocated
* by the I/O manager
*/
IRP_DEALLOCATE_BUFFER,
/*
* The IRP is for an input operation
*/
IRP_INPUT_OPERATION,
/*
* The paging operation should complete synchronously
*/
IRP_SYNCHRONOUS_PAGING_IO,
/*
* The IRP represents a filesystem create operation
*/
IRP_CREATE_OPERATION,
/*
* The IRP represents a filesystem read operation
*/
IRP_READ_OPERATION,
/*
* The IRP represents a filesystem write operation
*/
IRP_WRITE_OPERATION,
/*
* The IRP represents a filesystem close operation
*/
IRP_CLOSE_OPERATION,
/*
* Asynchronous behavior is advised but not required
*/
IRP_DEFER_IO_COMPLETION,
IRP_NOCACHE = 0x1,
IRP_PAGING_IO = 0x2,
IRP_MOUNT_COMPLETION = 0x4,
IRP_SYNCHRONOUS_API = 0x8,
IRP_ASSOCIATED_IRP = 0x10,
IRP_BUFFERED_IO = 0x20,
IRP_DEALLOCATE_BUFFER = 0x40,
IRP_INPUT_OPERATION = 0x80,
IRP_SYNCHRONOUS_PAGING_IO = 0x100,
IRP_CREATE_OPERATION = 0x200,
IRP_READ_OPERATION = 0x400,
IRP_WRITE_OPERATION = 0x800,
IRP_CLOSE_OPERATION = 0x1000,
IRP_DEFER_IO_COMPLETION = 0x2000,
};
/*
@@ -128,52 +72,27 @@ enum
*/
enum
{
/*
* Force an access check even if opened in kernel mode
*/
SL_FORCE_ACCESS_CHECK,
/*
* The file being opened is a paging file
*/
SL_OPEN_PAGING_FILE,
SL_OPEN_TARGET_DIRECTORY,
SL_CASE_SENSITIVE,
SL_KEY_SPECIFIED,
SL_OVERRIDE_VERIFY_VOLUME,
SL_WRITE_THROUGH,
SL_FT_SEQUENTIAL_WRITE,
SL_FAIL_IMMEDIATELY,
SL_EXCLUSIVE_LOCK,
SL_RESTART_SCAN,
SL_RETURN_SINGLE_ENTRY,
SL_INDEX_SPECIFIED,
SL_WATCH_TREE,
SL_ALLOW_RAW_MOUNT,
SL_PENDING_RETURNED,
SL_FORCE_ACCESS_CHECK = 0x1,
SL_OPEN_PAGING_FILE = 0x2,
SL_OPEN_TARGET_DIRECTORY = 0x4,
SL_CASE_SENSITIVE = 0x8,
SL_KEY_SPECIFIED = 0x10,
SL_OVERRIDE_VERIFY_VOLUME = 0x20,
SL_WRITE_THROUGH = 0x40,
SL_FT_SEQUENTIAL_WRITE = 0x80,
SL_FAIL_IMMEDIATELY = 0x100,
SL_EXCLUSIVE_LOCK = 0x200,
SL_RESTART_SCAN = 0x400,
SL_RETURN_SINGLE_ENTRY = 0x800,
SL_INDEX_SPECIFIED = 0x1000,
SL_WATCH_TREE = 0x2000,
SL_ALLOW_RAW_MOUNT = 0x4000,
};
enum
{
SL_INVOKE_ON_SUCCESS = 1,
SL_INVOKE_ON_ERROR = 2,
SL_INVOKE_ON_CANCEL = 4,
};
#define SL_PENDING_RETURNED 0x01
#define SL_INVOKE_ON_CANCEL 0x20
#define SL_INVOKE_ON_SUCCESS 0x40
#define SL_INVOKE_ON_ERROR 0x80
/*
* Possible flags for the device object flags
@@ -187,56 +106,60 @@ enum
/*
* Possible device types
*/
enum
{
/*
* Standard define types
*/
FILE_DEVICE_BEEP,
FILE_DEVICE_CDROM,
FILE_DEVICE_CONTROLLER,
FILE_DEVICE_DISK,
FILE_DEVICE_INPORT_PORT,
FILE_DEVICE_KEYBOARD,
FILE_DEVICE_MIDI_IN,
FILE_DEVICE_MIDI_OUT,
FILE_DEVICE_MOUSE,
FILE_DEVICE_NULL,
FILE_DEVICE_PARALLEL_PORT,
FILE_DEVICE_PRINTER,
FILE_DEVICE_SCANNER,
FILE_DEVICE_SERIAL_MOUSE_PORT,
FILE_DEVICE_SERIAL_PORT,
FILE_DEVICE_SCREEN,
FILE_DEVICE_TAPE,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_VIDEO,
FILE_DEVICE_VIRTUAL_DISK,
FILE_DEVICE_WAVE_IN,
FILE_DEVICE_WAVE_OUT,
FILE_DEVICE_8042_PORT,
FILE_DEVICE_FILE_SYSTEM,
/*
* Values beyond this are reserved for ISVs
*/
FILE_DEVICE_FIRST_FREE = 32768
};
#define FILE_DEVICE_BEEP 0x00000001
#define FILE_DEVICE_CD_ROM 0x00000002
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
#define FILE_DEVICE_CONTROLLER 0x00000004
#define FILE_DEVICE_DATALINK 0x00000005
#define FILE_DEVICE_DFS 0x00000006
#define FILE_DEVICE_DISK 0x00000007
#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
#define FILE_DEVICE_FILE_SYSTEM 0x00000009
#define FILE_DEVICE_INPORT_PORT 0x0000000a
#define FILE_DEVICE_KEYBOARD 0x0000000b
#define FILE_DEVICE_MAILSLOT 0x0000000c
#define FILE_DEVICE_MIDI_IN 0x0000000d
#define FILE_DEVICE_MIDI_OUT 0x0000000e
#define FILE_DEVICE_MOUSE 0x0000000f
#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
#define FILE_DEVICE_NAMED_PIPE 0x00000011
#define FILE_DEVICE_NETWORK 0x00000012
#define FILE_DEVICE_NETWORK_BROWSER 0x00000013
#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
#define FILE_DEVICE_NULL 0x00000015
#define FILE_DEVICE_PARALLEL_PORT 0x00000016
#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
#define FILE_DEVICE_PRINTER 0x00000018
#define FILE_DEVICE_SCANNER 0x00000019
#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
#define FILE_DEVICE_SERIAL_PORT 0x0000001b
#define FILE_DEVICE_SCREEN 0x0000001c
#define FILE_DEVICE_SOUND 0x0000001d
#define FILE_DEVICE_STREAMS 0x0000001e
#define FILE_DEVICE_TAPE 0x0000001f
#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
#define FILE_DEVICE_TRANSPORT 0x00000021
#define FILE_DEVICE_UNKNOWN 0x00000022
#define FILE_DEVICE_VIDEO 0x00000023
#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
#define FILE_DEVICE_WAVE_IN 0x00000025
#define FILE_DEVICE_WAVE_OUT 0x00000026
#define FILE_DEVICE_8042_PORT 0x00000027
#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
#define FILE_DEVICE_BATTERY 0x00000029
#define FILE_DEVICE_BUS_EXTENDER 0x0000002a
#define FILE_DEVICE_MODEM 0x0000002b
#define FILE_DEVICE_VDM 0x0000002c
#define FILE_REMOVABLE_MEDIA 0x00000001
#define FILE_READ_ONLY_DEVICE 0x00000002
#define FILE_FLOPPY_DISKETTE 0x00000004
#define FILE_WRITE_ONCE_MEDIA 0x00000008
#define FILE_REMOTE_DEVICE 0x00000010
#define FILE_DEVICE_IS_MOUNTED 0x00000020
#define FILE_VIRTUAL_VOLUME 0x00000040
/*
* Possible device characteristics
*/
enum
{
FILE_REMOVABLE_MEDIA = 0x1,
FILE_READ_ONLY_DEVICE = 0x2,
FILE_FLOPPY_DISKETTE = 0x4,
FILE_WRITE_ONCE_MEDIA = 0x8,
FILE_REMOTE_DEVICE = 0x10,
};
/*
* PURPOSE: Bus types
*/
@@ -286,22 +209,123 @@ enum
IRP_MJ_MAXIMUM_FUNCTION,
};
enum
/*
* PURPOSE: Details about the result of a file open or create
* Minor function numbers for IRP_MJ_FILE_SYSTEM_CONTROL
*/
{
FILE_CREATED,
// FILE_OPENED,
FILE_OVERWRITTEN,
FILE_SUPERSEDED,
FILE_EXISTS,
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
#define IO_DISK_INCREMENT 4
#define FILE_WORD_ALIGNMENT 0x0001
/*
* File disposition values
*/
#define FILE_CREATED 0x0000
#define FILE_OPENED 0x0001
#define FILE_OVERWRITTEN 0x0002
#define FILE_SUPERSEDED 0x0003
#define FILE_DOES_NOT_EXIST 0x0004
/*
* file creation flags
*/
#define FILE_DIRECTORY_FILE 0x00000001
#define FILE_WRITE_THROUGH 0x00000002
#define FILE_SEQUENTIAL_ONLY 0x00000004
#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008
#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010
#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020
#define FILE_NON_DIRECTORY_FILE 0x00000040
#define FILE_CREATE_TREE_CONNECTION 0x00000080
#define FILE_COMPLETE_IF_OPLOCKED 0x00000100
#define FILE_NO_EA_KNOWLEDGE 0x00000200
#define FILE_RANDOM_ACCESS 0x00000800
#define FILE_DELETE_ON_CLOSE 0x00001000
#define FILE_OPEN_BY_FILE_ID 0x00002000
#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000
#define FILE_NO_COMPRESSION 0x00008000
#define FILE_RESERVE_OPFILTER 0x00100000
#define FILE_TRANSACTED_MODE 0x00200000
#define FILE_OPEN_OFFLINE_FILE 0x00400000
#define FILE_VALID_OPTION_FLAGS 0x007fffff
#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032
#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032
#define FILE_VALID_SET_FLAGS 0x00001036
/*
* file information
*/
#define FileDirectoryInformation 1
#define FileFullDirectoryInformation 2
#define FileBothDirectoryInformation 3
#define FileBasicInformation 4
#define FileStandardInformation 5
#define FileInternalInformation 6
#define FileEaInformation 7
#define FileAccessInformation 8
#define FileNameInformation 9
#define FileRenameInformation 10
#define FileLinkInformation 11
#define FileNamesInformation 12
#define FileDispositionInformation 13
#define FilePositionInformation 14
#define FileFullEaInformation 15
#define FileModeInformation 16
#define FileAlignmentInformation 17
#define FileAllInformation 18
#define FileAllocationInformation 19
#define FileEndOfFileInformation 20
#define FileAlternateNameInformation 21
#define FileStreamInformation 22
#define FilePipeInformation 23
#define FilePipeLocalInformation 24
#define FilePipeRemoteInformation 25
#define FileMailslotQueryInformation 26
#define FileMailslotSetInformation 27
#define FileCompressionInformation 28
#define FileCopyOnWriteInformation 29
#define FileCompletionInformation 30
#define FileMoveClusterInformation 31
#define FileOleClassIdInformation 32
#define FileOleStateBitsInformation 33
#define FileNetworkOpenInformation 34
#define FileObjectIdInformation 35
#define FileOleAllInformation 36
#define FileOleDirectoryInformation 37
#define FileContentIndexInformation 38
#define FileInheritContentIndexInformation 39
#define FileOleInformation 40
#define FileMaximumInformation 41
typedef ULONG FS_INFORMATION_CLASS;
/*
* file system information class values
*/
#define FileFsVolumeInformation 1
#define FileFsLabelInformation 2
#define FileFsSizeInformation 3
#define FileFsDeviceInformation 4
#define FileFsAttributeInformation 5
#define FileFsControlInformation 6
#define FileFsQuotaQueryInformation 7
#define FileFsQuotaSetInformation 8
#define FileFsMaximumInformation 9
#define IRP_MN_QUERY_DIRECTORY 0x01
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02
#endif

View File

@@ -1,5 +1,10 @@
/* IO MANAGER ***************************************************************/
BOOLEAN IoRaiseInformationalHardError(NTSTATUS ErrorStatus,
PUNICODE_STRING String,
PKTHREAD Thread);
/*
* FUNCTION: Registers the driver with WMI
* ARGUMENTS:
@@ -503,7 +508,6 @@ NTSTATUS IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG NumberOfHeads,
struct _DRIVE_LAYOUT_INFORMATION* PBuffer);
typedef ULONG FS_INFORMATION_CLASS;
// Preliminary guess
NTKERNELAPI NTSTATUS IoQueryFileVolumeInformation(IN PFILE_OBJECT FileObject,

View File

@@ -127,6 +127,42 @@ typedef struct _IO_STACK_LOCATION
struct _VPB* Vpb;
struct _DEVICE_OBJECT* DeviceObject;
} Mount;
struct {
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
} QueryFile;
struct {
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} QueryVolume;
struct {
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} SetVolume;
struct {
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
struct FILE_OBJECT* FileObject;
union {
struct {
BOOLEAN ReplaceIfExists;
BOOLEAN AdvanceOnly;
} d;
ULONG ClusterCount;
HANDLE DeleteHandle;
} u;
} SetFile;
/*
* This is a guess
*/
struct
{
FILE_INFORMATION_CLASS FileInformationClass;
BOOLEAN ReturnSingleEntry;
PUNICODE_STRING FileName;
BOOLEAN RestartScan;
} QueryDirectory;
} Parameters;
PIO_COMPLETION_ROUTINE CompletionRoutine;

View File

@@ -155,4 +155,88 @@ VOID KeBugCheckEx(ULONG BugCheckCode,
*/
VOID KeBugCheck(ULONG BugCheckCode);
// kmutant definition slightly modified from nt5 ddk
typedef struct _KMUTANT
{
DISPATCHER_HEADER Header;
LIST_ENTRY MutantListEntry;
struct _KTHREAD* OwnerThread;
BOOLEAN Abandoned;
UCHAR ApcDisable;
} KMUTANT, *PKMUTANT;
// io permission map has a 8k size
// Each bit in the IOPM corresponds to an io port byte address. The bitmap
// is initialized to allow IO at any port. [ all bits set ].
typedef struct _IOPM
{
UCHAR Bitmap[8192];
} IOPM, *PIOPM;
/*
* FUNCTION: Provides the kernel with a new access map for a driver
* ARGUMENTS:
* NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
* the kernel disables access to a particular port.
* IoPortMap = Caller supplies storage for the io permission map.
* REMARKS
* Each bit in the IOPM corresponds to an io port byte address. The bitmap
* is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
* the minium privilege level required to perform IO prior to checking the permission map.
*/
void Ke386SetIoAccessMap(int NewMap, PIOPM *IoPermissionMap);
/*
* FUNCTION: Queries the io permission map.
* ARGUMENTS:
* NewMap: = If FALSE the kernel's map is set to all disabled. If TRUE
* the kernel disables access to a particular port.
* IoPortMap = Caller supplies storage for the io permission map.
* REMARKS
* Each bit in the IOPM corresponds to an io port byte address. The bitmap
* is initialized to allow IO at any port. [ all bits set ]. The IOPL determines
* the minium privilege level required to perform IO prior to checking the permission map.
*/
void Ke386QueryIoAccessMap(BOOLEAN NewMap, PIOPM *IoPermissionMap);
/*
* FUNCTION: Set the process IOPL
* ARGUMENTS:
* Eprocess = Pointer to a executive process object
* EnableIo = Specify TRUE to enable IO and FALSE to disable
*/
NTSTATUS Ke386IoSetAccessProcess(PEPROCESS Eprocess, BOOLEAN EnableIo);
/*
* FUNCTION: Releases a set of Global Descriptor Table Selectors
* ARGUMENTS:
* SelArray =
* NumOfSelectors =
*/
NTSTATUS KeI386ReleaseGdtSelectors(
OUT PULONG SelArray,
IN ULONG NumOfSelectors
);
/*
* FUNCTION: Allocates a set of Global Descriptor Table Selectors
* ARGUMENTS:
* SelArray =
* NumOfSelectors =
*/
NTSTATUS KeI386AllocateGdtSelectors(
OUT PULONG SelArray,
IN ULONG NumOfSelectors
);
/*
* FUNCTION: Raises a user mode exception
* ARGUMENTS:
* ExceptionCode = Status code of the exception
*/
void KeRaiseUserException(NTSTATUS ExceptionCode);
#endif /* __INCLUDE_DDK_KEFUNCS_H */

View File

@@ -101,65 +101,6 @@ typedef struct _KDEVICE_QUEUE
KSPIN_LOCK Lock;
} KDEVICE_QUEUE, *PKDEVICE_QUEUE;
#if RIGHT_DEFINITION_PROVIDED_ABOVE
#define _KTHREAD _ETHREAD
typedef struct _KTHREAD
/*
* PURPOSE: Describes a thread of execution
*/
{
CSHORT Type;
CSHORT Size;
/*
* PURPOSE: Head of the queue of apcs
*/
LIST_ENTRY ApcQueueHead;
/*
* PURPOSE: Entry in the linked list of threads
*/
LIST_ENTRY Entry;
/*
* PURPOSE: Current state of the thread
*/
ULONG State;
/*
* PURPOSE: Priority modifier of the thread
*/
ULONG Priority;
/*
* PURPOSE: Pointer to our process
*/
struct _EPROCESS* Process;
/*
* PURPOSE: Handle of our process
*/
HANDLE ProcessHandle;
/*
* PURPOSE: Thread affinity mask
*/
ULONG AffinityMask;
/*
* PURPOSE: Saved thread context
*/
hal_thread_state context;
/*
* PURPOSE: Timeout for the thread to be woken up
*/
signed long long int wake_time;
} KTHREAD, *PKTHREAD, *PETHREAD;
#endif
typedef struct _KAPC
{

View File

@@ -1,6 +1,13 @@
/* MEMORY MANAGMENT ******************************************************/
#include <internal/hal/page.h>
#include <internal/mmhal.h>
BOOLEAN MmIsNonPagedSystemAddressValid(PVOID VirtualAddress);
BOOLEAN MmIsThisAnNtAsSystem(VOID);
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGESIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) )
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff))
/*
* FUNCTION: Determines if the given virtual address is page aligned

View File

@@ -22,13 +22,6 @@ extern "C"
#define QUAD_PART(LI) (*(LONGLONG *)(&LI))
#define IO_DISK_INCREMENT 4
#define FILE_WORD_ALIGNMENT 0x0001
#define FILE_OPENED 0x0001
#include <ddk/status.h>
#include <ddk/ntdef.h>
#include <ddk/defines.h>
@@ -41,6 +34,7 @@ extern "C"
#include <ddk/iotypes.h>
#include <ddk/extypes.h>
#include <ddk/pstypes.h>
#include <ddk/zwtypes.h>
#include <ddk/ioctrl.h>
#include <internal/hal/ddk.h>
@@ -53,7 +47,8 @@ extern "C"
#include <ddk/psfuncs.h>
#include <ddk/obfuncs.h>
#include <ddk/dbgfuncs.h>
#include <ddk/sefuncs.h>
#ifdef __cplusplus
};
#endif

View File

@@ -6,5 +6,8 @@ struct _ETHREAD;
struct _EPROCESS;
#define NTKERNELAPI
#define NTSYSAPI
#define NTAPI
#endif

View File

@@ -6,7 +6,7 @@
* ARGUMENTS:
* Object = Object's body
*/
VOID ObDeferenceObject(PVOID Object);
VOID ObDereferenceObject(PVOID Object);
/*
* FUNCTION: Performs access validation on an object handle and if access

View File

@@ -96,27 +96,13 @@ typedef struct _OBJECT
* PURPOSE: Header for every object managed by the object manager
*/
{
/*
* PURPOSE: Name of this entry
*/
UNICODE_STRING name;
/*
* PURPOSE: Our entry in our parents list of subdirectory
*/
LIST_ENTRY entry;
/*
* PURPOSE: Number of non-handle references to this object
*/
ULONG RefCount;
/*
* PURPOSE: Number of handles opened to this object
*/
ULONG HandleCount;
struct _DIRECTORY_OBJECT* Parent;
UNICODE_STRING Name;
LIST_ENTRY Entry;
ULONG RefCount;
ULONG HandleCount;
BOOLEAN Permanent;
struct _DIRECTORY_OBJECT* Parent;
POBJECT_TYPE ObjectType;
/*
* PURPOSE: Object type
@@ -141,3 +127,9 @@ typedef struct _OBJECT_ATTRIBUTES {
SECURITY_DESCRIPTOR *SecurityDescriptor;
SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
typedef struct _HANDLE_TABLE
{
LIST_ENTRY ListHead;
KSPIN_LOCK ListLock;
} HANDLE_TABLE, *PHANDLE_TABLE;

View File

@@ -25,7 +25,7 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext);
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
NTSTATUS PsSuspendThread(VOID);
NTSTATUS PsWakeThread(PETHREAD Thread);
VOID PsSuspendThread(PETHREAD Thread);
VOID PsResumeThread(PETHREAD Thread);
PETHREAD PsGetCurrentThread(VOID);
struct _EPROCESS* PsGetCurrentProcess(VOID);

View File

@@ -131,7 +131,7 @@ typedef struct _KTHREAD
ULONG Quantum;
UCHAR ThreadState; //Thread state is a typeless enum, otherwise it should be const integer
ULONG FreezeCount;
ULONG SuspendCount;
LONG SuspendCount;
PTRAP_FRAME TrapFrame;
PVOID *Tls;
KWAIT_BLOCK WaitBlock[4];
@@ -149,6 +149,7 @@ typedef struct _KTHREAD
*/
hal_thread_state Context;
LIST_ENTRY Entry;
ULONG LastTick;
} KTHREAD, *PKTHREAD;
@@ -255,26 +256,28 @@ typedef struct _ETHREAD {
} ETHREAD, *PETHREAD;
typedef struct _KPROCESS {
DISPATCHER_HEADER DispatcherHeader;
PVOID PageTableDirectory; // FIXME: I shoud point to a PTD
TIME ElapsedTime;
TIME KernelTime;
TIME UserTime;
LIST_ENTRY InOutSwap; // ??
KSPIN_LOCK SpinLock;
KAFFINITY Affinity;
ULONG StackCount;
KPRIORITY BasePriority;
ULONG DefaultThreadQuantum;
UCHAR ProcessState;
ULONG ThreadSeed;
UCHAR DisableBoost;
typedef struct _KPROCESS
{
DISPATCHER_HEADER DispatcherHeader;
PVOID PageTableDirectory; // FIXME: I shoud point to a PTD
TIME ElapsedTime;
TIME KernelTime;
TIME UserTime;
LIST_ENTRY InOutSwap; // ??
KSPIN_LOCK SpinLock;
KAFFINITY Affinity;
ULONG StackCount;
KPRIORITY BasePriority;
ULONG DefaultThreadQuantum;
UCHAR ProcessState;
ULONG ThreadSeed;
UCHAR DisableBoost;
/*
* Added by David Welch (welch@mcmail.com)
*/
LIST_ENTRY MemoryAreaList;
HANDLE_TABLE HandleTable;
} KPROCESS, *PKPROCESS;
typedef struct _EPROCESS

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,
@@ -299,5 +319,30 @@ RtlFreeHeap(
PVOID Address
);
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString);
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
OUT PULONG Value);
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString);
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString);
BOOLEAN RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
NTSTATUS RtlWriteRegistryValue(ULONG RelativeTo,
PWSTR Path,
PWSTR ValueName,
ULONG ValueType,
PVOID ValueData,
ULONG ValueLength);
VOID RtlStoreUlong(PULONG Address,
ULONG Value);
#endif /* __DDK_RTL_H */

View File

@@ -14,10 +14,6 @@
typedef ULONG ACCESS_MODE, *PACCESS_MODE;
typedef SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE;
typedef struct _SECURITY_SUBJECT_CONTEXT
{
} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
typedef struct _SECURITY_DESCRIPTOR_CONTEXT
{
} SECURITY_DESCRIPTOR_CONTEXT, *PSECURITY_DESCRIPTOR_CONTEXT;
@@ -44,4 +40,13 @@ typedef struct _ACCESS_TOKEN {
UCHAR VariablePart[0];
} ACCESS_TOKEN, *PACCESS_TOKEN;
typedef struct _SECURITY_SUBJECT_CONTEXT
{
PACCESS_TOKEN ClientToken;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
PACCESS_TOKEN PrimaryToken;
PVOID ProcessAuditId;
} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT;
#endif

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;

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,224 @@
#ifndef _GNU_H_WINDOWS32_DEFINES
#define _GNU_H_WINDOWS32_DEFINES
#define WINBASEAPI
#define EXCEPTION_MAXIMUM_PARAMETERS (15)
#define ANYSIZE_ARRAY (1)
#define STATUS_WAIT_0 (0x00000000L)
#define STATUS_ABANDONED_WAIT_0 (0x00000080L)
#define STATUS_USER_APC (0x000000C0L)
#define STATUS_TIMEOUT (0x00000102L)
#define STATUS_PENDING (0x00000103L)
#define STATUS_GUARD_PAGE_VIOLATION (0x80000001L)
#define STATUS_DATATYPE_MISALIGNMENT (0x80000002L)
#define STATUS_BREAKPOINT (0x80000003L)
#define STATUS_SINGLE_STEP (0x80000004L)
#define STATUS_IN_PAGE_ERROR (0xC0000006L)
#define STATUS_INVALID_HANDLE (0xC0000008L)
#define STATUS_ILLEGAL_INSTRUCTION (0xC000001DL)
#define STATUS_NONCONTINUABLE_EXCEPTION (0xC0000025L)
#define STATUS_INVALID_DISPOSITION (0xC0000026L)
#define STATUS_ARRAY_BOUNDS_EXCEEDED (0xC000008CL)
#define STATUS_FLOAT_DENORMAL_OPERAND (0xC000008DL)
#define STATUS_FLOAT_DIVIDE_BY_ZERO (0xC000008EL)
#define STATUS_FLOAT_INEXACT_RESULT (0xC000008FL)
#define STATUS_FLOAT_INVALID_OPERATION (0xC0000090L)
#define STATUS_FLOAT_OVERFLOW (0xC0000091L)
#define STATUS_FLOAT_STACK_CHECK (0xC0000092L)
#define STATUS_FLOAT_UNDERFLOW (0xC0000093L)
#define STATUS_INTEGER_DIVIDE_BY_ZERO (0xC0000094L)
#define STATUS_INTEGER_OVERFLOW (0xC0000095L)
#define STATUS_PRIVILEGED_INSTRUCTION (0xC0000096L)
#define STATUS_STACK_OVERFLOW (0xC00000FDL)
#define STATUS_CONTROL_C_EXIT (0xC000013AL)
#define SEC_COMMIT (134217728)
#define SEC_IMAGE (16777216)
#define SEC_NOCACHE (268435456)
#define SEC_RESERVE (67108864)
#define PAGE_READONLY (2)
#define PAGE_READWRITE (4)
#define PAGE_WRITECOPY (8)
#define PAGE_EXECUTE (16)
#define PAGE_EXECUTE_READ (32)
#define PAGE_EXECUTE_READWRITE (64)
#define PAGE_EXECUTE_WRITECOPY (128)
#define PAGE_GUARD (256)
#define PAGE_NOACCESS (1)
#define PAGE_NOCACHE (512)
#define MEM_COMMIT (4096)
#define MEM_FREE (65536)
#define MEM_RESERVE (8192)
#define MEM_IMAGE (16777216)
#define MEM_MAPPED (262144)
#define MEM_PRIVATE (131072)
#define MEM_DECOMMIT (16384)
#define MEM_RELEASE (32768)
#define MEM_TOP_DOWN (1048576)
#define EXCEPTION_GUARD_PAGE (0x80000001L)
#define SECTION_EXTEND_SIZE (0x10)
#define SECTION_MAP_READ (0x4)
#define SECTION_MAP_WRITE (0x2)
#define SECTION_QUERY (0x1)
#define SECTION_ALL_ACCESS (0xf001fL)
/* DuplicateHandle, MapViewOfFile */
#define DUPLICATE_CLOSE_SOURCE (1)
#define DUPLICATE_SAME_ACCESS (2)
#define FILE_MAP_ALL_ACCESS (0xf001fL)
#define FILE_MAP_READ (4)
#define FILE_MAP_WRITE (2)
#define FILE_MAP_COPY (1)
#define MUTEX_ALL_ACCESS (0x1f0001L)
#define MUTEX_MODIFY_STATE (1)
#define SYNCHRONIZE (0x100000L)
#define SEMAPHORE_ALL_ACCESS (0x1f0003L)
#define SEMAPHORE_MODIFY_STATE (2)
#define EVENT_ALL_ACCESS (0x1f0003L)
#define EVENT_MODIFY_STATE (2)
#define KEY_ALL_ACCESS (0xf003fL)
#define KEY_CREATE_LINK (32)
#define KEY_CREATE_SUB_KEY (4)
#define KEY_ENUMERATE_SUB_KEYS (8)
#define KEY_EXECUTE (0x20019L)
#define KEY_NOTIFY (16)
#define KEY_QUERY_VALUE (1)
#define KEY_READ (0x20019L)
#define KEY_SET_VALUE (2)
#define KEY_WRITE (0x20006L)
#define PROCESS_ALL_ACCESS (0x1f0fffL)
#define PROCESS_CREATE_PROCESS (128)
#define PROCESS_CREATE_THREAD (2)
#define PROCESS_DUP_HANDLE (64)
#define PROCESS_QUERY_INFORMATION (1024)
#define PROCESS_SET_INFORMATION (512)
#define PROCESS_TERMINATE (1)
#define PROCESS_VM_OPERATION (8)
#define PROCESS_VM_READ (16)
#define PROCESS_VM_WRITE (32)
#define THREAD_ALL_ACCESS (0x1f03ffL)
#define THREAD_DIRECT_IMPERSONATION (512)
#define THREAD_GET_CONTEXT (8)
#define THREAD_IMPERSONATE (256)
#define THREAD_QUERY_INFORMATION (64)
#define THREAD_SET_CONTEXT (16)
#define THREAD_SET_INFORMATION (32)
#define THREAD_SET_THREAD_TOKEN (128)
#define THREAD_SUSPEND_RESUME (2)
#define THREAD_TERMINATE (1)
#define PACKED __attribute__((packed))
#define THREAD_PRIORITY_ABOVE_NORMAL (1)
#define THREAD_PRIORITY_BELOW_NORMAL (-1)
#define THREAD_PRIORITY_HIGHEST (2)
#define THREAD_PRIORITY_IDLE (-15)
#define THREAD_PRIORITY_LOWEST (-2)
#define THREAD_PRIORITY_NORMAL (0)
#define THREAD_PRIORITY_TIME_CRITICAL (15)
#define THREAD_PRIORITY_ERROR_RETURN (2147483647)
/* CreateFile, GetFileAttributes, SetFileAttributes */
#define GENERIC_READ (0x80000000L)
#define GENERIC_WRITE (0x40000000L)
#define FILE_READ_DATA ( 0x0001 ) /* file & pipe */
#define FILE_LIST_DIRECTORY ( 0x0001 ) /* directory */
#define FILE_WRITE_DATA ( 0x0002 ) /* file & pipe */
#define FILE_ADD_FILE ( 0x0002 ) /* directory */
#define FILE_APPEND_DATA ( 0x0004 ) /* file */
#define FILE_ADD_SUBDIRECTORY ( 0x0004 ) /* directory */
#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) /* named pipe */
#define FILE_READ_EA ( 0x0008 ) /* file & directory */
#define FILE_READ_PROPERTIES FILE_READ_EA
#define FILE_WRITE_EA ( 0x0010 ) /* file & directory */
#define FILE_WRITE_PROPERTIES FILE_WRITE_EA
#define FILE_EXECUTE ( 0x0020 ) /* file */
#define FILE_TRAVERSE ( 0x0020 ) /* directory */
#define FILE_DELETE_CHILD ( 0x0040 ) /* directory */
#define FILE_READ_ATTRIBUTES ( 0x0080 ) /* all */
#define FILE_WRITE_ATTRIBUTES ( 0x0100 ) /* all */
#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
FILE_READ_DATA |\
FILE_READ_ATTRIBUTES |\
FILE_READ_EA |\
SYNCHRONIZE)
#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
FILE_WRITE_DATA |\
FILE_WRITE_ATTRIBUTES |\
FILE_WRITE_EA |\
FILE_APPEND_DATA |\
SYNCHRONIZE)
#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
FILE_READ_ATTRIBUTES |\
FILE_EXECUTE |\
SYNCHRONIZE)
#define FILE_SHARE_DELETE (4)
#define FILE_SHARE_READ (1)
#define FILE_SHARE_WRITE (2)
#define CONSOLE_TEXTMODE_BUFFER (1)
#define CREATE_NEW (1)
#define CREATE_ALWAYS (2)
#define OPEN_EXISTING (3)
#define OPEN_ALWAYS (4)
#define TRUNCATE_EXISTING (5)
#define FILE_ATTRIBUTE_ARCHIVE (32)
#define FILE_ATTRIBUTE_COMPRESSED (2048)
#define FILE_ATTRIBUTE_NORMAL (128)
#define FILE_ATTRIBUTE_DIRECTORY (16)
#define FILE_ATTRIBUTE_HIDDEN (2)
#define FILE_ATTRIBUTE_READONLY (1)
#define FILE_ATTRIBUTE_SYSTEM (4)
#define FILE_ATTRIBUTE_TEMPORARY (256)
#define FILE_FLAG_WRITE_THROUGH (2147483648)
#define FILE_FLAG_OVERLAPPED (1073741824)
#define FILE_FLAG_NO_BUFFERING (536870912)
#define FILE_FLAG_RANDOM_ACCESS (268435456)
#define FILE_FLAG_SEQUENTIAL_SCAN (134217728)
#define FILE_FLAG_DELETE_ON_CLOSE (67108864)
#define FILE_FLAG_BACKUP_SEMANTICS (33554432)
#define FILE_FLAG_POSIX_SEMANTICS (16777216)
#define SECURITY_ANONYMOUS (0)
#define SECURITY_IDENTIFICATION (65536)
#define SECURITY_IMPERSONATION (131072)
#define SECURITY_DELEGATION (196608)
#define SECURITY_CONTEXT_TRACKING (262144)
#define SECURITY_EFFECTIVE_ONLY (524288)
#define SECURITY_SQOS_PRESENT (1048576)
/* Standard rights */
#define STANDARD_RIGHTS_REQUIRED (0xf0000L)
#define STANDARD_RIGHTS_WRITE (0x20000L)
#define STANDARD_RIGHTS_READ (0x20000L)
#define STANDARD_RIGHTS_EXECUTE (0x20000L)
#define STANDARD_RIGHTS_ALL (0x1f0000L)
#define SPECIFIC_RIGHTS_ALL (0xffffL)
/* ACCESS_MASK */
#define MAXIMUM_ALLOWED (0x2000000L)
#define GENERIC_ALL (0x10000000L)
#ifndef WIN32_LEAN_AND_MEAN
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -45,7 +263,6 @@ extern "C" {
#define SECURITY_DYNAMIC_TRACKING (1)
#define MAX_DEFAULTCHAR (2)
#define MAX_LEADBYTES (12)
#define EXCEPTION_MAXIMUM_PARAMETERS (15)
#define CCHDEVICENAME (32)
#define CCHFORMNAME (32)
#define MENU_TEXT_LEN (40)
@@ -54,7 +271,6 @@ extern "C" {
#define NETBIOS_NAME_LEN (16)
#define OFS_MAXPATHNAME (128)
#define MAX_TAB_STOPS (32)
#define ANYSIZE_ARRAY (1)
#define RAS_MaxCallbackNumber (128)
#define RAS_MaxDeviceName (128)
#define RAS_MaxDeviceType (16)
@@ -382,119 +598,7 @@ extern "C" {
#define DIB_PAL_COLORS (1)
#define DIB_RGB_COLORS (0)
/* CreateFile, GetFileAttributes, SetFileAttributes */
#define GENERIC_READ (0x80000000L)
#define GENERIC_WRITE (0x40000000L)
#define FILE_READ_DATA ( 0x0001 ) /* file & pipe */
#define FILE_LIST_DIRECTORY ( 0x0001 ) /* directory */
#define FILE_WRITE_DATA ( 0x0002 ) /* file & pipe */
#define FILE_ADD_FILE ( 0x0002 ) /* directory */
#define FILE_APPEND_DATA ( 0x0004 ) /* file */
#define FILE_ADD_SUBDIRECTORY ( 0x0004 ) /* directory */
#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) /* named pipe */
#define FILE_READ_EA ( 0x0008 ) /* file & directory */
#define FILE_READ_PROPERTIES FILE_READ_EA
#define FILE_WRITE_EA ( 0x0010 ) /* file & directory */
#define FILE_WRITE_PROPERTIES FILE_WRITE_EA
#define FILE_EXECUTE ( 0x0020 ) /* file */
#define FILE_TRAVERSE ( 0x0020 ) /* directory */
#define FILE_DELETE_CHILD ( 0x0040 ) /* directory */
#define FILE_READ_ATTRIBUTES ( 0x0080 ) /* all */
#define FILE_WRITE_ATTRIBUTES ( 0x0100 ) /* all */
#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
FILE_READ_DATA |\
FILE_READ_ATTRIBUTES |\
FILE_READ_EA |\
SYNCHRONIZE)
#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
FILE_WRITE_DATA |\
FILE_WRITE_ATTRIBUTES |\
FILE_WRITE_EA |\
FILE_APPEND_DATA |\
SYNCHRONIZE)
#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
FILE_READ_ATTRIBUTES |\
FILE_EXECUTE |\
SYNCHRONIZE)
#define FILE_SHARE_DELETE (4)
#define FILE_SHARE_READ (1)
#define FILE_SHARE_WRITE (2)
#define CONSOLE_TEXTMODE_BUFFER (1)
#define CREATE_NEW (1)
#define CREATE_ALWAYS (2)
#define OPEN_EXISTING (3)
#define OPEN_ALWAYS (4)
#define TRUNCATE_EXISTING (5)
#define FILE_ATTRIBUTE_ARCHIVE (32)
#define FILE_ATTRIBUTE_COMPRESSED (2048)
#define FILE_ATTRIBUTE_NORMAL (128)
#define FILE_ATTRIBUTE_DIRECTORY (16)
#define FILE_ATTRIBUTE_HIDDEN (2)
#define FILE_ATTRIBUTE_READONLY (1)
#define FILE_ATTRIBUTE_SYSTEM (4)
#define FILE_ATTRIBUTE_TEMPORARY (256)
#define FILE_FLAG_WRITE_THROUGH (2147483648)
#define FILE_FLAG_OVERLAPPED (1073741824)
#define FILE_FLAG_NO_BUFFERING (536870912)
#define FILE_FLAG_RANDOM_ACCESS (268435456)
#define FILE_FLAG_SEQUENTIAL_SCAN (134217728)
#define FILE_FLAG_DELETE_ON_CLOSE (67108864)
#define FILE_FLAG_BACKUP_SEMANTICS (33554432)
#define FILE_FLAG_POSIX_SEMANTICS (16777216)
#define SECURITY_ANONYMOUS (0)
#define SECURITY_IDENTIFICATION (65536)
#define SECURITY_IMPERSONATION (131072)
#define SECURITY_DELEGATION (196608)
#define SECURITY_CONTEXT_TRACKING (262144)
#define SECURITY_EFFECTIVE_ONLY (524288)
#define SECURITY_SQOS_PRESENT (1048576)
/* CreateFileMapping, VirtualAlloc, VirtualFree, VirtualProtect */
#define SEC_COMMIT (134217728)
#define SEC_IMAGE (16777216)
#define SEC_NOCACHE (268435456)
#define SEC_RESERVE (67108864)
#define PAGE_READONLY (2)
#define PAGE_READWRITE (4)
#define PAGE_WRITECOPY (8)
#define PAGE_EXECUTE (16)
#define PAGE_EXECUTE_READ (32)
#define PAGE_EXECUTE_READWRITE (64)
#define PAGE_EXECUTE_WRITECOPY (128)
#define PAGE_GUARD (256)
#define PAGE_NOACCESS (1)
#define PAGE_NOCACHE (512)
#define MEM_COMMIT (4096)
#define MEM_FREE (65536)
#define MEM_RESERVE (8192)
#define MEM_IMAGE (16777216)
#define MEM_MAPPED (262144)
#define MEM_PRIVATE (131072)
#define MEM_DECOMMIT (16384)
#define MEM_RELEASE (32768)
#define MEM_TOP_DOWN (1048576)
#define EXCEPTION_GUARD_PAGE (0x80000001L)
#define SECTION_EXTEND_SIZE (0x10)
#define SECTION_MAP_READ (0x4)
#define SECTION_MAP_WRITE (0x2)
#define SECTION_QUERY (0x1)
#define SECTION_ALL_ACCESS (0xf001fL)
/* CreateFont */
#define FW_DONTCARE (0)
@@ -1051,50 +1155,6 @@ extern "C" {
#define DT_WORDBREAK (16)
#define DT_INTERNAL (4096)
/* DuplicateHandle, MapViewOfFile */
#define DUPLICATE_CLOSE_SOURCE (1)
#define DUPLICATE_SAME_ACCESS (2)
#define FILE_MAP_ALL_ACCESS (0xf001fL)
#define FILE_MAP_READ (4)
#define FILE_MAP_WRITE (2)
#define FILE_MAP_COPY (1)
#define MUTEX_ALL_ACCESS (0x1f0001L)
#define MUTEX_MODIFY_STATE (1)
#define SYNCHRONIZE (0x100000L)
#define SEMAPHORE_ALL_ACCESS (0x1f0003L)
#define SEMAPHORE_MODIFY_STATE (2)
#define EVENT_ALL_ACCESS (0x1f0003L)
#define EVENT_MODIFY_STATE (2)
#define KEY_ALL_ACCESS (0xf003fL)
#define KEY_CREATE_LINK (32)
#define KEY_CREATE_SUB_KEY (4)
#define KEY_ENUMERATE_SUB_KEYS (8)
#define KEY_EXECUTE (0x20019L)
#define KEY_NOTIFY (16)
#define KEY_QUERY_VALUE (1)
#define KEY_READ (0x20019L)
#define KEY_SET_VALUE (2)
#define KEY_WRITE (0x20006L)
#define PROCESS_ALL_ACCESS (0x1f0fffL)
#define PROCESS_CREATE_PROCESS (128)
#define PROCESS_CREATE_THREAD (2)
#define PROCESS_DUP_HANDLE (64)
#define PROCESS_QUERY_INFORMATION (1024)
#define PROCESS_SET_INFORMATION (512)
#define PROCESS_TERMINATE (1)
#define PROCESS_VM_OPERATION (8)
#define PROCESS_VM_READ (16)
#define PROCESS_VM_WRITE (32)
#define THREAD_ALL_ACCESS (0x1f03ffL)
#define THREAD_DIRECT_IMPERSONATION (512)
#define THREAD_GET_CONTEXT (8)
#define THREAD_IMPERSONATE (256)
#define THREAD_QUERY_INFORMATION (64)
#define THREAD_SET_CONTEXT (16)
#define THREAD_SET_INFORMATION (32)
#define THREAD_SET_THREAD_TOKEN (128)
#define THREAD_SUSPEND_RESUME (2)
#define THREAD_TERMINATE (1)
/* EditWordBreakProc */
#define WB_ISDELIMITER (2)
@@ -1902,14 +1962,6 @@ extern "C" {
#define VTA_CENTER (6)
/* GetThreadPriority */
#define THREAD_PRIORITY_ABOVE_NORMAL (1)
#define THREAD_PRIORITY_BELOW_NORMAL (-1)
#define THREAD_PRIORITY_HIGHEST (2)
#define THREAD_PRIORITY_IDLE (-15)
#define THREAD_PRIORITY_LOWEST (-2)
#define THREAD_PRIORITY_NORMAL (0)
#define THREAD_PRIORITY_TIME_CRITICAL (15)
#define THREAD_PRIORITY_ERROR_RETURN (2147483647)
#define TLS_MINIMUM_AVAILABLE (64)
/* GetTimeFormat */
@@ -4110,17 +4162,6 @@ extern "C" {
#define TAPE_DRIVE_WRITE_SETMARKS (-2130706432)
#define TAPE_DRIVE_WRITE_SHORT_FMKS (-2080374784)
/* Standard rights */
#define STANDARD_RIGHTS_REQUIRED (0xf0000L)
#define STANDARD_RIGHTS_WRITE (0x20000L)
#define STANDARD_RIGHTS_READ (0x20000L)
#define STANDARD_RIGHTS_EXECUTE (0x20000L)
#define STANDARD_RIGHTS_ALL (0x1f0000L)
#define SPECIFIC_RIGHTS_ALL (0xffffL)
/* ACCESS_MASK */
#define MAXIMUM_ALLOWED (0x2000000L)
#define GENERIC_ALL (0x10000000L)
/* SID */
#define SECURITY_NULL_RID (0L)
@@ -5052,33 +5093,6 @@ extern "C" {
#define POLYFILL_LAST (2)
#define STATUS_WAIT_0 (0x00000000L)
#define STATUS_ABANDONED_WAIT_0 (0x00000080L)
#define STATUS_USER_APC (0x000000C0L)
#define STATUS_TIMEOUT (0x00000102L)
#define STATUS_PENDING (0x00000103L)
#define STATUS_GUARD_PAGE_VIOLATION (0x80000001L)
#define STATUS_DATATYPE_MISALIGNMENT (0x80000002L)
#define STATUS_BREAKPOINT (0x80000003L)
#define STATUS_SINGLE_STEP (0x80000004L)
#define STATUS_IN_PAGE_ERROR (0xC0000006L)
#define STATUS_INVALID_HANDLE (0xC0000008L)
#define STATUS_ILLEGAL_INSTRUCTION (0xC000001DL)
#define STATUS_NONCONTINUABLE_EXCEPTION (0xC0000025L)
#define STATUS_INVALID_DISPOSITION (0xC0000026L)
#define STATUS_ARRAY_BOUNDS_EXCEEDED (0xC000008CL)
#define STATUS_FLOAT_DENORMAL_OPERAND (0xC000008DL)
#define STATUS_FLOAT_DIVIDE_BY_ZERO (0xC000008EL)
#define STATUS_FLOAT_INEXACT_RESULT (0xC000008FL)
#define STATUS_FLOAT_INVALID_OPERATION (0xC0000090L)
#define STATUS_FLOAT_OVERFLOW (0xC0000091L)
#define STATUS_FLOAT_STACK_CHECK (0xC0000092L)
#define STATUS_FLOAT_UNDERFLOW (0xC0000093L)
#define STATUS_INTEGER_DIVIDE_BY_ZERO (0xC0000094L)
#define STATUS_INTEGER_OVERFLOW (0xC0000095L)
#define STATUS_PRIVILEGED_INSTRUCTION (0xC0000096L)
#define STATUS_STACK_OVERFLOW (0xC00000FDL)
#define STATUS_CONTROL_C_EXIT (0xC000013AL)
#define EXCEPTION_CTRL_C
@@ -5139,7 +5153,6 @@ DECLARE_HANDLE(HANDLE);
#define ASCIICHAR AsciiChar
#define FAR
#define PACKED __attribute__((packed))
#define FILTER_TEMP_DUPLICATE_ACCOUNT (0x0001)
#define FILTER_NORMAL_ACCOUNT (0x0002)
@@ -5164,4 +5177,6 @@ DECLARE_HANDLE(HANDLE);
}
#endif /* __cplusplus */
#endif /* WIN32_LEAN_AND_MEAN */
#endif /* _GNU_H_WINDOWS32_DEFINES */

View File

@@ -31,6 +31,8 @@
#ifndef _GNU_H_WINDOWS32_FUNCTIONS
#define _GNU_H_WINDOWS32_FUNCTIONS
#ifndef WIN32_LEAN_AND_MEAN
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -7430,6 +7432,9 @@ DWORD STDCALL NetGroupEnum (LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
DWORD STDCALL NetLocalGroupEnum (LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
LPDWORD, LPDWORD);
VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length);
void WINAPI
SHAddToRecentDocs (UINT, LPCVOID);
@@ -7481,4 +7486,6 @@ SHLoadInProc (REFCLSID);
}
#endif /* __cplusplus */
#endif /* WIN32_LEAN_AND_MEAN */
#endif /* _GNU_H_WINDOWS32_FUNCTIONS */

View File

@@ -38,6 +38,11 @@ extern char _ctmp;
#define upalpha ('A' - 'a')
extern inline int isspace(char c)
{
return(c==' '||c=='\t');
}
extern inline char toupper(char c)
{
if ((c>='a') && (c<='z')) return (c+upalpha);

View File

@@ -23,15 +23,17 @@
#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);
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
#ifndef NDEBUG
#define DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); ExAllocatePool(NonPagedPool, 0); } while(0);
#define OLD_DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); ExAllocatePool(NonPagedPool,0); } while(0);
//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
#define CHECKPOINT do {DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool, 0); } while(0);
#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
#else
#define DPRINT(fmt,args...)
#define DPRINT(args...)
#define OLD_DPRINT(args...)
#define assert(x)
#define CHECKPOINT
#endif /* 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,82 +0,0 @@
/*
* Lowlevel memory managment definitions
*/
#ifndef __INTERNAL_HAL_PAGE_H
#define __INTERNAL_HAL_PAGE_H
#include <ddk/ntddk.h>
#define PAGESIZE (4096)
/*
* Sets a page entry
* vaddr: The virtual address to set the page entry for
* attributes: The access attributes to give the page
* physaddr: The physical address the page should map to
*/
void set_page(unsigned int vaddr, unsigned int attributes,
unsigned int physaddr);
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGESIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) )
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff))
/*
* Page access attributes (or these together)
*/
#define PA_READ (1<<0)
#define PA_WRITE ((1<<0)+(1<<1))
#define PA_EXECUTE PA_READ
#define PA_PCD (1<<4)
#define PA_PWT (1<<3)
/*
* Page attributes
*/
#define PA_USER (1<<2)
#define PA_SYSTEM (0)
#define KERNEL_BASE (0xc0000000)
#define IDMAP_BASE (0xd0000000)
/*
* Return a linear address which can be used to access the physical memory
* starting at x
*/
extern inline unsigned int physical_to_linear(unsigned int x)
{
return(x+IDMAP_BASE);
}
extern inline unsigned int linear_to_physical(unsigned int x)
{
return(x-IDMAP_BASE);
}
#define FLUSH_TLB __asm__("movl %cr3,%eax\n\tmovl %eax,%cr3\n\t")
extern inline unsigned int* get_page_directory(void)
{
unsigned int page_dir=0;
__asm__("movl %%cr3,%0\n\t"
: "=r" (page_dir));
return((unsigned int *)physical_to_linear(page_dir));
}
/*
* Amount of memory that can be mapped by a page table
*/
#define PAGE_TABLE_SIZE (4*1024*1024)
#define PAGE_MASK(x) (x&(~0xfff))
#define VADDR_TO_PT_OFFSET(x) (((x/1024)%4096))
#define VADDR_TO_PD_OFFSET(x) ((x)/(4*1024*1024))
unsigned int* get_page_entry(unsigned int vaddr);
BOOL is_page_present(unsigned int vaddr);
#endif /* __INTERNAL_HAL_PAGE_H */

View File

@@ -1,343 +0,0 @@
#ifndef _ASM_SEGMENT_H
#define _ASM_SEGMENT_H
#define ZERO_DS 0x18
#define KERNEL_CS 0x20
#define KERNEL_DS 0x28
#ifndef __ASSEMBLY__
/*
* Uh, these should become the main single-value transfer routines..
* They automatically use the right size if we just have the right
* pointer type..
*/
#define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
#define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
/*
* This is a silly but good way to make sure that
* the __put_user function is indeed always optimized,
* and that we use the correct sizes..
*/
extern int bad_user_access_length(void);
/*
* dummy pointer type structure.. gcc won't try to do something strange
* this way..
*/
struct __segment_dummy { unsigned long a[100]; };
#define __sd(x) ((struct __segment_dummy *) (x))
#define __const_sd(x) ((const struct __segment_dummy *) (x))
static inline void __put_user(unsigned long x, void * y, int size)
{
switch (size) {
case 1:
__asm__ ("movb %b1,%%fs:%0"
:"=m" (*__sd(y))
:"iq" ((unsigned char) x), "m" (*__sd(y)));
break;
case 2:
__asm__ ("movw %w1,%%fs:%0"
:"=m" (*__sd(y))
:"ir" ((unsigned short) x), "m" (*__sd(y)));
break;
case 4:
__asm__ ("movl %1,%%fs:%0"
:"=m" (*__sd(y))
:"ir" (x), "m" (*__sd(y)));
break;
default:
bad_user_access_length();
}
}
static inline unsigned long __get_user(const void * y, int size)
{
unsigned long result;
switch (size) {
case 1:
__asm__ ("movb %%fs:%1,%b0"
:"=q" (result)
:"m" (*__const_sd(y)));
return (unsigned char) result;
case 2:
__asm__ ("movw %%fs:%1,%w0"
:"=r" (result)
:"m" (*__const_sd(y)));
return (unsigned short) result;
case 4:
__asm__ ("movl %%fs:%1,%0"
:"=r" (result)
:"m" (*__const_sd(y)));
return result;
default:
return bad_user_access_length();
}
}
static inline void __generic_memcpy_tofs(void * to, const void * from, unsigned long n)
{
__asm__ volatile
(" cld
push %%es
push %%fs
cmpl $3,%0
pop %%es
jbe 1f
movl %%edi,%%ecx
negl %%ecx
andl $3,%%ecx
subl %%ecx,%0
rep; movsb
movl %0,%%ecx
shrl $2,%%ecx
rep; movsl
andl $3,%0
1: movl %0,%%ecx
rep; movsb
pop %%es"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si");
}
static inline void __constant_memcpy_tofs(void * to, const void * from, unsigned long n)
{
switch (n) {
case 0:
return;
case 1:
__put_user(*(const char *) from, (char *) to, 1);
return;
case 2:
__put_user(*(const short *) from, (short *) to, 2);
return;
case 3:
__put_user(*(const short *) from, (short *) to, 2);
__put_user(*(2+(const char *) from), 2+(char *) to, 1);
return;
case 4:
__put_user(*(const int *) from, (int *) to, 4);
return;
case 8:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
return;
case 12:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
__put_user(*(2+(const int *) from), 2+(int *) to, 4);
return;
case 16:
__put_user(*(const int *) from, (int *) to, 4);
__put_user(*(1+(const int *) from), 1+(int *) to, 4);
__put_user(*(2+(const int *) from), 2+(int *) to, 4);
__put_user(*(3+(const int *) from), 3+(int *) to, 4);
return;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"push %%es\n\t" \
"push %%fs\n\t" \
"pop %%es\n\t" \
"rep ; movsl\n\t" \
x \
"pop %%es" \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si")
switch (n % 4) {
case 0:
COMMON("");
return;
case 1:
COMMON("movsb\n\t");
return;
case 2:
COMMON("movsw\n\t");
return;
case 3:
COMMON("movsw\n\tmovsb\n\t");
return;
}
#undef COMMON
}
static inline void __generic_memcpy_fromfs(void * to, const void * from, unsigned long n)
{
__asm__ volatile
(" cld
cmpl $3,%0
jbe 1f
movl %%edi,%%ecx
negl %%ecx
andl $3,%%ecx
subl %%ecx,%0
fs; rep; movsb
movl %0,%%ecx
shrl $2,%%ecx
fs; rep; movsl
andl $3,%0
1: movl %0,%%ecx
fs; rep; movsb"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si", "memory");
}
static inline void __constant_memcpy_fromfs(void * to, const void * from, unsigned long n)
{
switch (n) {
case 0:
return;
case 1:
*(char *)to = __get_user((const char *) from, 1);
return;
case 2:
*(short *)to = __get_user((const short *) from, 2);
return;
case 3:
*(short *) to = __get_user((const short *) from, 2);
*((char *) to + 2) = __get_user(2+(const char *) from, 1);
return;
case 4:
*(int *) to = __get_user((const int *) from, 4);
return;
case 8:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
return;
case 12:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
*(2+(int *) to) = __get_user(2+(const int *) from, 4);
return;
case 16:
*(int *) to = __get_user((const int *) from, 4);
*(1+(int *) to) = __get_user(1+(const int *) from, 4);
*(2+(int *) to) = __get_user(2+(const int *) from, 4);
*(3+(int *) to) = __get_user(3+(const int *) from, 4);
return;
}
#define COMMON(x) \
__asm__("cld\n\t" \
"rep ; fs ; movsl\n\t" \
x \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si","memory")
switch (n % 4) {
case 0:
COMMON("");
return;
case 1:
COMMON("fs ; movsb");
return;
case 2:
COMMON("fs ; movsw");
return;
case 3:
COMMON("fs ; movsw\n\tfs ; movsb");
return;
}
#undef COMMON
}
#define memcpy_fromfs(to, from, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy_fromfs((to),(from),(n)) : \
__generic_memcpy_fromfs((to),(from),(n)))
#define memcpy_tofs(to, from, n) \
(__builtin_constant_p(n) ? \
__constant_memcpy_tofs((to),(from),(n)) : \
__generic_memcpy_tofs((to),(from),(n)))
/*
* These are deprecated..
*
* Use "put_user()" and "get_user()" with the proper pointer types instead.
*/
#define get_fs_byte(addr) __get_user((const unsigned char *)(addr),1)
#define get_fs_word(addr) __get_user((const unsigned short *)(addr),2)
#define get_fs_long(addr) __get_user((const unsigned int *)(addr),4)
#define put_fs_byte(x,addr) __put_user((x),(unsigned char *)(addr),1)
#define put_fs_word(x,addr) __put_user((x),(unsigned short *)(addr),2)
#define put_fs_long(x,addr) __put_user((x),(unsigned int *)(addr),4)
#ifdef WE_REALLY_WANT_TO_USE_A_BROKEN_INTERFACE
static inline unsigned short get_user_word(const short *addr)
{
return __get_user(addr, 2);
}
static inline unsigned char get_user_byte(const char * addr)
{
return __get_user(addr,1);
}
static inline unsigned long get_user_long(const int *addr)
{
return __get_user(addr, 4);
}
static inline void put_user_byte(char val,char *addr)
{
__put_user(val, addr, 1);
}
static inline void put_user_word(short val,short * addr)
{
__put_user(val, addr, 2);
}
static inline void put_user_long(unsigned long val,int * addr)
{
__put_user(val, addr, 4);
}
#endif
/*
* Someone who knows GNU asm better than I should double check the following.
* It seems to work, but I don't know if I'm doing something subtly wrong.
* --- TYT, 11/24/91
* [ nothing wrong here, Linus: I just changed the ax to be any reg ]
*/
static inline unsigned long get_fs(void)
{
unsigned long _v;
__asm__("mov %%fs,%w0":"=r" (_v):"0" (0));
return _v;
}
static inline unsigned long get_ds(void)
{
unsigned long _v;
__asm__("mov %%ds,%w0":"=r" (_v):"0" (0));
return _v;
}
static inline void set_fs(unsigned long val)
{
__asm__ __volatile__("mov %w0,%%fs": /* no output */ :"r" (val));
}
static inline void set_ds(unsigned long val)
{
__asm__ __volatile__("mov %w0,%%ds": /* no output */ :"r" (val));
}
#endif /* __ASSEMBLY__ */
#endif /* _ASM_SEGMENT_H */

View File

@@ -51,6 +51,7 @@ typedef struct
unsigned char io_bitmap[1];
} hal_thread_state;
/*
* FUNCTION: Probes for a PCI bus
* RETURNS: True if found

View File

@@ -14,6 +14,10 @@
#include <ddk/ntddk.h>
#include <internal/ob.h>
extern POBJECT_TYPE IoDeviceType;
extern POBJECT_TYPE IoFileType;
extern POBJECT_TYPE IoSymbolicLinkType;
/*
* FUNCTION: Called to initalize a loaded driver
* ARGUMENTS:
@@ -36,5 +40,9 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
PKEVENT UserEvent,
PIO_STATUS_BLOCK IoStatusBlock,
PDEVICE_OBJECT DeviceToMount);
NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
PVOID Address,
PLARGE_INTEGER Offset,
PIO_STATUS_BLOCK StatusBlock);
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
#endif

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

@@ -15,6 +15,10 @@
/* INTERNAL KERNEL FUNCTIONS ************************************************/
VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
VOID KiInterruptDispatch(ULONG irq);
VOID KiDispatchInterrupt(ULONG irq);
VOID KiTimerInterrupt(VOID);

View File

@@ -5,8 +5,6 @@
#ifndef __INCLUDE_INTERNAL_MM_H
#define __INCLUDE_INTERNAL_MM_H
#define PAGE_SYSTEM (0x80000000)
#include <internal/linkage.h>
#include <internal/ntoskrnl.h>
#include <windows.h>
@@ -16,25 +14,31 @@
enum
{
MEMORY_AREA_INVALID,
MEMORY_AREA_SECTION_VIEW,
MEMORY_AREA_SECTION_VIEW_COMMIT,
MEMORY_AREA_CONTINUOUS_MEMORY,
MEMORY_AREA_NO_CACHE,
MEMORY_AREA_IO_MAPPING,
MEMORY_AREA_SYSTEM,
MEMORY_AREA_MDL_MAPPING,
MEMORY_AREA_COMMIT,
MEMORY_AREA_RESERVE,
MEMORY_AREA_SECTION_VIEW_RESERVE,
};
typedef struct
{
CSHORT Type;
CSHORT Size;
FILE_OBJECT* File;
} SECTION_OBJECT;
LARGE_INTEGER MaximumSize;
ULONG SectionPageProtection;
ULONG AllocateAttributes;
PFILE_OBJECT FileObject;
} SECTION_OBJECT, *PSECTION_OBJECT;
typedef struct
{
ULONG Type;
ULONG BaseAddress;
PVOID BaseAddress;
ULONG Length;
ULONG Attributes;
LIST_ENTRY Entry;
@@ -47,22 +51,28 @@ typedef struct
ULONG ViewOffset;
} SectionData;
} Data;
} MEMORY_AREA;
} MEMORY_AREA, *PMEMORY_AREA;
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
PEPROCESS Process,
ULONG Type,
PULONG BaseAddress,
PVOID* BaseAddress,
ULONG Length,
ULONG Attributes,
MEMORY_AREA** Result);
MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address);
MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address);
NTSTATUS MmInitMemoryAreas(VOID);
VOID ExInitNonPagedPool(ULONG BaseAddress);
NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
PVOID BaseAddress,
ULONG Length,
BOOLEAN FreePages);
VOID MmDumpMemoryAreas(VOID);
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead);
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea);
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea);
NTSTATUS MmInitSectionImplementation(VOID);
/*
* FUNCTION: Gets a page with a restricted max physical address (i.e.
@@ -96,4 +106,13 @@ void mark_page_not_writable(unsigned int vaddr);
void VirtualInit(boot_param* bp);
#define MM_LOWEST_USER_ADDRESS (4096)
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
PMEMORY_AREA OriginalMemoryArea,
PVOID BaseAddress,
ULONG Length,
ULONG NewType,
ULONG NewAttributes);
#endif

View File

@@ -44,6 +44,8 @@ enum
OBJTYP_DEVICE,
OBJTYP_THREAD,
OBJTYP_FILE,
OBJTYP_PROCESS,
OBJTYP_SECTION,
OBJTYP_MAX,
};
@@ -51,27 +53,23 @@ BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object);
VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
VOID ObInitializeObjectHeader(POBJECT_TYPE Type, 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);
HANDLE ObInsertHandle(PKPROCESS Process, PVOID ObjectBody,
ACCESS_MASK GrantedAccess, BOOLEAN Inherit);
VOID ObDeleteHandle(HANDLE Handle);
NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
PWSTR* UnparsedSection);
PVOID ObGetObjectByHandle(HANDLE h);
PVOID ObGenericCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
CSHORT Type);
POBJECT_TYPE Type);
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* Object, PWSTR* UnparsedSection);
VOID ObInitializeHandleTable(PKPROCESS Parent, BOOLEAN Inherit,
PKPROCESS Process);
VOID ObRemoveEntry(POBJECT_HEADER Header);
/*
* FUNCTION: Creates an entry within a directory
@@ -92,6 +90,18 @@ 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))
#define OBJECT_ALLOC_SIZE(type) (type->NonpagedPoolCharge+sizeof(OBJECT_HEADER)-sizeof(COMMON_BODY_HEADER))
/*
* PURPOSE: Defines a handle
*/
typedef struct
{
PVOID ObjectBody;
ACCESS_MASK GrantedAccess;
BOOLEAN Inherit;
} HANDLE_REP, *PHANDLE_REP;
PHANDLE_REP ObTranslateHandle(PKPROCESS Process, HANDLE h);
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */

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

@@ -5,7 +5,7 @@
#include <internal/linkage.h>
static PVOID ExAllocatePagedPool(POOL_TYPE Type, ULONG size);
static PVOID ExAllocateNonPagedPool(POOL_TYPE Type, ULONG size);
PVOID ExAllocatePagedPoolWithTag(POOL_TYPE Type, ULONG size, ULONG Tag);
PVOID ExAllocateNonPagedPoolWithTag(POOL_TYPE Type, ULONG size, ULONG Tag);
#endif /* __INTERNAL_POOL_H */

View File

@@ -3,12 +3,16 @@
#include <internal/hal.h>
extern EPROCESS SystemProcess;
extern PEPROCESS SystemProcess;
extern HANDLE SystemProcessHandle;
extern POBJECT_TYPE PsThreadType;
extern POBJECT_TYPE PsProcessType;
void PsInitThreadManagment(void);
VOID PsInitProcessManagment(VOID);
VOID PsInitIdleThread(VOID);
VOID PsDispatchThread(VOID);
/*
* PURPOSE: Thread states
@@ -45,9 +49,9 @@ enum
* Functions the HAL must provide
*/
void HalInitFirstTask(PKTHREAD thread);
BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
PVOID StartContext);
void HalInitFirstTask(PETHREAD thread);
BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
void HalTaskSwitch(PKTHREAD thread);
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
#endif

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.11"
#define KERNEL_VERSION "0.0.12"
#define KERNEL_MAJOR_VERSION 0
#define KERNEL_MINOR_VERSION 0
#define KERNEL_PATCH_LEVEL 11
#define KERNEL_PATCH_LEVEL 12
#endif

View File

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

View File

@@ -105,6 +105,4 @@ typedef struct __HEAP
HEAP_BLOCK Start __attribute__((aligned (8)));
} HEAP, *PHEAP;
//PHEAP __ProcessHeap;
#endif /* __INCLUDE_KERNEL32_HEAP_H */

View File

@@ -32,10 +32,338 @@
#ifndef _GNU_H_WINDOWS32_STRUCTURES
#define _GNU_H_WINDOWS32_STRUCTURES
typedef struct _LARGE_INTEGER {
DWORD LowPart;
LONG HighPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
typedef struct _LIST_ENTRY {
struct _LIST_ENTRY *Flink;
struct _LIST_ENTRY *Blink;
} LIST_ENTRY, *PLIST_ENTRY;
typedef DWORD ACCESS_MASK;
typedef struct _SID_IDENTIFIER_AUTHORITY {
BYTE Value[6];
} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY,
*LPSID_IDENTIFIER_AUTHORITY;
typedef struct _ACL {
BYTE AclRevision;
BYTE Sbz1;
WORD AclSize;
WORD AceCount;
WORD Sbz2;
} ACL, *PACL;
typedef struct _SID {
BYTE Revision;
BYTE SubAuthorityCount;
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
DWORD SubAuthority[ANYSIZE_ARRAY];
} SID, *PSID;
typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
typedef struct _SECURITY_DESCRIPTOR {
BYTE Revision;
BYTE Sbz1;
SECURITY_DESCRIPTOR_CONTROL Control;
PSID Owner;
PSID Group;
PACL Sacl;
PACL Dacl;
} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
typedef struct _SECURITY_QUALITY_OF_SERVICE {
DWORD Length;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
/* SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; */
WINBOOL ContextTrackingMode;
BOOLEAN EffectiveOnly;
} SECURITY_QUALITY_OF_SERVICE;
typedef LARGE_INTEGER LUID, *PLUID;
typedef struct _TOKEN_SOURCE {
CHAR SourceName[8];
LUID SourceIdentifier;
} TOKEN_SOURCE;
typedef struct _PARTITION_INFORMATION {
BYTE PartitionType;
BOOLEAN BootIndicator;
BOOLEAN RecognizedPartition;
BOOLEAN RewritePartition;
LARGE_INTEGER StartingOffset;
LARGE_INTEGER PartitionLength;
LARGE_INTEGER HiddenSectors;
} PARTITION_INFORMATION ;
typedef struct _SINGLE_LIST_ENTRY {
struct _SINGLE_LIST_ENTRY *Next;
} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
typedef struct _CRITICAL_SECTION_DEBUG {
WORD Type;
WORD CreatorBackTraceIndex;
struct _CRITICAL_SECTION *CriticalSection;
LIST_ENTRY ProcessLocksList;
DWORD EntryCount;
DWORD ContentionCount;
DWORD Depth;
PVOID OwnerBackTrace[ 5 ];
} CRITICAL_SECTION_DEBUG, *PCRITICAL_SECTION_DEBUG;
typedef struct _CRITICAL_SECTION {
PCRITICAL_SECTION_DEBUG DebugInfo;
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
HANDLE LockSemaphore;
DWORD Reserved;
} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
typedef struct _ULARGE_INTEGER {
DWORD LowPart;
DWORD HighPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
typedef struct _GENERIC_MAPPING {
ACCESS_MASK GenericRead;
ACCESS_MASK GenericWrite;
ACCESS_MASK GenericExecute;
ACCESS_MASK GenericAll;
} GENERIC_MAPPING, *PGENERIC_MAPPING;
typedef struct _LUID_AND_ATTRIBUTES {
LUID Luid;
DWORD Attributes;
} LUID_AND_ATTRIBUTES;
typedef struct _PRIVILEGE_SET {
DWORD PrivilegeCount;
DWORD Control;
LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
} PRIVILEGE_SET, *PPRIVILEGE_SET, *LPPRIVILEGE_SET;
#ifdef __i386__
typedef struct _FLOATING_SAVE_AREA {
DWORD ControlWord;
DWORD StatusWord;
DWORD TagWord;
DWORD ErrorOffset;
DWORD ErrorSelector;
DWORD DataOffset;
DWORD DataSelector;
BYTE RegisterArea[80];
DWORD Cr0NpxState;
} FLOATING_SAVE_AREA;
typedef struct _CONTEXT {
DWORD ContextFlags;
DWORD Dr0;
DWORD Dr1;
DWORD Dr2;
DWORD Dr3;
DWORD Dr6;
DWORD Dr7;
FLOATING_SAVE_AREA FloatSave;
DWORD SegGs;
DWORD SegFs;
DWORD SegEs;
DWORD SegDs;
DWORD Edi;
DWORD Esi;
DWORD Ebx;
DWORD Edx;
DWORD Ecx;
DWORD Eax;
DWORD Ebp;
DWORD Eip;
DWORD SegCs;
DWORD EFlags;
DWORD Esp;
DWORD SegSs;
} CONTEXT, *PCONTEXT, *LPCONTEXT;
#else /* __ppc__ */
typedef struct
{
/* Floating point registers returned when CONTEXT_FLOATING_POINT is set */
double Fpr0;
double Fpr1;
double Fpr2;
double Fpr3;
double Fpr4;
double Fpr5;
double Fpr6;
double Fpr7;
double Fpr8;
double Fpr9;
double Fpr10;
double Fpr11;
double Fpr12;
double Fpr13;
double Fpr14;
double Fpr15;
double Fpr16;
double Fpr17;
double Fpr18;
double Fpr19;
double Fpr20;
double Fpr21;
double Fpr22;
double Fpr23;
double Fpr24;
double Fpr25;
double Fpr26;
double Fpr27;
double Fpr28;
double Fpr29;
double Fpr30;
double Fpr31;
double Fpscr;
/* Integer registers returned when CONTEXT_INTEGER is set. */
DWORD Gpr0;
DWORD Gpr1;
DWORD Gpr2;
DWORD Gpr3;
DWORD Gpr4;
DWORD Gpr5;
DWORD Gpr6;
DWORD Gpr7;
DWORD Gpr8;
DWORD Gpr9;
DWORD Gpr10;
DWORD Gpr11;
DWORD Gpr12;
DWORD Gpr13;
DWORD Gpr14;
DWORD Gpr15;
DWORD Gpr16;
DWORD Gpr17;
DWORD Gpr18;
DWORD Gpr19;
DWORD Gpr20;
DWORD Gpr21;
DWORD Gpr22;
DWORD Gpr23;
DWORD Gpr24;
DWORD Gpr25;
DWORD Gpr26;
DWORD Gpr27;
DWORD Gpr28;
DWORD Gpr29;
DWORD Gpr30;
DWORD Gpr31;
DWORD Cr; /* Condition register */
DWORD Xer; /* Fixed point exception register */
/* The following are set when CONTEXT_CONTROL is set. */
DWORD Msr; /* Machine status register */
DWORD Iar; /* Instruction address register */
DWORD Lr; /* Link register */
DWORD Ctr; /* Control register */
/* Control which context values are returned */
DWORD ContextFlags;
DWORD Fill[3];
/* Registers returned if CONTEXT_DEBUG_REGISTERS is set. */
DWORD Dr0; /* Breakpoint Register 1 */
DWORD Dr1; /* Breakpoint Register 2 */
DWORD Dr2; /* Breakpoint Register 3 */
DWORD Dr3; /* Breakpoint Register 4 */
DWORD Dr4; /* Breakpoint Register 5 */
DWORD Dr5; /* Breakpoint Register 6 */
DWORD Dr6; /* Debug Status Register */
DWORD Dr7; /* Debug Control Register */
} CONTEXT, *PCONTEXT, *LPCONTEXT;
#endif
typedef struct value_ent {
LPTSTR ve_valuename;
DWORD ve_valuelen;
DWORD ve_valueptr;
DWORD ve_type;
} VALENT, *PVALENT;
typedef struct _EXCEPTION_RECORD {
DWORD ExceptionCode;
DWORD ExceptionFlags;
struct _EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD;
typedef struct _DRIVE_LAYOUT_INFORMATION {
DWORD PartitionCount;
DWORD Signature;
PARTITION_INFORMATION PartitionEntry[1];
} DRIVE_LAYOUT_INFORMATION;
typedef struct _KEY_EVENT_RECORD {
WINBOOL bKeyDown;
WORD wRepeatCount;
WORD wVirtualKeyCode;
WORD wVirtualScanCode;
char AsciiChar;
char pad;
#if 0
union {
WCHAR UnicodeChar;
CHAR AsciiChar;
} uChar;
#endif
DWORD dwControlKeyState;
} KEY_EVENT_RECORD PACKED;
typedef struct _COORD {
SHORT X;
SHORT Y;
} COORD;
typedef struct _MOUSE_EVENT_RECORD {
COORD dwMousePosition;
DWORD dwButtonState;
DWORD dwControlKeyState;
DWORD dwEventFlags;
} MOUSE_EVENT_RECORD;
typedef struct _DISK_GEOMETRY {
LARGE_INTEGER Cylinders;
MEDIA_TYPE MediaType;
DWORD TracksPerCylinder;
DWORD SectorsPerTrack;
DWORD BytesPerSector;
} DISK_GEOMETRY ;
#ifndef WIN32_LEAN_AND_MEAN
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _ABC {
int abcA;
UINT abcB;
@@ -60,7 +388,6 @@ typedef struct _ACE_HEADER {
WORD AceSize;
} ACE_HEADER;
typedef DWORD ACCESS_MASK;
typedef ACCESS_MASK REGSAM;
typedef struct _ACCESS_ALLOWED_ACE {
@@ -81,14 +408,6 @@ typedef struct tagACCESSTIMEOUT {
DWORD iTimeOutMSec;
} ACCESSTIMEOUT;
typedef struct _ACL {
BYTE AclRevision;
BYTE Sbz1;
WORD AclSize;
WORD AceCount;
WORD Sbz2;
} ACL, *PACL;
typedef struct _ACL_REVISION_INFORMATION {
DWORD AclRevision;
} ACL_REVISION_INFORMATION;
@@ -629,11 +948,6 @@ typedef struct _CONSOLE_CURSOR_INFO {
WINBOOL bVisible;
} CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO;
typedef struct _COORD {
SHORT X;
SHORT Y;
} COORD;
typedef struct _SMALL_RECT {
SHORT Left;
SHORT Top;
@@ -649,183 +963,6 @@ typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
COORD dwMaximumWindowSize;
} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO ;
#ifdef __i386__
typedef struct _FLOATING_SAVE_AREA {
DWORD ControlWord;
DWORD StatusWord;
DWORD TagWord;
DWORD ErrorOffset;
DWORD ErrorSelector;
DWORD DataOffset;
DWORD DataSelector;
BYTE RegisterArea[80];
DWORD Cr0NpxState;
} FLOATING_SAVE_AREA;
typedef struct _CONTEXT {
DWORD ContextFlags;
DWORD Dr0;
DWORD Dr1;
DWORD Dr2;
DWORD Dr3;
DWORD Dr6;
DWORD Dr7;
FLOATING_SAVE_AREA FloatSave;
DWORD SegGs;
DWORD SegFs;
DWORD SegEs;
DWORD SegDs;
DWORD Edi;
DWORD Esi;
DWORD Ebx;
DWORD Edx;
DWORD Ecx;
DWORD Eax;
DWORD Ebp;
DWORD Eip;
DWORD SegCs;
DWORD EFlags;
DWORD Esp;
DWORD SegSs;
} CONTEXT, *PCONTEXT, *LPCONTEXT;
#else /* __ppc__ */
typedef struct
{
/* Floating point registers returned when CONTEXT_FLOATING_POINT is set */
double Fpr0;
double Fpr1;
double Fpr2;
double Fpr3;
double Fpr4;
double Fpr5;
double Fpr6;
double Fpr7;
double Fpr8;
double Fpr9;
double Fpr10;
double Fpr11;
double Fpr12;
double Fpr13;
double Fpr14;
double Fpr15;
double Fpr16;
double Fpr17;
double Fpr18;
double Fpr19;
double Fpr20;
double Fpr21;
double Fpr22;
double Fpr23;
double Fpr24;
double Fpr25;
double Fpr26;
double Fpr27;
double Fpr28;
double Fpr29;
double Fpr30;
double Fpr31;
double Fpscr;
/* Integer registers returned when CONTEXT_INTEGER is set. */
DWORD Gpr0;
DWORD Gpr1;
DWORD Gpr2;
DWORD Gpr3;
DWORD Gpr4;
DWORD Gpr5;
DWORD Gpr6;
DWORD Gpr7;
DWORD Gpr8;
DWORD Gpr9;
DWORD Gpr10;
DWORD Gpr11;
DWORD Gpr12;
DWORD Gpr13;
DWORD Gpr14;
DWORD Gpr15;
DWORD Gpr16;
DWORD Gpr17;
DWORD Gpr18;
DWORD Gpr19;
DWORD Gpr20;
DWORD Gpr21;
DWORD Gpr22;
DWORD Gpr23;
DWORD Gpr24;
DWORD Gpr25;
DWORD Gpr26;
DWORD Gpr27;
DWORD Gpr28;
DWORD Gpr29;
DWORD Gpr30;
DWORD Gpr31;
DWORD Cr; /* Condition register */
DWORD Xer; /* Fixed point exception register */
/* The following are set when CONTEXT_CONTROL is set. */
DWORD Msr; /* Machine status register */
DWORD Iar; /* Instruction address register */
DWORD Lr; /* Link register */
DWORD Ctr; /* Control register */
/* Control which context values are returned */
DWORD ContextFlags;
DWORD Fill[3];
/* Registers returned if CONTEXT_DEBUG_REGISTERS is set. */
DWORD Dr0; /* Breakpoint Register 1 */
DWORD Dr1; /* Breakpoint Register 2 */
DWORD Dr2; /* Breakpoint Register 3 */
DWORD Dr3; /* Breakpoint Register 4 */
DWORD Dr4; /* Breakpoint Register 5 */
DWORD Dr5; /* Breakpoint Register 6 */
DWORD Dr6; /* Debug Status Register */
DWORD Dr7; /* Debug Control Register */
} CONTEXT, *PCONTEXT, *LPCONTEXT;
#endif
typedef struct _LIST_ENTRY {
struct _LIST_ENTRY *Flink;
struct _LIST_ENTRY *Blink;
} LIST_ENTRY, *PLIST_ENTRY;
typedef struct _CRITICAL_SECTION_DEBUG {
WORD Type;
WORD CreatorBackTraceIndex;
struct _CRITICAL_SECTION *CriticalSection;
LIST_ENTRY ProcessLocksList;
DWORD EntryCount;
DWORD ContentionCount;
DWORD Depth;
PVOID OwnerBackTrace[ 5 ];
} CRITICAL_SECTION_DEBUG, *PCRITICAL_SECTION_DEBUG;
typedef struct _CRITICAL_SECTION {
PCRITICAL_SECTION_DEBUG DebugInfo;
LONG LockCount;
LONG RecursionCount;
HANDLE OwningThread;
HANDLE LockSemaphore;
DWORD Reserved;
} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
typedef struct _SECURITY_QUALITY_OF_SERVICE {
DWORD Length;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
/* SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; */
WINBOOL ContextTrackingMode;
BOOLEAN EffectiveOnly;
} SECURITY_QUALITY_OF_SERVICE;
typedef struct tagCONVCONTEXT {
UINT cb;
UINT wFlags;
@@ -1009,15 +1146,6 @@ typedef struct {
BYTE rgb[1];
} DDEUP;
typedef struct _EXCEPTION_RECORD {
DWORD ExceptionCode;
DWORD ExceptionFlags;
struct _EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD;
typedef struct _EXCEPTION_DEBUG_INFO {
EXCEPTION_RECORD ExceptionRecord;
DWORD dwFirstChance;
@@ -1176,20 +1304,7 @@ typedef struct tagDIBSECTION {
HANDLE dshSection;
DWORD dsOffset;
} DIBSECTION;
typedef struct _LARGE_INTEGER {
DWORD LowPart;
LONG HighPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
typedef struct _DISK_GEOMETRY {
LARGE_INTEGER Cylinders;
MEDIA_TYPE MediaType;
DWORD TracksPerCylinder;
DWORD SectorsPerTrack;
DWORD BytesPerSector;
} DISK_GEOMETRY ;
typedef struct _DISK_PERFORMANCE {
LARGE_INTEGER BytesRead;
LARGE_INTEGER BytesWritten;
@@ -1274,21 +1389,7 @@ typedef struct {
UINT uiLengthDrawn;
} DRAWTEXTPARAMS, *LPDRAWTEXTPARAMS;
typedef struct _PARTITION_INFORMATION {
BYTE PartitionType;
BOOLEAN BootIndicator;
BOOLEAN RecognizedPartition;
BOOLEAN RewritePartition;
LARGE_INTEGER StartingOffset;
LARGE_INTEGER PartitionLength;
LARGE_INTEGER HiddenSectors;
} PARTITION_INFORMATION ;
typedef struct _DRIVE_LAYOUT_INFORMATION {
DWORD PartitionCount;
DWORD Signature;
PARTITION_INFORMATION PartitionEntry[1];
} DRIVE_LAYOUT_INFORMATION;
typedef struct _DRIVER_INFO_1 {
LPTSTR pName;
@@ -2255,12 +2356,6 @@ typedef struct tagGCP_RESULTS {
UINT nMaxFit;
} GCP_RESULTS, *LPGCP_RESULTS;
typedef struct _GENERIC_MAPPING {
ACCESS_MASK GenericRead;
ACCESS_MASK GenericWrite;
ACCESS_MASK GenericExecute;
ACCESS_MASK GenericAll;
} GENERIC_MAPPING, *PGENERIC_MAPPING;
typedef struct _GLYPHMETRICS {
UINT gmBlackBoxX;
@@ -2366,30 +2461,6 @@ typedef struct _IMAGEINFO {
RECT rcImage;
} IMAGEINFO;
typedef struct _KEY_EVENT_RECORD {
WINBOOL bKeyDown;
WORD wRepeatCount;
WORD wVirtualKeyCode;
WORD wVirtualScanCode;
char AsciiChar;
char pad;
#if 0
union {
WCHAR UnicodeChar;
CHAR AsciiChar;
} uChar;
#endif
DWORD dwControlKeyState;
} KEY_EVENT_RECORD PACKED;
typedef struct _MOUSE_EVENT_RECORD {
COORD dwMousePosition;
DWORD dwButtonState;
DWORD dwControlKeyState;
DWORD dwEventFlags;
} MOUSE_EVENT_RECORD;
typedef struct _WINDOW_BUFFER_SIZE_RECORD {
COORD dwSize;
} WINDOW_BUFFER_SIZE_RECORD;
@@ -2439,29 +2510,6 @@ typedef struct _JOB_INFO_1 {
SYSTEMTIME Submitted;
} JOB_INFO_1;
typedef struct _SID_IDENTIFIER_AUTHORITY {
BYTE Value[6];
} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY,
*LPSID_IDENTIFIER_AUTHORITY;
typedef struct _SID {
BYTE Revision;
BYTE SubAuthorityCount;
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
DWORD SubAuthority[ANYSIZE_ARRAY];
} SID, *PSID;
typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
typedef struct _SECURITY_DESCRIPTOR {
BYTE Revision;
BYTE Sbz1;
SECURITY_DESCRIPTOR_CONTROL Control;
PSID Owner;
PSID Group;
PACL Sacl;
PACL Dacl;
} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
typedef struct _JOB_INFO_2 {
DWORD JobId;
@@ -2541,12 +2589,7 @@ typedef struct _LOCALGROUP_MEMBERS_INFO_3 {
typedef long FXPT16DOT16, * LPFXPT16DOT16;
typedef LARGE_INTEGER LUID, *PLUID;
typedef struct _LUID_AND_ATTRIBUTES {
LUID Luid;
DWORD Attributes;
} LUID_AND_ATTRIBUTES;
typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
@@ -3472,11 +3515,6 @@ typedef struct _PRINTPROCESSOR_INFO_1 {
LPTSTR pName;
} PRINTPROCESSOR_INFO_1;
typedef struct _PRIVILEGE_SET {
DWORD PrivilegeCount;
DWORD Control;
LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
} PRIVILEGE_SET, *PPRIVILEGE_SET, *LPPRIVILEGE_SET;
typedef struct _PROCESS_HEAP_ENTRY {
PVOID lpData;
@@ -3839,9 +3877,6 @@ typedef struct _SID_AND_ATTRIBUTES {
typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY;
typedef struct _SINGLE_LIST_ENTRY {
struct _SINGLE_LIST_ENTRY *Next;
} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
typedef struct tagSOUNDSENTRY {
UINT cbSize;
@@ -4083,11 +4118,6 @@ typedef struct tagTOGGLEKEYS {
DWORD cbSize;
DWORD dwFlags;
} TOGGLEKEYS;
typedef struct _TOKEN_SOURCE {
CHAR SourceName[8];
LUID SourceIdentifier;
} TOKEN_SOURCE;
typedef struct _TOKEN_CONTROL {
LUID TokenId;
@@ -4216,12 +4246,7 @@ typedef struct {
UINT nSec;
UINT nInc;
} UDACCEL;
typedef struct _ULARGE_INTEGER {
DWORD LowPart;
DWORD HighPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
typedef struct _UNIVERSAL_NAME_INFO {
LPTSTR lpUniversalName;
} UNIVERSAL_NAME_INFO;
@@ -4232,13 +4257,6 @@ typedef struct tagUSEROBJECTFLAGS {
DWORD dwFlags;
} USEROBJECTFLAGS;
typedef struct value_ent {
LPTSTR ve_valuename;
DWORD ve_valuelen;
DWORD ve_valueptr;
DWORD ve_type;
} VALENT, *PVALENT;
typedef struct _VERIFY_INFORMATION {
LARGE_INTEGER StartingOffset;
DWORD Length;
@@ -4555,5 +4573,7 @@ typedef struct
}
#endif /* __cplusplus */
#endif /* WIN32_LEAN_AND_MEAN */
#endif /* _GNU_H_WINDOWS32_STRUCTURES */

View File

@@ -41,7 +41,7 @@
#include <base.h>
/* WIN32 messages */
#ifndef _WIN32_LEAN_AND_MEAN
#ifndef WIN32_LEAN_AND_MEAN
#include <messages.h>
#endif
@@ -54,20 +54,22 @@
#include <structs.h>
/* WIN32 functions */
#ifndef _WIN32_LEAN_AND_MEAN
#ifndef WIN32_LEAN_AND_MEAN
#include <funcs.h>
#endif
#endif /* ! defined (RC_INVOKED) */
/* WIN32 error codes */
#ifndef WIN32_LEAN_AND_MEAN
#include <errors.h>
#endif
#ifndef RC_INVOKED
/* Windows sockets specification version 1.1 */
#ifdef Win32_Winsock
#ifndef _WIN32_LEAN_AND_MEAN
#ifndef WIN32_LEAN_AND_MEAN
#include <sockets.h>
#endif
#endif

View File

@@ -36,6 +36,11 @@ extern size_t wcsnlen(const wchar_t * s, size_t count);
extern int wcsicmp(const wchar_t* cs,const wchar_t * ct);
extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
WCHAR wtoupper(WCHAR c);
WCHAR wtolower(WCHAR c);
#ifdef __cplusplus
}
#endif

View File

@@ -1,32 +1,16 @@
/*
* Win32 File Api functions
* Author: Boudewijn Dekker
* to do: many more to add ..
*/
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
// AnsiOrOemtoUnicode
// pupose: internal procedure used in file api
NTSTATUS AnsiOrOemtoUnicode(PUNICODE_STRING DestinationString,PANSI_STRING SourceString, BOOLEAN AllocateDestinationString);
#include <ddk/ntddk.h>
BOOLEAN bIsFileApiAnsi; // set the file api to ansi or oem
NTSTATUS AnsiOrOemtoUnicode(PUNICODE_STRING DestinationString,PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
{
if ( bIsFileApiAnsi ) {
return __AnsiStringToUnicodeString(DestinationString, SourceString, AllocateDestinationString);
else
return __OemStringToUnicodeString(DestinationString, SourceString, AllocateDestinationString);
}
WINBASEAPI
VOID
WINAPI
@@ -36,7 +20,59 @@ SetFileApisToOEM(VOID)
return;
}
HANDLE STDCALL CreateFileA(LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
HANDLE FileHandle;
NTSTATUS Status;
WCHAR FileNameW[255];
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
ULONG i = 0;
UNICODE_STRING FileNameString;
ULONG Flags = 0;
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
{
Flags = Flags | FILE_SYNCHRONOUS_IO_ALERT;
}
FileNameString.Length = 0;
while ((*lpFileName)!=0)
{
FileNameW[i] = *lpFileName;
lpFileName++;
i++;
FileNameString.Length++;
}
FileNameW[i] = 0;
FileNameString.Length++;
FileNameString.Buffer = &FileNameW;
FileNameString.MaximumLength = FileNameString.Length;
ObjectAttributes.RootDirectory = NULL;
ObjectAttributes.ObjectName = &FileNameString;
Status = NtCreateFile(&FileHandle,
dwDesiredAccess,
&ObjectAttributes,
&IoStatusBlock,
NULL,
dwFlagsAndAttributes,
dwShareMode,
dwCreationDisposition,
Flags,
NULL,
0);
return(FileHandle);
}
WINBASEAPI
VOID
@@ -49,10 +85,275 @@ SetFileApisToANSI(VOID)
WINBASEAPI
BOOLEAN
WINAPI
WINBOOL
STDCALL
AreFileApisANSI(VOID)
{
return bIsFileApiAnsi;
}
BOOL STDCALL WriteFile(HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverLapped)
{
//FIXME: WriteFile should write to a console if appropriate
LARGE_INTEGER Offset;
HANDLE hEvent = NULL;
NTSTATUS errCode;
if (lpOverLapped != NULL )
{
Offset.LowPart = lpOverLapped->Offset;
Offset.HighPart = lpOverLapped->OffsetHigh;
lpOverLapped->Internal = STATUS_PENDING;
hEvent= lpOverLapped->hEvent;
}
errCode = NtWriteFile(hFile,hEvent,NULL,NULL,
(PIO_STATUS_BLOCK)lpOverLapped,
lpBuffer,
nNumberOfBytesToWrite,
&Offset,
NULL);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return(TRUE);
}
WINBOOL STDCALL ReadFile(HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverLapped)
{
//FIXME ReadFile should write to a console if appropriate
HANDLE hEvent = NULL;
LARGE_INTEGER Offset;
NTSTATUS errCode;
PIO_STATUS_BLOCK IoStatusBlock;
IO_STATUS_BLOCK IIosb;
OVERLAPPED IOverlapped;
if ( lpOverLapped != NULL )
{
Offset.LowPart = lpOverLapped->Offset;
Offset.HighPart = lpOverLapped->OffsetHigh;
lpOverLapped->Internal = STATUS_PENDING;
hEvent = lpOverLapped->hEvent;
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
}
else
{
IoStatusBlock = &IIosb;
}
errCode = NtReadFile(hFile,
hEvent,
NULL,
NULL,
IoStatusBlock,
lpBuffer,
nNumberOfBytesToRead,
&Offset,
NULL);
if ( errCode < 0 )
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return TRUE;
}
WINBOOL
STDCALL
ReadFileEx(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPOVERLAPPED lpOverLapped,
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
)
{
HANDLE hEvent = NULL;
LARGE_INTEGER Offset;
NTSTATUS errCode;
if ( lpOverLapped != NULL ) {
Offset.LowPart = lpOverLapped->Offset;
Offset.HighPart = lpOverLapped->OffsetHigh;
lpOverLapped->Internal = STATUS_PENDING;
hEvent = lpOverLapped->hEvent;
}
errCode = NtReadFile(hFile,
hEvent,
(PIO_APC_ROUTINE)lpCompletionRoutine,
NULL,
(PIO_STATUS_BLOCK)lpOverLapped,
lpBuffer,
nNumberOfBytesToRead,
&Offset,
NULL);
if ( errCode < 0 ) {
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return TRUE;
}
WINBOOL
STDCALL
LockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow,
DWORD nNumberOfBytesToLockHigh
)
{
DWORD dwReserved;
OVERLAPPED Overlapped;
Overlapped.Offset = dwFileOffsetLow;
Overlapped.OffsetHigh = dwFileOffsetHigh;
dwReserved = 0;
return LockFileEx(hFile, LOCKFILE_FAIL_IMMEDIATELY|LOCKFILE_EXCLUSIVE_LOCK,dwReserved,nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, &Overlapped ) ;
}
WINBOOL
STDCALL
LockFileEx(
HANDLE hFile,
DWORD dwFlags,
DWORD dwReserved,
DWORD nNumberOfBytesToLockLow,
DWORD nNumberOfBytesToLockHigh,
LPOVERLAPPED lpOverlapped
)
{
LARGE_INTEGER BytesToLock;
BOOL LockImmediate;
BOOL LockExclusive;
NTSTATUS errCode;
LARGE_INTEGER Offset;
if(dwReserved != 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
lpOverlapped->Internal = STATUS_PENDING;
Offset.LowPart = lpOverlapped->Offset;
Offset.HighPart = lpOverlapped->OffsetHigh;
if ( (dwFlags & LOCKFILE_FAIL_IMMEDIATELY) == LOCKFILE_FAIL_IMMEDIATELY )
LockImmediate = TRUE;
else
LockImmediate = FALSE;
if ( (dwFlags & LOCKFILE_EXCLUSIVE_LOCK) == LOCKFILE_EXCLUSIVE_LOCK )
LockExclusive = TRUE;
else
LockExclusive = FALSE;
BytesToLock.LowPart = nNumberOfBytesToLockLow;
BytesToLock.HighPart = nNumberOfBytesToLockHigh;
errCode = NtLockFile(hFile,
NULL,
NULL,
NULL,
(PIO_STATUS_BLOCK)lpOverlapped,
&Offset,
&BytesToLock,
NULL,
LockImmediate,
LockExclusive);
if ( errCode < 0 )
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return TRUE;
}
WINBOOL
STDCALL
UnlockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh
)
{
DWORD dwReserved;
OVERLAPPED Overlapped;
Overlapped.Offset = dwFileOffsetLow;
Overlapped.OffsetHigh = dwFileOffsetHigh;
dwReserved = 0;
return UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, &Overlapped);
}
WINBOOL STDCALL UnlockFileEx(HANDLE hFile,
DWORD dwReserved,
DWORD nNumberOfBytesToUnLockLow,
DWORD nNumberOfBytesToUnLockHigh,
LPOVERLAPPED lpOverlapped)
{
LARGE_INTEGER BytesToUnLock;
LARGE_INTEGER StartAddress;
NTSTATUS errCode;
if(dwReserved != 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if ( lpOverlapped == NULL )
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
BytesToUnLock.LowPart = nNumberOfBytesToUnLockLow;
BytesToUnLock.HighPart = nNumberOfBytesToUnLockHigh;
StartAddress.LowPart = lpOverlapped->Offset;
StartAddress.HighPart = lpOverlapped->OffsetHigh;
errCode = NtUnlockFile(hFile,
(PIO_STATUS_BLOCK)lpOverlapped,
StartAddress,
BytesToUnLock,
NULL);
if ( errCode < 0 ) {
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return TRUE;
}

View File

@@ -5,10 +5,11 @@
* todo: check the _lopen for correctness
*/
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string.h>
#include <wstring.h>
#include <fcntl.h>
@@ -26,8 +27,7 @@ long _hread(
}
long
_lread(HFILE fd,LPVOID buffer,long count)
UINT STDCALL _lread(HFILE fd,LPVOID buffer,UINT count)
{
return _hread(fd,buffer, count);
}
@@ -54,14 +54,15 @@ long _hwrite(
}
long _lwrite(
HFILE hFile,
LPCSTR lpBuffer,
long lBytes
)
UINT
STDCALL
_lwrite(
HFILE hFile,
LPCSTR lpBuffer,
UINT uBytes
)
{
return _hwrite(hFile,lpBuffer,lBytes);
return _hwrite(hFile,lpBuffer,uBytes);
}
#define OF_OPENMASK (OF_READ|OF_READWRITE|OF_WRITE|OF_CREATE)
@@ -123,7 +124,7 @@ int _lclose(
if ( CloseHandle((HANDLE)hFile) )
return 0;
else
rerturn -1;
return -1;
}
LONG _llseek(

View File

@@ -1,9 +1,30 @@
all: dummy
all: kernel32.a
OBJECTS = file/file.o file/lfile.o mem/virtual.o mem/local.o mem/global.o
SYNCH_OBJECTS = synch/critical.o
kernel32_lib: $(OBJECTS)
$(LD) --oformat=coff-go32 -Ttext b0000000 $(LDFLAGS) $(OBJECTS) -o kernel32.dll
#MISC_OBJECTS = misc/atom.o
MISC_OBJECTS = misc/error.o
#FILE_OBJECTS = file/file.o file/lfile.o
FILE_OBJECTS = file/file.o file/curdir.o
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
#THREAD_OBJECTS = thread/thread.o
PROCESS_OBJECTS = process/proc.o
STRING_OBJECTS = string/lstring.o
INTERNAL_OBJECTS = internal/dprintf.o internal/vsprintf.o
OBJECTS = $(MISC_OBJECTS) $(FILE_OBJECTS) $(THREAD_OBJECTS) \
$(PROCESS_OBJECTS) $(STRING_OBJECTS) $(MEM_OBJECTS) \
$(INTERNAL_OBJECTS) $(SYNCH_OBJECTS)
kernel32.a: $(OBJECTS)
$(AR) vrcs kernel32.a $(OBJECTS)
dummy:

View File

@@ -1,320 +0,0 @@
/*
* Win32 Global/Local heap functions (GlobalXXX, LocalXXX).
* These functions included in Win32 for compatibility with 16 bit Windows
* Especially the moveable blocks and handles are oldish.
* But the ability to directly allocate memory with GPTR and LPTR is widely
* used.
*/
#include <windows.h>
#define MAGIC_GLOBAL_USED 0x5342BEEF
#define GLOBAL_LOCK_MAX 0xFF
typedef struct __GLOBAL_LOCAL_HANDLE
{
ULONG Magic;
LPVOID Pointer;
BYTE Flags;
BYTE LockCount;
} GLOBAL_HANDLE, LOCAL_HANDLE, *PGLOBAL_HANDLE, *PLOCAL_HANDLE;
/*********************************************************************
* GlobalAlloc -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalAlloc(UINT flags, DWORD size)
{
PGLOBAL_HANDLE phandle;
LPVOID palloc;
aprintf("GlobalAlloc( 0x%X, 0x%lX )\n", flags, size );
if((flags & GMEM_MOVEABLE)==0) /* POINTER */
{
palloc=HeapAlloc(__ProcessHeap, 0, size);
return (HGLOBAL) palloc;
}
else /* HANDLE */
{
HeapLock(__ProcessHeap);
phandle=__HeapAllocFragment(__ProcessHeap, 0, sizeof(GLOBAL_HANDLE));
if(size)
{
palloc=HeapAlloc(__ProcessHeap, 0, size+sizeof(HANDLE));
*(PHANDLE)palloc=(HANDLE) &(phandle->Pointer);
phandle->Pointer=palloc+sizeof(HANDLE);
}
else
phandle->Pointer=NULL;
phandle->Magic=MAGIC_GLOBAL_USED;
phandle->Flags=flags>>8;
phandle->LockCount=0;
HeapUnlock(__ProcessHeap);
return (HGLOBAL) &(phandle->Pointer);
}
}
/*********************************************************************
* GlobalLock -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI GlobalLock(HGLOBAL hmem)
{
PGLOBAL_HANDLE phandle;
LPVOID palloc;
aprintf("GlobalLock( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%8)==0)
return (LPVOID) hmem;
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
if(phandle->LockCount<GLOBAL_LOCK_MAX)
phandle->LockCount++;
palloc=phandle->Pointer;
}
else
{
dprintf("GlobalLock: invalid handle\n");
palloc=(LPVOID) hmem;
}
HeapUnlock(__ProcessHeap);
return palloc;
}
/*********************************************************************
* GlobalUnlock -- KERNEL32 *
*********************************************************************/
BOOL WINAPI GlobalUnlock(HGLOBAL hmem)
{
PGLOBAL_HANDLE phandle;
BOOL locked;
aprintf("GlobalUnlock( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%8)==0)
return FALSE;
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
if((phandle->LockCount<GLOBAL_LOCK_MAX)&&(phandle->LockCount>0))
phandle->LockCount--;
locked=(phandle->LockCount==0) ? TRUE : FALSE;
}
else
{
dprintf("GlobalUnlock: invalid handle\n");
locked=FALSE;
}
HeapUnlock(__ProcessHeap);
return locked;
}
/*********************************************************************
* GlobalHandle -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalHandle(LPCVOID pmem)
{
aprintf("GlobalHandle( 0x%lX )\n", (ULONG) pmem );
if(((ULONG)pmem%8)==0) /* FIXED */
return (HGLOBAL) pmem;
else /* MOVEABLE */
return (HGLOBAL) *(LPVOID *)(pmem-sizeof(HANDLE));
}
/*********************************************************************
* GlobalReAlloc -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalReAlloc(HGLOBAL hmem, DWORD size, UINT flags)
{
LPVOID palloc;
HGLOBAL hnew;
PGLOBAL_HANDLE phandle;
aprintf("GlobalReAlloc( 0x%lX, 0x%lX, 0x%X )\n", (ULONG) hmem, size, flags );
hnew=NULL;
HeapLock(__ProcessHeap);
if(flags & GMEM_MODIFY) /* modify flags */
{
if( (((ULONG)hmem%8)==0) && (flags & GMEM_MOVEABLE))
{
/* make a fixed block moveable
* actually only NT is able to do this. And it's soo simple
*/
size=HeapSize(__ProcessHeap, 0, (LPVOID) hmem);
hnew=GlobalAlloc( flags, size);
palloc=GlobalLock(hnew);
memcpy(palloc, (LPVOID) hmem, size);
GlobalUnlock(hnew);
GlobalFree(hmem);
}
else if((((ULONG)hmem%8) != 0)&&(flags & GMEM_DISCARDABLE))
{
/* change the flags to make our block "discardable" */
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
phandle->Flags = phandle->Flags | (GMEM_DISCARDABLE >> 8);
hnew=hmem;
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
hnew=NULL;
}
}
else
{
if(((ULONG)hmem%8)!=0)
{
/* reallocate fixed memory */
hnew=(HANDLE)HeapReAlloc(__ProcessHeap, 0, (LPVOID) hmem, size);
}
else
{
/* reallocate a moveable block */
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->LockCount!=0)
SetLastError(ERROR_INVALID_HANDLE);
else if(size!=0)
{
hnew=hmem;
if(phandle->Pointer)
{
palloc=HeapReAlloc(__ProcessHeap, 0,
phandle->Pointer-sizeof(HANDLE),
size+sizeof(HANDLE) );
phandle->Pointer=palloc+sizeof(HANDLE);
}
else
{
palloc=HeapAlloc(__ProcessHeap, 0, size+sizeof(HANDLE));
*(PHANDLE)palloc=hmem;
phandle->Pointer=palloc+sizeof(HANDLE);
}
}
else
{
if(phandle->Pointer)
{
HeapFree(__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
phandle->Pointer=NULL;
}
}
}
}
HeapUnlock(__ProcessHeap);
return hnew;
}
/*********************************************************************
* GlobalFree -- KERNEL32 *
*********************************************************************/
HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
{
PGLOBAL_HANDLE phandle;
aprintf("GlobalFree( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%4)==0) /* POINTER */
{
HeapFree(__ProcessHeap, 0, (LPVOID) hmem);
}
else /* HANDLE */
{
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
HeapLock(__ProcessHeap);
if(phandle->LockCount!=0)
SetLastError(ERROR_INVALID_HANDLE);
if(phandle->Pointer)
HeapFree(__ProcessHeap, 0, phandle->Pointer-sizeof(HANDLE));
__HeapFreeFragment(__ProcessHeap, 0, phandle);
}
HeapUnlock(__ProcessHeap);
}
return hmem;
}
/*********************************************************************
* GlobalSize -- KERNEL32 *
*********************************************************************/
DWORD WINAPI GlobalSize(HGLOBAL hmem)
{
DWORD retval;
PGLOBAL_HANDLE phandle;
aprintf("GlobalSize( 0x%lX )\n", (ULONG) hmem );
if(((ULONG)hmem%8)==0)
{
retval=HeapSize(__ProcessHeap, 0, hmem);
}
else
{
HeapLock(__ProcessHeap);
phandle=(PGLOBAL_HANDLE)(((LPVOID) hmem)-4);
if(phandle->Magic==MAGIC_GLOBAL_USED)
{
retval=HeapSize(__ProcessHeap, 0, (phandle->Pointer)-sizeof(HANDLE))-4;
}
else
{
dprintf("GlobalSize: invalid handle\n");
retval=0;
}
HeapUnlock(__ProcessHeap);
}
return retval;
}
/*********************************************************************
* GlobalWire -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI GlobalWire(HGLOBAL hmem)
{
return GlobalLock( hmem );
}
/*********************************************************************
* GlobalUnWire -- KERNEL32 *
*********************************************************************/
BOOL WINAPI GlobalUnWire(HGLOBAL hmem)
{
return GlobalUnlock( hmem);
}
/*********************************************************************
* GlobalFix -- KERNEL32 *
*********************************************************************/
VOID WINAPI GlobalFix(HGLOBAL hmem)
{
GlobalLock( hmem );
}
/*********************************************************************
* GlobalUnfix -- KERNEL32 *
*********************************************************************/
VOID WINAPI GlobalUnfix(HGLOBAL hmem)
{
GlobalUnlock( hmem);
}
/*********************************************************************
* GlobalFlags -- KERNEL32 *
*********************************************************************/
UINT WINAPI GlobalFlags(HGLOBAL hmem)
{
return LocalFlags( (HLOCAL) hmem);
}

View File

@@ -26,7 +26,9 @@
* Put the type definitions of the heap in a seperate header. Boudewijn Dekker
*/
#include <kernel32/kernel32.h>
#include <kernel32/heap.h>
#include <internal/string.h>
static HEAP_BUCKET __HeapDefaultBuckets[]=
{
@@ -40,13 +42,14 @@ static HEAP_BUCKET __HeapDefaultBuckets[]=
{ NULL, 256, 15, 4088 },
};
PHEAP __ProcessHeap;
static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end);
static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end);
static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag);
static VOID __HeapFreeRest(PHEAP pheap, PHEAP_BLOCK pfree, ULONG allocsize,
ULONG newsize);
static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, ULONG size);
static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size);
static BOOL __HeapFree(PHEAP pheap, ULONG flags, LPVOID pmem);
static PHEAP_SUBALLOC __HeapAllocSub(PHEAP pheap, PHEAP_BUCKET pbucket);
static LPVOID __HeapAllocFragment(PHEAP pheap, ULONG flags, ULONG size);
@@ -67,12 +70,14 @@ static BOOL __HeapCommit(PHEAP pheap, LPVOID start, LPVOID end)
{
dprintf("__HeapCommit( 0x%lX, 0x%lX, 0x%lX)\n",
(ULONG) pheap, (ULONG) start, (ULONG) end);
#ifdef NOT
__VirtualDump();
#endif
if(end >= pheap->LastBlock)
pheap->LastBlock=end;
return __VirtualCommit(start, end-start, PAGE_READWRITE);
if (VirtualAlloc(start,end-start,MEM_COMMIT,PAGE_READWRITE)!=start)
{
return(FALSE);
}
return(TRUE);
}
/*********************************************************************
@@ -89,7 +94,8 @@ static BOOL __HeapDecommit(PHEAP pheap, LPVOID start, LPVOID end)
#endif
if((end >= pheap->LastBlock)&&(start<= pheap->LastBlock))
pheap->LastBlock=start;
return __VirtualDecommit(start, end-start );
return(VirtualFree(start,end-start,MEM_RESERVE));
}
/*********************************************************************
@@ -106,7 +112,10 @@ static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag)
LPVOID commitend;
ULONG freesize;
ULONG allocsize;
dprintf("__HeapAlloc(pheap %x, flags %x, size %d, tag %x)\n",
pheap,flags,size,tag);
pfree=&(pheap->Start);
allocsize=SIZE_ROUND(size);
freesize=HEAP_SIZE(pfree);
@@ -154,7 +163,7 @@ static LPVOID __HeapAlloc(PHEAP pheap, ULONG flags, ULONG size, ULONG tag)
/* update our administration */
palloc->Size= size | tag;
if((flags | pheap->Flags)& HEAP_ZERO_MEMORY)
memset((LPVOID)palloc+HEAP_ADMIN_SIZE, 0, allocsize);
FillMemory((LPVOID)palloc+HEAP_ADMIN_SIZE, allocsize, 0);
return (LPVOID)palloc+HEAP_ADMIN_SIZE;
}
@@ -236,7 +245,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
/* alloc a new fragment */
pmem=__HeapAllocFragment(pheap, flags, size);
if(pmem)
memcpy(pmem, pold, size);
CopyMemory(pmem, pold, size);
return pmem;
}
#endif
@@ -300,7 +309,7 @@ static LPVOID __HeapReAlloc(PHEAP pheap, ULONG flags, LPVOID pold, DWORD size)
oldsize=HEAP_SIZE(prealloc);
pmem=__HeapAlloc(pheap, flags, size, HEAP_NORMAL_TAG);
if(pmem)
memcpy(pmem, pold, oldsize);
CopyMemory(pmem, pold, oldsize);
if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
memset(pmem + oldsize, 0, size-oldsize);
__HeapFree(pheap, flags, pold);
@@ -502,7 +511,7 @@ static LPVOID __HeapReAllocFragment(PHEAP pheap, ULONG flags,
pmem=__HeapAllocFragment(pheap, flags, size);
if(pmem)
memcpy(pmem, pold, size);
CopyMemory(pmem, pold, size);
if((flags|pheap->Flags)&HEAP_ZERO_MEMORY)
memset(pmem+pfrag->Size, 0, size-pfrag->Size);
@@ -580,12 +589,15 @@ static BOOL __HeapFreeFragment(PHEAP pheap, ULONG flags, LPVOID pfree )
PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
{
PHEAP pheap=(PHEAP) base;
dprintf("__HeapPrepare(base %x, minsize %d, maxsize %d, flags %x)\n",
base,minsize,maxsize,flags);
pheap->Magic=MAGIC_HEAP;
pheap->End= ((LPVOID)pheap)+minsize;
pheap->Flags=flags;
pheap->LastBlock=(LPVOID)pheap + PAGESIZE;
memcpy(pheap->Bucket,__HeapDefaultBuckets,sizeof(__HeapDefaultBuckets));
CopyMemory(pheap->Bucket,__HeapDefaultBuckets,sizeof(__HeapDefaultBuckets));
if(__ProcessHeap)
{
pheap->NextHeap=__ProcessHeap->NextHeap;
@@ -611,8 +623,8 @@ PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize)
{
mmap(base, PAGESIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
__DevZero, 0);
VirtualAlloc(base,maxsize,MEM_RESERVE,PAGE_READWRITE);
VirtualAlloc(base,PAGESIZE,MEM_COMMIT,PAGE_READWRITE);
__HeapPrepare(base, minsize, maxsize, 0);
}
@@ -621,16 +633,14 @@ VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize)
/*********************************************************************
* HeapCreate -- KERNEL32 *
*********************************************************************/
HANDLE WINAPI HeapCreate(ULONG flags, ULONG minsize, ULONG maxsize)
HANDLE STDCALL HeapCreate(DWORD flags, DWORD minsize, DWORD maxsize)
{
PHEAP pheap;
aprintf("HeapCreate( 0x%lX, 0x%lX, 0x%lX )\n", flags, minsize, maxsize);
pheap = __VirtualReserve(NULL, minsize, PAGE_READWRITE | MEM_TOP_DOWN);
__VirtualCommit(pheap, PAGESIZE, PAGE_READWRITE);
__VirtualDump();
pheap = VirtualAlloc(NULL, minsize, MEM_TOP_DOWN, PAGE_READWRITE);
VirtualAlloc(pheap, PAGESIZE, MEM_COMMIT, PAGE_READWRITE);
return (HANDLE) __HeapPrepare(pheap, minsize, maxsize, flags);
}
@@ -647,15 +657,15 @@ BOOL WINAPI HeapDestroy(HANDLE hheap)
return __ErrorReturnFalse(ERROR_INVALID_PARAMETER);
DeleteCriticalSection(&(pheap->Synchronize));
__VirtualRelease(pheap);
VirtualFree(pheap,0,MEM_RELEASE);
return TRUE;
}
/*********************************************************************
* HeapAlloc -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI HeapAlloc(HANDLE hheap, ULONG flags, ULONG size)
LPVOID STDCALL HeapAlloc(HANDLE hheap, DWORD flags, DWORD size)
{
PHEAP pheap=hheap;
LPVOID retval;
@@ -684,7 +694,7 @@ LPVOID WINAPI HeapAlloc(HANDLE hheap, ULONG flags, ULONG size)
/*********************************************************************
* HeapReAlloc -- KERNEL32 *
*********************************************************************/
LPVOID WINAPI HeapReAlloc(HANDLE hheap, ULONG flags, LPVOID ptr, ULONG size)
LPVOID STDCALL HeapReAlloc(HANDLE hheap, DWORD flags, LPVOID ptr, DWORD size)
{
PHEAP pheap=hheap;
PHEAP_BLOCK pfree=((PHEAP_BLOCK)ptr-1);
@@ -714,7 +724,7 @@ LPVOID WINAPI HeapReAlloc(HANDLE hheap, ULONG flags, LPVOID ptr, ULONG size)
/*********************************************************************
* HeapFree -- KERNEL32 *
*********************************************************************/
BOOL WINAPI HeapFree(HANDLE hheap, ULONG flags, LPVOID ptr)
WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr)
{
PHEAP pheap=hheap;
PHEAP_BLOCK pfree=(PHEAP_BLOCK)((LPVOID)ptr-HEAP_ADMIN_SIZE);

View File

@@ -1,23 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user mode libraries
* FILE: kernel32/mem/utils.cc
* PURPOSE: Various simple memory initalizations functions
*/
#include <windows.h>
VOID ZeroMemory(PVOID Destination, DWORD Length)
{
#ifdef __i386__
#endif /* __i386__ */
}
VOID CopyMemory(PVOID Destination, CONST VOID* Source, DWORD Length)
{
#ifdef __i386__
#endif /* __i386__ */
}

View File

@@ -9,11 +9,92 @@
/* INCLUDES ******************************************************************/
#include <windows.h>
#include <ddk/ntddk.h>
/* FUNCTIONS *****************************************************************/
LPVOID STDCALL VirtualAllocEx(HANDLE hProcess,
LPVOID lpAddress,
DWORD dwSize,
DWORD flAllocationType,
DWORD flProtect)
{
NTSTATUS Status;
Status = ZwAllocateVirtualMemory(hProcess,
&lpAddress,
0,
dwSize,
flAllocationType,
flProtect);
if (Status != STATUS_SUCCESS)
{
return(NULL);
}
return(lpAddress);
}
LPVOID STDCALL VirtualAlloc(LPVOID lpAddress,
DWORD dwSize,
DWORD flAllocationType,
DWORD flProtect)
{
return(VirtualAllocEx(GetCurrentProcess(),lpAddress,dwSize,flAllocationType,
flProtect));
}
WINBOOL STDCALL VirtualFreeEx(HANDLE hProcess,
LPVOID lpAddress,
DWORD dwSize,
DWORD dwFreeType)
{
NTSTATUS Status;
Status = ZwFreeVirtualMemory(hProcess,
&lpAddress,
dwSize,
dwFreeType);
if (Status != STATUS_SUCCESS)
{
return(FALSE);
}
return(TRUE);
}
WINBOOL STDCALL VirtualFree(LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType)
{
return(VirtualFreeEx(GetCurrentProcess(),lpAddress,dwSize,dwFreeType));
}
WINBOOL STDCALL VirtualProtect(LPVOID lpAddress,
DWORD dwSize,
DWORD flNewProtect,
PDWORD lpflOldProtect)
{
return(VirtualProtectEx(GetCurrentProcess(),
lpAddress,
dwSize,
flNewProtect,
lpflOldProtect));
}
WINBOOL STDCALL VirtualProtectEx(HANDLE hProcess,
LPVOID lpAddress,
DWORD dwSize,
DWORD flNewProtect,
PDWORD lpflOldProtect)
{
NTSTATUS Status;
Status = ZwProtectVirtualMemory(hProcess,
lpAddress,
dwSize,
flNewProtect,
lpflOldProtect);
if (Status != STATUS_SUCCESS)
{
return(FALSE);
}
return(TRUE);
}

View File

@@ -1,3 +1,4 @@
#include <windows.h>
#include <process.h>
/*
* Win32 Process Api functions
@@ -14,14 +15,18 @@
#define NT_CURRENT_THREAD 0xFFFFFFFE
WINBASEAPI
HANDLE
WINAPI
GetCurrentProcess()
HANDLE STDCALL GetCurrentProcess(VOID)
{
return NT_CURRENT_PROCESS;
}
HANDLE STDCALL GetCurrentThread()
{
return NT_CURRENT_PROCESS;
}
#if 0
WINBASEAPI
DWORD
WINAPI
@@ -31,14 +36,6 @@ GetCurrentProcessId()
}
WINBASEAPI
HANDLE
WINAPI
GetCurrentThread()
{
return NT_CURRENT_PROCESS;
}
WINBASEAPI
DWORD
WINAPI
@@ -135,3 +132,5 @@ BOOL FlushInstructionCache(
return FALSE;
}
}
#endif

View File

@@ -1,123 +0,0 @@
#include <windows.h>
#include <string.h>
#include <wstring.h>
int
STDCALL
lstrcmpA(
LPCSTR lpString1,
LPCSTR lpString2
)
{
return strcmp(lpString1,lpString2);
}
int
STDCALL
lstrcmpiA(
LPCSTR lpString1,
LPCSTR lpString2
)
{
return stricmp(lpString1,lpString2);
}
LPSTR
STDCALL
lstrcpynA(
LPSTR lpString1,
LPCSTR lpString2,
int iMaxLength
)
{
return strncpy(lpString1,lpString2,iMaxLength);
}
LPSTR
STDCALL
lstrcpyA(
LPSTR lpString1,
LPCSTR lpString2
)
{
return strcpy(lpString1,lpString2);
}
LPSTR
STDCALL
lstrcatA(
LPSTR lpString1,
LPCSTR lpString2
)
{
return strcat(lpString1,lpString2);
}
int
STDCALL
lstrlenA(
LPCSTR lpString
)
{
return strlen(lpString);
}
int
STDCALL
lstrcmpW(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
return wcscmp(lpString1,lpString2);
}
int
STDCALL
lstrcmpiW(
LPCWSTR lpString1,
LPCWSTR lpString2
)
{
return wcsicmp(lpString1,lpString2);
}
LPWSTR
STDCALL
lstrcpynW(
LPWSTR lpString1,
LPCWSTR lpString2,
int iMaxLength
)
{
return wcsncpy(lpString1,lpString2,iMaxLength);
}
LPWSTR
STDCALL
lstrcpyW(
LPWSTR lpString1,
LPCWSTR lpString2
)
{
return wcscpy(lpString1,lpString2);
}
LPWSTR
STDCALL
lstrcatW(
LPWSTR lpString1,
LPCWSTR lpString2
)
{
return wcscat(lpString1,lpString2);
}
int
STDCALL
lstrlenW(
LPCWSTR lpString
)
{
return wcslen(lpString);
}

View File

@@ -1,12 +0,0 @@
LIBRARIES = ntdll kernel32
all: $(LIBRARIES)
ntdll: dummy
make -C ntdll
kernel32: dummy
make -C kernel32
dummy:

View File

@@ -1,89 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS version of ntdll
* FILE: lib/ntdll/genntdll.c
* PURPOSE: Generates the system call stubs in ntdll
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
/* INCLUDE ******************************************************************/
#include <stdio.h>
#include <stdlib.h>
/* FUNCTIONS ****************************************************************/
int process(FILE* in, FILE* out)
{
char line[255];
char* s;
char* name;
char* value;
char* nr_args;
fprintf(out,"; Machine generated, don't edit\n");
fprintf(out,"\n\n");
while (!feof(in) && fgets(line,255,in)!=NULL)
{
fgets(line,255,in);
if ((s=strchr(line,'\n'))!=NULL)
{
*s=0;
}
s=&line[0];
if ((*s)!='#')
{
name = strtok(s," \t");
value = strtok(NULL," \t");
nr_args = strtok(NULL," \t");
// printf("name %s value %s\n",name,value);
fprintf(out,"%s:\n",name);
fprintf(out,"\tmov\teax,%s\n",value);
fprintf(out,"\tlea\tedx,[esp+4]\n");
fprintf(out,"\tint\t2Eh\n");
fprintf(out,"\tret\t%s\n\n",nr_args);
}
}
}
void usage(void)
{
printf("Usage: genntdll infile.cll outfile.c\n");
}
int main(int argc, char* argv[])
{
FILE* in;
FILE* out;
int ret;
if (argc!=3)
{
usage();
return(1);
}
in = fopen(argv[1],"rb");
if (in==NULL)
{
perror("Failed to open input file");
return(1);
}
out = fopen(argv[2],"wb");
if (out==NULL)
{
perror("Failed to open output file");
return(1);
}
ret = process(in,out);
fclose(in);
fclose(out);
return(ret);
}

View File

@@ -1,7 +1,10 @@
all: genntdll$(EXE_POSTFIX)
all: ntdll.a
genntdll$(EXE_POSTFIX): genntdll.c
$(NATIVE_CC) -g genntdll.c -o genntdll$(EXE_POSTFIX)
OBJECTS = napi.o
ntdll.a: $(OBJECTS)
$(AR) vcsr ntdll.a $(OBJECTS)
dummy:
include ../../rules.mak

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
; Machine generated, don't edit
NtAlertThread:
mov eax,4
lea edx,[esp+4]
int 2Eh
ret 14

View File

@@ -1,7 +0,0 @@
#
# This defines the kernel entry points used by ntdll
#
# They have the following format
# <name> <system call number> <size of the parameters in bytes>
#
NtAlertThread 4 14

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

View File

@@ -567,10 +567,10 @@ l8:
dw 0x00eb,0x00eb ; jmp $+2, jmp $+2
out 0A0h,al ; and to 8259A-2
dw 0x00eb,0x00eb
mov al,020h ; start of hardware int's (0x20)
mov al,040h ; start of hardware int's (0x20)
out 021h,al
dw 0x00eb,0x00eb
mov al,028h ; start of hardware int's 2 (0x28)
mov al,048h ; start of hardware int's 2 (0x28)
out 0A1h,al
dw 0x00eb,0x00eb
mov al,04h ; 8259-1 is master
@@ -626,6 +626,7 @@ next:
mov ss,ax
mov es,ax
mov fs,ax
mov gs,ax
;
; Initalize eflags
@@ -691,4 +692,3 @@ gdt:
_end:

Binary file not shown.

View File

@@ -5,60 +5,129 @@
#
# Select your host
#
#HOST = djgpp-linux
#HOST = mingw32-linux
#HOST = djgpp-linux
#HOST = mingw32-linux
HOST = djgpp-msdos
#HOST = mingw32-windows
#HOST = mingw32-windows
include rules.mak
include rules.mak
#
# Required to run the system
#
COMPONENTS = kernel lib
COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32
#
# Select the loader(s) you want to build
# Select the server(s) you want to build
#
LOADERS = dos
SERVERS = win32 posix linux os2
#
# Select the modules you want
# Select the loader(s) you want to build
#
MODULES = parallel keyboard
all: $(COMPONENTS) $(LOADERS) $(MODULES)
LOADERS = dos
#
# Device driver rules
# Select the device drivers and filesystems you want
#
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test sdisk \
minix vfat
APPS = hello shell
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
clean: dummy
make -C iface/native clean
#
# Applications
#
hello: dummy
make -C apps/hello
cmd: dummy
make -C apps/cmd
shell: dummy
make -C apps/shell
#
# Interfaces
#
iface_native: dummy
make -C iface/native
#
# Device driver rules
#
vfat: dummy
make -C services/fs/vfat
sdisk: dummy
make -C services/dd/sdisk
minix: dummy
make -C services/fs/minix
template: dummy
make -C services/fs/template
ide-test: dummy
make -C services/dd/ide-test
ide: dummy
make -C services/ide
make -C services/dd/ide
test: dummy
make -C services/dd/test
test1: dummy
make -C services/dd/test1
null: dummy
make -C services/dd/null
parallel: dummy
make -C services/parallel
make -C services/dd/parallel
keyboard: dummy
make -C services/keyboard
make -C services/dd/keyboard
mouse: dummy
make -C services/mouse
make -C services/dd/mouse
serial: dummy
make -C services/dd/serial
sound: dummy
make -C services/dd/sound
#
# Kernel loaders
#
dos: dummy
make -C loaders/dos
make -C loaders/dos
#
# Required system components
#
kernel: dummy
make -C ntoskrnl
ntoskrnl: dummy
make -C ntoskrnl
lib: dummy
make -C lib
kernel32: dummy
make -C lib/kernel32
ntdll: dummy
make -C lib/ntdll
crtdll: dummy
make -C lib/crtdll
mingw32: dummy
make -C lib/mingw32
dummy:

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
@@ -15,7 +15,7 @@ include rules.mak
#
# Required to run the system
#
COMPONENTS = kernel lib
COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32
#
# Select the server(s) you want to build
@@ -30,55 +30,79 @@ LOADERS = dos
#
# Select the device drivers and filesystems you want
#
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test minix
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test sdisk \
minix vfat
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES)
APPS = hello shell
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
clean: dummy
make -C iface/native clean
#
# Applications
#
hello: dummy
make -C apps/hello
cmd: dummy
make -C apps/cmd
shell: dummy
make -C apps/shell
#
# Interfaces
#
iface_native: dummy
make -C iface/native
#
# Device driver rules
#
vfat: dummy
make -C services/fs/vfat
sdisk: dummy
make -C services/sdisk
make -C services/dd/sdisk
minix: dummy
make -C services/fs/minix
template: dummy
make -C services/fs/template
ide-test: dummy
make -C services/ide-test
make -C services/dd/ide-test
ide: dummy
make -C services/ide
make -C services/dd/ide
test: dummy
make -C services/test
make -C services/dd/test
test1: dummy
make -C services/test1
make -C services/dd/test1
null: dummy
make -C services/null
make -C services/dd/null
parallel: dummy
make -C services/parallel
make -C services/dd/parallel
keyboard: dummy
make -C services/keyboard
make -C services/dd/keyboard
mouse: dummy
make -C services/mouse
make -C services/dd/mouse
serial: dummy
make -C services/serial
make -C services/dd/serial
sound: dummy
make -C services/sound
ide: dummy
make -C services/ide
ide-test: dummy
make -C services/ide-test
make -C services/dd/sound
#
# Kernel loaders
@@ -91,10 +115,19 @@ dos: dummy
# Required system components
#
kernel: dummy
ntoskrnl: dummy
make -C ntoskrnl
lib: dummy
make -C lib
kernel32: dummy
make -C lib/kernel32
ntdll: dummy
make -C lib/ntdll
crtdll: dummy
make -C lib/crtdll
mingw32: dummy
make -C lib/mingw32
dummy:

View File

@@ -16,6 +16,11 @@
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL NtSystemDebugControl(VOID)
{
UNIMPLEMENTED;
}
VOID DbgBreakPoint(VOID)
{
__asm__("int $3\n\t");

View File

@@ -23,9 +23,12 @@ VOID ExCallUserCallBack(PVOID fn)
{
}
VOID NtReturnFromCallBack(VOID)
/*
* FUNCTION: Returns from a user callback
*/
NTSTATUS STDCALL NtCallbackReturn(VOID)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL NtW32Call(VOID)
{
UNIMPLEMENTED;
}

View File

@@ -16,6 +16,28 @@
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
IN PLARGE_INTEGER NewSystemTime OPTIONAL)
{
return(ZwSetSystemTime(SystemTime,NewSystemTime));
}
NTSTATUS STDCALL ZwSetSystemTime(IN PLARGE_INTEGER SystemTime,
IN PLARGE_INTEGER NewSystemTime OPTIONAL)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL NtQuerySystemTime (OUT TIME *CurrentTime)
{
return(ZwQuerySystemTime(CurrentTime));
}
NTSTATUS STDCALL ZwQuerySystemTime (OUT TIME *CurrentTime)
{
UNIMPLEMENTED;
}
VOID ExLocalTimeToSystemTime(PLARGE_INTEGER LocalTime,
PLARGE_INTEGER SystemTime)
{

View File

@@ -142,7 +142,7 @@ VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
ASSERT_IRQL(DISPATCH_LEVEL);
/*
* Insert the item in the appropiate queue and wake on any thread
* Insert the item in the appropiate queue and wake up any thread
* waiting for something to do
*/
switch(QueueType)
@@ -152,5 +152,5 @@ VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
&normal_work_queue.Lock);
KeSetEvent(&normal_work_queue.Busy,IO_NO_INCREMENT,FALSE);
break;
};
}
}

View File

@@ -377,3 +377,10 @@ ZwUnmapViewOfSection
ZwWriteFile
sprintf
wcschr
wcsncat
wcsncpy
wtolower
wtoupper
CbInitDccb
CbAcquireForRead
CbReleaseFromRead

View File

@@ -18,8 +18,8 @@
#include <ddk/ntddk.h>
#include <internal/mm.h>
#include <internal/string.h>
#include <internal/hal/page.h>
#include <internal/hal/segment.h>
#include <internal/mmhal.h>
#include <internal/i386/segment.h>
/* TYPES ******************************************************************/

View File

@@ -13,16 +13,16 @@
#include <windows.h>
#include <internal/ntoskrnl.h>
#include <internal/ke.h>
#include <internal/hal/segment.h>
#include <internal/hal/page.h>
#include <internal/i386/segment.h>
#include <internal/mmhal.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *****************************************************************/
typedef unsigned int (exception_hook)(CONTEXT* c, unsigned int exp);
asmlinkage unsigned int ExHookException(exception_hook fn, UINT exp);
asmlinkage int page_fault_handler(unsigned int cs,
unsigned int eip);
extern descriptor idt[256];
static exception_hook* exception_hooks[256]={NULL,};
@@ -30,43 +30,74 @@ static exception_hook* exception_hooks[256]={NULL,};
#define _STR(x) #x
#define STR(x) _STR(x)
extern void interrupt_handler2e(void);
/* FUNCTIONS ****************************************************************/
#define EXCEPTION_HANDLER_WITH_ERROR(x,y) \
void exception_handler##y (void); \
__asm__("\n\t_exception_handler"##x":\n\t" \
"pushl %gs\n\t" \
"pushl %fs\n\t" \
"pushl %es\n\t" \
"pushl %ds\n\t" \
"pushl $"##x"\n\t" \
"pusha\n\t" \
"movw $"STR(KERNEL_DS)",%ax\n\t" \
"movw %ax,%ds\n\t" \
"movw %ax,%es\n\t" \
"movw %ax,%fs\n\t" \
"movw %ax,%gs\n\t" \
"call _exception_handler\n\t" \
"popa\n\t" \
"addl $8,%esp\n\t" \
"addl $4,%esp\n\t" \
"popl %ds\n\t" \
"popl %es\n\t" \
"popl %fs\n\t" \
"popl %gs\n\t" \
"addl $4,%esp\n\t" \
"iret\n\t")
#define EXCEPTION_HANDLER_WITHOUT_ERROR(x,y) \
asmlinkage void exception_handler##y (void); \
__asm__("\n\t_exception_handler"##x":\n\t" \
"pushl $0\n\t" \
"pushl %gs\n\t" \
"pushl %fs\n\t" \
"pushl %es\n\t" \
"pushl %ds\n\t" \
"pushl $"##x"\n\t" \
"pusha\n\t" \
"movw $"STR(KERNEL_DS)",%ax\n\t" \
"movw %ax,%ds\n\t" \
"movw %ax,%es\n\t" \
"movw %ax,%fs\n\t" \
"movw %ax,%gs\n\t" \
"call _exception_handler\n\t" \
"popa\n\t" \
"addl $8,%esp\n\t" \
"addl $4,%esp\n\t" \
"popl %ds\n\t" \
"popl %es\n\t" \
"popl %fs\n\t" \
"popl %gs\n\t" \
"addl $4,%esp\n\t" \
"iret\n\t")
asmlinkage void exception_handler_unknown(void);
__asm__("\n\t_exception_handler_unknown:\n\t"
"pushl $0\n\t"
"pushl %gs\n\t"
"pushl %fs\n\t"
"pushl %es\n\t"
"pushl %ds\n\t"
"pushl %ds\n\t"
"pushl $0xff\n\t"
"pusha\n\t"
"movw $"STR(KERNEL_DS)",%ax\n\t"
"movw %ax,%ds\n\t"
"movw %ax,%es\n\t"
"movw %ax,%fs\n\t"
"movw %ax,%gs\n\t"
"call _exception_handler\n\t"
"popa\n\t"
"addl $8,%esp\n\t"
@@ -87,14 +118,7 @@ EXCEPTION_HANDLER_WITH_ERROR("10",10);
EXCEPTION_HANDLER_WITH_ERROR("11",11);
EXCEPTION_HANDLER_WITH_ERROR("12",12);
EXCEPTION_HANDLER_WITH_ERROR("13",13);
/*
* The page fault handler is defined by the memory managment because it is
* special
*/
//EXCEPTION_HANDLER_WITH_ERROR("14",14);
asmlinkage void exception_handler14(void);
EXCEPTION_HANDLER_WITH_ERROR("14",14);
EXCEPTION_HANDLER_WITH_ERROR("15",15);
EXCEPTION_HANDLER_WITHOUT_ERROR("16",16);
@@ -104,9 +128,12 @@ asmlinkage void exception_handler(unsigned int edi,
unsigned int esi, unsigned int ebp,
unsigned int esp, unsigned int ebx,
unsigned int edx, unsigned int ecx,
unsigned int eax,
unsigned int eax,
unsigned int type,
unsigned int ds,
unsigned int ds,
unsigned int es,
unsigned int fs,
unsigned int gs,
unsigned int error_code,
unsigned int eip,
unsigned int cs, unsigned int eflags,
@@ -124,6 +151,19 @@ asmlinkage void exception_handler(unsigned int edi,
__asm__("cli\n\t");
if (type==14)
{
if (page_fault_handler(cs&0xffff,eip))
{
return;
}
}
if (type==1)
{
DbgPrint("Trap at CS:EIP %x:%x\n",cs&0xffff,eip);
return;
}
/*
* Activate any hook for the exception
*/
@@ -137,6 +177,8 @@ 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);
printk("DS %x ES %x FS %x GS %x\n",ds&0xffff,es&0xffff,fs&0xffff,
gs&0xfff);
// for(;;);
printk("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
printk("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
@@ -145,6 +187,10 @@ asmlinkage void exception_handler(unsigned int edi,
{
printk("ESP %.8x\n",esp);
}
else
{
printk("ESP %.8x\n",esp);
}
__asm__("movl %%cr2,%0\n\t"
: "=d" (cr2));
@@ -181,6 +227,15 @@ asmlinkage void exception_handler(unsigned int edi,
for(;;);
}
static void set_system_call_gate(unsigned int sel, unsigned int func)
{
DPRINT("sel %x %d\n",sel,sel);
idt[sel].a = (((int)func)&0xffff) +
(KERNEL_CS << 16);
idt[sel].b = 0xef00 + (((int)func)&0xffff0000);
DPRINT("idt[sel].b %x\n",idt[sel].b);
}
static void set_interrupt_gate(unsigned int sel, unsigned int func)
{
idt[sel].a = (((int)func)&0xffff) +
@@ -232,4 +287,6 @@ asmlinkage void KeInitExceptions(void)
{
set_interrupt_gate(i,(int)exception_handler_unknown);
}
set_system_call_gate(0x2e,(int)interrupt_handler2e);
}

View File

@@ -26,7 +26,7 @@
#include <internal/linkage.h>
#include <internal/string.h>
#include <internal/hal/segment.h>
#include <internal/i386/segment.h>
#include <internal/hal/io.h>
#define NDEBUG
@@ -35,7 +35,7 @@
/* GLOBALS *****************************************************************/
#define NR_IRQS (16)
#define IRQ_BASE (0x20)
#define IRQ_BASE (0x40)
asmlinkage void irq_handler_0(void);
asmlinkage void irq_handler_1(void);

View File

@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: mkernel/hal/irql.c
* FILE: ntoskrnl/hal/x86/irql.c
* PURPOSE: Implements IRQLs
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
@@ -118,12 +118,12 @@ VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
/*
* sanity check
*/
DPRINT("CurrentIrql %x NewIrql %x OldIrql %x\n",CurrentIrql,NewIrql,
OldIrql);
DPRINT("CurrentIrql %x NewIrql %x OldIrql %x\n",CurrentIrql,NewIrql,
OldIrql);
if (NewIrql < CurrentIrql)
{
DbgPrint("%s:%d CurrentIrql %x NewIrql %x OldIrql %x\n",__FILE__,__LINE__,
CurrentIrql,NewIrql,OldIrql);
DbgPrint("%s:%d CurrentIrql %x NewIrql %x OldIrql %x\n",
__FILE__,__LINE__,CurrentIrql,NewIrql,OldIrql);
for(;;);
}

View File

@@ -1,205 +0,0 @@
.file "irql.c"
gcc2_compiled.:
___gnu_compiled_c:
.globl _CurrentIrql
.data
_CurrentIrql:
.byte 19
.text
.p2align 2
_pic_get_current_mask:
pushl %ebp
movl %esp,%ebp
/APP
inb $33,%al
outb %al,$0x80
inb $161,%al
outb %al,$0x80
/NO_APP
leave
ret
.p2align 2
_pic_set_current_mask:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
/APP
outb %al,$33
outb %al,$0x80
/NO_APP
shrl $8,%eax
/APP
outb %al,$161
outb %al,$0x80
/NO_APP
leave
ret
.p2align 2
_switch_irql:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
pushl %ebx
movb _CurrentIrql,%al
cmpb $19,%al
jne L62
pushl $65535
call _pic_set_current_mask
jmp L61
.align 2,0x90
L62:
cmpb $2,%al
jbe L71
movl $0,-4(%ebp)
movzbl _CurrentIrql,%eax
leal -2(%eax),%edx
cmpl $2,%edx
jbe L65
movl $16,%ebx
leal -4(%ebp),%ecx
.align 2,0x90
L67:
movl %ebx,%eax
subl %edx,%eax
/APP
btsl %eax,(%ecx)
sbbl %eax,%eax
/NO_APP
decl %edx
cmpl $2,%edx
ja L67
L65:
pushl -4(%ebp)
call _pic_set_current_mask
/APP
sti
/NO_APP
jmp L61
.align 2,0x90
L71:
pushl $0
call _pic_set_current_mask
/APP
sti
/NO_APP
L61:
movl -8(%ebp),%ebx
leave
ret
.p2align 2
.globl _KeSetCurrentIrql
_KeSetCurrentIrql:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
movb %al,_CurrentIrql
leave
ret
.p2align 2
.globl _KeGetCurrentIrql
_KeGetCurrentIrql:
pushl %ebp
movl %esp,%ebp
movzbl _CurrentIrql,%eax
leave
ret
LC0:
.ascii "irql.c\0"
LC1:
.ascii "(%s:%d) \0"
LC2:
.ascii "NewIrql %x CurrentIrql %x\12\0"
LC3:
.ascii "Assertion NewIrql <= CurrentIrql failed at %s:%d\12\0"
.p2align 2
.globl _KeLowerIrql
_KeLowerIrql:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movb 8(%ebp),%bl
/APP
cli
/NO_APP
pushl $103
pushl $LC0
pushl $LC1
call _printk
movzbl _CurrentIrql,%eax
pushl %eax
movzbl %bl,%eax
pushl %eax
pushl $LC2
call _printk
addl $24,%esp
cmpb %bl,_CurrentIrql
jae L79
pushl $104
pushl $LC0
pushl $LC3
call _printk
.align 2,0x90
L82:
jmp L82
.align 2,0x90
L79:
movb %bl,_CurrentIrql
call _switch_irql
movl -4(%ebp),%ebx
leave
ret
LC4:
.ascii "%s:%d\12\0"
LC5:
.ascii "NewIrql %x OldIrql %x CurrentIrql %x\12\0"
.p2align 2
.globl _KeRaiseIrql
_KeRaiseIrql:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %ebx
movl 12(%ebp),%esi
movb 8(%ebp),%al
cmpb %al,_CurrentIrql
jbe L84
pushl $122
pushl $LC0
pushl $LC4
call _printk
.align 2,0x90
L87:
jmp L87
.align 2,0x90
L84:
/APP
cli
/NO_APP
movzbl %al,%ebx
pushl %ebx
pushl $_CurrentIrql
call _InterlockedExchange
movb %al,(%esi)
pushl $129
pushl $LC0
pushl $LC1
call _printk
movzbl _CurrentIrql,%eax
pushl %eax
movzbl (%esi),%eax
pushl %eax
pushl %ebx
pushl $LC5
call _printk
addl $28,%esp
call _switch_irql
leal -8(%ebp),%esp
popl %ebx
popl %esi
leave
ret
.comm ___ProcessHeap,4

View File

@@ -15,7 +15,7 @@
/* FUNCTIONS *****************************************************************/
BOOL HalIsaProbe()
BOOL HalIsaProbe(VOID)
/*
* FUNCTION: Probes for an ISA bus
* RETURNS: True if detected
@@ -28,5 +28,5 @@ BOOL HalIsaProbe()
/*
* Probe for plug and play support
*/
return(TRUE);
}

View File

@@ -10,7 +10,7 @@
/* INCLUDES ***************************************************************/
#include <internal/hal/page.h>
#include <internal/mmhal.h>
#include <internal/mm.h>
#include <internal/string.h>
#include <internal/bitops.h>
@@ -29,6 +29,81 @@
/* FUNCTIONS ***************************************************************/
static ULONG ProtectToPTE(ULONG flProtect)
{
ULONG Attributes = 0;
if (flProtect & PAGE_NOACCESS || flProtect & PAGE_GUARD)
{
Attributes = 0;
}
if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
{
Attributes = PA_WRITE;
}
if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
flProtect & PAGE_EXECUTE_READ)
{
Attributes = PA_READ;
}
return(Attributes);
}
PULONG MmGetPageEntry(PEPROCESS Process, ULONG Address)
{
unsigned int page_table;
unsigned int* page_tlb;
unsigned int* page_dir = linear_to_physical(
Process->Pcb.PageTableDirectory);
DPRINT("vaddr %x ",vaddr);
page_tlb = (unsigned int *)physical_to_linear(
PAGE_MASK(page_dir[VADDR_TO_PD_OFFSET(Address)]));
DPRINT("page_tlb %x\n",page_tlb);
if (PAGE_MASK(page_dir[VADDR_TO_PD_OFFSET(Address)])==0)
{
DPRINT("Creating new page directory\n",0);
page_table = get_free_page(); // Returns a physical address
page_tlb=(unsigned int *)physical_to_linear(page_table);
memset(page_tlb,0,PAGESIZE);
page_dir[VADDR_TO_PD_OFFSET(Address)]=page_table+0x7;
}
return(&page_tlb[VADDR_TO_PT_OFFSET(Address)/4]);
}
BOOLEAN MmIsPagePresent(PEPROCESS Process, PVOID Address)
{
return((*MmGetPageEntry(Process, Address)) & PA_PRESENT);
}
VOID MmSetPage(PEPROCESS Process,
PVOID Address,
ULONG flProtect,
ULONG PhysicalAddress)
{
ULONG Attributes = 0;
Attributes = ProtectToPTE(flProtect);
(*MmGetPageEntry(Process, Address)) = PhysicalAddress | Attributes;
}
VOID MmSetPageProtect(PEPROCESS Process,
PVOID Address,
ULONG flProtect)
{
ULONG Attributes = 0;
PULONG PageEntry;
Attributes = ProtectToPTE(flProtect);
PageEntry = MmGetPageEntry(Process,Address);
(*PageEntry) = PAGE_MASK(*PageEntry) | Attributes;
}
/*
* The mark_page_xxxx manipulate the attributes of a page. Use the
* higher level functions for synchronization. These functions only work

View File

@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: mkernel/hal/eisa.c
* FILE: ntoskrnl/hal/x86/pci.c
* PURPOSE: Interfaces to the PCI bus
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:

View File

@@ -13,7 +13,7 @@
#include <internal/ntoskrnl.h>
#include <internal/string.h>
#include <internal/hal/page.h>
#include <internal/mmhal.h>
#include <internal/hal/io.h>
#include <internal/debug.h>
@@ -66,6 +66,7 @@ static unsigned char mode03[] = {0x67,0x00,0x03,0x00,0x03,0x00,0x02,
/* FUNCTIONS ***************************************************************/
void HalSwitchToBlueScreen(void)
/*
* FUNCTION: Switches the monitor to text mode and writes a blue background
@@ -94,6 +95,14 @@ void HalSwitchToBlueScreen(void)
}
NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString)
{
// DbgPrint("DisplayString %x\n",DisplayString);
DbgPrint("%s",DisplayString);
return(STATUS_SUCCESS);
}
void HalDisplayString(char* string)
/*
* FUNCTION: Switches the screen to HAL console mode (BSOD) if not there

View File

@@ -2,4 +2,4 @@ HAL_OBJECTS = hal/x86/head.o hal/x86/irq.o hal/x86/exp.o hal/x86/isa.o \
hal/x86/pci.o hal/x86/irqhand.o hal/x86/page.o hal/x86/halinit.o \
hal/x86/irql.o hal/x86/bios32.o hal/x86/thread.o hal/x86/spinlock.o \
hal/x86/printk.o hal/x86/mp.o hal/x86/dma.o hal/x86/bus.o hal/x86/mbr.o \
hal/x86/sysinfo.o
hal/x86/sysinfo.o hal/x86/usercall.o

View File

@@ -16,8 +16,8 @@
#include <internal/ps.h>
#include <internal/string.h>
#include <internal/hal.h>
#include <internal/hal/segment.h>
#include <internal/hal/page.h>
#include <internal/i386/segment.h>
#include <internal/mmhal.h>
#define NDEBUG
#include <internal/debug.h>
@@ -29,7 +29,7 @@
static char null_ldt[8]={0,};
static unsigned int null_ldt_sel=0;
static PKTHREAD FirstThread=NULL;
static PETHREAD FirstThread=NULL;
/* FUNCTIONS **************************************************************/
@@ -42,6 +42,7 @@ void HalTaskSwitch(PKTHREAD thread)
* again
*/
{
DPRINT("Scheduling thread %x\n",thread);
DPRINT("Scheduling thread %x\n",thread->Context.nr);
DPRINT("previous task %x reserved1 %x esp0 %x ss0 %x\n",
thread->Context.previous_task,thread->Context.reserved1,
@@ -75,7 +76,6 @@ void HalTaskSwitch(PKTHREAD thread)
: /* No outputs */
: "m" (*(((unsigned char *)(&(thread->Context.nr)))-4) )
: "ax","dx");
// set_breakpoint(0,&(FirstThread->Context.gs),HBP_READWRITE,HBP_DWORD);
}
static unsigned int allocate_tss_descriptor(void)
@@ -114,8 +114,129 @@ static void begin_thread(PKSTART_ROUTINE fn, PVOID start_context)
for(;;);
}
BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
PVOID StartContext)
#define FLAG_NT (1<<14)
#define FLAG_VM (1<<17)
#define FLAG_IF (1<<9)
#define FLAG_IOPL ((1<<12)+(1<<13))
NTSTATUS KeValidateUserContext(PCONTEXT Context)
/*
* FUNCTION: Validates a processor context
* ARGUMENTS:
* Context = Context to validate
* RETURNS: Status
* NOTE: This only validates the context as not violating system security, it
* doesn't guararantee the thread won't crash at some point
* NOTE2: This relies on there only being two selectors which can access
* system space
*/
{
if (Context->Eip >= KERNEL_BASE)
{
return(STATUS_UNSUCCESSFUL);
}
if (Context->SegCs == KERNEL_CS)
{
return(STATUS_UNSUCCESSFUL);
}
if (Context->SegDs == KERNEL_DS)
{
return(STATUS_UNSUCCESSFUL);
}
if (Context->SegEs == KERNEL_DS)
{
return(STATUS_UNSUCCESSFUL);
}
if (Context->SegFs == KERNEL_DS)
{
return(STATUS_UNSUCCESSFUL);
}
if (Context->SegGs == KERNEL_DS)
{
return(STATUS_UNSUCCESSFUL);
}
if ((Context->EFlags & FLAG_IOPL) != 0 ||
(Context->EFlags & FLAG_NT) ||
(Context->EFlags & FLAG_VM) ||
(!(Context->EFlags & FLAG_IF)))
{
return(STATUS_SUCCESS);
}
return(STATUS_SUCCESS);
}
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
/*
* FUNCTION: Initialize a task with a user mode context
* ARGUMENTS:
* Thread = Thread to initialize
* Context = Processor context to initialize it with
* RETURNS: Status
*/
{
unsigned int desc;
unsigned int length;
unsigned int base;
unsigned int* kernel_stack;
NTSTATUS Status;
DPRINT("HalInitTaskWithContext(Thread %x, Context %x)\n",
Thread,Context);
assert(sizeof(hal_thread_state)>=0x68);
if ((Status=KeValidateUserContext(Context))!=STATUS_SUCCESS)
{
return(Status);
}
desc = allocate_tss_descriptor();
length = sizeof(hal_thread_state) - 1;
base = (unsigned int)(&(Thread->Tcb.Context));
kernel_stack = ExAllocatePool(NonPagedPool,PAGESIZE);
/*
* Setup a TSS descriptor
*/
gdt[desc].a = (length & 0xffff) | ((base & 0xffff) << 16);
gdt[desc].b = ((base & 0xff0000)>>16) | 0x8900 | (length & 0xf0000)
| (base & 0xff000000);
/*
* Initialize the thread context
*/
memset(&Thread->Tcb.Context,0,sizeof(hal_thread_state));
Thread->Tcb.Context.ldt = null_ldt_sel;
Thread->Tcb.Context.eflags = Context->EFlags;
Thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
Thread->Tcb.Context.esp0 = (ULONG)&kernel_stack[1021];
Thread->Tcb.Context.ss0 = KERNEL_DS;
Thread->Tcb.Context.esp = Context->Esp;
Thread->Tcb.Context.ss = Context->SegSs;
Thread->Tcb.Context.cs = Context->SegCs;
Thread->Tcb.Context.eip = Context->Eip;
Thread->Tcb.Context.io_bitmap[0] = 0xff;
Thread->Tcb.Context.cr3 =
linear_to_physical(Thread->ThreadsProcess->Pcb.PageTableDirectory);
Thread->Tcb.Context.ds = Context->SegDs;
Thread->Tcb.Context.es = Context->SegEs;
Thread->Tcb.Context.fs = Context->SegFs;
Thread->Tcb.Context.gs = Context->SegGs;
Thread->Tcb.Context.eax = Context->Eax;
Thread->Tcb.Context.ebx = Context->Ebx;
Thread->Tcb.Context.ecx = Context->Ecx;
Thread->Tcb.Context.edx = Context->Edx;
Thread->Tcb.Context.edi = Context->Edi;
Thread->Tcb.Context.esi = Context->Esi;
Thread->Tcb.Context.ebp = Context->Ebp;
Thread->Tcb.Context.nr = desc * 8;
DPRINT("Allocated %x\n",desc*8);
return(STATUS_SUCCESS);
}
BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
/*
* FUNCTION: Initializes the HAL portion of a thread object
* ARGUMENTS:
@@ -127,12 +248,13 @@ BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
{
unsigned int desc = allocate_tss_descriptor();
unsigned int length = sizeof(hal_thread_state) - 1;
unsigned int base = (unsigned int)(&(thread->Context));
unsigned int base = (unsigned int)(&(thread->Tcb.Context));
unsigned int* kernel_stack = ExAllocatePool(NonPagedPool,4096);
DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
thread,fn,StartContext);
DPRINT("thread->ThreadsProcess %x\n",thread->ThreadsProcess);
/*
* Make sure
*/
@@ -156,30 +278,31 @@ BOOLEAN HalInitTask(PKTHREAD thread, PKSTART_ROUTINE fn,
/*
* Initialize the thread context
*/
memset(&thread->Context,0,sizeof(hal_thread_state));
thread->Context.ldt = null_ldt_sel;
thread->Context.eflags = (1<<1)+(1<<9);
thread->Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
thread->Context.esp0 = &kernel_stack[1021];
thread->Context.ss0 = KERNEL_DS;
thread->Context.esp = &kernel_stack[1021];
thread->Context.ss = KERNEL_DS;
thread->Context.cs = KERNEL_CS;
thread->Context.eip = (unsigned long)begin_thread;
thread->Context.io_bitmap[0] = 0xff;
thread->Context.cr3 = ((unsigned int)get_page_directory()) - IDMAP_BASE;
thread->Context.ds = KERNEL_DS;
thread->Context.es = KERNEL_DS;
thread->Context.fs = KERNEL_DS;
thread->Context.gs = KERNEL_DS;
thread->Context.nr = desc * 8;
memset(&thread->Tcb.Context,0,sizeof(hal_thread_state));
thread->Tcb.Context.ldt = null_ldt_sel;
thread->Tcb.Context.eflags = (1<<1)+(1<<9);
thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
thread->Tcb.Context.esp0 = &kernel_stack[1021];
thread->Tcb.Context.ss0 = KERNEL_DS;
thread->Tcb.Context.esp = &kernel_stack[1021];
thread->Tcb.Context.ss = KERNEL_DS;
thread->Tcb.Context.cs = KERNEL_CS;
thread->Tcb.Context.eip = (unsigned long)begin_thread;
thread->Tcb.Context.io_bitmap[0] = 0xff;
thread->Tcb.Context.cr3 =
linear_to_physical(thread->ThreadsProcess->Pcb.PageTableDirectory);
thread->Tcb.Context.ds = KERNEL_DS;
thread->Tcb.Context.es = KERNEL_DS;
thread->Tcb.Context.fs = KERNEL_DS;
thread->Tcb.Context.gs = KERNEL_DS;
thread->Tcb.Context.nr = desc * 8;
DPRINT("Allocated %x\n",desc*8);
return(TRUE);
}
void HalInitFirstTask(PKTHREAD thread)
void HalInitFirstTask(PETHREAD thread)
/*
* FUNCTION: Called to setup the HAL portion of a thread object for the
* initial thread
@@ -208,6 +331,6 @@ void HalInitFirstTask(PKTHREAD thread)
*/
__asm__("ltr %%ax"
: /* no output */
: "a" (thread->Context.nr));
: "a" (thread->Tcb.Context.nr));
FirstThread = thread;
}

View File

@@ -1,46 +1,35 @@
;
;
%include "internal/hal/segment.inc"
%include 'internal/hal/segment.inc'
bits 32
section .text
extern _SystemServiceTable
extern __SystemServiceTable
global _interrupt_handler2e
_kernel_mode_call_handler:
;
; Save some registers
;
push ds
push es
push esi
push edi
;
; Transfer the parameters from user mode
;
push USER_DS
pop es
mov edx,esi
mov esp,edi
mov ecx,_SystemServiceTable[eax*4]
sub esp,ecx
cld
rep movsb
;
; Call the actual service routine
;
mov eax,_SystemServiceTable[eax*4+4]
jmp eax
;
; Restore registers and return
;
pop edi
pop esi
pop es
pop ds
ret
_interrupt_handler2e:
push ds
push es
push esi
push edi
mov bx,KERNEL_DS
mov es,bx
mov esi,edx
mov ecx,[es:__SystemServiceTable+eax*8]
sub esp,ecx
mov edi,esp
rep movsb
mov ds,bx
mov eax,[__SystemServiceTable+4+eax*8]
call eax
pop edi
pop esi
pop es
pop ds
iret

View File

@@ -17,6 +17,13 @@
/* FUNCTIONS *****************************************************************/
NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
PVOID Length)
{
}
PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
PDEVICE_OBJECT DeviceObject,
PKEVENT UserEvent,
@@ -27,6 +34,10 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
* ARGUMENTS:
* MinorFunction = Type of filesystem control
* DeviceObject = Device object to send the request to
* UserEvent = Event used to notify the caller of completion
* IoStatusBlock (OUT) = Used to return the status of the operation
* DeviceToMount = Device to mount (for the IRP_MN_MOUNT_DEVICE
* request)
*/
{
PIRP Irp;
@@ -48,9 +59,23 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->Parameters.Mount.Vpb = DeviceObject->Vpb;
StackPtr->Parameters.Mount.DeviceObject = DeviceToMount;
switch(MinorFunction)
{
case IRP_MN_USER_FS_REQUEST:
break;
case IRP_MN_MOUNT_VOLUME:
StackPtr->Parameters.Mount.Vpb = DeviceObject->Vpb;
StackPtr->Parameters.Mount.DeviceObject = DeviceToMount;
break;
case IRP_MN_VERIFY_VOLUME:
break;
case IRP_MN_LOAD_FILE_SYSTEM:
break;
}
return(Irp);
}
@@ -74,40 +99,20 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
* NULL on failure
*/
{
PIRP Irp;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
DPRINT("IoBuildAsynchronousFsdRequest(MajorFunction %x, DeviceObject %x, "
"Buffer %x, Length %x, StartingOffset %x, "
"IoStatusBlock %x\n",MajorFunction,DeviceObject,Buffer,Length,
StartingOffset,IoStatusBlock);
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;
@@ -116,19 +121,45 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
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;
}
if (MajorFunction == IRP_MJ_READ || MajorFunction == IRP_MJ_WRITE)
{
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);
}
}
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;
}
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;
}
}
Irp->UserIosb = IoStatusBlock;
return(Irp);
}
@@ -181,43 +212,7 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
{
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);
}
if (MajorFunction == IRP_MJ_WRITE)
{
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
}
Irp->UserBuffer = NULL;
}
if (DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT("Doing direct i/o\n",0);
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
if (MajorFunction == IRP_MJ_READ)
{
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
}
else
{
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
}
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
}
Irp->UserIosb = IoStatusBlock;
Irp->UserEvent = Event;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
@@ -226,36 +221,59 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->Parameters.Write.Length = Length;
if (MajorFunction == IRP_MJ_READ)
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
if (MajorFunction == IRP_MJ_READ || MajorFunction == IRP_MJ_WRITE)
{
if (StartingOffset!=NULL)
{
StackPtr->Parameters.Read.ByteOffset.LowPart =
StartingOffset->LowPart;
StackPtr->Parameters.Read.ByteOffset.HighPart =
StartingOffset->HighPart;
}
else
{
StackPtr->Parameters.Read.ByteOffset.LowPart = 0;
StackPtr->Parameters.Read.ByteOffset.HighPart = 0;
}
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);
}
if (MajorFunction == IRP_MJ_WRITE)
{
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer,
Length);
}
}
if (DeviceObject->Flags&DO_DIRECT_IO)
{
DPRINT("Doing direct i/o\n",0);
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
Irp->UserBuffer = NULL;
if (MajorFunction == IRP_MJ_READ)
{
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
}
else
{
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
}
Irp->AssociatedIrp.SystemBuffer = NULL;
}
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;
}
}
else
{
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;
}
}
Irp->UserIosb = IoStatusBlock;
Irp->UserEvent = Event;
return(Irp);
}

View File

@@ -21,6 +21,18 @@ static KSPIN_LOCK CancelSpinLock = {0,};
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL NtCancelIoFile(IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock)
{
return(ZwCancelIoFile(FileHandle,IoStatusBlock));
}
NTSTATUS STDCALL ZwCancelIoFile(IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock)
{
UNIMPLEMENTED;
}
BOOLEAN IoCancelIrp(PIRP Irp)
{
KIRQL oldlvl;

View File

@@ -22,6 +22,41 @@
/* FUNCTIONS *************************************************************/
NTSTATUS STDCALL NtDeleteFile(IN POBJECT_ATTRIBUTES ObjectAttributes)
{
return(ZwDeleteFile(ObjectAttributes));
}
NTSTATUS STDCALL ZwDeleteFile(IN POBJECT_ATTRIBUTES ObjectAttributes)
{
UNIMPLEMENTED;
}
NTSTATUS NtCreateFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
PLARGE_INTEGER AllocateSize,
ULONG FileAttributes,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
PVOID EaBuffer,
ULONG EaLength)
{
return(ZwCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
AllocateSize,
FileAttributes,
ShareAccess,
CreateDisposition,
CreateOptions,
EaBuffer,
EaLength));
}
NTSTATUS ZwCreateFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
@@ -56,7 +91,144 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
* RETURNS: Status
*/
{
UNIMPLEMENTED;
PVOID Object;
NTSTATUS Status;
PIRP Irp;
KEVENT Event;
PDEVICE_OBJECT DeviceObject;
PFILE_OBJECT FileObject;
PIO_STACK_LOCATION StackLoc;
PWSTR Remainder;
DPRINT("ZwCreateFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %w)\n",
FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer);
assert_irql(PASSIVE_LEVEL);
*FileHandle=0;
FileObject = ObGenericCreateObject(FileHandle,DesiredAccess,NULL,IoFileType);
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__);
ZwClose(*FileHandle);
*FileHandle=0;
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->ObjectName->Length);
FileObject->FileName.Length = ObjectAttributes->Length;
RtlCopyUnicodeString(&(FileObject->FileName),
ObjectAttributes->ObjectName);
}
else
{
CHECKPOINT;
if (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM &&
DeviceObject->DeviceType != FILE_DEVICE_DISK)
{
ZwClose(*FileHandle);
*FileHandle=0;
return(STATUS_UNSUCCESSFUL);
}
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
{
Status = IoTryToMountStorageDevice(DeviceObject);
if (Status!=STATUS_SUCCESS)
{
ZwClose(*FileHandle);
*FileHandle=0;
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;
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
{
FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
{
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
}
FileObject->DeviceObject=DeviceObject;
FileObject->Vpb=DeviceObject->Vpb;
KeInitializeEvent(&Event,NotificationEvent,FALSE);
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
if (Irp==NULL)
{
ZwClose(*FileHandle);
*FileHandle=0;
return(STATUS_UNSUCCESSFUL);
}
StackLoc = IoGetNextIrpStackLocation(Irp);
StackLoc->MajorFunction = IRP_MJ_CREATE;
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
StackLoc->DeviceObject = DeviceObject;
StackLoc->FileObject=FileObject;
Status = IoCallDriver(DeviceObject,Irp);
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = IoStatusBlock->Status;
}
if (Status!=STATUS_SUCCESS)
{
ZwClose(*FileHandle);
*FileHandle=0;
}
DPRINT("*FileHandle %x\n",*FileHandle);
return(Status);
}
NTSTATUS NtOpenFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG OpenOptions)
{
return(ZwOpenFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
ShareAccess,
OpenOptions));
}
NTSTATUS ZwOpenFile(PHANDLE FileHandle,
@@ -79,119 +251,17 @@ NTSTATUS ZwOpenFile(PHANDLE FileHandle,
* NOTE: Undocumented
*/
{
PVOID Object;
NTSTATUS Status;
PIRP Irp;
KEVENT Event;
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;
FileObject = ObGenericCreateObject(FileHandle,0,NULL,OBJTYP_FILE);
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->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);
StackLoc->MajorFunction = IRP_MJ_CREATE;
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
StackLoc->DeviceObject = DeviceObject;
StackLoc->FileObject=FileObject;
Status = IoCallDriver(DeviceObject,Irp);
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = IoStatusBlock->Status;
}
if (Status!=STATUS_SUCCESS)
{
ObDeleteHandle(*FileHandle);
*FileHandle=0;
ExFreePool(FileObject);
}
return(Status);
return(ZwCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
NULL,
0,
ShareAccess,
FILE_OPEN,
OpenOptions,
NULL,
0));
}

View File

@@ -21,6 +21,27 @@
/* FUNCTIONS ***************************************************************/
NTSTATUS
STDCALL
NtUnloadDriver(
IN PUNICODE_STRING DriverServiceName
)
{
}
NTSTATUS
STDCALL
ZwUnloadDriver(
IN PUNICODE_STRING DriverServiceName
)
{
}
NTSTATUS NtLoadDriver(PUNICODE_STRING DriverServiceName)
{
}
NTSTATUS ZwLoadDriver(PUNICODE_STRING DriverServiceName)
/*
* FUNCTION: Loads a driver
@@ -187,11 +208,11 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
if (DeviceName!=NULL)
{
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
dev = ObGenericCreateObject(&devh,0,&dev_attr,IoDeviceType);
}
else
{
dev = ObGenericCreateObject(&devh,0,NULL,OBJTYP_DEVICE);
dev = ObGenericCreateObject(&devh,0,NULL,IoDeviceType);
}
*DeviceObject=NULL;

View File

@@ -11,38 +11,48 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/mm.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle)
/*
* FUNCTION: Releases a section of driver code or driver data, previously
* locked into system space with MmLockPagableCodeSection,
* MmLockPagableDataSection or MmLockPagableSectionByHandle
* ARGUMENTS:
* ImageSectionHandle = Handle returned by MmLockPagableCodeSection or
* MmLockPagableDataSection
*/
{
UNIMPLEMENTED;
MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
}
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle)
{
UNIMPLEMENTED;
MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
}
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection)
{
UNIMPLEMENTED;
PVOID Handle;
Handle = MmOpenMemoryAreaByAddress(NULL,AddressWithinSection);
MmLockPagableSectionByHandle(Handle);
return(Handle);
}
PVOID MmLockPagableDataSection(PVOID AddressWithinSection)
{
UNIMPLEMENTED;
return(MmLockPagableCodeSection(AddressWithinSection));
}
VOID MmPageEntireDriver(PVOID AddressWithinSection)
{
UNIMPLEMENTED;
}
VOID MmResetDriverPaging(PVOID AddressWithinSection)
{
UNIMPLEMENTED;
}

View File

@@ -25,6 +25,15 @@ NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
UNIMPLEMENTED;
}
NTSTATUS NtQueryInformationFile(HANDLE FileHandle,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID FileInformation,
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass)
{
UNIMPLEMENTED;
}
NTSTATUS ZwSetInformationFile(HANDLE FileHandle,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID FileInformation,
@@ -34,7 +43,90 @@ NTSTATUS ZwSetInformationFile(HANDLE FileHandle,
UNIMPLEMENTED;
}
NTSTATUS NtSetInformationFile(HANDLE FileHandle,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID FileInformation,
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass)
{
UNIMPLEMENTED;
}
PGENERIC_MAPPING IoGetFileObjectGenericMapping()
{
UNIMPLEMENTED;
}
NTSTATUS
STDCALL
NtQueryAttributesFile(
IN HANDLE FileHandle,
IN PVOID Buffer
)
{
}
NTSTATUS
STDCALL
ZwQueryAttributesFile(
IN HANDLE FileHandle,
IN PVOID Buffer
)
{
}
NTSTATUS
STDCALL
NtQueryFullAttributesFile(
IN HANDLE FileHandle,
IN PVOID Attributes
)
{
}
NTSTATUS
STDCALL
ZwQueryFullAttributesFile(
IN HANDLE FileHandle,
IN PVOID Attributes
)
{
}
NTSTATUS
STDCALL
NtQueryEaFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID Buffer,
IN ULONG Length,
IN BOOLEAN ReturnSingleEntry,
IN PVOID EaList OPTIONAL,
IN ULONG EaListLength,
IN PULONG EaIndex OPTIONAL,
IN BOOLEAN RestartScan
)
{
}
NTSTATUS
STDCALL
NtSetEaFile(
IN HANDLE FileHandle,
IN PIO_STATUS_BLOCK IoStatusBlock,
PVOID EaBuffer,
ULONG EaBufferSize
)
{
}
NTSTATUS
STDCALL
ZwSetEaFile(
IN HANDLE FileHandle,
IN PIO_STATUS_BLOCK IoStatusBlock,
PVOID EaBuffer,
ULONG EaBufferSize
)
{
}

View File

@@ -31,6 +31,51 @@ static LIST_ENTRY FileSystemListHead = {NULL,NULL};
/* FUNCTIONS *****************************************************************/
NTSTATUS
STDCALL
NtFsControlFile(
IN HANDLE DeviceHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG IoControlCode,
IN PVOID InputBuffer,
IN ULONG InputBufferSize,
OUT PVOID OutputBuffer,
IN ULONG OutputBufferSize
)
{
return(ZwFsControlFile(DeviceHandle,
Event,
ApcRoutine,
ApcContext,
IoStatusBlock,
IoControlCode,
InputBuffer,
InputBufferSize,
OutputBuffer,
OutputBufferSize));
}
NTSTATUS
STDCALL
ZwFsControlFile(
IN HANDLE DeviceHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
IN PVOID ApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG IoControlCode,
IN PVOID InputBuffer,
IN ULONG InputBufferSize,
OUT PVOID OutputBuffer,
IN ULONG OutputBufferSize
)
{
UNIMPLEMENTED;
}
VOID IoInitFileSystemImplementation(VOID)
{
InitializeListHead(&FileSystemListHead);
@@ -142,6 +187,7 @@ VOID IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
if (current->DeviceObject == DeviceObject)
{
RemoveEntryList(current_entry);
ExFreePool(current);
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
return;
}

View File

@@ -20,3 +20,37 @@ ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode)
{
UNIMPLEMENTED;
}
NTSTATUS
STDCALL
NtDeviceIoControlFile(
IN HANDLE DeviceHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
IN PVOID UserApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG IoControlCode,
IN PVOID InputBuffer,
IN ULONG InputBufferSize,
OUT PVOID OutputBuffer,
IN ULONG OutputBufferSize
)
{
}
NTSTATUS
STDCALL
ZwDeviceIoControlFile(
IN HANDLE DeviceHandle,
IN HANDLE Event OPTIONAL,
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
IN PVOID UserApcContext OPTIONAL,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG IoControlCode,
IN PVOID InputBuffer,
IN ULONG InputBufferSize,
OUT PVOID OutputBuffer,
IN ULONG OutputBufferSize
)
{
}

View File

@@ -13,45 +13,15 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
#define NDEBUG
#include <internal/debug.h>
/* GLOBALS *******************************************************************/
OBJECT_TYPE DeviceObjectType = {{0,0,NULL},
0,
0,
ULONG_MAX,
ULONG_MAX,
sizeof(DEVICE_OBJECT),
0,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
OBJECT_TYPE FileObjectType = {{0,0,NULL},
0,
0,
ULONG_MAX,
ULONG_MAX,
sizeof(FILE_OBJECT),
0,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
POBJECT_TYPE IoDeviceType = NULL;
POBJECT_TYPE IoFileType = NULL;
/* FUNCTIONS ****************************************************************/
@@ -60,31 +30,63 @@ VOID IoInit(VOID)
{
OBJECT_ATTRIBUTES attr;
HANDLE handle;
UNICODE_STRING string;
ANSI_STRING astring;
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
/*
* Register iomgr types
*/
RtlInitAnsiString(&astring,"Device");
RtlAnsiStringToUnicodeString(&DeviceObjectType.TypeName,&astring,TRUE);
ObRegisterType(OBJTYP_DEVICE,&DeviceObjectType);
RtlInitAnsiString(&astring,"File");
RtlAnsiStringToUnicodeString(&FileObjectType.TypeName,&astring,TRUE);
ObRegisterType(OBJTYP_FILE,&FileObjectType);
IoDeviceType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
IoDeviceType->TotalObjects = 0;
IoDeviceType->TotalHandles = 0;
IoDeviceType->MaxObjects = ULONG_MAX;
IoDeviceType->MaxHandles = ULONG_MAX;
IoDeviceType->PagedPoolCharge = 0;
IoDeviceType->NonpagedPoolCharge = sizeof(DEVICE_OBJECT);
IoDeviceType->Dump = NULL;
IoDeviceType->Open = NULL;
IoDeviceType->Close = NULL;
IoDeviceType->Delete = NULL;
IoDeviceType->Parse = NULL;
IoDeviceType->Security = NULL;
IoDeviceType->QueryName = NULL;
IoDeviceType->OkayToClose = NULL;
RtlInitAnsiString(&AnsiString,"Device");
RtlAnsiStringToUnicodeString(&IoDeviceType->TypeName,&AnsiString,TRUE);
IoFileType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
IoFileType->TotalObjects = 0;
IoFileType->TotalHandles = 0;
IoFileType->MaxObjects = ULONG_MAX;
IoFileType->MaxHandles = ULONG_MAX;
IoFileType->PagedPoolCharge = 0;
IoFileType->NonpagedPoolCharge = sizeof(FILE_OBJECT);
IoFileType->Dump = NULL;
IoFileType->Open = NULL;
IoFileType->Close = NULL;
IoFileType->Delete = NULL;
IoFileType->Parse = NULL;
IoFileType->Security = NULL;
IoFileType->QueryName = NULL;
IoFileType->OkayToClose = NULL;
RtlInitAnsiString(&AnsiString,"File");
RtlAnsiStringToUnicodeString(&IoFileType->TypeName,&AnsiString,TRUE);
/*
* Create the device directory
*/
RtlInitAnsiString(&astring,"\\Device");
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
RtlInitAnsiString(&AnsiString,"\\Device");
RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
InitializeObjectAttributes(&attr,&UnicodeString,0,NULL,NULL);
ZwCreateDirectoryObject(&handle,0,&attr);
RtlInitAnsiString(&astring,"\\??");
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
RtlInitAnsiString(&AnsiString,"\\??");
RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
InitializeObjectAttributes(&attr,&UnicodeString,0,NULL,NULL);
ZwCreateDirectoryObject(&handle,0,&attr);
IoInitCancelHandling();

Some files were not shown because too many files have changed in this diff Show More