mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 11:02:16 +00:00
*** empty log message ***
svn path=/trunk/; revision=375
This commit is contained in:
parent
eee72fe55d
commit
d837d19fac
68 changed files with 3357 additions and 3159 deletions
|
@ -6,7 +6,7 @@
|
|||
#include <defines.h>
|
||||
#include <ddk/ntddblue.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
||||
|
@ -144,9 +144,11 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
vidmem = DeviceExtension->VideoMemory;
|
||||
cursorx = DeviceExtension->CursorX;
|
||||
cursory = DeviceExtension->CursorY;
|
||||
|
||||
// cursorx = DeviceExtension->CursorX;
|
||||
// cursory = DeviceExtension->CursorY;
|
||||
cursorx = __wherex();
|
||||
cursory = __wherey();
|
||||
|
||||
for (i = 0; i < stk->Parameters.Write.Length; i++, pch++)
|
||||
{
|
||||
switch (*pch)
|
||||
|
@ -228,8 +230,9 @@ NTSTATUS ScrWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
offset >>= 8;
|
||||
outb_p (CRTC_DATA, offset);
|
||||
|
||||
DeviceExtension->CursorX = cursorx;
|
||||
DeviceExtension->CursorY = cursory;
|
||||
// DeviceExtension->CursorX = cursorx;
|
||||
// DeviceExtension->CursorY = cursory;
|
||||
__goxy(cursorx, cursory);
|
||||
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
@ -465,6 +468,8 @@ NTSTATUS ScrIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
offset = (Buf->dwCoord.Y * NR_COLUMNS * 2) +
|
||||
(Buf->dwCoord.X * 2);
|
||||
|
||||
CHECKPOINT
|
||||
|
||||
for (dwCount = 0; dwCount < Buf->nLength; dwCount++)
|
||||
{
|
||||
vidmem[offset + (dwCount * 2)] = (char) Buf->cCharacter;
|
||||
|
|
|
@ -1580,6 +1580,37 @@ NTSTATUS FsdGetStandardInformation(PVfatFCB FCB, PDEVICE_OBJECT DeviceObject,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FsdSetPositionInformation(PFILE_OBJECT FileObject,
|
||||
PVfatFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_POSITION_INFORMATION PositionInfo)
|
||||
{
|
||||
DbgPrint("FsdSetPositionInformation()\n");
|
||||
|
||||
DbgPrint("PositionInfo %x\n", PositionInfo);
|
||||
DbgPrint("Setting position %d\n",GET_LARGE_INTEGER_LOW_PART(
|
||||
PositionInfo->CurrentByteOffset));
|
||||
memcpy(&FileObject->CurrentByteOffset,&PositionInfo->CurrentByteOffset,
|
||||
sizeof(LARGE_INTEGER));
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetPositionInformation(PFILE_OBJECT FileObject,
|
||||
PVfatFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_POSITION_INFORMATION PositionInfo)
|
||||
{
|
||||
DbgPrint("FsdGetPositionInformation()\n");
|
||||
|
||||
memcpy(&PositionInfo->CurrentByteOffset, &FileObject->CurrentByteOffset,
|
||||
sizeof(LARGE_INTEGER));
|
||||
DbgPrint("Getting position %x\n",GET_LARGE_INTEGER_LOW_PART(
|
||||
PositionInfo->CurrentByteOffset));
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Retrieve the specified file information
|
||||
|
@ -1618,6 +1649,12 @@ NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
case FileStandardInformation:
|
||||
RC = FsdGetStandardInformation(FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
case FilePositionInformation:
|
||||
RC = FsdGetPositionInformation(FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
break;
|
||||
default:
|
||||
RC=STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -1625,6 +1662,60 @@ NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return RC;
|
||||
}
|
||||
|
||||
NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Retrieve the specified file information
|
||||
*/
|
||||
{
|
||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
FILE_INFORMATION_CLASS FileInformationClass;
|
||||
PFILE_OBJECT FileObject = NULL;
|
||||
PVfatFCB FCB = NULL;
|
||||
// PVfatCCB CCB = NULL;
|
||||
NTSTATUS RC = STATUS_SUCCESS;
|
||||
PVOID SystemBuffer;
|
||||
|
||||
/* PRECONDITION */
|
||||
assert(DeviceObject != NULL);
|
||||
assert(Irp != NULL);
|
||||
|
||||
DbgPrint("FsdSetInformation(DeviceObject %x, Irp %x)\n",
|
||||
DeviceObject,Irp);
|
||||
|
||||
/* INITIALIZATION */
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileInformationClass = Stack->Parameters.SetFile.FileInformationClass;
|
||||
FileObject = Stack->FileObject;
|
||||
FCB = ((PVfatCCB)(FileObject->FsContext2))->pFcb;
|
||||
|
||||
// FIXME : determine Buffer for result :
|
||||
if (Irp->MdlAddress)
|
||||
SystemBuffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||
else
|
||||
SystemBuffer = Irp->UserBuffer;
|
||||
// SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
DbgPrint("FileInformationClass %d\n",FileInformationClass);
|
||||
DbgPrint("SystemBuffer %x\n",SystemBuffer);
|
||||
|
||||
switch(FileInformationClass)
|
||||
{
|
||||
case FilePositionInformation:
|
||||
RC = FsdSetPositionInformation(FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
break;
|
||||
default:
|
||||
RC = STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return RC;
|
||||
}
|
||||
|
||||
|
||||
STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||
PUNICODE_STRING RegistryPath)
|
||||
/*
|
||||
|
@ -1662,6 +1753,8 @@ STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|||
FsdFileSystemControl;
|
||||
VFATDriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
|
||||
FsdQueryInformation;
|
||||
VFATDriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
|
||||
FsdSetInformation;
|
||||
VFATDriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
||||
FsdDirectoryControl;
|
||||
|
||||
|
|
1
reactos/include/crtdll/crtdll.h
Normal file
1
reactos/include/crtdll/crtdll.h
Normal file
|
@ -0,0 +1 @@
|
|||
void debug_printf(char* fmt, ...);
|
|
@ -60,3 +60,14 @@ time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder );
|
|||
#endif
|
||||
|
||||
#endif /* __dj_include_libc_file_h__ */
|
||||
|
||||
#define __FILE_REC_MAX 20
|
||||
typedef struct __file_rec
|
||||
{
|
||||
struct __file_rec *next;
|
||||
int count;
|
||||
FILE *files[__FILE_REC_MAX];
|
||||
} __file_rec;
|
||||
|
||||
extern __file_rec *__file_rec_list;
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
* DISCLAMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.5 $
|
||||
* $Revision: 1.6 $
|
||||
* $Author: dwelch $
|
||||
* $Date: 1999/04/10 12:08:06 $
|
||||
* $Date: 1999/04/14 00:46:22 $
|
||||
*
|
||||
*/
|
||||
/* Appropriated for Reactos Crtdll by Ariadne */
|
||||
|
@ -95,12 +95,11 @@ typedef struct {
|
|||
* NOTE: These will go to the bit-bucket silently in GUI applications!
|
||||
*/
|
||||
extern FILE (*_iob)[]; /* A pointer to an array of FILE */
|
||||
//#define _iob (*__imp__iob) /* An array of FILE */
|
||||
#define stdin (&_iob[0])
|
||||
#define stdout (&_iob[1])
|
||||
#define stderr (&_iob[2])
|
||||
#define stdaux (&_iob[3])
|
||||
#define stdprn (&_iob[4])
|
||||
#define stdin (&(*_iob)[0])
|
||||
#define stdout (&(*_iob)[1])
|
||||
#define stderr (&(*_iob)[2])
|
||||
#define stdaux (&(*_iob)[3])
|
||||
#define stdprn (&(*_iob)[4])
|
||||
|
||||
/* Returned by various functions on end of file condition or error. */
|
||||
#define EOF (-1)
|
||||
|
|
|
@ -36,6 +36,7 @@ BOOLEAN MmIsThisAnNtAsSystem(VOID);
|
|||
* Size = Size of range
|
||||
* RETURNS: The number of pages
|
||||
*/
|
||||
#if 0
|
||||
extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
|
||||
ULONG Size)
|
||||
{
|
||||
|
@ -46,6 +47,7 @@ extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
|
|||
LowestAddr = PAGE_ROUND_DOWN((ULONG)Va);
|
||||
return((HighestAddr - LowestAddr) / PAGESIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef __INCLUDE_DDK_PSTYPES_H
|
||||
#define __INCLUDE_DDK_PSTYPES_H
|
||||
|
||||
#include <kernel32/heap.h>
|
||||
#include <kernel32/atom.h>
|
||||
#include <internal/hal.h>
|
||||
|
||||
|
@ -94,7 +93,7 @@ typedef struct _NT_PEB
|
|||
WORD NtGlobalFlag;
|
||||
|
||||
PPROCESSINFOW StartupInfo;
|
||||
PHEAP ProcessHeap;
|
||||
HANDLE ProcessHeap;
|
||||
ATOMTABLE LocalAtomTable;
|
||||
LPCRITICAL_SECTION CriticalSection;
|
||||
DWORD CriticalSectionTimeout;
|
||||
|
|
|
@ -2829,21 +2829,17 @@ NtQueryInformationAtom(
|
|||
GetFullPathName, GetFileType, GetFileSize, GetFileTime functions.
|
||||
* RETURNS: Status
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtQueryInformationFile(
|
||||
IN HANDLE FileHandle,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PVOID FileInformation,
|
||||
IN ULONG Length,
|
||||
IN FILE_INFORMATION_CLASS FileInformationClass
|
||||
);
|
||||
NTSTATUS STDCALL NtQueryInformationFile(IN HANDLE FileHandle,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PVOID FileInformation,
|
||||
IN ULONG Length,
|
||||
IN FILE_INFORMATION_CLASS FileInformationClass);
|
||||
|
||||
NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID FileInformation,
|
||||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass);
|
||||
NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID FileInformation,
|
||||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass);
|
||||
|
||||
/*
|
||||
* FUNCTION: Queries the information of a process object.
|
||||
|
|
|
@ -2010,7 +2010,8 @@ extern "C" {
|
|||
#define HEAP_NO_SERIALIZE (1)
|
||||
#define HEAP_ZERO_MEMORY (8)
|
||||
#define HEAP_REALLOC_IN_PLACE_ONLY (16)
|
||||
|
||||
#define HEAP_GROWABLE (32)
|
||||
|
||||
/* ImageList_Create */
|
||||
#define ILC_COLOR (0)
|
||||
#define ILC_COLOR4 (4)
|
||||
|
|
|
@ -94,4 +94,8 @@ VOID MmFreePage(PVOID PhysicalAddress, ULONG Nr);
|
|||
VOID MmDeletePageTable(PEPROCESS Process, PVOID Address);
|
||||
NTSTATUS MmCopyMmInfo(PEPROCESS Src, PEPROCESS Dest);
|
||||
NTSTATUS MmReleaseMmInfo(PEPROCESS Process);
|
||||
NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process);
|
||||
VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address, BOOL FreePage);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* limits.h
|
||||
*
|
||||
* Defines constants for the sizes of integral types.
|
||||
*
|
||||
* NOTE: GCC should supply a version of this header and it should be safe to
|
||||
* use that version instead of this one (maybe safer).
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Author: ariadne $
|
||||
* $Date: 1999/03/22 20:48:08 $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LIMITS_H_
|
||||
#define _LIMITS_H_
|
||||
|
||||
/*
|
||||
* File system limits
|
||||
*
|
||||
* TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
|
||||
* same as FILENAME_MAX and FOPEN_MAX from stdio.h?
|
||||
* NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
|
||||
* required for the NUL. TODO: Test?
|
||||
*/
|
||||
#define PATH_MAX (259)
|
||||
|
||||
/*
|
||||
* Characteristics of the char data type.
|
||||
*
|
||||
* TODO: Is MB_LEN_MAX correct?
|
||||
*/
|
||||
#define CHAR_BIT 8
|
||||
#define MB_LEN_MAX 2
|
||||
|
||||
#define SCHAR_MIN (-128)
|
||||
#define SCHAR_MAX 127
|
||||
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
/* TODO: Is this safe? I think it might just be testing the preprocessor,
|
||||
* not the compiler itself... */
|
||||
#if ('\x80' < 0)
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#else
|
||||
#define CHAR_MIN 0
|
||||
#define CHAR_MAX UCHAR_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum and minimum values for ints.
|
||||
*/
|
||||
#define INT_MAX 2147483647
|
||||
#define INT_MIN (-INT_MAX-1)
|
||||
|
||||
#define UINT_MAX (2U * INT_MAX + 1)
|
||||
|
||||
/*
|
||||
* Maximum and minimum values for shorts.
|
||||
*/
|
||||
#define SHRT_MAX 32767
|
||||
#define SHRT_MIN (-SHRT_MAX-1)
|
||||
|
||||
#define USHRT_MAX ((unsigned short) (2U * SHRT_MAX + 1))
|
||||
|
||||
/*
|
||||
* Maximum and minimum values for longs and unsigned longs.
|
||||
*
|
||||
* TODO: This is not correct for Alphas, which have 64 bit longs.
|
||||
*/
|
||||
#define LONG_MAX 2147483647L
|
||||
|
||||
#define LONG_MIN (-LONG_MAX-1)
|
||||
|
||||
#define ULONG_MAX (2UL * LONG_MAX + 1)
|
||||
|
||||
|
||||
/*
|
||||
* The GNU C compiler also allows 'long long int'
|
||||
*/
|
||||
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
||||
|
||||
#define LONG_LONG_MAX 9223372036854775807LL
|
||||
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
|
||||
|
||||
#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)
|
||||
|
||||
#endif /* Not Strict ANSI and GNU C compiler */
|
||||
|
||||
|
||||
#endif /* not _LIMITS_H_ */
|
|
@ -7,3 +7,4 @@ VOID RtlEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
|||
VOID RtlInitializeCriticalSection(LPCRITICAL_SECTION pcritical);
|
||||
VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
||||
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
||||
DWORD WINAPI RtlCompactHeap( HANDLE heap, DWORD flags );
|
||||
|
|
|
@ -1,337 +0,0 @@
|
|||
/*
|
||||
* stdio.h
|
||||
*
|
||||
* Definitions of types and prototypes of functions for standard input and
|
||||
* output.
|
||||
*
|
||||
* NOTE: The file manipulation functions provided by Microsoft seem to
|
||||
* work with either slash (/) or backslash (\) as the path separator.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.6 $
|
||||
* $Author: rex $
|
||||
* $Date: 1999/03/19 05:55:06 $
|
||||
*
|
||||
*/
|
||||
/* Appropriated for Reactos Crtdll by Ariadne */
|
||||
/* implemented clearerr feof ferror perror as macros */
|
||||
#ifndef _STDIO_H_
|
||||
#define _STDIO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#define __need_wchar_t
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/* Some flags for the iobuf structure provided by djgpp stdio.h */
|
||||
#define _IOREAD 000010
|
||||
#define _IOWRT 000020
|
||||
#define _IOMYBUF 000040
|
||||
#define _IOEOF 000100
|
||||
#define _IOERR 000200
|
||||
#define _IOSTRG 000400
|
||||
#define _IORW 001000
|
||||
#define _IOAPPEND 002000
|
||||
#define _IORMONCL 004000 /* remove on close, for temp files */
|
||||
/* if _flag & _IORMONCL, ._name_to_remove needs freeing */
|
||||
#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
|
||||
|
||||
|
||||
/*
|
||||
* I used to include stdarg.h at this point, in order to allow for the
|
||||
* functions later on in the file which use va_list. That conflicts with
|
||||
* using stdio.h and varargs.h in the same file, so I do the typedef myself.
|
||||
*/
|
||||
#ifndef _VA_LIST
|
||||
#define _VA_LIST
|
||||
typedef char* va_list;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FILE should be used as a pointer to an opaque data type. Do not rely on
|
||||
* anything else, especially the size or contents of this structure!
|
||||
*/
|
||||
#ifndef _FILE_DEFINED
|
||||
typedef struct {
|
||||
char *_ptr;
|
||||
int _cnt;
|
||||
char *_base;
|
||||
int _flag;
|
||||
int _file;
|
||||
int _ungotchar;
|
||||
int _bufsiz;
|
||||
char *_name_to_remove;
|
||||
} FILE;
|
||||
#define _FILE_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The three standard file pointers provided by the run time library.
|
||||
* NOTE: These will go to the bit-bucket silently in GUI applications!
|
||||
*/
|
||||
extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */
|
||||
#define _iob (*__imp__iob) /* An array of FILE */
|
||||
#define stdin (&_iob[0])
|
||||
#define stdout (&_iob[1])
|
||||
#define stderr (&_iob[2])
|
||||
#define stdaux (&_iob[3])
|
||||
#define stdprn (&_iob[4])
|
||||
|
||||
/* Returned by various functions on end of file condition or error. */
|
||||
#define EOF (-1)
|
||||
|
||||
|
||||
/*
|
||||
* The maximum length of a file name. You should use GetVolumeInformation
|
||||
* instead of this constant. But hey, this works.
|
||||
*
|
||||
* NOTE: This is used in the structure _finddata_t (see dir.h) so changing it
|
||||
* is probably not a good idea.
|
||||
*/
|
||||
#define FILENAME_MAX (260)
|
||||
|
||||
/*
|
||||
* The maximum number of files that may be open at once. I have set this to
|
||||
* a conservative number. The actual value may be higher.
|
||||
*/
|
||||
#define FOPEN_MAX (20)
|
||||
|
||||
|
||||
/*
|
||||
* File Operations
|
||||
*/
|
||||
|
||||
FILE* fopen (const char* szFileName, const char* szMode);
|
||||
FILE* freopen (const char* szNewFileName, const char* szNewMode,
|
||||
FILE* fileChangeAssociation);
|
||||
int fflush (FILE* fileFlush);
|
||||
int fclose (FILE* fileClose);
|
||||
int remove (const char* szFileName);
|
||||
int rename (const char* szOldFileName, const char* szNewFileName);
|
||||
FILE* tmpfile (void);
|
||||
|
||||
|
||||
/*
|
||||
* The maximum size of name (including NUL) that will be put in the user
|
||||
* supplied buffer caName.
|
||||
* NOTE: This has not been determined by experiment, but based on the
|
||||
* maximum file name length above it is probably reasonable. I could be
|
||||
* wrong...
|
||||
*/
|
||||
#define L_tmpnam (260)
|
||||
|
||||
char* tmpnam (char caName[]);
|
||||
char* _tempnam (const char *szDir, const char *szPfx);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
#define tempnam _tempnam
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
/*
|
||||
* The three possible buffering mode (nMode) values for setvbuf.
|
||||
* NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
|
||||
* maybe I'm testing it wrong?
|
||||
*/
|
||||
#define _IOFBF 0 /* fully buffered */
|
||||
#define _IOLBF 1 /* line buffered */
|
||||
#define _IONBF 2 /* unbuffered */
|
||||
|
||||
int setvbuf (FILE* fileSetBuffer, char* caBuffer, int nMode,
|
||||
size_t sizeBuffer);
|
||||
|
||||
|
||||
/*
|
||||
* The buffer size as used by setbuf such that it is equivalent to
|
||||
* (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
|
||||
*/
|
||||
#define BUFSIZ 512
|
||||
|
||||
void setbuf (FILE* fileSetBuffer, char* caBuffer);
|
||||
|
||||
/*
|
||||
* Pipe Operations
|
||||
*/
|
||||
|
||||
int _pclose (FILE* pipeClose);
|
||||
FILE* _popen (const char* szPipeName, const char* szMode);
|
||||
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
|
||||
/* Wide character version */
|
||||
FILE* _wpopen (const wchar_t* szPipeName, const wchar_t* szMode);
|
||||
|
||||
/*
|
||||
* Formatted Output
|
||||
*/
|
||||
|
||||
int fprintf (FILE* filePrintTo, const char* szFormat, ...);
|
||||
int printf (const char* szFormat, ...);
|
||||
int sprintf (char* caBuffer, const char* szFormat, ...);
|
||||
int vfprintf (FILE* filePrintTo, const char* szFormat, va_list varg);
|
||||
int vprintf (const char* szFormat, va_list varg);
|
||||
int vsprintf (char* caBuffer, const char* szFormat, va_list varg);
|
||||
|
||||
/* Wide character versions */
|
||||
int fwprintf (FILE* filePrintTo, const wchar_t* wsFormat, ...);
|
||||
int wprintf (const wchar_t* wsFormat, ...);
|
||||
int swprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, ...);
|
||||
int vfwprintf (FILE* filePrintTo, const wchar_t* wsFormat, va_list varg);
|
||||
int vwprintf (const wchar_t* wsFormat, va_list varg);
|
||||
int vswprintf (wchar_t* wcaBuffer, const wchar_t* wsFormat, va_list varg);
|
||||
|
||||
/*
|
||||
* Formatted Input
|
||||
*/
|
||||
|
||||
int fscanf (FILE* fileReadFrom, const char* szFormat, ...);
|
||||
int scanf (const char* szFormat, ...);
|
||||
int sscanf (const char* szReadFrom, const char* szFormat, ...);
|
||||
|
||||
/* Wide character versions */
|
||||
int fwscanf (FILE* fileReadFrom, const wchar_t* wsFormat, ...);
|
||||
int wscanf (const wchar_t* wsFormat, ...);
|
||||
int swscanf (const wchar_t* wsReadFrom, const wchar_t* wsFormat, ...);
|
||||
|
||||
/*
|
||||
* Character Input and Output Functions
|
||||
*/
|
||||
|
||||
int fgetc (FILE* fileRead);
|
||||
char* fgets (char* caBuffer, int nBufferSize, FILE* fileRead);
|
||||
int fputc (int c, FILE* fileWrite);
|
||||
int fputs (const char* szOutput, FILE* fileWrite);
|
||||
int getc (FILE* fileRead);
|
||||
int getchar (void);
|
||||
char* gets (char* caBuffer); /* Unsafe: how does gets know how long the
|
||||
* buffer is? */
|
||||
int putc (int c, FILE* fileWrite);
|
||||
int putchar (int c);
|
||||
int puts (const char* szOutput);
|
||||
int ungetc (int c, FILE* fileWasRead);
|
||||
|
||||
/* Wide character versions */
|
||||
int fgetwc (FILE* fileRead);
|
||||
int fputwc (wchar_t wc, FILE* fileWrite);
|
||||
int ungetwc (wchar_t wc, FILE* fileWasRead);
|
||||
|
||||
/*
|
||||
* Not exported by CRTDLL.DLL included for reference purposes.
|
||||
*/
|
||||
#if 0
|
||||
wchar_t* fgetws (wchar_t* wcaBuffer, int nBufferSize, FILE* fileRead);
|
||||
int fputws (const wchar_t* wsOutput, FILE* fileWrite);
|
||||
int getwc (FILE* fileRead);
|
||||
int getwchar ();
|
||||
wchar_t* getws (wchar_t* wcaBuffer);
|
||||
int putwc (wchar_t wc, FILE* fileWrite);
|
||||
int putws (const wchar_t* wsOutput);
|
||||
#endif /* 0 */
|
||||
|
||||
/* NOTE: putchar has no wide char equivalent even in tchar.h */
|
||||
|
||||
|
||||
/*
|
||||
* Direct Input and Output Functions
|
||||
*/
|
||||
|
||||
size_t fread (void* pBuffer, size_t sizeObject, size_t sizeObjCount,
|
||||
FILE* fileRead);
|
||||
size_t fwrite (const void* pObjArray, size_t sizeObject, size_t sizeObjCount,
|
||||
FILE* fileWrite);
|
||||
|
||||
|
||||
/*
|
||||
* File Positioning Functions
|
||||
*/
|
||||
|
||||
/* Constants for nOrigin indicating the position relative to which fseek
|
||||
* sets the file position. Enclosed in ifdefs because io.h could also
|
||||
* define them. (Though not anymore since io.h includes this file now.) */
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET (0)
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR (1)
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END (2)
|
||||
#endif
|
||||
|
||||
int fseek (FILE* fileSetPosition, long lnOffset, int nOrigin);
|
||||
long ftell (FILE* fileGetPosition);
|
||||
void rewind (FILE* fileRewind);
|
||||
|
||||
/*
|
||||
* An opaque data type used for storing file positions... The contents of
|
||||
* this type are unknown, but we (the compiler) need to know the size
|
||||
* because the programmer using fgetpos and fsetpos will be setting aside
|
||||
* storage for fpos_t structres. Actually I tested using a byte array and
|
||||
* it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
|
||||
* Perhaps an unsigned long? TODO?
|
||||
*/
|
||||
typedef long fpos_t;
|
||||
|
||||
int fgetpos (FILE* fileGetPosition, fpos_t* pfpos);
|
||||
int fsetpos (FILE* fileSetPosition, const fpos_t* pfpos);
|
||||
|
||||
|
||||
/*
|
||||
* Error Functions
|
||||
*/
|
||||
#if 0
|
||||
void clearerr (FILE* fileClearErrors);
|
||||
int feof (FILE* fileIsAtEnd);
|
||||
int ferror (FILE* fileIsError);
|
||||
void perror (const char* szErrorMessage);
|
||||
|
||||
#endif
|
||||
|
||||
#define clearerr(f) (((f)->_flag) &= ~(_IOERR|_IOEOF))
|
||||
#define feof(f) (((f)->_flag&_IOEOF)!=0)
|
||||
#define ferror(f) (((f)->_flag&_IOERR)!=0)
|
||||
#define perror(s) (fprintf(stderr, "%s: %s\n", (s), _strerror(NULL)))
|
||||
/*
|
||||
* Non ANSI functions
|
||||
*/
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
int _fgetchar (void);
|
||||
int _fputchar (int c);
|
||||
FILE* _fdopen (int nHandle, char* szMode);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
#define fgetchar _fgetchar
|
||||
#define fputchar _fputchar
|
||||
#define fdopen _fdopen
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STDIO_H_ */
|
|
@ -17,9 +17,9 @@
|
|||
; DISCLAMED. This includes but is not limited to warrenties of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
;
|
||||
; $Revision: 1.5 $
|
||||
; $Revision: 1.6 $
|
||||
; $Author: dwelch $
|
||||
; $Date: 1999/04/10 12:08:09 $
|
||||
; $Date: 1999/04/14 00:51:18 $
|
||||
;
|
||||
; These three functions appear to be name mangled in some way, so GCC is
|
||||
; probably not going to be able to use them in any case.
|
||||
|
@ -253,7 +253,7 @@ _cexit
|
|||
;_chdir
|
||||
;_chdrive
|
||||
;_chgsign
|
||||
;_chmod
|
||||
_chmod
|
||||
;_chsize
|
||||
;_clearfp
|
||||
;_close
|
||||
|
@ -276,21 +276,21 @@ _cexit
|
|||
;_endthread
|
||||
;_environ_dll
|
||||
;_eof
|
||||
;_errno
|
||||
_errno
|
||||
;_except_handler2
|
||||
;_execl
|
||||
;_execle
|
||||
;_execlp
|
||||
;_execlpe
|
||||
;_execv
|
||||
_execl
|
||||
_execle
|
||||
_execlp
|
||||
_execlpe
|
||||
_execv
|
||||
;_execve
|
||||
;_execvp
|
||||
;_execvpe
|
||||
;_exit
|
||||
_execvp
|
||||
_execvpe
|
||||
_exit
|
||||
;_expand
|
||||
;_fcloseall
|
||||
_fcloseall
|
||||
;_fcvt
|
||||
;_fdopen
|
||||
_fdopen
|
||||
;_fgetchar
|
||||
;_fgetwchar
|
||||
;_filbuf
|
||||
|
@ -310,7 +310,7 @@ _fpreset
|
|||
;_fputchar
|
||||
;_fputwchar
|
||||
;_fsopen
|
||||
;_fstat
|
||||
_fstat
|
||||
;_ftime
|
||||
;_ftol
|
||||
;_fullpath
|
||||
|
@ -432,7 +432,7 @@ _iob
|
|||
;_memccpy
|
||||
;_memicmp
|
||||
;_mkdir
|
||||
;_mktemp
|
||||
_mktemp
|
||||
;_msize
|
||||
;_nextafter
|
||||
;_onexit
|
||||
|
@ -446,7 +446,7 @@ _iob
|
|||
;_pclose
|
||||
;_pctype_dll
|
||||
;_pgmptr_dll
|
||||
;_pipe
|
||||
_pipe
|
||||
;_popen
|
||||
;_purecall
|
||||
;_putch
|
||||
|
@ -468,29 +468,29 @@ _setmode
|
|||
;_snprintf
|
||||
;_snwprintf
|
||||
;_sopen
|
||||
;_spawnl
|
||||
;_spawnle
|
||||
;_spawnlp
|
||||
;_spawnlpe
|
||||
;_spawnv
|
||||
;_spawnve
|
||||
;_spawnvp
|
||||
;_spawnvpe
|
||||
_spawnl
|
||||
_spawnle
|
||||
_spawnlp
|
||||
_spawnlpe
|
||||
_spawnv
|
||||
_spawnve
|
||||
_spawnvp
|
||||
_spawnvpe
|
||||
;_splitpath
|
||||
;_stat
|
||||
_stat
|
||||
;_statusfp
|
||||
;_strcmpi
|
||||
;_strdate
|
||||
;_strdec
|
||||
;_strdup
|
||||
;_strerror
|
||||
;_stricmp
|
||||
_stricmp
|
||||
;_stricoll
|
||||
;_strinc
|
||||
;_strlwr
|
||||
;_strncnt
|
||||
;_strnextc
|
||||
;_strnicmp
|
||||
_strnicmp
|
||||
;_strninc
|
||||
;_strnset
|
||||
;_strrev
|
||||
|
@ -509,15 +509,15 @@ _setmode
|
|||
;_tzname
|
||||
;_tzset
|
||||
;_ultoa
|
||||
;_umask
|
||||
_umask
|
||||
;_ungetch
|
||||
;_unlink
|
||||
_unlink
|
||||
;_unloaddll
|
||||
;_utime
|
||||
;_vsnprintf
|
||||
;_vsnwprintf
|
||||
;_wcsdup
|
||||
;_wcsicmp
|
||||
_wcsicmp
|
||||
;_wcsicoll
|
||||
;_wcslwr
|
||||
;_wcsnicmp
|
||||
|
@ -528,7 +528,7 @@ _setmode
|
|||
;_winmajor_dll
|
||||
;_winminor_dll
|
||||
;_winver_dll
|
||||
;_write
|
||||
_write
|
||||
;_wtoi
|
||||
;_wtol
|
||||
;_y0
|
||||
|
@ -543,8 +543,8 @@ abort
|
|||
;atan2
|
||||
atexit
|
||||
;atof
|
||||
;atoi
|
||||
;atol
|
||||
atoi
|
||||
atol
|
||||
;bsearch
|
||||
;calloc
|
||||
;ceil
|
||||
|
@ -552,69 +552,69 @@ atexit
|
|||
;clock
|
||||
;cos
|
||||
;cosh
|
||||
;ctime
|
||||
ctime
|
||||
;difftime
|
||||
;div
|
||||
;exit
|
||||
exit
|
||||
;exp
|
||||
;fabs
|
||||
;fclose
|
||||
;feof
|
||||
;ferror
|
||||
;fflush
|
||||
;fgetc
|
||||
;fgetpos
|
||||
;fgets
|
||||
fclose
|
||||
feof
|
||||
ferror
|
||||
fflush
|
||||
fgetc
|
||||
fgetpos
|
||||
fgets
|
||||
;fgetwc
|
||||
;floor
|
||||
;fmod
|
||||
;fopen
|
||||
;fprintf
|
||||
;fputc
|
||||
;fputs
|
||||
fopen
|
||||
fprintf
|
||||
fputc
|
||||
fputs
|
||||
;fputwc
|
||||
;fread
|
||||
;free
|
||||
fread
|
||||
free
|
||||
;freopen
|
||||
;frexp
|
||||
;fscanf
|
||||
;fseek
|
||||
;fsetpos
|
||||
;ftell
|
||||
fscanf
|
||||
fseek
|
||||
fsetpos
|
||||
ftell
|
||||
;fwprintf
|
||||
;fwrite
|
||||
fwrite
|
||||
;fwscanf
|
||||
;getc
|
||||
;getchar
|
||||
;getenv
|
||||
;gets
|
||||
getc
|
||||
getchar
|
||||
getenv
|
||||
gets
|
||||
;gmtime
|
||||
;is_wctype
|
||||
;isalnum
|
||||
;isalpha
|
||||
;iscntrl
|
||||
;isdigit
|
||||
;isgraph
|
||||
is_wctype
|
||||
isalnum
|
||||
isalpha
|
||||
iscntrl
|
||||
isdigit
|
||||
isgraph
|
||||
;isleadbyte
|
||||
;islower
|
||||
;isprint
|
||||
;ispunct
|
||||
;isspace
|
||||
;isupper
|
||||
;iswalnum
|
||||
;iswalpha
|
||||
;iswascii
|
||||
;iswcntrl
|
||||
;iswctype
|
||||
;iswdigit
|
||||
;iswgraph
|
||||
;iswlower
|
||||
;iswprint
|
||||
;iswpunct
|
||||
;iswspace
|
||||
;iswupper
|
||||
;iswxdigit
|
||||
;isxdigit
|
||||
islower
|
||||
isprint
|
||||
ispunct
|
||||
isspace
|
||||
isupper
|
||||
iswalnum
|
||||
iswalpha
|
||||
iswascii
|
||||
iswcntrl
|
||||
iswctype
|
||||
iswdigit
|
||||
iswgraph
|
||||
iswlower
|
||||
iswprint
|
||||
iswpunct
|
||||
iswspace
|
||||
iswupper
|
||||
iswxdigit
|
||||
isxdigit
|
||||
;labs
|
||||
;ldexp
|
||||
;ldiv
|
||||
|
@ -623,92 +623,92 @@ atexit
|
|||
;log
|
||||
;log10
|
||||
;longjmp
|
||||
;malloc
|
||||
malloc
|
||||
;mblen
|
||||
;mbstowcs
|
||||
;mbtowc
|
||||
;memchr
|
||||
;memcmp
|
||||
;memcpy
|
||||
;memmove
|
||||
;memset
|
||||
memchr
|
||||
memcmp
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
;mktime
|
||||
;modf
|
||||
;perror
|
||||
perror
|
||||
;pow
|
||||
;printf
|
||||
;putc
|
||||
;putchar
|
||||
;puts
|
||||
printf
|
||||
putc
|
||||
putchar
|
||||
puts
|
||||
;qsort
|
||||
;raise
|
||||
;rand
|
||||
;realloc
|
||||
;remove
|
||||
;rename
|
||||
;rewind
|
||||
;scanf
|
||||
realloc
|
||||
remove
|
||||
rename
|
||||
rewind
|
||||
scanf
|
||||
;setbuf
|
||||
;setlocale
|
||||
;setvbuf
|
||||
;signal
|
||||
;sin
|
||||
;sinh
|
||||
;sprintf
|
||||
sprintf
|
||||
;sqrt
|
||||
;srand
|
||||
;sscanf
|
||||
;strcat
|
||||
;strchr
|
||||
;strcmp
|
||||
sscanf
|
||||
strcat
|
||||
strchr
|
||||
strcmp
|
||||
;strcoll
|
||||
;strcpy
|
||||
strcpy
|
||||
;strcspn
|
||||
;strerror
|
||||
strerror
|
||||
;strftime
|
||||
strlen
|
||||
;strncat
|
||||
;strncmp
|
||||
;strncpy
|
||||
strncmp
|
||||
strncpy
|
||||
;strpbrk
|
||||
;strrchr
|
||||
strrchr
|
||||
;strspn
|
||||
;strstr
|
||||
;strtod
|
||||
;strtok
|
||||
;strtol
|
||||
;strtoul
|
||||
strtol
|
||||
strtoul
|
||||
;strxfrm
|
||||
;swprintf
|
||||
;swscanf
|
||||
;system
|
||||
;tan
|
||||
;tanh
|
||||
;time
|
||||
time
|
||||
;tmpfile
|
||||
;tmpnam
|
||||
;tolower
|
||||
tolower
|
||||
;toupper
|
||||
;towlower
|
||||
;towupper
|
||||
;ungetc
|
||||
;ungetwc
|
||||
;vfprintf
|
||||
vfprintf
|
||||
;vfwprintf
|
||||
;vprintf
|
||||
vsprintf
|
||||
;vswprintf
|
||||
;vwprintf
|
||||
;wcscat
|
||||
;wcschr
|
||||
;wcscmp
|
||||
;wcscoll
|
||||
;wcscpy
|
||||
;wcscspn
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscoll
|
||||
wcscpy
|
||||
wcscspn
|
||||
;wcsftime
|
||||
;wcslen
|
||||
;wcsncat
|
||||
;wcsncmp
|
||||
wcslen
|
||||
wcsncat
|
||||
wcsncmp
|
||||
;wcsncpy
|
||||
;wcspbrk
|
||||
;wcsrchr
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
void _fpreset (void)
|
||||
{
|
||||
__asm__ __volatile__("fninit\n\t");
|
||||
/* FIXME: This causes an exception */
|
||||
// __asm__ __volatile__("fninit\n\t");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ int _findfirst(const char *_name, struct _finddata_t *result)
|
|||
result->attrib = FindFileData.dwFileAttributes;
|
||||
|
||||
|
||||
result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
|
||||
result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
|
||||
result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
|
||||
// result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
|
||||
// result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
|
||||
// result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
|
||||
result->size = FindFileData.nFileSizeLow;
|
||||
strncpy(result->name,FindFileData.cFileName,260);
|
||||
return hFindFile;
|
||||
|
@ -41,9 +41,9 @@ int _findnext(int handle, struct _finddata_t *result)
|
|||
return -1;
|
||||
|
||||
result->attrib = FindFileData.dwFileAttributes;
|
||||
result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
|
||||
result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
|
||||
result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
|
||||
// result->time_create = FileTimeToUnixTime( &FindFileData.ftCreationTime,NULL);
|
||||
// result->time_access = FileTimeToUnixTime( &FindFileData.ftLastAccessTime,NULL);
|
||||
// result->time_write = FileTimeToUnixTime( &FindFileData.ftLastWriteTime,NULL);
|
||||
result->size = FindFileData.nFileSizeLow;
|
||||
strncpy(result->name,FindFileData.cFileName,260);
|
||||
return 0;
|
||||
|
|
|
@ -7,5 +7,3 @@ long _lseek(int _fildes, long _offset, int _whence)
|
|||
return _llseek((HFILE)filehnd(_fildes),_offset,_whence);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
#include <crtdll/string.h>
|
||||
#include <crtdll/io.h>
|
||||
|
||||
char* mktemp (char *_template)
|
||||
{
|
||||
return(_mktemp(_template));
|
||||
}
|
||||
|
||||
char *
|
||||
mktemp (char *_template)
|
||||
char* _mktemp (char *_template)
|
||||
{
|
||||
static int count = 0;
|
||||
char *cp, *dp;
|
||||
|
|
|
@ -28,10 +28,11 @@ fileno_modes_type *fileno_modes = NULL;
|
|||
int maxfno = 5;
|
||||
int minfno = 5;
|
||||
|
||||
char __is_text_file(FILE *p) {
|
||||
if ( p == NULL || fileno_modes == NULL )
|
||||
return FALSE;
|
||||
return (!((p)->_flag&_IOSTRG) && (fileno_modes[(p)->_file].mode&O_TEXT));
|
||||
char __is_text_file(FILE *p)
|
||||
{
|
||||
if ( p == NULL || fileno_modes == NULL )
|
||||
return FALSE;
|
||||
return (!((p)->_flag&_IOSTRG) && (fileno_modes[(p)->_file].mode&O_TEXT));
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,79 +43,78 @@ int __fileno_alloc(HANDLE hFile, int mode);
|
|||
|
||||
int _open(const char *_path, int _oflag,...)
|
||||
{
|
||||
|
||||
HANDLE hFile;
|
||||
DWORD dwDesiredAccess = 0;
|
||||
DWORD dwShareMode = 0;
|
||||
DWORD dwCreationDistribution = 0;
|
||||
DWORD dwFlagsAndAttributes = 0;
|
||||
HANDLE hFile;
|
||||
DWORD dwDesiredAccess = 0;
|
||||
DWORD dwShareMode = 0;
|
||||
DWORD dwCreationDistribution = 0;
|
||||
DWORD dwFlagsAndAttributes = 0;
|
||||
|
||||
if (( _oflag & S_IREAD ) == S_IREAD)
|
||||
dwShareMode = FILE_SHARE_READ;
|
||||
else if ( ( _oflag & S_IWRITE) == S_IWRITE ) {
|
||||
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||
}
|
||||
if (( _oflag & S_IREAD ) == S_IREAD)
|
||||
dwShareMode = FILE_SHARE_READ;
|
||||
else if ( ( _oflag & S_IWRITE) == S_IWRITE ) {
|
||||
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
*
|
||||
* _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
|
||||
* _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
|
||||
*
|
||||
*/
|
||||
if (( _oflag & _O_RDWR ) == _O_RDWR )
|
||||
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA |
|
||||
FILE_WRITE_DATA | FILE_READ_ATTRIBUTES |
|
||||
FILE_WRITE_ATTRIBUTES;
|
||||
else if (( _oflag & O_RDONLY ) == O_RDONLY )
|
||||
dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES
|
||||
| FILE_WRITE_ATTRIBUTES;
|
||||
else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
|
||||
dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA |
|
||||
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES;
|
||||
|
||||
_O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.)
|
||||
_O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.)
|
||||
if (( _oflag & S_IREAD ) == S_IREAD )
|
||||
dwShareMode |= FILE_SHARE_READ;
|
||||
|
||||
if (( _oflag & S_IWRITE ) == S_IWRITE )
|
||||
dwShareMode |= FILE_SHARE_WRITE;
|
||||
|
||||
*/
|
||||
if (( _oflag & _O_RDWR ) == _O_RDWR )
|
||||
dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ;
|
||||
else if (( _oflag & O_RDONLY ) == O_RDONLY )
|
||||
dwDesiredAccess |= GENERIC_READ;
|
||||
else if (( _oflag & _O_WRONLY ) == _O_WRONLY )
|
||||
dwDesiredAccess |= GENERIC_WRITE;
|
||||
|
||||
if (( _oflag & S_IREAD ) == S_IREAD )
|
||||
dwShareMode |= FILE_SHARE_READ;
|
||||
|
||||
if (( _oflag & S_IWRITE ) == S_IWRITE )
|
||||
dwShareMode |= FILE_SHARE_WRITE;
|
||||
if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
|
||||
dwCreationDistribution |= CREATE_NEW;
|
||||
|
||||
if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) )
|
||||
dwCreationDistribution |= CREATE_NEW;
|
||||
|
||||
else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
|
||||
if (( _oflag & O_CREAT ) == O_CREAT )
|
||||
dwCreationDistribution |= CREATE_ALWAYS;
|
||||
else if (( _oflag & O_RDONLY ) != O_RDONLY )
|
||||
dwCreationDistribution |= TRUNCATE_EXISTING;
|
||||
}
|
||||
else if (( _oflag & _O_APPEND ) == _O_APPEND )
|
||||
dwCreationDistribution |= OPEN_EXISTING;
|
||||
else if (( _oflag & _O_CREAT ) == _O_CREAT )
|
||||
dwCreationDistribution |= OPEN_ALWAYS;
|
||||
else
|
||||
dwCreationDistribution |= OPEN_EXISTING;
|
||||
|
||||
|
||||
|
||||
if (( _oflag & _O_RANDOM ) == _O_RANDOM )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
|
||||
if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
|
||||
|
||||
if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
|
||||
|
||||
if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
|
||||
|
||||
hFile = CreateFileA(
|
||||
_path,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
NULL,
|
||||
dwCreationDistribution,
|
||||
dwFlagsAndAttributes,
|
||||
NULL
|
||||
);
|
||||
if ( hFile == (HANDLE)-1 )
|
||||
return -1;
|
||||
return __fileno_alloc(hFile,_oflag);
|
||||
else if (( _oflag & O_TRUNC ) == O_TRUNC ) {
|
||||
if (( _oflag & O_CREAT ) == O_CREAT )
|
||||
dwCreationDistribution |= CREATE_ALWAYS;
|
||||
else if (( _oflag & O_RDONLY ) != O_RDONLY )
|
||||
dwCreationDistribution |= TRUNCATE_EXISTING;
|
||||
}
|
||||
else if (( _oflag & _O_APPEND ) == _O_APPEND )
|
||||
dwCreationDistribution |= OPEN_EXISTING;
|
||||
else if (( _oflag & _O_CREAT ) == _O_CREAT )
|
||||
dwCreationDistribution |= OPEN_ALWAYS;
|
||||
else
|
||||
dwCreationDistribution |= OPEN_EXISTING;
|
||||
|
||||
if (( _oflag & _O_RANDOM ) == _O_RANDOM )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
|
||||
if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
|
||||
|
||||
if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
|
||||
|
||||
if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED )
|
||||
dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
|
||||
|
||||
hFile = CreateFileA(_path,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
NULL,
|
||||
dwCreationDistribution,
|
||||
dwFlagsAndAttributes,
|
||||
NULL);
|
||||
if (hFile == (HANDLE)-1)
|
||||
return -1;
|
||||
return __fileno_alloc(hFile,_oflag);
|
||||
|
||||
// _O_APPEND Moves file pointer to end of file before every write operation.
|
||||
|
||||
|
@ -252,4 +252,4 @@ int _open_osfhandle (void *osfhandle, int flags )
|
|||
void *_get_osfhandle( int fileno )
|
||||
{
|
||||
return filehnd(fileno);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,15 @@
|
|||
|
||||
size_t _read(int _fd, void *_buf, size_t _nbyte)
|
||||
{
|
||||
size_t _rbyte;
|
||||
if ( !ReadFile(_get_osfhandle(_fd),_buf,_nbyte,&_rbyte,NULL) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _rbyte;
|
||||
size_t _rbyte;
|
||||
|
||||
printf("_read(fd %d, buf %x, _nbyte %d)\n",_fd,_buf,_nbyte);
|
||||
|
||||
if (!ReadFile(_get_osfhandle(_fd),_buf,_nbyte,&_rbyte,NULL))
|
||||
{
|
||||
printf("_read() = %d\n",-1);
|
||||
return -1;
|
||||
}
|
||||
printf("_read() = %d\n",_rbyte);
|
||||
return _rbyte;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
|
||||
|
||||
|
||||
size_t _write(int _fd, const void *_buf, size_t _nbyte)
|
||||
size_t _write(int _fd, const void *_buf, size_t _nbyte)
|
||||
{
|
||||
size_t _wbyte;
|
||||
if ( !WriteFile(_get_osfhandle(_fd),_buf,_nbyte,&_wbyte,NULL) ) {
|
||||
return -1;
|
||||
}
|
||||
return _wbyte;
|
||||
size_t _wbyte;
|
||||
|
||||
if ( !WriteFile(_get_osfhandle(_fd),_buf,_nbyte,&_wbyte,NULL) ) {
|
||||
return -1;
|
||||
}
|
||||
return _wbyte;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ STRING_OBJECTS = string/memchr.o string/memcmp.o string/strcat.o \
|
|||
string/strxfrm.o string/memmove.o string/memset.o \
|
||||
string/strdup.o string/strlwr.o string/strupr.o \
|
||||
string/str_old.o string/strerror.o string/stricmp.o\
|
||||
string/strnlen.o
|
||||
string/strnlen.o string/strnicmp.o
|
||||
|
||||
WCHAR_OBJECTS = wchar/wcscat.o wchar/wcschr.o wchar/wcscmp.o \
|
||||
wchar/wcscoll.o wchar/wcscpy.o wchar/wcscspn.o \
|
||||
|
@ -58,8 +58,9 @@ STDIO_OBJECTS = stdio/getenv.o stdio/doprnt.o stdio/doscan.o stdio/filbuf.o \
|
|||
stdio/scanf.o stdio/setbuf.o stdio/setbuffe.o stdlib/obsol.o\
|
||||
stdio/setlineb.o stdio/setvbuf.o stdio/sprintf.o stdio/sscanf.o \
|
||||
stdio/stdiohk.o stdio/stdhnd.o stdio/tempnam.o stdio/tmpfile.o stdio/tmpnam.o \
|
||||
stdio/ungetc.o stdio/vfprintf.o stdio/vprintf.o stdio/vsprintf.o
|
||||
|
||||
stdio/ungetc.o stdio/vfprintf.o stdio/vprintf.o \
|
||||
stdio/fdopen.o stdio/vsprintf.o stdio/frlist.o \
|
||||
|
||||
|
||||
IO_OBJECTS = io/access.o io/close.o io/create.o io/dup.o io/dup2.o io/find.o io/isatty.o io/lseek.o \
|
||||
io/open.o io/read.o io/setmode.o io/unlink.o io/write.o io/fmode.o io/mktemp.o\
|
||||
|
@ -80,7 +81,7 @@ SIGNAL_OBJECTS = signal/signal.o
|
|||
PROCESS_OBJECTS = process/_cwait.o process/dll.o process/spawnl.o process/spawnlp.o process/spawnlpe.o process/spawnvpe.o process/spawnvp.o \
|
||||
process/spawnv.o process/spawnve.o process/spawnle.o process/execl.o process/execlp.o process/execlpe.o \
|
||||
process/execvpe.o process/execvp.o process/execv.o process/execle.o process/_system.o\
|
||||
process/threadid.o process/thread.o
|
||||
process/threadid.o
|
||||
|
||||
TCHAR_OBJECTS = tchar/strdec.o tchar/strinc.o tchar/strninc.o tchar/strncnt.o tchar/strnextc.o tchar/strspnp.o
|
||||
|
||||
|
@ -89,7 +90,8 @@ TIME_OBJECTS = time/ctime.o time/difftime.o time/strftime.o time/time.o time/clo
|
|||
FLOAT_OBJECTS = float/fpreset.o float/clearfp.o float/cntrlfp.o float/statfp.o float/logb.o\
|
||||
float/chgsign.o
|
||||
|
||||
SYS_STAT_OBJECTS = sys_stat/fstat.o sys_stat/stat.o sys_stat/futime.o
|
||||
#SYS_STAT_OBJECTS = sys_stat/fstat.o sys_stat/stat.o sys_stat/futime.o
|
||||
SYS_STAT_OBJECTS = sys_stat/fstat.o sys_stat/stat.o
|
||||
|
||||
|
||||
MATH_OBJECTS = math/acos.o math/acosh.o math/asin.o math/asinh.o math/atan.o math/atan2.o\
|
||||
|
@ -107,10 +109,20 @@ MATH_OBJECTS = math/acos.o math/acosh.o math/asin.o math/asinh.o math/atan.o mat
|
|||
# $(SEARCH_OBJECTS)
|
||||
|
||||
|
||||
OBJECTS = $(MISC_OBJECTS) string/strdup.o stdlib/malloc.o stdlib/abort.o \
|
||||
OLD_OBJECTS = $(MISC_OBJECTS) stdlib/malloc.o stdlib/abort.o \
|
||||
stdlib/_exit.o stdlib/atexit.o stdio/fileno.o io/fmode.o \
|
||||
float/fpreset.o stdio/stdhnd.o io/setmode.o io/open.o \
|
||||
stdio/vsprintf.o
|
||||
stdio/vsprintf.o $(CTYPE_OBJECTS) stdlib/atoi.o stdlib/strtol.o \
|
||||
stdio/flsbuf.o stdio/putc.o stdio/doprnt.o $(STRING_OBJECTS)\
|
||||
io/write.o io/isatty.o sys_stat/fstat.o misc/dllmain.o \
|
||||
stdlib/errno.o
|
||||
|
||||
OBJECTS = $(MISC_OBJECTS) $(STDLIB_OBJECTS) $(IO_OBJECTS) \
|
||||
$(FLOAT_OBJECTS) $(ASSERT_OBJECTS) $(PROCESS_OBJECTS) \
|
||||
$(STDIO_OBJECTS) $(CTYPE_OBJECTS) $(MATH_OBJECTS) \
|
||||
$(STRING_OBJECTS) $(TIME_OBJECTS) $(WCHAR_OBJECTS) \
|
||||
$(SYS_STAT_OBJECTS) misc/dllmain.o $(MALLOC_OBJECTS) \
|
||||
$(SEARCH_OBJECTS) $(CONIO_OBJECTS) $(DIRECT_OBJECTS)
|
||||
|
||||
|
||||
crtdll.a: $(OBJECTS)
|
||||
|
|
|
@ -17,13 +17,28 @@
|
|||
* DISCLAMED. This includes but is not limited to warrenties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Author: rex $
|
||||
* $Date: 1999/01/16 02:11:43 $
|
||||
* $Revision: 1.2 $
|
||||
* $Author: dwelch $
|
||||
* $Date: 1999/04/14 00:51:19 $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
HANDLE OutputHandle;
|
||||
|
||||
AllocConsole();
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
|
|
|
@ -10,22 +10,13 @@ FILE * __alloc_file(void);
|
|||
|
||||
/* A FILE* is considered "free" if its flag is zero. */
|
||||
|
||||
#define __FILE_REC_MAX 20
|
||||
typedef struct __file_rec {
|
||||
struct __file_rec *next;
|
||||
int count;
|
||||
FILE *files[__FILE_REC_MAX];
|
||||
} __file_rec;
|
||||
|
||||
extern __file_rec *__file_rec_list;
|
||||
|
||||
FILE *__alloc_file(void)
|
||||
{
|
||||
__file_rec *fr = __file_rec_list;
|
||||
__file_rec **last_fr = &__file_rec_list;
|
||||
FILE *rv=0;
|
||||
int i;
|
||||
|
||||
|
||||
/* Try to find an empty slot */
|
||||
while (fr)
|
||||
{
|
||||
|
@ -33,8 +24,12 @@ FILE *__alloc_file(void)
|
|||
|
||||
/* If one of the existing slots is available, return it */
|
||||
for (i=0; i<fr->count; i++)
|
||||
if (fr->files[i]->_flag == 0)
|
||||
return fr->files[i];
|
||||
{
|
||||
if (fr->files[i]->_flag == 0)
|
||||
{
|
||||
return fr->files[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* If this one is full, go to the next */
|
||||
if (fr->count == __FILE_REC_MAX)
|
||||
|
@ -64,30 +59,30 @@ FILE *__alloc_file(void)
|
|||
|
||||
int _fcloseall( void )
|
||||
{
|
||||
__file_rec *fr = __file_rec_list;
|
||||
__file_rec **last_fr = &__file_rec_list;
|
||||
__file_rec *fr = __file_rec_list;
|
||||
__file_rec **last_fr = &__file_rec_list;
|
||||
|
||||
int total_closed = 0;
|
||||
int i = 0;
|
||||
int total_closed = 0;
|
||||
int i = 0;
|
||||
|
||||
/* Try to find an empty slot */
|
||||
while (fr)
|
||||
{
|
||||
last_fr = &(fr->next);
|
||||
|
||||
/* If one of the existing slots is available, return it */
|
||||
for (i=0; i<fr->count; i++)
|
||||
if (fr->files[i]->_flag != 0) {
|
||||
fclose(fr->files[i]);
|
||||
total_closed++;
|
||||
/* Try to find an empty slot */
|
||||
while (fr)
|
||||
{
|
||||
last_fr = &(fr->next);
|
||||
|
||||
/* If one of the existing slots is available, return it */
|
||||
for (i=0; i<fr->count; i++)
|
||||
if (fr->files[i]->_flag != 0) {
|
||||
fclose(fr->files[i]);
|
||||
total_closed++;
|
||||
}
|
||||
|
||||
/* If this one is full, go to the next */
|
||||
if (fr->count == __FILE_REC_MAX)
|
||||
fr = fr->next;
|
||||
else
|
||||
/* it isn't full, we can add to it */
|
||||
break;
|
||||
}
|
||||
return total_closed;
|
||||
|
||||
/* If this one is full, go to the next */
|
||||
if (fr->count == __FILE_REC_MAX)
|
||||
fr = fr->next;
|
||||
else
|
||||
/* it isn't full, we can add to it */
|
||||
break;
|
||||
}
|
||||
return total_closed;
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ FILE *_fdopen(int handle, char *mode)
|
|||
return stdprn;
|
||||
|
||||
file = __alloc_file();
|
||||
if (f == NULL)
|
||||
if (file == NULL)
|
||||
return NULL;
|
||||
file->_file = handle;
|
||||
|
||||
rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+'));
|
||||
|
||||
if (*mode == 'a')
|
||||
lseek(fd, 0, SEEK_END);
|
||||
_lseek(handle, 0, SEEK_END);
|
||||
|
||||
file->_cnt = 0;
|
||||
file->_file = handle;
|
||||
|
@ -40,7 +40,7 @@ FILE *_fdopen(int handle, char *mode)
|
|||
else
|
||||
file->_flag = _IOWRT;
|
||||
|
||||
file->_base = f->_ptr = NULL;
|
||||
file->_base = file->_ptr = NULL;
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
#include <crtdll/io.h>
|
||||
|
||||
|
||||
int
|
||||
fflush(FILE *f)
|
||||
int fflush(FILE *f)
|
||||
{
|
||||
char *base;
|
||||
int n, rn;
|
||||
|
|
|
@ -10,13 +10,12 @@
|
|||
FILE * __alloc_file(void);
|
||||
|
||||
|
||||
FILE *
|
||||
fopen(const char *file, const char *mode)
|
||||
FILE* fopen(const char *file, const char *mode)
|
||||
{
|
||||
FILE *f;
|
||||
int fd, rw, oflags = 0;
|
||||
char tbchar;
|
||||
|
||||
|
||||
if (file == 0)
|
||||
return 0;
|
||||
if (mode == 0)
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <crtdll/stdio.h>
|
||||
//#include <crtdll/local.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
extern FILE _crtdll_iob[5];
|
||||
|
||||
static __file_rec __initial_file_rec = {
|
||||
0,
|
||||
5,
|
||||
{ stdin, stdout, stderr, stdprn, stdaux }
|
||||
{ &_crtdll_iob[0], &_crtdll_iob[1], &_crtdll_iob[2],
|
||||
&_crtdll_iob[3], &_crtdll_iob[4] }
|
||||
};
|
||||
|
||||
__file_rec *__file_rec_list = &__initial_file_rec;
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
#include <crtdll/internal/file.h>
|
||||
|
||||
|
||||
int
|
||||
printf(const char *fmt, ...)
|
||||
int printf(const char *fmt, ...)
|
||||
{
|
||||
int len;
|
||||
va_list a = 0;
|
||||
va_list a;
|
||||
|
||||
va_start( a, fmt );
|
||||
len = _doprnt(fmt, a, stdout);
|
||||
|
||||
|
|
|
@ -3,17 +3,18 @@
|
|||
#include <windows.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
#include <crtdll/crtdll.h>
|
||||
|
||||
int putc(int c, FILE *fp)
|
||||
{
|
||||
|
||||
if (fp->_cnt > 0 ) {
|
||||
fp->_cnt--;
|
||||
*(fp)->_ptr++ = (char)c;
|
||||
return (int)c;
|
||||
}
|
||||
else
|
||||
return _flsbuf(c,fp);
|
||||
|
||||
return -1;
|
||||
|
||||
{
|
||||
if (fp->_cnt > 0 )
|
||||
{
|
||||
fp->_cnt--;
|
||||
*(fp)->_ptr++ = (char)c;
|
||||
return (int)c;
|
||||
}
|
||||
else
|
||||
return _flsbuf(c,fp);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#undef putc
|
||||
#undef putchar
|
||||
int
|
||||
putchar(int c)
|
||||
|
||||
int putchar(int c)
|
||||
{
|
||||
int r = putc(c, stdout);
|
||||
if (stdout->_flag & _IOLBF)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
|
||||
FILE _crtdll_iob[] =
|
||||
FILE _crtdll_iob[5] =
|
||||
{
|
||||
// stdin
|
||||
{
|
||||
|
|
|
@ -4,14 +4,6 @@
|
|||
#include <limits.h>
|
||||
#include <crtdll/internal/file.h>
|
||||
|
||||
#if 1
|
||||
int
|
||||
vsprintf(char *str, const char *fmt, va_list ap)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
#else
|
||||
int
|
||||
vsprintf(char *str, const char *fmt, va_list ap)
|
||||
{
|
||||
FILE f;
|
||||
|
@ -24,4 +16,3 @@ vsprintf(char *str, const char *fmt, va_list ap)
|
|||
*f._ptr = 0;
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
struct __atexit *__atexit_ptr = 0;
|
||||
|
||||
#if 0
|
||||
void exit(int status)
|
||||
{
|
||||
//int i;
|
||||
|
@ -28,7 +27,6 @@ void exit(int status)
|
|||
_exit(status);
|
||||
for(;;);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void _exit(int _status)
|
||||
|
|
|
@ -6,6 +6,6 @@ static char msg[] = "Abort!\r\n";
|
|||
|
||||
void abort()
|
||||
{
|
||||
// _write(stderr->_file, msg, sizeof(msg)-1);
|
||||
// _exit(1);
|
||||
_write(stderr->_file, msg, sizeof(msg)-1);
|
||||
_exit(1);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ _fstat(int fd, struct stat *statbuf)
|
|||
|
||||
if ( !GetFileInformationByHandle(_get_osfhandle(fd),&FileInformation) )
|
||||
return -1;
|
||||
statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
|
||||
statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
|
||||
statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL);
|
||||
// statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
|
||||
// statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
|
||||
// statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL);
|
||||
|
||||
statbuf->st_dev = fd;
|
||||
statbuf->st_size = FileInformation.nFileSizeLow;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NDEBUG
|
||||
//#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* EXTERNS ******************************************************************/
|
||||
|
@ -175,7 +175,7 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return NULL;
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
return(FileHandle);
|
||||
}
|
||||
|
|
89
reactos/lib/kernel32/file/delete.c
Normal file
89
reactos/lib/kernel32/file/delete.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/file/file.c
|
||||
* PURPOSE: Directory functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* GetTempFileName is modified from WINE [ Alexandre Juiliard ]
|
||||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* FIXME: the large integer manipulations in this file dont handle overflow */
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
WINBOOL STDCALL DeleteFileA(LPCSTR lpFileName)
|
||||
{
|
||||
ULONG i;
|
||||
WCHAR FileNameW[MAX_PATH];
|
||||
|
||||
i = 0;
|
||||
while ((*lpFileName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
FileNameW[i] = *lpFileName;
|
||||
lpFileName++;
|
||||
i++;
|
||||
}
|
||||
FileNameW[i] = 0;
|
||||
return DeleteFileW(FileNameW);
|
||||
}
|
||||
|
||||
WINBOOL STDCALL DeleteFileW(LPCWSTR lpFileName)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING FileNameString;
|
||||
NTSTATUS errCode;
|
||||
WCHAR PathNameW[MAX_PATH];
|
||||
UINT Len;
|
||||
|
||||
if (lpFileName[1] != ':')
|
||||
{
|
||||
Len = GetCurrentDirectoryW(MAX_PATH,PathNameW);
|
||||
if ( Len == 0 )
|
||||
return FALSE;
|
||||
if ( PathNameW[Len-1] != L'\\' )
|
||||
{
|
||||
PathNameW[Len] = L'\\';
|
||||
PathNameW[Len+1] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
PathNameW[0] = 0;
|
||||
lstrcatW(PathNameW,lpFileName);
|
||||
FileNameString.Length = lstrlenW( PathNameW)*sizeof(WCHAR);
|
||||
if ( FileNameString.Length == 0 )
|
||||
return FALSE;
|
||||
|
||||
if (FileNameString.Length > MAX_PATH*sizeof(WCHAR))
|
||||
return FALSE;
|
||||
|
||||
FileNameString.Buffer = (WCHAR *)PathNameW;
|
||||
FileNameString.MaximumLength = FileNameString.Length+sizeof(WCHAR);
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = &FileNameString;
|
||||
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE| OBJ_INHERIT;
|
||||
ObjectAttributes.SecurityDescriptor = NULL;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
errCode = NtDeleteFile(&ObjectAttributes);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
172
reactos/lib/kernel32/file/lock.c
Normal file
172
reactos/lib/kernel32/file/lock.c
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/file/file.c
|
||||
* PURPOSE: Directory functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* GetTempFileName is modified from WINE [ Alexandre Juiliard ]
|
||||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* FIXME: the large integer manipulations in this file dont handle overflow */
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
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;
|
||||
|
||||
SET_LARGE_INTEGER_LOW_PART(Offset, lpOverlapped->Offset);
|
||||
SET_LARGE_INTEGER_HIGH_PART(Offset, 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;
|
||||
|
||||
SET_LARGE_INTEGER_LOW_PART(BytesToLock, nNumberOfBytesToLockLow);
|
||||
SET_LARGE_INTEGER_HIGH_PART(BytesToLock, nNumberOfBytesToLockHigh);
|
||||
|
||||
errCode = NtLockFile(hFile,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(PIO_STATUS_BLOCK)lpOverlapped,
|
||||
&Offset,
|
||||
&BytesToLock,
|
||||
NULL,
|
||||
LockImmediate,
|
||||
LockExclusive);
|
||||
if ( !NT_SUCCESS(errCode) )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
SET_LARGE_INTEGER_LOW_PART(BytesToUnLock, nNumberOfBytesToUnLockLow);
|
||||
SET_LARGE_INTEGER_HIGH_PART(BytesToUnLock, nNumberOfBytesToUnLockHigh);
|
||||
|
||||
SET_LARGE_INTEGER_LOW_PART(StartAddress, lpOverlapped->Offset);
|
||||
SET_LARGE_INTEGER_HIGH_PART(StartAddress, lpOverlapped->OffsetHigh);
|
||||
|
||||
errCode = NtUnlockFile(hFile,
|
||||
(PIO_STATUS_BLOCK)lpOverlapped,
|
||||
&StartAddress,
|
||||
&BytesToUnLock,
|
||||
NULL);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
129
reactos/lib/kernel32/file/move.c
Normal file
129
reactos/lib/kernel32/file/move.c
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/file/file.c
|
||||
* PURPOSE: Directory functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* GetTempFileName is modified from WINE [ Alexandre Juiliard ]
|
||||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* FIXME: the large integer manipulations in this file dont handle overflow */
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
MoveFileA(
|
||||
LPCSTR lpExistingFileName,
|
||||
LPCSTR lpNewFileName
|
||||
)
|
||||
{
|
||||
return MoveFileExA(lpExistingFileName,lpNewFileName,MOVEFILE_COPY_ALLOWED);
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
MoveFileExA(
|
||||
LPCSTR lpExistingFileName,
|
||||
LPCSTR lpNewFileName,
|
||||
DWORD dwFlags
|
||||
)
|
||||
{
|
||||
ULONG i;
|
||||
WCHAR ExistingFileNameW[MAX_PATH];
|
||||
WCHAR NewFileNameW[MAX_PATH];
|
||||
|
||||
|
||||
|
||||
i = 0;
|
||||
while ((*lpExistingFileName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
ExistingFileNameW[i] = *lpExistingFileName;
|
||||
lpExistingFileName++;
|
||||
i++;
|
||||
}
|
||||
ExistingFileNameW[i] = 0;
|
||||
|
||||
i = 0;
|
||||
while ((*lpNewFileName)!=0 && i < MAX_PATH)
|
||||
{
|
||||
NewFileNameW[i] = *lpNewFileName;
|
||||
lpNewFileName++;
|
||||
i++;
|
||||
}
|
||||
NewFileNameW[i] = 0;
|
||||
|
||||
return MoveFileExW(ExistingFileNameW,NewFileNameW,dwFlags);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
MoveFileW(
|
||||
LPCWSTR lpExistingFileName,
|
||||
LPCWSTR lpNewFileName
|
||||
)
|
||||
{
|
||||
return MoveFileExW(lpExistingFileName,lpNewFileName,MOVEFILE_COPY_ALLOWED);
|
||||
}
|
||||
|
||||
#define FILE_RENAME_SIZE MAX_PATH +sizeof(FILE_RENAME_INFORMATION)
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
MoveFileExW(
|
||||
LPCWSTR lpExistingFileName,
|
||||
LPCWSTR lpNewFileName,
|
||||
DWORD dwFlags
|
||||
)
|
||||
{
|
||||
HANDLE hFile = NULL;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
FILE_RENAME_INFORMATION *FileRename;
|
||||
USHORT Buffer[FILE_RENAME_SIZE];
|
||||
NTSTATUS errCode;
|
||||
|
||||
hFile = CreateFileW(
|
||||
lpExistingFileName,
|
||||
GENERIC_ALL,
|
||||
FILE_SHARE_WRITE|FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
|
||||
FileRename = (FILE_RENAME_INFORMATION *)Buffer;
|
||||
if ( ( dwFlags & MOVEFILE_REPLACE_EXISTING ) == MOVEFILE_REPLACE_EXISTING )
|
||||
FileRename->Replace = TRUE;
|
||||
else
|
||||
FileRename->Replace = FALSE;
|
||||
|
||||
FileRename->FileNameLength = lstrlenW(lpNewFileName);
|
||||
memcpy(FileRename->FileName,lpNewFileName,min(FileRename->FileNameLength,MAX_PATH));
|
||||
|
||||
errCode = NtSetInformationFile(hFile,&IoStatusBlock,FileRename, FILE_RENAME_SIZE, FileRenameInformation);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
if ( CopyFileW(lpExistingFileName,lpNewFileName,FileRename->Replace) )
|
||||
DeleteFileW(lpExistingFileName);
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
return TRUE;
|
||||
}
|
28
reactos/lib/kernel32/file/pipe.c
Normal file
28
reactos/lib/kernel32/file/pipe.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/file/create.c
|
||||
* PURPOSE: Directory functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
||||
PHANDLE hWritePipe,
|
||||
LPSECURITY_ATTRIBUTES lpPipeAttributes,
|
||||
DWORD nSize)
|
||||
{
|
||||
DPRINT("CreatePipe is unimplemented\n");
|
||||
return(FALSE);
|
||||
}
|
153
reactos/lib/kernel32/file/rw.c
Normal file
153
reactos/lib/kernel32/file/rw.c
Normal file
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/file/rw.c
|
||||
* PURPOSE: Read/write functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
WINBOOL STDCALL WriteFile(HANDLE hFile,
|
||||
LPCVOID lpBuffer,
|
||||
DWORD nNumberOfBytesToWrite,
|
||||
LPDWORD lpNumberOfBytesWritten,
|
||||
LPOVERLAPPED lpOverLapped)
|
||||
{
|
||||
|
||||
LARGE_INTEGER Offset;
|
||||
HANDLE hEvent = NULL;
|
||||
NTSTATUS errCode;
|
||||
PIO_STATUS_BLOCK IoStatusBlock;
|
||||
IO_STATUS_BLOCK IIosb;
|
||||
|
||||
DPRINT("WriteFile(hFile %x)\n",hFile);
|
||||
|
||||
if (lpOverLapped != NULL )
|
||||
{
|
||||
SET_LARGE_INTEGER_LOW_PART(Offset, lpOverLapped->Offset);
|
||||
SET_LARGE_INTEGER_HIGH_PART(Offset, lpOverLapped->OffsetHigh);
|
||||
lpOverLapped->Internal = STATUS_PENDING;
|
||||
hEvent= lpOverLapped->hEvent;
|
||||
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
|
||||
}
|
||||
else
|
||||
{
|
||||
IoStatusBlock = &IIosb;
|
||||
Offset = NULL;
|
||||
}
|
||||
errCode = NtWriteFile(hFile,
|
||||
hEvent,
|
||||
NULL,
|
||||
NULL,
|
||||
IoStatusBlock,
|
||||
(PVOID)lpBuffer,
|
||||
nNumberOfBytesToWrite,
|
||||
&Offset,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
DPRINT("WriteFile() failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (lpNumberOfBytesWritten != NULL )
|
||||
{
|
||||
*lpNumberOfBytesWritten = IoStatusBlock->Information;
|
||||
}
|
||||
DPRINT("WriteFile() succeeded\n");
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
WINBOOL STDCALL KERNEL32_ReadFile(HANDLE hFile,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nNumberOfBytesToRead,
|
||||
LPDWORD lpNumberOfBytesRead,
|
||||
LPOVERLAPPED lpOverLapped,
|
||||
LPOVERLAPPED_COMPLETION_ROUTINE
|
||||
lpCompletionRoutine)
|
||||
{
|
||||
HANDLE hEvent = NULL;
|
||||
LARGE_INTEGER Offset;
|
||||
NTSTATUS errCode;
|
||||
IO_STATUS_BLOCK IIosb;
|
||||
PIO_STATUS_BLOCK IoStatusBlock;
|
||||
PLARGE_INTEGER ptrOffset;
|
||||
|
||||
if (lpOverLapped != NULL)
|
||||
{
|
||||
SET_LARGE_INTEGER_LOW_PART(Offset, lpOverLapped->Offset);
|
||||
SET_LARGE_INTEGER_HIGH_PART(Offset, lpOverLapped->OffsetHigh);
|
||||
lpOverLapped->Internal = STATUS_PENDING;
|
||||
hEvent = lpOverLapped->hEvent;
|
||||
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
|
||||
ptrOffset = &Offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrOffset = NULL;
|
||||
IoStatusBlock = &IIosb;
|
||||
}
|
||||
|
||||
errCode = NtReadFile(hFile,
|
||||
hEvent,
|
||||
(PIO_APC_ROUTINE)lpCompletionRoutine,
|
||||
NULL,
|
||||
IoStatusBlock,
|
||||
lpBuffer,
|
||||
nNumberOfBytesToRead,
|
||||
ptrOffset,
|
||||
NULL);
|
||||
|
||||
if (errCode != STATUS_PENDING && lpNumberOfBytesRead != NULL)
|
||||
{
|
||||
*lpNumberOfBytesRead = IoStatusBlock->Information;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
WINBOOL STDCALL ReadFile(HANDLE hFile,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nNumberOfBytesToRead,
|
||||
LPDWORD lpNumberOfBytesRead,
|
||||
LPOVERLAPPED lpOverLapped)
|
||||
{
|
||||
return(KERNEL32_ReadFile(hFile,
|
||||
lpBuffer,
|
||||
nNumberOfBytesToRead,
|
||||
lpNumberOfBytesRead,
|
||||
lpOverLapped,
|
||||
NULL));
|
||||
}
|
||||
|
||||
WINBOOL STDCALL ReadFileEx(HANDLE hFile,
|
||||
LPVOID lpBuffer,
|
||||
DWORD nNumberOfBytesToRead,
|
||||
LPOVERLAPPED lpOverLapped,
|
||||
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
||||
{
|
||||
return(KERNEL32_ReadFile(hFile,
|
||||
lpBuffer,
|
||||
nNumberOfBytesToRead,
|
||||
NULL,
|
||||
lpOverLapped,
|
||||
lpCompletionRoutine));
|
||||
}
|
|
@ -35,12 +35,14 @@ EXPORTS
|
|||
;AddConsoleAliasA@12
|
||||
;AddConsoleAliasW@12
|
||||
AllocConsole@0
|
||||
AllocConsole = AllocConsole@0
|
||||
;AreFileApisANSI@0
|
||||
;BackupRead@28
|
||||
;BackupSeek@24
|
||||
;BackupWrite@28
|
||||
;BaseAttachCompleteThunk@0
|
||||
;Beep@8
|
||||
Beep@8
|
||||
Beep = Beep@8
|
||||
;BeginUpdateResourceA@8
|
||||
;BeginUpdateResourceW@8
|
||||
;BuildCommDCBA@8
|
||||
|
@ -53,6 +55,7 @@ AllocConsole@0
|
|||
;ClearCommError@12
|
||||
;CloseConsoleHandle@4
|
||||
CloseHandle@4
|
||||
CloseHandle = CloseHandle@4
|
||||
;CloseProfileUserMapping@0
|
||||
;CmdBatNotification@4
|
||||
;CommConfigDialogA@12
|
||||
|
@ -65,18 +68,28 @@ CloseHandle@4
|
|||
;ContinueDebugEvent@12
|
||||
;ConvertDefaultLocale@4
|
||||
;CopyFileA@12
|
||||
;CopyFileW@12
|
||||
CopyFileA = CopyFileA@12
|
||||
CopyFileW@12
|
||||
CopyFileW = CopyFileW@12
|
||||
;CreateConsoleScreenBuffer@20
|
||||
CreateDirectoryA@8
|
||||
CreateDirectoryA = CreateDirectoryA@8
|
||||
CreateDirectoryExA@12
|
||||
CreateDirectoryExA = CreateDirectoryExA@12
|
||||
CreateDirectoryExW@12
|
||||
CreateDirectoryExW = CreateDirectoryExW@12
|
||||
CreateDirectoryW@8
|
||||
CreateDirectoryW = CreateDirectoryW@8
|
||||
CreateEventA@16
|
||||
CreateEventA = CreateEventA@16
|
||||
CreateEventW@16
|
||||
CreateEventW = CreateEventW@16
|
||||
CreateFileA@28
|
||||
CreateFileA = CreateFileA@28
|
||||
;CreateFileMappingA@24
|
||||
;CreateFileMappingW@24
|
||||
CreateFileW@28
|
||||
CreateFileW = CreateFileW@28
|
||||
;CreateIoCompletionPort@16
|
||||
;CreateMailslotA@16
|
||||
;CreateMailslotW@16
|
||||
|
@ -84,14 +97,19 @@ CreateFileW@28
|
|||
;CreateMutexW@12
|
||||
;CreateNamedPipeA@32
|
||||
;CreateNamedPipeW@32
|
||||
;CreatePipe@16
|
||||
CreatePipe@16
|
||||
CreatePipe = CreatePipe@16
|
||||
CreateProcessA@40
|
||||
CreateProcessA = CreateProcessA@40
|
||||
CreateProcessW@40
|
||||
CreateProcessW = CreateProcessW@40
|
||||
CreateRemoteThread@28
|
||||
CreateRemoteThread = CreateRemoteThread@28
|
||||
;CreateSemaphoreA@16
|
||||
;CreateSemaphoreW@16
|
||||
;CreateTapePartition@16
|
||||
CreateThread@24
|
||||
CreateThread = CreateThread@24
|
||||
;CreateVirtualBuffer@12
|
||||
;DebugActiveProcess@4
|
||||
;DebugBreak@0
|
||||
|
@ -99,8 +117,11 @@ CreateThread@24
|
|||
;DefineDosDeviceW@12
|
||||
;DeleteAtom@4
|
||||
DeleteCriticalSection@4
|
||||
;DeleteFileA@4
|
||||
;DeleteFileW@4
|
||||
DeleteCriticalSection = DeleteCriticalSection@4
|
||||
DeleteFileA@4
|
||||
DeleteFileA = DeleteFileA@4
|
||||
DeleteFileW@4
|
||||
DeleteFileW = DeleteFileW@4
|
||||
;DeviceIoControl@32
|
||||
;DisableThreadLibraryCalls@4
|
||||
;DisconnectNamedPipe@4
|
||||
|
@ -129,6 +150,7 @@ DeleteCriticalSection@4
|
|||
;EraseTape@12
|
||||
;EscapeCommFunction@8
|
||||
ExitProcess@4
|
||||
ExitProcess = ExitProcess@4
|
||||
;ExitThread@4
|
||||
;ExitVDM@8
|
||||
;ExpandEnvironmentStringsA@12
|
||||
|
@ -148,20 +170,26 @@ ExitProcess@4
|
|||
;FindAtomA@4
|
||||
;FindAtomW@4
|
||||
FindClose@4
|
||||
FindClose = FindClose@4
|
||||
;FindCloseChangeNotification@4
|
||||
;FindFirstChangeNotificationA@12
|
||||
;FindFirstChangeNotificationW@12
|
||||
FindFirstFileA@8
|
||||
FindFirstFileA = FindFirstFileA@8
|
||||
FindFirstFileW@8
|
||||
FindFirstFileW = FindFirstFileW@8
|
||||
;FindNextChangeNotification@4
|
||||
FindNextFileA@8
|
||||
FindNextFileA = FindNextFileA@8
|
||||
FindNextFileW@8
|
||||
FindNextFileW = FindNextFileW@8
|
||||
;FindResourceA@12
|
||||
;FindResourceExA@16
|
||||
;FindResourceExW@16
|
||||
;FindResourceW@12
|
||||
;FlushConsoleInputBuffer@4
|
||||
;FlushFileBuffers@4
|
||||
FlushFileBuffers@4
|
||||
FlushFileBuffers = FlushFileBuffers@4
|
||||
;FlushInstructionCache@12
|
||||
;FlushViewOfFile@8
|
||||
;FoldStringA@20
|
||||
|
@ -171,7 +199,8 @@ FindNextFileW@8
|
|||
;FreeConsole@0
|
||||
;FreeEnvironmentStringsA@4
|
||||
;FreeEnvironmentStringsW@4
|
||||
;FreeLibrary@4
|
||||
FreeLibrary@4
|
||||
FreeLibrary = FreeLibrary@4
|
||||
;FreeLibraryAndExitThread@8
|
||||
;FreeResource@4
|
||||
;FreeVirtualBuffer@4
|
||||
|
@ -190,9 +219,13 @@ FindNextFileW@8
|
|||
;GetCommState@8
|
||||
;GetCommTimeouts@8
|
||||
GetCommandLineA@0
|
||||
GetCommandLineA = GetCommandLineA@0
|
||||
GetCommandLineW@0
|
||||
;GetCompressedFileSizeA@8
|
||||
;GetCompressedFileSizeW@8
|
||||
GetCommandLineW = GetCommandLineW@0
|
||||
GetCompressedFileSizeA@8
|
||||
GetCompressedFileSizeA = GetCompressedFileSizeA@8
|
||||
GetCompressedFileSizeW@8
|
||||
GetCompressedFileSizeW = GetCompressedFileSizeW@8
|
||||
;GetComputerNameA@8
|
||||
;GetComputerNameW@8
|
||||
;GetConsoleAliasA@16
|
||||
|
@ -225,37 +258,58 @@ GetCommandLineW@0
|
|||
;GetCurrencyFormatW@24
|
||||
;GetCurrentConsoleFont@12
|
||||
GetCurrentDirectoryA@8
|
||||
GetCurrentDirectoryA = GetCurrentDirectoryA@8
|
||||
GetCurrentDirectoryW@8
|
||||
;GetCurrentProcess@0
|
||||
GetCurrentDirectoryW = GetCurrentDirectoryW@8
|
||||
GetCurrentProcess@0
|
||||
GetCurrentProcess = GetCurrentProcess@0
|
||||
;GetCurrentProcessId@0
|
||||
;GetCurrentThread@0
|
||||
;GetCurrentThreadId@0
|
||||
GetCurrentThread@0
|
||||
GetCurrentThread = GetCurrentThread@0
|
||||
GetCurrentThreadId@0
|
||||
GetCurrentThreadId = GetCurrentThreadId@0
|
||||
;GetDateFormatA@24
|
||||
;GetDateFormatW@24
|
||||
;GetDefaultCommConfigA@12
|
||||
;GetDefaultCommConfigW@12
|
||||
;GetDiskFreeSpaceA@20
|
||||
;GetDiskFreeSpaceW@20
|
||||
GetDiskFreeSpaceA@20
|
||||
GetDiskFreeSpaceA = GetDiskFreeSpaceA@20
|
||||
GetDiskFreeSpaceW@20
|
||||
GetDiskFreeSpaceW = GetDiskFreeSpaceW@20
|
||||
;GetDriveTypeA@4
|
||||
;GetDriveTypeW@4
|
||||
;GetEnvironmentStrings@0
|
||||
GetEnvironmentStringsA@0
|
||||
GetEnvironmentStringsA = GetEnvironmentStringsA@0
|
||||
GetEnvironmentStringsW@0
|
||||
;GetEnvironmentVariableA@12
|
||||
;GetEnvironmentVariableW@12
|
||||
;GetExitCodeProcess@8
|
||||
GetEnvironmentStringsW = GetEnvironmentStringsW@0
|
||||
GetEnvironmentVariableA@12
|
||||
GetEnvironmentVariableA = GetEnvironmentVariableA@12
|
||||
GetEnvironmentVariableW@12
|
||||
GetEnvironmentVariableW = GetEnvironmentVariableW@12
|
||||
GetExitCodeProcess@8
|
||||
GetExitCodeProcess = GetExitCodeProcess@8
|
||||
;GetExitCodeThread@8
|
||||
;GetFileAttributesA@4
|
||||
;GetFileAttributesW@4
|
||||
;GetFileInformationByHandle@8
|
||||
;GetFileSize@8
|
||||
;GetFileTime@16
|
||||
;GetFileType@4
|
||||
;GetFullPathNameA@16
|
||||
;GetFullPathNameW@16
|
||||
GetFileAttributesA@4
|
||||
GetFileAttributesA = GetFileAttributesA@4
|
||||
GetFileAttributesW@4
|
||||
GetFileAttributesW = GetFileAttributesW@4
|
||||
GetFileInformationByHandle@8
|
||||
GetFileInformationByHandle = GetFileInformationByHandle@8
|
||||
GetFileSize@8
|
||||
GetFileSize = GetFileSize@8
|
||||
GetFileTime@16
|
||||
GetFileTime = GetFileTime@16
|
||||
GetFileType@4
|
||||
GetFileType = GetFileType@4
|
||||
GetFullPathNameA@16
|
||||
GetFullPathNameA = GetFullPathNameA@16
|
||||
GetFullPathNameW@16
|
||||
GetFullPathNameW = GetFullPathNameW@16
|
||||
;GetHandleInformation@8
|
||||
;GetLargestConsoleWindowSize@4
|
||||
;GetLastError@0
|
||||
GetLastError@0
|
||||
GetLastError = GetLastError@0
|
||||
;GetLocalTime@4
|
||||
;GetLocaleInfoA@16
|
||||
;GetLocaleInfoW@16
|
||||
|
@ -289,12 +343,15 @@ GetEnvironmentStringsW@0
|
|||
;GetPrivateProfileStringW@24
|
||||
;GetPrivateProfileStructA@20
|
||||
;GetPrivateProfileStructW@20
|
||||
;GetProcAddress@8
|
||||
GetProcAddress@8
|
||||
GetProcAddress = GetProcAddress@8
|
||||
;GetProcessAffinityMask@12
|
||||
GetProcessHeap@0
|
||||
GetProcessHeap = GetProcessHeap@0
|
||||
;GetProcessHeaps@8
|
||||
;GetProcessShutdownParameters@8
|
||||
;GetProcessTimes@20
|
||||
GetProcessTimes@20
|
||||
GetProcessTimes = GetProcessTimes@20
|
||||
;GetProcessVersion@4
|
||||
;GetProcessWorkingSetSize@12
|
||||
;GetProfileIntA@12
|
||||
|
@ -309,6 +366,7 @@ GetProcessHeap@0
|
|||
;GetStartupInfoA@4
|
||||
;GetStartupInfoW@4
|
||||
GetStdHandle@4
|
||||
GetStdHandle = GetStdHandle@4
|
||||
;GetStringTypeA@20
|
||||
;GetStringTypeExA@20
|
||||
;GetStringTypeExW@20
|
||||
|
@ -321,14 +379,19 @@ GetStdHandle@4
|
|||
;GetSystemPowerStatus@4
|
||||
;GetSystemTime@4
|
||||
;GetSystemTimeAdjustment@12
|
||||
;GetSystemTimeAsFileTime@4
|
||||
GetSystemTimeAsFileTime@4
|
||||
GetSystemTimeAsFileTime = GetSystemTimeAsFileTime@4
|
||||
;GetTapeParameters@16
|
||||
;GetTapePosition@20
|
||||
;GetTapeStatus@4
|
||||
;GetTempFileNameA@16
|
||||
;GetTempFileNameW@16
|
||||
;GetTempPathA@8
|
||||
;GetTempPathW@8
|
||||
GetTempFileNameA@16
|
||||
GetTempFileNameA = GetTempFileNameA@16
|
||||
GetTempFileNameW@16
|
||||
GetTempFileNameW = GetTempFileNameW@16
|
||||
GetTempPathA@8
|
||||
GetTempPathA = GetTempPathA@8
|
||||
GetTempPathW@8
|
||||
GetTempPathW = GetTempPathW@8
|
||||
;GetThreadContext@8
|
||||
;GetThreadLocale@0
|
||||
;GetThreadPriority@4
|
||||
|
@ -342,6 +405,7 @@ GetStdHandle@4
|
|||
;GetUserDefaultLangID@0
|
||||
;GetVDMCurrentDirectories@8
|
||||
GetVersion@0
|
||||
GetVersion = GetVersion@0
|
||||
;GetVersionExA@4
|
||||
;GetVersionExW@4
|
||||
;GetVolumeInformationA@32
|
||||
|
@ -370,20 +434,29 @@ GetVersion@0
|
|||
;GlobalUnlock@4
|
||||
;GlobalWire@4
|
||||
HeapAlloc@12
|
||||
HeapAlloc = HeapAlloc@12
|
||||
HeapCompact@8
|
||||
HeapCompact = HeapCompact@8
|
||||
HeapCreate@12
|
||||
HeapCreate = HeapCreate@12
|
||||
;HeapCreateTagsW@16
|
||||
HeapDestroy@4
|
||||
HeapDestroy = HeapDestroy@4
|
||||
;HeapExtend@16
|
||||
HeapFree@12
|
||||
HeapFree = HeapFree@12
|
||||
;HeapLock@4
|
||||
;HeapQueryTagW@20
|
||||
HeapReAlloc@16
|
||||
HeapReAlloc = HeapReAlloc@16
|
||||
HeapSize@12
|
||||
HeapSize = HeapSize@12
|
||||
;HeapSummary@12
|
||||
HeapUnlock@4
|
||||
HeapUnlock = HeapUnlock@4
|
||||
;HeapUsage@20
|
||||
HeapValidate@12
|
||||
HeapValidate = HeapValidate@12
|
||||
;HeapWalk@8
|
||||
;InitAtomTable@4
|
||||
;InitializeCriticalSection@4
|
||||
|
@ -406,7 +479,8 @@ HeapValidate@12
|
|||
;LCMapStringA@24
|
||||
;LCMapStringW@24
|
||||
;LeaveCriticalSection@4
|
||||
;LoadLibraryA@4
|
||||
LoadLibraryA@4
|
||||
LoadLibraryA = LoadLibraryA@4
|
||||
;LoadLibraryExA@12
|
||||
;LoadLibraryExW@12
|
||||
;LoadLibraryW@4
|
||||
|
@ -423,21 +497,27 @@ HeapValidate@12
|
|||
;LocalShrink@8
|
||||
;LocalSize@4
|
||||
;LocalUnlock@4
|
||||
;LockFile@20
|
||||
LockFile@20
|
||||
LockFile = LockFile@20
|
||||
;LockFileEx@24
|
||||
;LockResource@4
|
||||
;MapViewOfFile@20
|
||||
;MapViewOfFileEx@24
|
||||
;MoveFileA@8
|
||||
MoveFileA@8
|
||||
MoveFileA = MoveFileA@8
|
||||
;MoveFileExA@12
|
||||
;MoveFileExW@12
|
||||
;MoveFileW@8
|
||||
MoveFileW@8
|
||||
MoveFileW = MoveFileW@8
|
||||
;MulDiv@12
|
||||
;MultiByteToWideChar@24
|
||||
;OpenConsoleW@16
|
||||
;OpenEventA@12
|
||||
;OpenEventW@12
|
||||
;OpenFile@12
|
||||
OpenEventA@12
|
||||
OpenEventA = OpenEventA@12
|
||||
OpenEventW@12
|
||||
OpenEventW = OpenEventW@12
|
||||
OpenFile@12
|
||||
OpenFile = OpenFile@12
|
||||
;OpenFileMappingA@12
|
||||
;OpenFileMappingW@12
|
||||
;OpenMutexA@12
|
||||
|
@ -453,7 +533,8 @@ HeapValidate@12
|
|||
;PeekNamedPipe@24
|
||||
;PostQueuedCompletionStatus@16
|
||||
;PrepareTape@12
|
||||
;PulseEvent@4
|
||||
PulseEvent@4
|
||||
PulseEvent = PulseEvent@4
|
||||
;PurgeComm@8
|
||||
;QueryDosDeviceA@12
|
||||
;QueryDosDeviceW@12
|
||||
|
@ -462,6 +543,7 @@ HeapValidate@12
|
|||
;QueryWin31IniFilesMappedToRegistry@16
|
||||
;RaiseException@16
|
||||
ReadConsoleA@20
|
||||
ReadConsoleA = ReadConsoleA@20
|
||||
;ReadConsoleInputA@16
|
||||
;ReadConsoleInputW@16
|
||||
;ReadConsoleOutputA@20
|
||||
|
@ -471,7 +553,9 @@ ReadConsoleA@20
|
|||
;ReadConsoleOutputW@20
|
||||
;ReadConsoleW@20
|
||||
ReadFile@20
|
||||
ReadFile = ReadFile@20
|
||||
ReadFileEx@20
|
||||
ReadFileEx = ReadFileEx@20
|
||||
;ReadProcessMemory@20
|
||||
;RegisterConsoleVDM@44
|
||||
;RegisterWaitForInputIdle@4
|
||||
|
@ -479,9 +563,12 @@ ReadFileEx@20
|
|||
;RegisterWowExec@4
|
||||
;ReleaseMutex@4
|
||||
;ReleaseSemaphore@12
|
||||
;RemoveDirectoryA@4
|
||||
;RemoveDirectoryW@4
|
||||
;ResetEvent@4
|
||||
RemoveDirectoryA@4
|
||||
RemoveDirectoryA = RemoveDirectoryA@4
|
||||
RemoveDirectoryW@4
|
||||
RemoveDirectoryW = RemoveDirectoryW@4
|
||||
ResetEvent@4
|
||||
ResetEvent = ResetEvent@4
|
||||
;ResumeThread@4
|
||||
;RtlFillMemory@12
|
||||
;RtlMoveMemory@12
|
||||
|
@ -489,8 +576,10 @@ ReadFileEx@20
|
|||
;RtlZeroMemory@8
|
||||
;ScrollConsoleScreenBufferA@20
|
||||
;ScrollConsoleScreenBufferW@20
|
||||
;SearchPathA@24
|
||||
;SearchPathW@24
|
||||
SearchPathA@24
|
||||
SearchPathA = SearchPathA@24
|
||||
SearchPathW@24
|
||||
SearchPathW = SearchPathW@24
|
||||
;SetCommBreak@4
|
||||
;SetCommConfig@12
|
||||
;SetCommMask@8
|
||||
|
@ -522,20 +611,32 @@ ReadFileEx@20
|
|||
;SetConsoleTitleW@4
|
||||
;SetConsoleWindowInfo@12
|
||||
SetCurrentDirectoryA@4
|
||||
SetCurrentDirectoryA = SetCurrentDirectoryA@4
|
||||
SetCurrentDirectoryW@4
|
||||
SetCurrentDirectoryW = SetCurrentDirectoryW@4
|
||||
;SetDefaultCommConfigA@12
|
||||
;SetDefaultCommConfigW@12
|
||||
;SetEndOfFile@4
|
||||
;SetEnvironmentVariableA@8
|
||||
;SetEnvironmentVariableW@8
|
||||
;SetErrorMode@4
|
||||
;SetEvent@4
|
||||
;SetFileApisToANSI@0
|
||||
;SetFileApisToOEM@0
|
||||
;SetFileAttributesA@8
|
||||
;SetFileAttributesW@8
|
||||
SetEndOfFile@4
|
||||
SetEndOfFile = SetEndOfFile@4
|
||||
SetEnvironmentVariableA@8
|
||||
SetEnvironmentVariableA = SetEnvironmentVariableA@8
|
||||
SetEnvironmentVariableW@8
|
||||
SetEnvironmentVariableW = SetEnvironmentVariableW@8
|
||||
SetErrorMode@4
|
||||
SetErrorMode = SetErrorMode@4
|
||||
SetEvent@4
|
||||
SetEvent = SetEvent@4
|
||||
SetFileApisToANSI@0
|
||||
SetFileApisToANSI = SetFileApisToANSI@0
|
||||
SetFileApisToOEM@0
|
||||
SetFileApisToOEM = SetFileApisToOEM@0
|
||||
SetFileAttributesA@8
|
||||
SetFileAttributesA = SetFileAttributesA@8
|
||||
SetFileAttributesW@8
|
||||
SetFileAttributesW = SetFileAttributesW@8
|
||||
;SetFilePointer@16
|
||||
;SetFileTime@16
|
||||
SetFileTime@16
|
||||
SetFileTime = SetFileTime@16
|
||||
;SetHandleCount@4
|
||||
;SetHandleInformation@12
|
||||
;SetLastConsoleEventActive@0
|
||||
|
@ -560,14 +661,16 @@ SetCurrentDirectoryW@4
|
|||
;SetThreadLocale@4
|
||||
;SetThreadPriority@8
|
||||
;SetTimeZoneInformation@4
|
||||
;SetUnhandledExceptionFilter@4
|
||||
SetUnhandledExceptionFilter@4
|
||||
SetUnhandledExceptionFilter = SetUnhandledExceptionFilter@4
|
||||
;SetVDMCurrentDirectories@8
|
||||
;SetVolumeLabelA@8
|
||||
;SetVolumeLabelW@8
|
||||
;SetupComm@12
|
||||
;ShowConsoleCursor@8
|
||||
;SizeofResource@8
|
||||
;Sleep@4
|
||||
Sleep@4
|
||||
Sleep = Sleep@4
|
||||
;SleepEx@8
|
||||
;SuspendThread@4
|
||||
;SystemTimeToFileTime@8
|
||||
|
@ -610,8 +713,10 @@ WaitForSingleObject@8
|
|||
;WaitNamedPipeA@8
|
||||
;WaitNamedPipeW@8
|
||||
;WideCharToMultiByte@32
|
||||
;WinExec@8
|
||||
WinExec@8
|
||||
WinExec = WinExec@8
|
||||
WriteConsoleA@20
|
||||
WriteConsoleA = WriteConsoleA@20
|
||||
;WriteConsoleInputA@16
|
||||
;WriteConsoleInputVDMA@16
|
||||
;WriteConsoleInputVDMW@16
|
||||
|
@ -622,7 +727,8 @@ WriteConsoleA@20
|
|||
;WriteConsoleOutputCharacterW@20
|
||||
;WriteConsoleOutputW@20
|
||||
;WriteConsoleW@20
|
||||
;WriteFile@20
|
||||
WriteFile@20
|
||||
WriteFile = WriteFile@20
|
||||
;WriteFileEx@20
|
||||
;WritePrivateProfileSectionA@12
|
||||
;WritePrivateProfileSectionW@12
|
||||
|
@ -640,7 +746,8 @@ WriteConsoleA@20
|
|||
;_hwrite@12
|
||||
;_lclose@4
|
||||
;_lcreat@8
|
||||
;_llseek@12
|
||||
_llseek@12
|
||||
_llseek = _llseek@12
|
||||
;_lopen@8
|
||||
;_lread@12
|
||||
;_lwrite@12
|
||||
|
|
|
@ -18,7 +18,8 @@ MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o
|
|||
|
||||
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \
|
||||
file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \
|
||||
file/create.o file/find.o file/copy.o
|
||||
file/create.o file/find.o file/copy.o file/pipe.o \
|
||||
file/move.o file/lock.o file/rw.o file/delete.o
|
||||
|
||||
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o
|
||||
|
||||
|
@ -45,7 +46,8 @@ NLS_OBJECTS = nls/codepage.o nls/cpmisc.o nls/cptable.o\
|
|||
|
||||
THREAD_OBJECTS = thread/thread.o
|
||||
|
||||
PROCESS_OBJECTS = process/proc.o process/cmdline.o process/create.o
|
||||
PROCESS_OBJECTS = process/proc.o process/cmdline.o process/create.o \
|
||||
process/lib.o
|
||||
|
||||
STRING_OBJECTS = string/lstring.o
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
|
||||
|
@ -37,25 +37,23 @@ HANDLE StdPrint = INVALID_HANDLE_VALUE;
|
|||
/*--------------------------------------------------------------
|
||||
* GetStdHandle
|
||||
*/
|
||||
HANDLE
|
||||
STDCALL
|
||||
GetStdHandle(
|
||||
DWORD nStdHandle
|
||||
)
|
||||
HANDLE STDCALL GetStdHandle(DWORD nStdHandle)
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS); /* OK */
|
||||
switch (nStdHandle)
|
||||
{
|
||||
case STD_INPUT_HANDLE: return StdInput;
|
||||
case STD_OUTPUT_HANDLE: return StdOutput;
|
||||
case STD_ERROR_HANDLE: return StdError;
|
||||
DPRINT("GetStdHandle(nStdHandle %d)\n",nStdHandle);
|
||||
|
||||
SetLastError(ERROR_SUCCESS); /* OK */
|
||||
switch (nStdHandle)
|
||||
{
|
||||
case STD_INPUT_HANDLE: return StdInput;
|
||||
case STD_OUTPUT_HANDLE: return StdOutput;
|
||||
case STD_ERROR_HANDLE: return StdError;
|
||||
#ifdef EXTENDED_CONSOLE
|
||||
case STD_AUX_HANDLE: return StdError;
|
||||
case STD_PRINT_HANDLE: return StdError;
|
||||
case STD_AUX_HANDLE: return StdError;
|
||||
case STD_PRINT_HANDLE: return StdError;
|
||||
#endif
|
||||
}
|
||||
SetLastError(0); /* FIXME: What error code? */
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
SetLastError(0); /* FIXME: What error code? */
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <kernel32/proc.h>
|
||||
#include <internal/teb.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
WINBOOL STDCALL DllMain (HANDLE hInst,
|
||||
|
@ -33,12 +34,16 @@ WINBOOL STDCALL DllMain(HANDLE hInst,
|
|||
ULONG ul_reason_for_call,
|
||||
LPVOID lpReserved)
|
||||
{
|
||||
DPRINT("DllMain");
|
||||
DPRINT("DllMain(hInst %x, ul_reason_for_call %d)\n",
|
||||
hInst, ul_reason_for_call);
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
DPRINT("DLL_PROCESS_ATTACH\n");
|
||||
AllocConsole();
|
||||
SetCurrentDirectoryA("C:\\");
|
||||
break;
|
||||
}
|
||||
case DLL_THREAD_ATTACH:
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
#define MAX_ENVIRONMENT_VARS 255
|
||||
#define MAX_VALUE 1024
|
||||
|
||||
|
@ -26,13 +28,9 @@ typedef struct _ENV_ELEMENT
|
|||
ENV_ELEMENT Environment[MAX_ENVIRONMENT_VARS+1];
|
||||
UINT nEnvVar = 0;
|
||||
|
||||
DWORD
|
||||
STDCALL
|
||||
GetEnvironmentVariableA(
|
||||
LPCSTR lpName,
|
||||
LPSTR lpBuffer,
|
||||
DWORD nSize
|
||||
)
|
||||
DWORD STDCALL GetEnvironmentVariableA(LPCSTR lpName,
|
||||
LPSTR lpBuffer,
|
||||
DWORD nSize)
|
||||
{
|
||||
WCHAR BufferW[MAX_VALUE];
|
||||
WCHAR NameW[MAX_PATH];
|
||||
|
@ -237,72 +235,85 @@ GetVersionExA(
|
|||
|
||||
|
||||
|
||||
LPSTR
|
||||
STDCALL
|
||||
GetEnvironmentStringsA(
|
||||
VOID
|
||||
)
|
||||
LPSTR STDCALL GetEnvironmentStringsA(VOID)
|
||||
{
|
||||
WCHAR *EnvironmentStringsW;
|
||||
char *EnvironmentStringsA;
|
||||
int size = 0;
|
||||
int i;
|
||||
EnvironmentStringsW = GetEnvironmentStringsW();
|
||||
EnvironmentStringsA = (char *)EnvironmentStringsW;
|
||||
WCHAR *EnvironmentStringsW;
|
||||
char *EnvironmentStringsA;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
return(NULL);
|
||||
|
||||
/* FIXME: This doesn't work */
|
||||
#if 0
|
||||
EnvironmentStringsW = GetEnvironmentStringsW();
|
||||
EnvironmentStringsA = (char *)EnvironmentStringsW;
|
||||
|
||||
for(i=0;i<nEnvVar;i++) {
|
||||
if ( Environment[i].Valid ) {
|
||||
size += Environment[i].Name.Length;
|
||||
size += sizeof(WCHAR); // =
|
||||
size += Environment[i].Value.Length;
|
||||
size += sizeof(WCHAR); // zero
|
||||
}
|
||||
}
|
||||
size += sizeof(WCHAR);
|
||||
size /= sizeof(WCHAR);
|
||||
for(i=0;i<size;i++)
|
||||
EnvironmentStringsA[i] = (char)EnvironmentStringsW[i];
|
||||
return EnvironmentStringsA;
|
||||
for(i=0;i<nEnvVar;i++)
|
||||
{
|
||||
if ( Environment[i].Valid )
|
||||
{
|
||||
size += Environment[i].Name.Length;
|
||||
size += sizeof(WCHAR); // =
|
||||
size += Environment[i].Value.Length;
|
||||
size += sizeof(WCHAR); // zero
|
||||
}
|
||||
}
|
||||
size += sizeof(WCHAR);
|
||||
size /= sizeof(WCHAR);
|
||||
for(i=0;i<size;i++)
|
||||
EnvironmentStringsA[i] = (char)EnvironmentStringsW[i];
|
||||
return EnvironmentStringsA;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
LPWSTR
|
||||
STDCALL
|
||||
GetEnvironmentStringsW(
|
||||
VOID
|
||||
)
|
||||
LPWSTR STDCALL GetEnvironmentStringsW(VOID)
|
||||
{
|
||||
int size = 0;
|
||||
int i;
|
||||
WCHAR *EnvironmentString;
|
||||
WCHAR *EnvironmentStringSave;
|
||||
for(i=0;i<nEnvVar;i++) {
|
||||
if ( Environment[i].Valid ) {
|
||||
size += Environment[i].Name.Length;
|
||||
size += sizeof(WCHAR); // =
|
||||
size += Environment[i].Value.Length;
|
||||
size += sizeof(WCHAR); // zero
|
||||
}
|
||||
}
|
||||
size += sizeof(WCHAR); // extra zero
|
||||
EnvironmentString = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,size);
|
||||
EnvironmentStringSave = EnvironmentString;
|
||||
for(i=0;i<nEnvVar;i++) {
|
||||
if ( Environment[i].Valid ) {
|
||||
wcscpy(EnvironmentString,Environment[i].Name.Buffer);
|
||||
wcscat(EnvironmentString,L"=");
|
||||
wcscat(EnvironmentString,Environment[i].Value.Buffer);
|
||||
int size = 0;
|
||||
int i;
|
||||
WCHAR *EnvironmentString;
|
||||
WCHAR *EnvironmentStringSave;
|
||||
|
||||
size = Environment[i].Name.Length;
|
||||
size += sizeof(WCHAR); // =
|
||||
size += Environment[i].Value.Length;
|
||||
size += sizeof(WCHAR); // zero
|
||||
EnvironmentString += (size/sizeof(WCHAR));
|
||||
}
|
||||
}
|
||||
EnvironmentString++;
|
||||
*EnvironmentString = 0;
|
||||
return EnvironmentStringSave;
|
||||
return(NULL);
|
||||
|
||||
/* FIXME: This doesn't work, why not? */
|
||||
#if 0
|
||||
for(i=0;i<nEnvVar;i++)
|
||||
{
|
||||
if ( Environment[i].Valid )
|
||||
{
|
||||
size += Environment[i].Name.Length;
|
||||
size += sizeof(WCHAR); // =
|
||||
size += Environment[i].Value.Length;
|
||||
size += sizeof(WCHAR); // zero
|
||||
}
|
||||
}
|
||||
size += sizeof(WCHAR); // extra zero
|
||||
DPRINT("size %d\n",size);
|
||||
EnvironmentString = (WCHAR *)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
|
||||
size);
|
||||
DPRINT("EnvironmentString %x\n",EnvironmentString);
|
||||
EnvironmentStringSave = EnvironmentString;
|
||||
for(i=0;i<nEnvVar;i++)
|
||||
{
|
||||
if ( Environment[i].Valid )
|
||||
{
|
||||
wcscpy(EnvironmentString,Environment[i].Name.Buffer);
|
||||
wcscat(EnvironmentString,L"=");
|
||||
wcscat(EnvironmentString,Environment[i].Value.Buffer);
|
||||
|
||||
size = Environment[i].Name.Length;
|
||||
size += sizeof(WCHAR); // =
|
||||
size += Environment[i].Value.Length;
|
||||
size += sizeof(WCHAR); // zero
|
||||
EnvironmentString += (size/sizeof(WCHAR));
|
||||
}
|
||||
}
|
||||
*EnvironmentString = 0;
|
||||
return EnvironmentStringSave;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <ntdll/ldr.h>
|
||||
#include <internal/teb.h>
|
||||
|
||||
#define NDEBUG
|
||||
//#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
@ -106,22 +106,8 @@ HANDLE STDCALL CreateFirstThread(HANDLE ProcessHandle,
|
|||
BOOLEAN CreateSuspended = FALSE;
|
||||
PVOID BaseAddress;
|
||||
ULONG BytesWritten;
|
||||
ULONG CommandLineLen;
|
||||
HANDLE DupNTDllSectionHandle, DupSectionHandle;
|
||||
|
||||
if (lpCommandLine == NULL)
|
||||
{
|
||||
lpCommandLine = L"";
|
||||
CommandLineLen = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandLineLen = wcslen(lpCommandLine) + 1;
|
||||
}
|
||||
CommandLineLen = CommandLineLen * sizeof(WCHAR);
|
||||
CommandLineLen = (CommandLineLen & (~0x3)) + 4;
|
||||
DPRINT("CommandLineLen %d\n",CommandLineLen);
|
||||
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
|
@ -438,7 +424,12 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
|||
DPRINT("CreateProcessW(lpApplicationName '%w', lpCommandLine '%w')\n",
|
||||
lpApplicationName,lpCommandLine);
|
||||
|
||||
wcscpy(TempCommandLine, lpCommandLine);
|
||||
wcscpy(TempCommandLine, lpApplicationName);
|
||||
if (lpCommandLine != NULL)
|
||||
{
|
||||
wcscat(TempCommandLine, L" ");
|
||||
wcscat(TempCommandLine, lpCommandLine);
|
||||
}
|
||||
|
||||
|
||||
hSection = KERNEL32_MapFile(lpApplicationName,
|
||||
|
|
39
reactos/lib/kernel32/process/lib.c
Normal file
39
reactos/lib/kernel32/process/lib.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/proc/proc.c
|
||||
* PURPOSE: Process functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* UPDATE HISTORY:
|
||||
* Created 01/11/98
|
||||
*/
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#define UNICODE
|
||||
#include <windows.h>
|
||||
#include <kernel32/proc.h>
|
||||
#include <kernel32/thread.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/teb.h>
|
||||
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
HINSTANCE LoadLibraryW(LPCWSTR lpLibFileName)
|
||||
{
|
||||
dprintf("LoadLibraryW is unimplemented\n");
|
||||
}
|
||||
|
||||
HINSTANCE LoadLibraryA(LPCSTR lpLibFileName)
|
||||
{
|
||||
dprintf("LoadLibraryA is unimplemented\n");
|
||||
}
|
||||
|
||||
BOOL STDCALL FreeLibrary(HMODULE hLibModule)
|
||||
{
|
||||
dprintf("FreeLibrary is unimplemented\n");
|
||||
}
|
|
@ -32,6 +32,21 @@ VOID RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle
|
|||
|
||||
WINBOOL STDCALL GetProcessId(HANDLE hProcess, LPDWORD lpProcessId);
|
||||
|
||||
FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
||||
{
|
||||
dprintf("GetProcAddress is unimplemented\n");
|
||||
}
|
||||
|
||||
WINBOOL STDCALL GetProcessTimes(HANDLE hProcess,
|
||||
LPFILETIME lpCreationTime,
|
||||
LPFILETIME lpExitTime,
|
||||
LPFILETIME lpKernelTime,
|
||||
LPFILETIME lpUserTime)
|
||||
{
|
||||
dprintf("GetProcessTimes is unimplemented\n");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
HANDLE STDCALL GetCurrentProcess(VOID)
|
||||
{
|
||||
return (HANDLE)NtCurrentProcess();
|
||||
|
|
|
@ -422,7 +422,7 @@ ZwSetContextChannel@4
|
|||
ZwYieldExecution@0
|
||||
RtlAllocateHeap@12
|
||||
RtlCreateHeap@24
|
||||
RtlCompactHeap
|
||||
RtlCompactHeap@8
|
||||
RtlDestroyHeap@4
|
||||
RtlFreeHeap@12
|
||||
RtlGetProcessHeap@0
|
||||
|
|
|
@ -18,13 +18,15 @@
|
|||
#include <ntdll/ldr.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
//#define NDEBUG
|
||||
#include <ntdll/ntdll.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
DLL LdrDllListHead;
|
||||
extern unsigned int _image_base__;
|
||||
extern HANDLE __ProcessHeap;
|
||||
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@ -105,18 +107,21 @@ VOID LdrStartup(HANDLE SectionHandle,
|
|||
}
|
||||
|
||||
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);
|
||||
__RtlInitHeap((PVOID)HEAP_BASE,
|
||||
NTHeaders->OptionalHeader.SizeOfHeapCommit,
|
||||
NTHeaders->OptionalHeader.SizeOfHeapReserve);
|
||||
__ProcessHeap = RtlCreateHeap(0,
|
||||
(PVOID)HEAP_BASE,
|
||||
NTHeaders->OptionalHeader.SizeOfHeapCommit,
|
||||
NTHeaders->OptionalHeader.SizeOfHeapReserve,
|
||||
NULL,
|
||||
NULL);
|
||||
EntryPoint = LdrPEStartup((PVOID)ImageBase, SectionHandle);
|
||||
|
||||
if (EntryPoint == NULL)
|
||||
{
|
||||
DPRINT("Failed to initialize image\n");
|
||||
ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL);
|
||||
dprintf("Failed to initialize image\n");
|
||||
ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
DPRINT("Transferring control to image at %x\n",EntryPoint);
|
||||
dprintf("Transferring control to image at %x\n",EntryPoint);
|
||||
Status = EntryPoint();
|
||||
ZwTerminateProcess(NtCurrentProcess(),Status);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
|
|||
HANDLE FileHandle, SectionHandle;
|
||||
PDLLMAIN_FUNC Entrypoint;
|
||||
|
||||
DPRINT("LdrLoadDll(Base %x, Name %s)\n",Dll,Name);
|
||||
dprintf("LdrLoadDll(Base %x, Name %s)\n",Dll,Name);
|
||||
|
||||
strcat(fqname, Name);
|
||||
|
||||
|
@ -140,8 +140,9 @@ static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
|
|||
Entrypoint = (PDLLMAIN_FUNC)LdrPEStartup(ImageBase, SectionHandle);
|
||||
if (Entrypoint != NULL)
|
||||
{
|
||||
DPRINT("Calling entry point at %x\n",Entrypoint);
|
||||
dprintf("Calling entry point at %x\n",Entrypoint);
|
||||
Entrypoint(ImageBase, DLL_PROCESS_ATTACH, NULL);
|
||||
dprintf("Successful called entrypoint\n");
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -231,6 +232,8 @@ static PVOID LdrGetExportByOrdinal(PDLL Module, ULONG Ordinal)
|
|||
ExportDir->AddressOfNameOrdinals);
|
||||
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
|
||||
ExportDir->AddressOfFunctions);
|
||||
dprintf("LdrGetExportByOrdinal(Ordinal %d) = %x\n",
|
||||
Ordinal,ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
|
||||
return(ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
|
||||
}
|
||||
|
||||
|
@ -260,12 +263,14 @@ static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
|
|||
for (i=0; i<ExportDir->NumberOfFunctions; i++)
|
||||
{
|
||||
ExName = RVA(Module->BaseAddress, ExNames[i]);
|
||||
DPRINT("Comparing '%s' '%s'\n",ExName,SymbolName);
|
||||
if (strcmp(ExName,SymbolName) == 0)
|
||||
{
|
||||
Ordinal = ExOrdinals[i];
|
||||
return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
|
||||
}
|
||||
}
|
||||
dprintf("LdrGetExportByName() = failed to find %s\n",SymbolName);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -430,6 +435,7 @@ PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle)
|
|||
Status = LdrPerformRelocations(NTHeaders, ImageBase);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
dprintf("LdrPerformRelocations() failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
@ -440,13 +446,14 @@ PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle)
|
|||
Status = LdrFixupImports(NTHeaders, ImageBase);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
dprintf("LdrFixupImports() failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
EntryPoint = (PEPFUNC)(ImageBase +
|
||||
NTHeaders->OptionalHeader.AddressOfEntryPoint);
|
||||
|
||||
dprintf("LdrPEStartup() = %x\n",EntryPoint);
|
||||
return(EntryPoint);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -233,6 +233,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
DbgPrint("ESP %.8x\n",esp);
|
||||
}
|
||||
|
||||
for(;;);
|
||||
|
||||
if ((cs & 0xffff) == KERNEL_CS)
|
||||
{
|
||||
|
|
|
@ -58,32 +58,16 @@ static ULONG ProtectToPTE(ULONG flProtect)
|
|||
(((ULONG)v / (1024 * 1024))&(~0x3)))
|
||||
#define ADDR_TO_PTE(v) (PULONG)(PAGETABLE_MAP + ((ULONG)v / 1024))
|
||||
|
||||
NTSTATUS MmReleaseMmInfo(PEPROCESS Process)
|
||||
NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
|
||||
{
|
||||
ULONG i,j,addr;
|
||||
|
||||
DbgPrint("MmReleaseMmInfo(Process %x)\n",Process);
|
||||
DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process);
|
||||
|
||||
KeAttachProcess(Process);
|
||||
for (i=0; i<1024; i++)
|
||||
{
|
||||
if (ADDR_TO_PDE(i*4*1024*1024) != 0)
|
||||
{
|
||||
for (j=0; j<1024; j++)
|
||||
{
|
||||
addr = i*4*1024*1024 + j*4*1024;
|
||||
if (ADDR_TO_PTE(addr) != 0)
|
||||
{
|
||||
MmFreePage((PVOID)PAGE_MASK(*ADDR_TO_PTE(addr)), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
KeDetachProcess();
|
||||
MmFreePage(Process->Pcb.PageTableDirectory, 1);
|
||||
Process->Pcb.PageTableDirectory = NULL;
|
||||
|
||||
DbgPrint("Finished MmReleaseMmInfo()\n");
|
||||
DPRINT("Finished Mmi386ReleaseMmInfo()\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -123,13 +107,15 @@ NTSTATUS MmCopyMmInfo(PEPROCESS Src, PEPROCESS Dest)
|
|||
|
||||
VOID MmDeletePageTable(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
*(ADDR_TO_PDE(Address)) = 0;
|
||||
FLUSH_TLB;
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
@ -138,40 +124,46 @@ VOID MmDeletePageTable(PEPROCESS Process, PVOID Address)
|
|||
ULONG MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
ULONG Entry;
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
Entry = *MmGetPageEntry(Address);
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
return(Entry);
|
||||
}
|
||||
|
||||
VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address)
|
||||
VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
||||
{
|
||||
PULONG page_tlb;
|
||||
PULONG page_dir;
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
page_dir = ADDR_TO_PDE(Address);
|
||||
if ((*page_dir) == 0)
|
||||
{
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
return;
|
||||
}
|
||||
page_tlb = ADDR_TO_PTE(Address);
|
||||
if (FreePage)
|
||||
{
|
||||
MmFreePage(PAGE_MASK(*page_tlb),1);
|
||||
}
|
||||
*page_tlb = 0;
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
@ -212,7 +204,7 @@ VOID MmSetPage(PEPROCESS Process,
|
|||
ULONG flProtect,
|
||||
ULONG PhysicalAddress)
|
||||
{
|
||||
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
ULONG Attributes = 0;
|
||||
|
||||
DPRINT("MmSetPage(Process %x, Address %x, flProtect %x, "
|
||||
|
@ -221,13 +213,13 @@ VOID MmSetPage(PEPROCESS Process,
|
|||
|
||||
Attributes = ProtectToPTE(flProtect);
|
||||
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
(*MmGetPageEntry(Address)) = PhysicalAddress | Attributes;
|
||||
FLUSH_TLB;
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
@ -239,17 +231,18 @@ VOID MmSetPageProtect(PEPROCESS Process,
|
|||
{
|
||||
ULONG Attributes = 0;
|
||||
PULONG PageEntry;
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
Attributes = ProtectToPTE(flProtect);
|
||||
|
||||
if (Process != PsGetCurrentProcess())
|
||||
if (Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
PageEntry = MmGetPageEntry(Address);
|
||||
(*PageEntry) = PAGE_MASK(*PageEntry) | Attributes;
|
||||
FLUSH_TLB;
|
||||
if (Process != PsGetCurrentProcess())
|
||||
if (Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
|
|
@ -219,8 +219,7 @@ NTSTATUS STDCALL ZwCreateFile(PHANDLE FileHandle,
|
|||
(*FileHandle) = 0;
|
||||
}
|
||||
|
||||
DPRINT("(*FileHandle) %x\n",(*FileHandle));
|
||||
DPRINT("Finished ZwCreateFile()\n");
|
||||
DPRINT("Finished ZwCreateFile() (*FileHandle) %x\n",(*FileHandle));
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,17 +11,18 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/io.h>
|
||||
|
||||
#define NDEBUG
|
||||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS NtQueryInformationFile(HANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID FileInformation,
|
||||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass)
|
||||
NTSTATUS STDCALL NtQueryInformationFile(HANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID FileInformation,
|
||||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass)
|
||||
{
|
||||
return ZwQueryInformationFile(FileHandle,
|
||||
IoStatusBlock,
|
||||
|
@ -30,11 +31,11 @@ NTSTATUS NtQueryInformationFile(HANDLE FileHandle,
|
|||
FileInformationClass);
|
||||
}
|
||||
|
||||
NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID FileInformation,
|
||||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass)
|
||||
NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID FileInformation,
|
||||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
|
@ -52,11 +53,11 @@ NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
|
|||
/* Get the file object from the file handle */
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_READ_ATTRIBUTES,
|
||||
NULL,
|
||||
IoFileType,
|
||||
UserMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
@ -109,7 +110,58 @@ NTSTATUS ZwSetInformationFile(HANDLE FileHandle,
|
|||
ULONG Length,
|
||||
FILE_INFORMATION_CLASS FileInformationClass)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
KEVENT Event;
|
||||
|
||||
DPRINT("ZwSetInformation(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
|
||||
FileHandle,
|
||||
IoStatusBlock,
|
||||
FileInformation,
|
||||
Length,
|
||||
FileInformationClass);
|
||||
|
||||
/* Get the file object from the file handle */
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_WRITE_ATTRIBUTES,
|
||||
IoFileType,
|
||||
UserMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
DPRINT("FileObject %x\n", FileObject);
|
||||
|
||||
/* initialize an event object to wait on for the request */
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
|
||||
/* build the IRP to be sent to the driver for the request */
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SET_INFORMATION,
|
||||
FileObject->DeviceObject,
|
||||
FileInformation,
|
||||
Length,
|
||||
0,
|
||||
&Event,
|
||||
IoStatusBlock);
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
StackPtr->Parameters.SetFile.Length = Length;
|
||||
StackPtr->Parameters.SetFile.FileInformationClass = FileInformationClass;
|
||||
|
||||
/* Pass the IRP to the FSD (and wait for it if required) */
|
||||
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
|
||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID)
|
||||
|
|
|
@ -175,6 +175,7 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
Irp->Tail.Overlay.CurrentStackLocation--;
|
||||
Irp->CurrentLocation--;
|
||||
|
||||
DPRINT("MajorFunction %d\n",MajorFunction);
|
||||
DPRINT("DriverObject->MajorFunction[param->MajorFunction] %x\n",
|
||||
DriverObject->MajorFunction[param->MajorFunction]);
|
||||
Status = DriverObject->MajorFunction[param->MajorFunction](DeviceObject,
|
||||
|
|
|
@ -71,7 +71,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
|||
UserMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
if (!NT_SUCCESS(STATUS_SUCCESS))
|
||||
{
|
||||
DPRINT("ZwReadFile() = %x\n",Status);
|
||||
return(Status);
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <internal/string.h>
|
||||
#include <internal/symbol.h>
|
||||
#include <internal/teb.h>
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
|
|
|
@ -177,11 +177,12 @@ PVOID MmAllocPage(VOID)
|
|||
ListEntry = ExInterlockedRemoveHeadList(&FreePageListHead,
|
||||
&FreePageListLock);
|
||||
DPRINT("ListEntry %x\n",ListEntry);
|
||||
PageDescriptor = CONTAINING_RECORD(ListEntry, PHYSICAL_PAGE, ListEntry);
|
||||
if (PageDescriptor == NULL)
|
||||
if (ListEntry == NULL)
|
||||
{
|
||||
return(NULL);
|
||||
DbgPrint("MmAllocPage(): Out of memory\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
PageDescriptor = CONTAINING_RECORD(ListEntry, PHYSICAL_PAGE, ListEntry);
|
||||
DPRINT("PageDescriptor %x\n",PageDescriptor);
|
||||
PageDescriptor->Flags = PHYSICAL_PAGE_INUSE;
|
||||
ExInterlockedInsertTailList(&UsedPageListHead, ListEntry,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/stddef.h>
|
||||
#include <internal/mm.h>
|
||||
#include <string.h>
|
||||
|
@ -40,8 +41,206 @@ extern unsigned int end;
|
|||
static BOOLEAN IsThisAnNtAsSystem = FALSE;
|
||||
static MM_SYSTEM_SIZE MmSystemSize = MmSmallSystem;
|
||||
|
||||
extern unsigned int etext;
|
||||
extern unsigned int end;
|
||||
|
||||
static MEMORY_AREA* kernel_text_desc = NULL;
|
||||
static MEMORY_AREA* kernel_data_desc = NULL;
|
||||
static MEMORY_AREA* kernel_param_desc = NULL;
|
||||
static MEMORY_AREA* kernel_pool_desc = NULL;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
void VirtualInit(boot_param* bp)
|
||||
/*
|
||||
* FUNCTION: Intialize the memory areas list
|
||||
* ARGUMENTS:
|
||||
* bp = Pointer to the boot parameters
|
||||
* kernel_len = Length of the kernel
|
||||
*/
|
||||
{
|
||||
unsigned int kernel_len = bp->end_mem - bp->start_mem;
|
||||
PVOID BaseAddress;
|
||||
ULONG Length;
|
||||
ULONG ParamLength = kernel_len;
|
||||
|
||||
DPRINT("VirtualInit() %x\n",bp);
|
||||
|
||||
MmInitMemoryAreas();
|
||||
ExInitNonPagedPool(KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||
|
||||
|
||||
/*
|
||||
* Setup the system area descriptor list
|
||||
*/
|
||||
BaseAddress = (PVOID)KERNEL_BASE;
|
||||
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
|
||||
ParamLength = ParamLength - Length;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_text_desc);
|
||||
|
||||
Length = PAGE_ROUND_UP(((ULONG)&end)) - PAGE_ROUND_UP(((ULONG)&etext));
|
||||
ParamLength = ParamLength - Length;
|
||||
DPRINT("Length %x\n",Length);
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&etext));
|
||||
MmCreateMemoryArea(KernelMode,
|
||||
NULL,
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
&kernel_data_desc);
|
||||
|
||||
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&end));
|
||||
Length = ParamLength;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_param_desc);
|
||||
|
||||
BaseAddress = (PVOID)(KERNEL_BASE + PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||
Length = NONPAGED_POOL_SIZE;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_pool_desc);
|
||||
|
||||
// MmDumpMemoryAreas();
|
||||
CHECKPOINT;
|
||||
|
||||
MmInitSectionImplementation();
|
||||
}
|
||||
|
||||
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||
{
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||
{
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
|
||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||
MemoryArea,Address);
|
||||
|
||||
MmSetPage(NULL,
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
|
||||
LARGE_INTEGER_QUAD_PART(Offset) = (Address - MemoryArea->BaseAddress) +
|
||||
MemoryArea->Data.SectionData.ViewOffset;
|
||||
|
||||
DPRINT("MemoryArea->Data.SectionData.Section->FileObject %x\n",
|
||||
MemoryArea->Data.SectionData.Section->FileObject);
|
||||
|
||||
if (MemoryArea->Data.SectionData.Section->FileObject == NULL)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||
(PVOID)Address,
|
||||
&Offset,
|
||||
&IoStatus);
|
||||
|
||||
DPRINT("Returning from MmSectionHandleFault()\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
asmlinkage int page_fault_handler(unsigned int cs,
|
||||
unsigned int eip)
|
||||
/*
|
||||
* FUNCTION: Handle a page fault
|
||||
*/
|
||||
{
|
||||
KPROCESSOR_MODE FaultMode;
|
||||
MEMORY_AREA* MemoryArea;
|
||||
KIRQL oldlvl;
|
||||
ULONG stat;
|
||||
|
||||
/*
|
||||
* Get the address for the page fault
|
||||
*/
|
||||
unsigned int cr2;
|
||||
__asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
|
||||
DPRINT("Page fault at address %x with eip %x in process %x\n",cr2,eip,
|
||||
PsGetCurrentProcess());
|
||||
|
||||
cr2 = PAGE_ROUND_DOWN(cr2);
|
||||
|
||||
if (KeGetCurrentIrql() != PASSIVE_LEVEL)
|
||||
{
|
||||
DbgPrint("Page fault at high IRQL\n");
|
||||
return(0);
|
||||
// KeBugCheck(0);
|
||||
}
|
||||
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
||||
|
||||
/*
|
||||
* Find the memory area for the faulting address
|
||||
*/
|
||||
if (cr2>=KERNEL_BASE)
|
||||
{
|
||||
/*
|
||||
* Check permissions
|
||||
*/
|
||||
if (cs != KERNEL_CS)
|
||||
{
|
||||
printk("%s:%d\n",__FILE__,__LINE__);
|
||||
return(0);
|
||||
}
|
||||
FaultMode = UserMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
FaultMode = KernelMode;
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),(PVOID)cr2);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
printk("%s:%d\n",__FILE__,__LINE__);
|
||||
return(0);
|
||||
}
|
||||
|
||||
switch (MemoryArea->Type)
|
||||
{
|
||||
case MEMORY_AREA_SYSTEM:
|
||||
stat = 0;
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||
if (MmSectionHandleFault(MemoryArea, (PVOID)cr2)==STATUS_SUCCESS)
|
||||
{
|
||||
stat = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_COMMIT:
|
||||
stat = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
|
||||
break;
|
||||
|
||||
default:
|
||||
stat = 0;
|
||||
break;
|
||||
}
|
||||
DPRINT("Completed page fault handling\n");
|
||||
if (stat)
|
||||
{
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
return(stat);
|
||||
}
|
||||
|
||||
BOOLEAN MmIsThisAnNtAsSystem(VOID)
|
||||
{
|
||||
return(IsThisAnNtAsSystem);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
/* INCLUDE *****************************************************************/
|
||||
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/mmhal.h>
|
||||
#include <internal/ob.h>
|
||||
|
@ -24,206 +23,47 @@
|
|||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* TYPES *******************************************************************/
|
||||
|
||||
extern unsigned int etext;
|
||||
extern unsigned int end;
|
||||
|
||||
static MEMORY_AREA* kernel_text_desc = NULL;
|
||||
static MEMORY_AREA* kernel_data_desc = NULL;
|
||||
static MEMORY_AREA* kernel_param_desc = NULL;
|
||||
static MEMORY_AREA* kernel_pool_desc = NULL;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
void VirtualInit(boot_param* bp)
|
||||
/*
|
||||
* FUNCTION: Intialize the memory areas list
|
||||
* ARGUMENTS:
|
||||
* bp = Pointer to the boot parameters
|
||||
* kernel_len = Length of the kernel
|
||||
*/
|
||||
NTSTATUS MmReleaseMemoryArea(PEPROCESS Process, PMEMORY_AREA Marea)
|
||||
{
|
||||
unsigned int kernel_len = bp->end_mem - bp->start_mem;
|
||||
PVOID BaseAddress;
|
||||
ULONG Length;
|
||||
ULONG ParamLength = kernel_len;
|
||||
ULONG i;
|
||||
PHYSICAL_ADDRESS addr;
|
||||
|
||||
DPRINT("VirtualInit() %x\n",bp);
|
||||
DPRINT("MmReleaseMemoryArea(Process %x, Marea %x)\n",Process,Marea);
|
||||
|
||||
MmInitMemoryAreas();
|
||||
ExInitNonPagedPool(KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||
|
||||
|
||||
/*
|
||||
* Setup the system area descriptor list
|
||||
*/
|
||||
BaseAddress = (PVOID)KERNEL_BASE;
|
||||
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
|
||||
ParamLength = ParamLength - Length;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_text_desc);
|
||||
|
||||
Length = PAGE_ROUND_UP(((ULONG)&end)) - PAGE_ROUND_UP(((ULONG)&etext));
|
||||
ParamLength = ParamLength - Length;
|
||||
DPRINT("Length %x\n",Length);
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&etext));
|
||||
MmCreateMemoryArea(KernelMode,
|
||||
NULL,
|
||||
MEMORY_AREA_SYSTEM,
|
||||
&BaseAddress,
|
||||
Length,
|
||||
0,
|
||||
&kernel_data_desc);
|
||||
|
||||
|
||||
BaseAddress = (PVOID)PAGE_ROUND_UP(((ULONG)&end));
|
||||
Length = ParamLength;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_param_desc);
|
||||
|
||||
BaseAddress = (PVOID)(KERNEL_BASE + PAGE_ROUND_UP(kernel_len) + PAGESIZE);
|
||||
Length = NONPAGED_POOL_SIZE;
|
||||
MmCreateMemoryArea(KernelMode,NULL,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_pool_desc);
|
||||
|
||||
// MmDumpMemoryAreas();
|
||||
CHECKPOINT;
|
||||
|
||||
MmInitSectionImplementation();
|
||||
}
|
||||
|
||||
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||
{
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||
{
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
|
||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||
MemoryArea,Address);
|
||||
|
||||
MmSetPage(NULL,
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
|
||||
LARGE_INTEGER_QUAD_PART(Offset) = (Address - MemoryArea->BaseAddress) +
|
||||
MemoryArea->Data.SectionData.ViewOffset;
|
||||
|
||||
DPRINT("MemoryArea->Data.SectionData.Section->FileObject %x\n",
|
||||
MemoryArea->Data.SectionData.Section->FileObject);
|
||||
|
||||
if (MemoryArea->Data.SectionData.Section->FileObject == NULL)
|
||||
DPRINT("Releasing %x between %x %x\n",
|
||||
Marea, Marea->BaseAddress, Marea->BaseAddress + Marea->Length);
|
||||
for (i=Marea->BaseAddress; i<(Marea->BaseAddress + Marea->Length);
|
||||
i=i+PAGESIZE)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
MmDeletePageEntry(Process, (PVOID)i, TRUE);
|
||||
}
|
||||
|
||||
IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||
(PVOID)Address,
|
||||
&Offset,
|
||||
&IoStatus);
|
||||
|
||||
DPRINT("Returning from MmSectionHandleFault()\n");
|
||||
ExFreePool(Marea);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
asmlinkage int page_fault_handler(unsigned int cs,
|
||||
unsigned int eip)
|
||||
/*
|
||||
* FUNCTION: Handle a page fault
|
||||
*/
|
||||
NTSTATUS MmReleaseMmInfo(PEPROCESS Process)
|
||||
{
|
||||
KPROCESSOR_MODE FaultMode;
|
||||
MEMORY_AREA* MemoryArea;
|
||||
KIRQL oldlvl;
|
||||
ULONG stat;
|
||||
ULONG i,j,addr;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PMEMORY_AREA Current;
|
||||
|
||||
/*
|
||||
* Get the address for the page fault
|
||||
*/
|
||||
unsigned int cr2;
|
||||
__asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
|
||||
DPRINT("Page fault at address %x with eip %x in process %x\n",cr2,eip,
|
||||
PsGetCurrentProcess());
|
||||
|
||||
cr2 = PAGE_ROUND_DOWN(cr2);
|
||||
DPRINT("MmReleaseMmInfo(Process %x)\n",Process);
|
||||
|
||||
if (KeGetCurrentIrql() != PASSIVE_LEVEL)
|
||||
while (!IsListEmpty(&Process->Pcb.MemoryAreaList))
|
||||
{
|
||||
DbgPrint("Page fault at high IRQL\n");
|
||||
return(0);
|
||||
// KeBugCheck(0);
|
||||
}
|
||||
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
||||
|
||||
/*
|
||||
* Find the memory area for the faulting address
|
||||
*/
|
||||
if (cr2>=KERNEL_BASE)
|
||||
{
|
||||
/*
|
||||
* Check permissions
|
||||
*/
|
||||
if (cs != KERNEL_CS)
|
||||
{
|
||||
printk("%s:%d\n",__FILE__,__LINE__);
|
||||
return(0);
|
||||
}
|
||||
FaultMode = UserMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
FaultMode = KernelMode;
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),(PVOID)cr2);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
printk("%s:%d\n",__FILE__,__LINE__);
|
||||
return(0);
|
||||
}
|
||||
|
||||
switch (MemoryArea->Type)
|
||||
{
|
||||
case MEMORY_AREA_SYSTEM:
|
||||
stat = 0;
|
||||
break;
|
||||
CurrentEntry = RemoveHeadList(&Process->Pcb.MemoryAreaList);
|
||||
Current = CONTAINING_RECORD(CurrentEntry, MEMORY_AREA, Entry);
|
||||
|
||||
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||
if (MmSectionHandleFault(MemoryArea, (PVOID)cr2)==STATUS_SUCCESS)
|
||||
{
|
||||
stat = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_COMMIT:
|
||||
stat = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
|
||||
break;
|
||||
|
||||
default:
|
||||
stat = 0;
|
||||
break;
|
||||
MmReleaseMemoryArea(Process, Current);
|
||||
}
|
||||
DPRINT("Completed page fault handling\n");
|
||||
if (stat)
|
||||
{
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
return(stat);
|
||||
|
||||
Mmi386ReleaseMmInfo(Process);
|
||||
|
||||
DPRINT("Finished MmReleaseMmInfo()\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
BOOLEAN MmIsNonPagedSystemAddressValid(PVOID VirtualAddress)
|
||||
|
@ -319,9 +159,9 @@ ZwAllocateVirtualMemory(
|
|||
NTSTATUS Status;
|
||||
|
||||
DPRINT("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||
"ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
|
||||
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
|
||||
Protect);
|
||||
"ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
|
||||
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
|
||||
Protect);
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
|
@ -458,6 +298,11 @@ NTSTATUS STDCALL ZwFreeVirtualMemory(IN HANDLE ProcessHandle,
|
|||
NTSTATUS Status;
|
||||
PEPROCESS Process;
|
||||
|
||||
DPRINT("ZwFreeVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||
"*RegionSize %x, FreeType %x)\n",ProcessHandle,*BaseAddress,
|
||||
*RegionSize,FreeType);
|
||||
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
PsProcessType,
|
||||
|
@ -570,14 +415,14 @@ NTSTATUS STDCALL ZwProtectVirtualMemory(IN HANDLE ProcessHandle,
|
|||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
DbgPrint("ZwProtectVirtualMemory() = %x\n",Status);
|
||||
DPRINT("ZwProtectVirtualMemory() = %x\n",Status);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process,BaseAddress);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
DbgPrint("ZwProtectVirtualMemory() = %x\n",STATUS_UNSUCCESSFUL);
|
||||
DPRINT("ZwProtectVirtualMemory() = %x\n",STATUS_UNSUCCESSFUL);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <internal/ob.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -326,13 +327,15 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
|||
"ObjectType %x, AccessMode %d, Object %x)\n",Handle,DesiredAccess,
|
||||
ObjectType,AccessMode,Object);
|
||||
|
||||
if (Handle == NtCurrentProcess())
|
||||
if (Handle == NtCurrentProcess() &&
|
||||
(ObjectType == PsProcessType || ObjectType == NULL))
|
||||
{
|
||||
BODY_TO_HEADER(PsGetCurrentProcess())->RefCount++;
|
||||
*Object = PsGetCurrentProcess();
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
if (Handle == NtCurrentThread())
|
||||
if (Handle == NtCurrentThread() &&
|
||||
(ObjectType == PsThreadType || ObjectType == NULL))
|
||||
{
|
||||
BODY_TO_HEADER(PsGetCurrentThread())->RefCount++;
|
||||
*Object = PsGetCurrentThread();
|
||||
|
@ -350,7 +353,7 @@ NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
|||
|
||||
if (ObjectType != NULL && ObjectType != ObjectHeader->ObjectType)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
return(STATUS_OBJECT_TYPE_MISMATCH);
|
||||
}
|
||||
|
||||
if (!(HandleRep->GrantedAccess & DesiredAccess))
|
||||
|
|
|
@ -29,7 +29,7 @@ VOID PiDeleteProcess(PVOID ObjectBody)
|
|||
{
|
||||
DPRINT("PiDeleteProcess(ObjectBody %x)\n",ObjectBody);
|
||||
/* FIXME: This doesn't work, why? */
|
||||
// (VOID)MmReleaseMmInfo((PEPROCESS)ObjectBody);
|
||||
(VOID)MmReleaseMmInfo((PEPROCESS)ObjectBody);
|
||||
}
|
||||
|
||||
VOID PsTerminateCurrentThread(NTSTATUS ExitStatus)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue