Compare commits

..

1 Commits

Author SHA1 Message Date
The ReactOS Team
b83808650b This commit was manufactured by cvs2svn to create tag 'ros-0_0_20'.
svn path=/tags/ros-0_0_20/; revision=3317
2002-08-05 19:57:47 +00:00
3695 changed files with 823850 additions and 6183 deletions

View File

@@ -1,2 +0,0 @@
To build this branch apply the patch to trunk. And replace ntoskrnl/mm, ntoskrnl/cc with the folders from here.
This branch currently applies against: 0.3.1 branch - r25940

View File

@@ -1,120 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/cacheman.c
* PURPOSE: Cache manager
*
* PROGRAMMERS: David Welch (welch@cwcom.net)
*/
/* INCLUDES *****************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
PFSN_PREFETCHER_GLOBALS CcPfGlobals;
/* FUNCTIONS *****************************************************************/
VOID
NTAPI
CcPfInitializePrefetcher(VOID)
{
/* Notify debugger */
DbgPrintEx(DPFLTR_PREFETCHER_ID,
DPFLTR_TRACE_LEVEL,
"CCPF: InitializePrefetecher()\n");
/* Setup the Prefetcher Data */
InitializeListHead(&CcPfGlobals.ActiveTraces);
InitializeListHead(&CcPfGlobals.CompletedTraces);
ExInitializeFastMutex(&CcPfGlobals.CompletedTracesLock);
/* FIXME: Setup the rest of the prefetecher */
}
BOOLEAN NTAPI
CcInitializeCacheManager (VOID)
{
CcInitView ();
return TRUE;
}
/*
* @unimplemented
*/
LARGE_INTEGER NTAPI
CcGetFlushedValidData (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN BOOLEAN BcbListHeld)
{
LARGE_INTEGER i;
UNIMPLEMENTED;
i.QuadPart = 0;
return i;
}
/*
* @unimplemented
*/
PVOID NTAPI
CcRemapBcb (IN PVOID Bcb)
{
UNIMPLEMENTED;
return 0;
}
/*
* @unimplemented
*/
VOID NTAPI
CcScheduleReadAhead (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcSetAdditionalCacheAttributes (IN PFILE_OBJECT FileObject,
IN BOOLEAN DisableReadAhead,
IN BOOLEAN DisableWriteBehind)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcSetBcbOwnerPointer (IN PVOID Bcb,
IN PVOID Owner)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcSetDirtyPageThreshold (IN PFILE_OBJECT FileObject,
IN ULONG DirtyPageThreshold)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcSetReadAheadGranularity (IN PFILE_OBJECT FileObject,
IN ULONG Granularity)
{
DPRINT("CcSetReadAheadGranularity(0x%p 0x%x)\n", FileObject, Granularity);
}

616
cc/copy.c
View File

@@ -1,616 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/copy.c
* PURPOSE: Implements cache managers copy interface
*
* PROGRAMMERS:
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/
static PFN_TYPE CcZeroPage = 0;
#define MAX_ZERO_LENGTH (256 * 1024)
#define MAX_RW_LENGTH (256 * 1024)
#if defined(__GNUC__)
/* void * alloca(size_t size); */
#elif defined(_MSC_VER)
void *_alloca (size_t size);
#else
#error Unknown compiler for alloca intrinsic stack allocation "function"
#endif
ULONG CcFastMdlReadWait;
ULONG CcFastMdlReadNotPossible;
ULONG CcFastReadNotPossible;
ULONG CcFastReadWait;
ULONG CcFastReadNoWait;
ULONG CcFastReadResourceMiss;
extern FAST_MUTEX CcCacheViewLock;
extern LIST_ENTRY CcFreeCacheViewListHead;
extern LIST_ENTRY CcInUseCacheViewListHead;
/* FUNCTIONS *****************************************************************/
NTSTATUS NTAPI MmMapViewInSystemCache (PCACHE_VIEW);
VOID NTAPI
CcInitCacheZeroPage (VOID)
{
NTSTATUS Status;
Status = MmRequestPageMemoryConsumer (MC_NPPOOL, TRUE, &CcZeroPage);
if (!NT_SUCCESS (Status))
{
DbgPrint ("Can't allocate CcZeroPage.\n");
KeBugCheck(CACHE_MANAGER);
}
Status = MiZeroPage (CcZeroPage);
if (!NT_SUCCESS (Status))
{
DbgPrint ("Can't zero out CcZeroPage.\n");
KeBugCheck(CACHE_MANAGER);
}
}
/*
* @unimplemented
*/
BOOLEAN NTAPI
CcCanIWrite (IN PFILE_OBJECT FileObject,
IN ULONG BytesToWrite,
IN BOOLEAN Wait,
IN BOOLEAN Retrying)
{
/* Our cache is always ready for writes */
return TRUE;
}
BOOLEAN NTAPI
CcCopyRead (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus)
{
ULONG Index;
PBCB Bcb;
LARGE_INTEGER Offset;
PLIST_ENTRY entry;
PCACHE_VIEW current = NULL;
ULONG CurrentLength;
NTSTATUS Status;
DPRINT ("CcCopyRead(FileObject 0x%p, FileOffset %I64x, "
"Length %d, Wait %d, Buffer 0x%p, IoStatus 0x%p)\n",
FileObject, FileOffset->QuadPart, Length, Wait, Buffer, IoStatus);
if (!Wait)
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_UNSUCCESSFUL;
return FALSE;
}
IoStatus->Information = Length;
IoStatus->Status = STATUS_SUCCESS;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (FileOffset->QuadPart + Length > Bcb->FileSizes.FileSize.QuadPart)
{
KeBugCheck(CACHE_MANAGER);
}
if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) / sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Offset = *FileOffset;
ExAcquireFastMutex (&CcCacheViewLock);
while (Length)
{
Index = Offset.QuadPart / CACHE_VIEW_SIZE;
if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
{
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
Bcb->CacheView[Index]->RefCount++;
}
else
{
if (IsListEmpty (&CcFreeCacheViewListHead))
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
entry = CcFreeCacheViewListHead.Flink;
while (entry != &CcFreeCacheViewListHead)
{
current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
entry = entry->Flink;
if (current->Bcb == NULL)
{
break;
}
}
if (entry == &CcFreeCacheViewListHead)
{
KeBugCheck(CACHE_MANAGER);
}
if (current->Bcb)
{
current->Bcb->CacheView[current->SectionData.ViewOffset / CACHE_VIEW_SIZE] = NULL;
}
Bcb->CacheView[Index] = current;
if (Bcb->CacheView[Index]->Bcb != NULL)
{
DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[Index]->RefCount = 1;
Bcb->CacheView[Index]->Bcb = Bcb;
Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
if (Offset.QuadPart % CACHE_VIEW_SIZE)
{
if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
{
CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
}
else
{
CurrentLength = Length;
}
memcpy (Buffer,
(PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress + Offset.u.LowPart % CACHE_VIEW_SIZE), CurrentLength);
Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
Length -= CurrentLength;
Offset.QuadPart += CurrentLength;
}
else
{
CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
memcpy (Buffer, Bcb->CacheView[Index]->BaseAddress, CurrentLength);
Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
Length -= CurrentLength;
Offset.QuadPart += CurrentLength;
}
ExAcquireFastMutex (&CcCacheViewLock);
Bcb->CacheView[Index]->RefCount--;
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcFreeCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
return TRUE;
}
/*
* @implemented
*/
BOOLEAN NTAPI
CcCopyWrite (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN PVOID Buffer)
{
ULONG Index;
PBCB Bcb;
LARGE_INTEGER Offset;
PLIST_ENTRY entry;
PCACHE_VIEW current = NULL;
ULONG CurrentLength;
NTSTATUS Status;
DPRINT ("CcCopyWrite(FileObject 0x%p, FileOffset %I64x, "
"Length %d, Wait %d, Buffer 0x%p)\n", FileObject, FileOffset->QuadPart, Length, Wait, Buffer);
if (!Wait)
{
return FALSE;
}
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (FileOffset->QuadPart + Length > Bcb->FileSizes.FileSize.QuadPart)
{
KeBugCheck(CACHE_MANAGER);
}
if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) / sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Offset = *FileOffset;
ExAcquireFastMutex (&CcCacheViewLock);
while (Length)
{
Index = Offset.QuadPart / CACHE_VIEW_SIZE;
if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
{
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
Bcb->CacheView[Index]->RefCount++;
}
else
{
if (IsListEmpty (&CcFreeCacheViewListHead))
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
entry = CcFreeCacheViewListHead.Flink;
while (entry != &CcFreeCacheViewListHead)
{
current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
entry = entry->Flink;
if (current->Bcb == NULL)
{
break;
}
}
if (entry == &CcFreeCacheViewListHead)
{
KeBugCheck(CACHE_MANAGER);
}
if (current->Bcb)
{
current->Bcb->CacheView[current->SectionData.ViewOffset / CACHE_VIEW_SIZE] = NULL;
}
Bcb->CacheView[Index] = current;
if (Bcb->CacheView[Index]->Bcb != NULL)
{
DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[Index]->RefCount = 1;
Bcb->CacheView[Index]->Bcb = Bcb;
Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
if (Offset.QuadPart % CACHE_VIEW_SIZE)
{
if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
{
CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
}
else
{
CurrentLength = Length;
}
memcpy ((PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress + Offset.u.LowPart % CACHE_VIEW_SIZE),
Buffer, CurrentLength);
Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
Length -= CurrentLength;
Offset.QuadPart += CurrentLength;
}
else
{
CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
memcpy (Bcb->CacheView[Index]->BaseAddress, Buffer, CurrentLength);
Buffer = (PVOID) ((ULONG_PTR) Buffer + CurrentLength);
Length -= CurrentLength;
Offset.QuadPart += CurrentLength;
}
ExAcquireFastMutex (&CcCacheViewLock);
Bcb->CacheView[Index]->RefCount--;
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcFreeCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
return TRUE;
}
/*
* @unimplemented
*/
VOID NTAPI
CcDeferWrite (IN PFILE_OBJECT FileObject,
IN PCC_POST_DEFERRED_WRITE PostRoutine,
IN PVOID Context1,
IN PVOID Context2,
IN ULONG BytesToWrite,
IN BOOLEAN Retrying)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcFastCopyRead (IN PFILE_OBJECT FileObject,
IN ULONG FileOffset,
IN ULONG Length,
IN ULONG PageCount,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcFastCopyWrite (IN PFILE_OBJECT FileObject,
IN ULONG FileOffset,
IN ULONG Length,
IN PVOID Buffer)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
NTSTATUS NTAPI
CcWaitForCurrentLazyWriterActivity (VOID)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/*
* @implemented
*/
BOOLEAN NTAPI
CcZeroData (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER StartOffset,
IN PLARGE_INTEGER EndOffset,
IN BOOLEAN Wait)
{
NTSTATUS Status;
LARGE_INTEGER WriteOffset;
ULONG Length;
ULONG CurrentLength;
PMDL Mdl;
ULONG i;
IO_STATUS_BLOCK Iosb;
KEVENT Event;
LARGE_INTEGER Offset;
ULONG Index;
DPRINT ("CcZeroData(FileObject 0x%p, StartOffset %I64x, EndOffset %I64x, "
"Wait %d)\n", FileObject, StartOffset->QuadPart, EndOffset->QuadPart, Wait);
Length = EndOffset->u.LowPart - StartOffset->u.LowPart;
WriteOffset.QuadPart = StartOffset->QuadPart;
if (FileObject->SectionObjectPointer->SharedCacheMap == NULL)
{
/* File is not cached */
Mdl = alloca (MmSizeOfMdl (NULL, MAX_ZERO_LENGTH));
while (Length > 0)
{
if (Length + WriteOffset.u.LowPart % PAGE_SIZE > MAX_ZERO_LENGTH)
{
CurrentLength = MAX_ZERO_LENGTH - WriteOffset.u.LowPart % PAGE_SIZE;
}
else
{
CurrentLength = Length;
}
MmInitializeMdl (Mdl, (PVOID) WriteOffset.u.LowPart, CurrentLength);
Mdl->MdlFlags |= (MDL_PAGES_LOCKED | MDL_IO_PAGE_READ);
for (i = 0; i < ((Mdl->Size - sizeof (MDL)) / sizeof (ULONG)); i++)
{
((PPFN_TYPE) (Mdl + 1))[i] = CcZeroPage;
}
KeInitializeEvent (&Event, NotificationEvent, FALSE);
Status = IoSynchronousPageWrite (FileObject, Mdl, &WriteOffset, &Event, &Iosb);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject (&Event, Executive, KernelMode, FALSE, NULL);
Status = Iosb.Status;
}
MmUnmapLockedPages (Mdl->MappedSystemVa, Mdl);
if (!NT_SUCCESS (Status))
{
return (FALSE);
}
WriteOffset.QuadPart += CurrentLength;
Length -= CurrentLength;
}
}
else
{
/* File is cached */
PBCB Bcb;
PCACHE_VIEW current = NULL;
PLIST_ENTRY entry;
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (!Wait)
{
return FALSE;
}
if (EndOffset->QuadPart > Bcb->FileSizes.FileSize.QuadPart)
{
KeBugCheck(CACHE_MANAGER);
}
if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) / sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Offset = *StartOffset;
Length = EndOffset->QuadPart - StartOffset->QuadPart;
ExAcquireFastMutex (&CcCacheViewLock);
while (Length)
{
Index = Offset.QuadPart / CACHE_VIEW_SIZE;
if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
{
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
Bcb->CacheView[Index]->RefCount++;
}
else
{
if (IsListEmpty (&CcFreeCacheViewListHead))
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
entry = CcFreeCacheViewListHead.Flink;
while (entry != &CcFreeCacheViewListHead)
{
current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
entry = entry->Flink;
if (current->Bcb == NULL)
{
break;
}
}
if (entry == &CcFreeCacheViewListHead)
{
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[Index] = current;
if (Bcb->CacheView[Index]->Bcb != NULL)
{
DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[Index]->RefCount = 1;
Bcb->CacheView[Index]->Bcb = Bcb;
Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
if (Offset.QuadPart % CACHE_VIEW_SIZE)
{
if (Length > CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE)
{
CurrentLength = CACHE_VIEW_SIZE - Offset.u.LowPart % CACHE_VIEW_SIZE;
}
else
{
CurrentLength = Length;
}
memset ((PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress + Offset.u.LowPart % CACHE_VIEW_SIZE), 0,
CurrentLength);
Length -= CurrentLength;
Offset.QuadPart += CurrentLength;
}
else
{
CurrentLength = Length > CACHE_VIEW_SIZE ? CACHE_VIEW_SIZE : Length;
memset (Bcb->CacheView[Index]->BaseAddress, 0, CurrentLength);
Length -= CurrentLength;
Offset.QuadPart += CurrentLength;
}
ExAcquireFastMutex (&CcCacheViewLock);
Bcb->CacheView[Index]->RefCount--;
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcFreeCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
}
return (TRUE);
}

189
cc/fs.c
View File

@@ -1,189 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/fs.c
* PURPOSE: Implements cache managers functions useful for File Systems
*
* PROGRAMMERS: Alex Ionescu
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
#ifndef ROUND_DOWN
#define ROUND_DOWN(X,Y) ((X) & ~((Y) - 1))
#endif
/* GLOBALS *****************************************************************/
extern PCACHE_VIEW CcCacheViewArray;
extern ULONG CcCacheViewArrayCount;
extern FAST_MUTEX CcCacheViewLock;
NTSTATUS NTAPI MmUnmapViewInSystemCache (PCACHE_VIEW);
NTSTATUS NTAPI MmChangeSectionSize (PSECTION_OBJECT Section, PLARGE_INTEGER NewMaxSize);
/* FUNCTIONS *****************************************************************/
/*
* @unimplemented
*/
LARGE_INTEGER NTAPI
CcGetDirtyPages (IN PVOID LogHandle,
IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine,
IN PVOID Context1,
IN PVOID Context2)
{
LARGE_INTEGER i;
UNIMPLEMENTED;
i.QuadPart = 0;
return i;
}
/*
* @implemented
*/
PFILE_OBJECT NTAPI
CcGetFileObjectFromBcb (IN PVOID Bcb)
{
PINTERNAL_BCB iBcb = (PINTERNAL_BCB) Bcb;
return iBcb->Bcb->FileObject;
}
/*
* @unimplemented
*/
LARGE_INTEGER NTAPI
CcGetLsnForFileObject (IN PFILE_OBJECT FileObject,
OUT PLARGE_INTEGER OldestLsn OPTIONAL)
{
LARGE_INTEGER i;
UNIMPLEMENTED;
i.QuadPart = 0;
return i;
}
/*
* @unimplemented
*/
BOOLEAN NTAPI
CcIsThereDirtyData (IN PVPB Vpb)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
BOOLEAN NTAPI
CcPurgeCacheSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer,
IN PLARGE_INTEGER FileOffset OPTIONAL,
IN ULONG Length,
IN BOOLEAN UninitializeCacheMaps)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @implemented
*/
VOID NTAPI
CcSetFileSizes (IN PFILE_OBJECT FileObject,
IN PCC_FILE_SIZES FileSizes)
{
PBCB Bcb;
NTSTATUS Status;
ULONG i;
DPRINT ("CcSetFileSizes(FileObject 0x%p, FileSizes 0x%p)\n", FileObject, FileSizes);
DPRINT ("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
(ULONG) FileSizes->AllocationSize.QuadPart,
(ULONG) FileSizes->FileSize.QuadPart, (ULONG) FileSizes->ValidDataLength.QuadPart);
DPRINT ("%wZ\n", &FileObject->FileName);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (Bcb == NULL)
{
return;
}
DPRINT ("AllocationSize %d, FileSize %d, ValidDataLength %d\n",
(ULONG) Bcb->FileSizes.AllocationSize.QuadPart,
(ULONG) Bcb->FileSizes.FileSize.QuadPart, (ULONG) Bcb->FileSizes.ValidDataLength.QuadPart);
ExAcquireFastMutex (&CcCacheViewLock);
DPRINT ("%d\n", Bcb->FileSizes.FileSize.u.LowPart);
for (i = ROUND_DOWN (FileSizes->AllocationSize.QuadPart, CACHE_VIEW_SIZE) / CACHE_VIEW_SIZE;
i < ROUND_UP (Bcb->FileSizes.AllocationSize.QuadPart, CACHE_VIEW_SIZE) / CACHE_VIEW_SIZE; i++)
{
if (Bcb->CacheView[i] != NULL)
{
if (Bcb->CacheView[i]->Bcb != Bcb)
{
KeBugCheck(CACHE_MANAGER);
}
if (Bcb->CacheView[i]->RefCount > 0)
{
KeBugCheck(CACHE_MANAGER);
}
Status = MmUnmapViewInSystemCache (Bcb->CacheView[i]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[i]->RefCount = 0;
Bcb->CacheView[i]->Bcb = NULL;
Bcb->CacheView[i] = NULL;
}
}
#if 0
for (i = 0; i < CcCacheViewArrayCount; i++)
{
if (CcCacheViewArray[i].Bcb == Bcb)
{
if (PAGE_ROUND_UP (FileSizes->AllocationSize.QuadPart) <= CcCacheViewArray[i].SectionData.ViewOffset ||
(PAGE_ROUND_UP (FileSizes->AllocationSize.QuadPart) > CcCacheViewArray[i].SectionData.ViewOffset &&
PAGE_ROUND_UP (FileSizes->AllocationSize.QuadPart) <=
CcCacheViewArray[i].SectionData.ViewOffset + CACHE_VIEW_SIZE))
{
if (CcCacheViewArray[i].RefCount > 0)
{
KeBugCheck(CACHE_MANAGER);
}
Status = MmUnmapViewInSystemCache (&CcCacheViewArray[i]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
CcCacheViewArray[i].RefCount = 0;
CcCacheViewArray[i].Bcb = NULL;
}
}
}
#endif
Status = MmChangeSectionSize ((PSECTION_OBJECT)Bcb->Section, &FileSizes->FileSize);
Bcb->FileSizes = *FileSizes;
ExReleaseFastMutex (&CcCacheViewLock);
}
/*
* @unimplemented
*/
VOID NTAPI
CcSetLogHandleForFile (IN PFILE_OBJECT FileObject,
IN PVOID LogHandle,
IN PFLUSH_TO_LSN FlushToLsnRoutine)
{
UNIMPLEMENTED;
}

169
cc/mdl.c
View File

@@ -1,169 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/fs.c
* PURPOSE: Implements MDL Cache Manager Functions
*
* PROGRAMMERS: Alex Ionescu
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
VOID NTAPI
CcMdlRead (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
OUT PMDL * MdlChain,
OUT PIO_STATUS_BLOCK IoStatus)
{
UNIMPLEMENTED;
}
/*
* NAME INTERNAL
* CcMdlReadCompleteDev@8
*
* DESCRIPTION
*
* ARGUMENTS
* MdlChain
* DeviceObject
*
* RETURN VALUE
* None.
*
* NOTE
* Used by CcMdlReadComplete@8 and FsRtl
*
*/
VOID NTAPI
CcMdlReadCompleteDev (IN PMDL MdlChain,
IN PFILE_OBJECT FileObject)
{
PMDL Mdl;
/* Free MDLs */
while ((Mdl = MdlChain))
{
MdlChain = Mdl->Next;
MmUnlockPages (Mdl);
IoFreeMdl (Mdl);
}
}
/*
* NAME EXPORTED
* CcMdlReadComplete@8
*
* DESCRIPTION
*
* ARGUMENTS
*
* RETURN VALUE
* None.
*
* NOTE
* From Bo Branten's ntifs.h v13.
*
* @implemented
*/
VOID NTAPI
CcMdlReadComplete (IN PFILE_OBJECT FileObject,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
PFAST_IO_DISPATCH FastDispatch;
/* Get Fast Dispatch Data */
DeviceObject = IoGetRelatedDeviceObject (FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlReadComplete)
{
/* Use the fast path */
FastDispatch->MdlReadComplete (FileObject, MdlChain, DeviceObject);
}
/* Use slow path */
CcMdlReadComplete2 (MdlChain, FileObject);
}
/*
* @implemented
*/
VOID NTAPI
CcMdlWriteComplete (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain)
{
PDEVICE_OBJECT DeviceObject = NULL;
PFAST_IO_DISPATCH FastDispatch;
/* Get Fast Dispatch Data */
DeviceObject = IoGetRelatedDeviceObject (FileObject);
FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Check if we support Fast Calls, and check this one */
if (FastDispatch && FastDispatch->MdlWriteComplete)
{
/* Use the fast path */
FastDispatch->MdlWriteComplete (FileObject, FileOffset, MdlChain, DeviceObject);
}
/* Use slow path */
CcMdlWriteComplete2 (FileObject, FileOffset, MdlChain);
}
/*
* @unimplemented
*/
VOID NTAPI
CcMdlReadComplete2 (IN PMDL MemoryDescriptorList,
IN PFILE_OBJECT FileObject)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcMdlWriteComplete2 (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcMdlWriteAbort (IN PFILE_OBJECT FileObject,
IN PMDL MdlChain)
{
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID NTAPI
CcPrepareMdlWrite (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
OUT PMDL * MdlChain,
OUT PIO_STATUS_BLOCK IoStatus)
{
UNIMPLEMENTED;
}

313
cc/pin.c
View File

@@ -1,313 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/pin.c
* PURPOSE: Implements cache managers pinning interface
*
* PROGRAMMERS:
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/
extern NPAGED_LOOKASIDE_LIST iBcbLookasideList;
extern FAST_MUTEX CcCacheViewLock;
extern LIST_ENTRY CcFreeCacheViewListHead;
extern LIST_ENTRY CcInUseCacheViewListHead;
/* FUNCTIONS *****************************************************************/
NTSTATUS NTAPI MmMapViewInSystemCache (PCACHE_VIEW);
/*
* @implemented
*/
BOOLEAN NTAPI
CcMapData (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG Flags,
OUT PVOID * piBcb,
OUT PVOID * pBuffer)
{
PINTERNAL_BCB iBcb;
PBCB Bcb;
ULONG Index;
NTSTATUS Status;
PLIST_ENTRY entry;
PCACHE_VIEW current = NULL;
DPRINT ("CcMapData(FileObject 0x%p, FileOffset %I64x, Length %d,"
" pBcb 0x%p, pBuffer 0x%p)\n", FileObject, FileOffset->QuadPart, Length, piBcb, pBuffer);
ASSERT (FileObject);
ASSERT (FileObject->SectionObjectPointer);
ASSERT (FileObject->SectionObjectPointer->SharedCacheMap);
ASSERT (FileOffset);
ASSERT (piBcb);
ASSERT (pBuffer);
//ASSERT (Flags & MAP_WAIT);
if (!(Flags & MAP_WAIT))
{
DPRINT1("Reading without MAP_WAIT flag!\n");
//*piBcb = NULL;
//*pBuffer = NULL;
//return FALSE;
}
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (FileOffset->QuadPart + Length > Bcb->FileSizes.AllocationSize.QuadPart)
{
DPRINT ("%d %I64d %I64d\n", Length, FileOffset->QuadPart + Length, Bcb->FileSizes.AllocationSize.QuadPart);
// KEBUGCHECK(0);
}
if (FileOffset->QuadPart + Length - ROUND_DOWN (FileOffset->QuadPart, CACHE_VIEW_SIZE) > CACHE_VIEW_SIZE)
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
if (Bcb->FileSizes.AllocationSize.QuadPart > sizeof (Bcb->CacheView) / sizeof (Bcb->CacheView[0]) * CACHE_VIEW_SIZE)
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
ExAcquireFastMutex (&CcCacheViewLock);
Index = FileOffset->QuadPart / CACHE_VIEW_SIZE;
if (Bcb->CacheView[Index] && Bcb->CacheView[Index]->Bcb == Bcb)
{
if (Bcb->CacheView[Index]->RefCount == 0)
{
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
}
Bcb->CacheView[Index]->RefCount++;
}
else
{
if (IsListEmpty (&CcFreeCacheViewListHead))
{
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
entry = CcFreeCacheViewListHead.Flink;
while (entry != &CcFreeCacheViewListHead)
{
current = CONTAINING_RECORD (entry, CACHE_VIEW, ListEntry);
entry = entry->Flink;
if (current->Bcb == NULL)
{
break;
}
}
if (entry == &CcFreeCacheViewListHead)
{
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[Index] = current;
if (Bcb->CacheView[Index]->Bcb != NULL)
{
DPRINT1 ("%x\n", Bcb->CacheView[Index]->Bcb);
/* not implemented */
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[Index]->RefCount = 1;
Bcb->CacheView[Index]->Bcb = Bcb;
Bcb->CacheView[Index]->SectionData.ViewOffset = Index * CACHE_VIEW_SIZE;
Bcb->CacheView[Index]->SectionData.Section = Bcb->Section;
Bcb->CacheView[Index]->SectionData.Segment = Bcb->Section->Segment;
RemoveEntryList (&Bcb->CacheView[Index]->ListEntry);
InsertHeadList (&CcInUseCacheViewListHead, &Bcb->CacheView[Index]->ListEntry);
Status = MmMapViewInSystemCache (Bcb->CacheView[Index]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
}
ExReleaseFastMutex (&CcCacheViewLock);
iBcb = ExAllocateFromNPagedLookasideList (&iBcbLookasideList);
if (iBcb == NULL)
{
KeBugCheck(CACHE_MANAGER);
}
memset (iBcb, 0, sizeof (INTERNAL_BCB));
iBcb->Bcb = Bcb;
iBcb->Index = Index;
*piBcb = iBcb;
*pBuffer = (PVOID) ((ULONG_PTR) Bcb->CacheView[Index]->BaseAddress +
(ULONG_PTR) (FileOffset->QuadPart - Bcb->CacheView[Index]->SectionData.ViewOffset));
DPRINT ("CcMapData() done\n");
return TRUE;
}
/*
* @unimplemented
*/
BOOLEAN NTAPI
CcPinMappedData (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG Flags,
OUT PVOID * Bcb)
{
/* no-op for current implementation. */
return TRUE;
}
/*
* @unimplemented
*/
BOOLEAN NTAPI
CcPinRead (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG Flags,
OUT PVOID * Bcb,
OUT PVOID * Buffer)
{
if (CcMapData (FileObject, FileOffset, Length, Flags, Bcb, Buffer))
{
if (CcPinMappedData (FileObject, FileOffset, Length, Flags, Bcb))
return TRUE;
else
CcUnpinData (Bcb);
}
return FALSE;
}
/*
* @unimplemented
*/
BOOLEAN NTAPI
CcPreparePinWrite (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Zero,
IN ULONG Flags,
OUT PVOID * Bcb,
OUT PVOID * Buffer)
{
/*
* FIXME: This is function is similar to CcPinRead, but doesn't
* read the data if they're not present. Instead it should just
* prepare the cache segments and zero them out if Zero == TRUE.
*
* For now calling CcPinRead is better than returning error or
* just having UNIMPLEMENTED here.
*/
return CcPinRead (FileObject, FileOffset, Length, Flags, Bcb, Buffer);
}
/*
* @implemented
*/
VOID NTAPI
CcSetDirtyPinnedData (IN PVOID Bcb,
IN PLARGE_INTEGER Lsn)
{
// PINTERNAL_BCB iBcb = Bcb;
// iBcb->Dirty = TRUE;
// UNIMPLEMENTED;
}
/*
* @implemented
*/
VOID NTAPI
CcUnpinData (IN PVOID _iBcb)
{
PINTERNAL_BCB iBcb = _iBcb;
DPRINT ("CcUnpinData(%x)\n", _iBcb);
ExAcquireFastMutex (&CcCacheViewLock);
iBcb->Bcb->CacheView[iBcb->Index]->RefCount--;
if (iBcb->Bcb->CacheView[iBcb->Index]->RefCount == 0)
{
RemoveEntryList (&iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
InsertHeadList (&CcFreeCacheViewListHead, &iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
}
ExReleaseFastMutex (&CcCacheViewLock);
ExFreeToNPagedLookasideList (&iBcbLookasideList, iBcb);
DPRINT ("CcUnpinData done\n");
}
/*
* @unimplemented
*/
VOID NTAPI
CcUnpinDataForThread (IN PVOID Bcb,
IN ERESOURCE_THREAD ResourceThreadId)
{
UNIMPLEMENTED;
}
/*
* @implemented
*/
VOID NTAPI
CcRepinBcb (IN PVOID Bcb)
{
#if 0
PINTERNAL_BCB iBcb = Bcb;
// iBcb->RefCount++;
ExAcquireFastMutex (&CcCacheViewLock);
iBcb->Bcb->CacheView[iBcb->Index]->RefCount++;
ExReleaseFastMutex (&CcCacheViewLock);
#endif
}
/*
* @implemented
*/
VOID NTAPI
CcUnpinRepinnedBcb (IN PVOID Bcb,
IN BOOLEAN WriteThrough,
OUT PIO_STATUS_BLOCK IoStatus)
{
#if 0
PINTERNAL_BCB iBcb = Bcb;
DPRINT ("CcUnpinRepinnedBcb(%x)\n", Bcb);
ExAcquireFastMutex (&CcCacheViewLock);
iBcb->Bcb->CacheView[iBcb->Index]->RefCount--;
if (iBcb->Bcb->CacheView[iBcb->Index]->RefCount == 0)
{
RemoveEntryList (&iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
InsertHeadList (&CcFreeCacheViewListHead, &iBcb->Bcb->CacheView[iBcb->Index]->ListEntry);
}
ExReleaseFastMutex (&CcCacheViewLock);
ExFreeToNPagedLookasideList (&iBcbLookasideList, iBcb);
#endif
IoStatus->Status = STATUS_SUCCESS;
DPRINT ("CcUnpinRepinnedBcb done\n");
}

287
cc/view.c
View File

@@ -1,287 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/view.c
* PURPOSE: Cache manager
*
* PROGRAMMERS: David Welch (welch@mcmail.com)
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/
#ifdef ROUND_UP
#undef ROUND_UP
#endif
#ifdef ROUND_DOWN
#undef ROUND_DOWN
#endif
#define ROUND_UP(N, S) (((N) + (S) - 1) & ~((S) - 1))
#define ROUND_DOWN(N, S) ((N) & ~((S) - 1))
NPAGED_LOOKASIDE_LIST iBcbLookasideList;
static NPAGED_LOOKASIDE_LIST BcbLookasideList;
PVOID CcCacheViewBase;
ULONG CcCacheViewArrayCount;
PCACHE_VIEW CcCacheViewArray;
FAST_MUTEX CcCacheViewLock;
LIST_ENTRY CcFreeCacheViewListHead;
LIST_ENTRY CcInUseCacheViewListHead;
PMEMORY_AREA CcCacheViewMemoryArea;
NTSTATUS NTAPI MmCreateDataFileSection (PSECTION_OBJECT * SectionObject,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PLARGE_INTEGER UMaximumSize,
ULONG SectionPageProtection,
ULONG AllocationAttributes,
PFILE_OBJECT FileObject,
BOOLEAN CacheManager);
NTSTATUS NTAPI MmUnmapViewInSystemCache (PCACHE_VIEW);
NTSTATUS MmFlushDataFileSection (PSECTION_OBJECT Section, PLARGE_INTEGER StartOffset, ULONG Length);
/* FUNCTIONS *****************************************************************/
/*
* @implemented
*/
VOID NTAPI
CcFlushCache (IN PSECTION_OBJECT_POINTERS SectionObjectPointers,
IN PLARGE_INTEGER FileOffset OPTIONAL,
IN ULONG Length,
OUT PIO_STATUS_BLOCK IoStatus)
{
PBCB Bcb;
NTSTATUS Status = STATUS_SUCCESS;
DPRINT ("CcFlushCache(SectionObjectPointers 0x%p, FileOffset 0x%p, Length %d, IoStatus 0x%p)\n",
SectionObjectPointers, FileOffset, Length, IoStatus);
if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
{
Bcb = (PBCB) SectionObjectPointers->SharedCacheMap;
ASSERT (Bcb);
Status = MmFlushDataFileSection ((PSECTION_OBJECT)Bcb->Section, FileOffset, Length);
}
if (IoStatus)
{
IoStatus->Status = Status;
IoStatus->Status = STATUS_SUCCESS;
}
}
/*
* @implemented
*/
PFILE_OBJECT NTAPI
CcGetFileObjectFromSectionPtrs (IN PSECTION_OBJECT_POINTERS SectionObjectPointers)
{
PBCB Bcb;
if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
{
Bcb = (PBCB) SectionObjectPointers->SharedCacheMap;
ASSERT (Bcb);
return Bcb->FileObject;
}
return NULL;
}
NTSTATUS
CcTrimMemory (ULONG Target, ULONG Priority, PULONG NrFreedPages)
{
DPRINT1("Trim function for cache memory is not implemented yet.\n");
(*NrFreedPages) = 0;
return STATUS_SUCCESS;
}
VOID INIT_FUNCTION NTAPI
CcInitView (VOID)
{
NTSTATUS Status;
PHYSICAL_ADDRESS BoundaryAddressMultiple;
ULONG i;
ULONG Size;
PVOID Base;
DPRINT ("CcInitView()\n");
ExInitializeFastMutex (&CcCacheViewLock);
ExInitializeNPagedLookasideList (&iBcbLookasideList, NULL, NULL, 0, sizeof (INTERNAL_BCB), TAG_IBCB, 20);
ExInitializeNPagedLookasideList (&BcbLookasideList, NULL, NULL, 0, sizeof (BCB), TAG_BCB, 20);
InitializeListHead (&CcFreeCacheViewListHead);
InitializeListHead (&CcInUseCacheViewListHead);
BoundaryAddressMultiple.QuadPart = 0LL;
Size = MmSystemRangeStart >= (PVOID) 0xC0000000 ? 0x18000000 : 0x20000000;
CcCacheViewBase = (PVOID) (0xF0000000 - Size);
MmLockAddressSpace (MmGetKernelAddressSpace ());
Status = MmCreateMemoryArea (MmGetKernelAddressSpace (),
MEMORY_AREA_CACHE_SEGMENT,
&CcCacheViewBase, Size, 0, &CcCacheViewMemoryArea, FALSE, FALSE, BoundaryAddressMultiple);
MmUnlockAddressSpace (MmGetKernelAddressSpace ());
DPRINT ("CcCacheViewBase: %x\n", CcCacheViewBase);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
CcCacheViewArray = ExAllocatePool (NonPagedPool, sizeof (CACHE_VIEW) * (Size / CACHE_VIEW_SIZE));
if (CcCacheViewArray == NULL)
{
KeBugCheck(CACHE_MANAGER);
}
Base = CcCacheViewBase;
CcCacheViewArrayCount = Size / CACHE_VIEW_SIZE;
for (i = 0; i < CcCacheViewArrayCount; i++)
{
CcCacheViewArray[i].BaseAddress = Base;
CcCacheViewArray[i].RefCount = 0;
CcCacheViewArray[i].Bcb = NULL;
CcCacheViewArray[i].SectionData.ViewOffset = 0;
InsertTailList (&CcFreeCacheViewListHead, &CcCacheViewArray[i].ListEntry);
Base = (PVOID) ((ULONG_PTR) Base + CACHE_VIEW_SIZE);
}
MmInitializeMemoryConsumer(MC_CACHE, CcTrimMemory);
CcInitCacheZeroPage ();
}
VOID NTAPI
CcInitializeCacheMap (IN PFILE_OBJECT FileObject,
IN PCC_FILE_SIZES FileSizes,
IN BOOLEAN PinAccess,
IN PCACHE_MANAGER_CALLBACKS CallBacks,
IN PVOID LazyWriterContext)
{
PBCB Bcb;
NTSTATUS Status;
DPRINT ("CcInitializeCacheMap(), %wZ\n", &FileObject->FileName);
DPRINT ("%I64x (%I64d)\n", FileSizes->FileSize.QuadPart, FileSizes->FileSize.QuadPart);
ASSERT (FileObject);
ASSERT (FileSizes);
ExAcquireFastMutex (&CcCacheViewLock);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (Bcb == NULL)
{
Bcb = ExAllocateFromNPagedLookasideList (&BcbLookasideList);
if (Bcb == NULL)
{
KeBugCheck(CACHE_MANAGER);
}
memset (Bcb, 0, sizeof (BCB));
Bcb->FileObject = FileObject;
Bcb->FileSizes = *FileSizes;
Bcb->PinAccess = PinAccess;
Bcb->CallBacks = CallBacks;
Bcb->LazyWriterContext = LazyWriterContext;
Bcb->RefCount = 0;
DPRINT ("%x %x\n", FileObject, FileSizes->FileSize.QuadPart);
Status = MmCreateDataFileSection ((PSECTION_OBJECT*)&Bcb->Section,
STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE,
NULL, &Bcb->FileSizes.FileSize, PAGE_READWRITE, SEC_COMMIT, Bcb->FileObject, TRUE);
if (!NT_SUCCESS (Status))
{
DPRINT1 ("%x\n", Status);
KeBugCheck(CACHE_MANAGER);
}
FileObject->SectionObjectPointer->SharedCacheMap = Bcb;
}
if (FileObject->PrivateCacheMap == NULL)
{
FileObject->PrivateCacheMap = Bcb;
Bcb->RefCount++;
}
ExReleaseFastMutex (&CcCacheViewLock);
DPRINT ("CcInitializeCacheMap() done\n");
}
BOOLEAN NTAPI
CcUninitializeCacheMap (IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER TruncateSize OPTIONAL,
IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL)
{
PBCB Bcb;
ULONG i;
NTSTATUS Status;
DPRINT ("CcUninitializeCacheMap(), %wZ\n", &FileObject->FileName);
ExAcquireFastMutex (&CcCacheViewLock);
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
if (Bcb)
{
if (FileObject->PrivateCacheMap == Bcb)
{
Bcb->RefCount--;
FileObject->PrivateCacheMap = NULL;
}
if (Bcb->RefCount == 0)
{
Bcb->RefCount++;
ExReleaseFastMutex (&CcCacheViewLock);
MmFlushDataFileSection ((PSECTION_OBJECT)Bcb->Section, NULL, 0);
ExAcquireFastMutex (&CcCacheViewLock);
Bcb->RefCount--;
if (Bcb->RefCount == 0)
{
for (i = 0; i < ROUND_UP (Bcb->FileSizes.AllocationSize.QuadPart, CACHE_VIEW_SIZE) / CACHE_VIEW_SIZE; i++)
{
if (Bcb->CacheView[i] && Bcb->CacheView[i]->Bcb == Bcb)
{
if (Bcb->CacheView[i]->RefCount > 0)
{
KeBugCheck(CACHE_MANAGER);
}
Status = MmUnmapViewInSystemCache (Bcb->CacheView[i]);
if (!NT_SUCCESS (Status))
{
KeBugCheck(CACHE_MANAGER);
}
Bcb->CacheView[i]->RefCount = 0;
Bcb->CacheView[i]->Bcb = NULL;
Bcb->CacheView[i] = NULL;
}
}
DPRINT ("%x\n", Bcb->Section);
ObDereferenceObject (Bcb->Section);
FileObject->SectionObjectPointer->SharedCacheMap = NULL;
ExFreeToNPagedLookasideList (&BcbLookasideList, Bcb);
}
}
}
DPRINT ("CcUninitializeCacheMap() done, %wZ\n", &FileObject->FileName);
ExReleaseFastMutex (&CcCacheViewLock);
return TRUE;
}
/* EOF */

View File

@@ -1,141 +0,0 @@
Index: include/reactos/exeformat.h
===================================================================
--- include/reactos/exeformat.h (revision 34037)
+++ include/reactos/exeformat.h (working copy)
@@ -35,6 +35,7 @@
typedef NTSTATUS (NTAPI * PEXEFMT_CB_READ_FILE)
(
IN PVOID File,
+ ULONG SectorSize,
IN PLARGE_INTEGER Offset,
IN ULONG Length,
OUT PVOID * Data,
Index: ntoskrnl/include/internal/mm.h
===================================================================
--- ntoskrnl/include/internal/mm.h (revision 34040)
+++ ntoskrnl/include/internal/mm.h (working copy)
@@ -187,6 +187,9 @@
ULONG Flags;
ULONG Characteristics;
BOOLEAN WriteCopy;
+ LIST_ENTRY ListEntry;
+ ULONG BytesPerSector;
+ PFILE_OBJECT FileObject;
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
typedef struct _MM_IMAGE_SECTION_OBJECT
@@ -203,6 +206,10 @@
BOOLEAN Executable;
ULONG NrSegments;
ULONG ImageSize;
+ ULONG RefCount;
+ LIST_ENTRY ListEntry;
+ PFILE_OBJECT FileObject;
+ ULONG BytesPerSector;
PMM_SECTION_SEGMENT Segments;
} MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
@@ -221,6 +228,16 @@
};
} ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT;
+typedef struct
+{
+ ROS_SECTION_OBJECT* Section;
+ ULONG ViewOffset;
+ LIST_ENTRY ViewListEntry;
+ PMM_SECTION_SEGMENT Segment;
+// BOOLEAN WriteCopyView;
+ LIST_ENTRY RegionListHead;
+} SECTION_DATA, *PSECTION_DATA;
+
typedef struct _MEMORY_AREA
{
PVOID StartingAddress;
@@ -235,17 +252,10 @@
ULONG PageOpCount;
union
{
+ SECTION_DATA SectionData;
struct
{
- ROS_SECTION_OBJECT* Section;
- ULONG ViewOffset;
- PMM_SECTION_SEGMENT Segment;
- BOOLEAN WriteCopyView;
LIST_ENTRY RegionListHead;
- } SectionData;
- struct
- {
- LIST_ENTRY RegionListHead;
} VirtualMemoryData;
} Data;
} MEMORY_AREA, *PMEMORY_AREA;
Index: ntoskrnl/include/internal/cc.h
===================================================================
--- ntoskrnl/include/internal/cc.h (revision 34040)
+++ ntoskrnl/include/internal/cc.h (working copy)
@@ -102,19 +102,29 @@
LONG ActivePrefetches;
} PFSN_PREFETCHER_GLOBALS, *PPFSN_PREFETCHER_GLOBALS;
+#define CACHE_VIEW_SIZE (128 * 1024) // 128kB
+
+struct _BCB;
+
+typedef struct
+{
+ SECTION_DATA SectionData;
+ PVOID BaseAddress;
+ ULONG RefCount;
+ struct _BCB* Bcb;
+ LIST_ENTRY ListEntry;
+} CACHE_VIEW, *PCACHE_VIEW;
+
typedef struct _BCB
{
- LIST_ENTRY BcbSegmentListHead;
- LIST_ENTRY BcbRemoveListEntry;
- BOOLEAN RemoveOnClose;
- ULONG TimeStamp;
PFILE_OBJECT FileObject;
- ULONG CacheSegmentSize;
- LARGE_INTEGER AllocationSize;
- LARGE_INTEGER FileSize;
- PCACHE_MANAGER_CALLBACKS Callbacks;
- PVOID LazyWriteContext;
- KSPIN_LOCK BcbLock;
+ CC_FILE_SIZES FileSizes;
+ BOOLEAN PinAccess;
+ PCACHE_MANAGER_CALLBACKS CallBacks;
+ PVOID LazyWriterContext;
+ PCACHE_VIEW CacheView[2048];
+ PVOID LargeCacheView;
+ PROS_SECTION_OBJECT Section;
ULONG RefCount;
#if defined(DBG) || defined(KDBG)
BOOLEAN Trace; /* enable extra trace output for this BCB and it's cache segments */
@@ -159,8 +169,8 @@
typedef struct _INTERNAL_BCB
{
PUBLIC_BCB PFCB;
- PCACHE_SEGMENT CacheSegment;
- BOOLEAN Dirty;
+ PBCB Bcb;
+ ULONG Index;
CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
} INTERNAL_BCB, *PINTERNAL_BCB;
Index: drivers/filesystems/fastfat/vfat.h
===================================================================
--- drivers/filesystems/fastfat/vfat.h (revision 34037)
+++ drivers/filesystems/fastfat/vfat.h (working copy)
@@ -6,7 +6,7 @@
#ifdef __GNUC__
#include <ccros.h>
-#define USE_ROS_CC_AND_FS
+//#define USE_ROS_CC_AND_FS
#else
#define KEBUGCHECK KeBugCheck
#define KEBUGCHECKEX KeBugCheckEx

4346
mm.patch

File diff suppressed because it is too large Load Diff

9
reactos/.cvsignore Normal file
View File

@@ -0,0 +1,9 @@
dist
reactos
*.sys
*.exe
*.dll
*.a
*.o
*.d
*.coff

4
reactos/.gdbinit Normal file
View File

@@ -0,0 +1,4 @@
directory /mnt/windows/CvsHome/reactos/ntoskrnl
symbol-file ntoskrnl/ntoskrnl.nostrip.exe -mapped
set remotebaud 115200
target remote com2

340
reactos/COPYING Normal file
View File

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

41
reactos/CREDITS Normal file
View File

@@ -0,0 +1,41 @@
In no particular order
Rex Jolliff (rex@lvcablemodem.com)
Boudewijn Dekker (ariadne@xs4all.nl)
Eric Kohl (ekohl@rz-online.de)
Emanuele Aliberti (ea@iol.it)
David Welch (welch@cwcom.net)
Iwan Fatahi (i_fatahi@hotmail.com)
Robert Bergkvist (fragdance@hotmail.com)
Victor Kirhenshtein (sauros@iname.com)
Jason Filby (jasonfilby@yahoo.com)
Brian Palmer (brianp@sginet.com)
Phillip Susi (phreak@iag.net)
Paolo Pantaleo (paolopan@freemail.it)
Casper S. Hornstrup (chorns@users.sourceforge.net)
Source and inspiration from
WINE (http://www.winehq.com)
WinFree (http://www.stack.nl/~onno/win32/)
Linux (http://www.kernel.org)
References (Rex's at least)
Baker, Art. The Windows NT Device Driver Book. Prentice Hall, 1997.
Borate, Dabak & Phadke. Undocumented Windows NT. M&T Books, 1999.
Brain, Marshall. Win32 System Services. Prentice Hall, 1996.
Cant, Chris. Writing Windows WDM Device Drivers. R&D Books, 1999.
Canton & Sanchez. IBM Microcomputers: A Programmer's Handbook. McGraw Hill, 1990.
Davis & Wallace. Windows Undocumented File Formats. R&D Books, 1997.
Mason & Viscarola. Windows NT Device Driver Development. Macmillan, 1999.
Mitchell, Stan. Inside the Windows 95 File System. O'Reilly, 1997.
Murray, James D. Windows NT Event Logging. O'Reilly, 1998.
Nagar, Rajeev. Windows NT File System Internals. O'Reilly, 1997.
Osbourne, Sandra. Windows NT Registry: A Settings Reference. New Riders, 1998.
Pietrek, Matt. Windows 95 System Programming Secrets. IDG, 1995.
Richter, Jeffery. Advanced Windows, 3rd ed. Microsoft, 1997.
Simon, Richard J. Windows NT Win32 API Superbible. Waite Group, 1996.
Solomon, David A. Inside Windows NT, 2nd Ed. Microsoft, 1998.
"The NT Insider." Open Systems Resources, 1999-2000.

530
reactos/ChangeLog Normal file
View File

@@ -0,0 +1,530 @@
2002-07-13 Casper S. Hornstrup <chorns@users.sourceforge.net>
* rules.mak (RSYM): Define.
* include/ddk/zwtypes.h (DebugDbgLoadSymbols): Add to enum
_DEBUG_CONTROL_CODE.
* include/ntdll/ldr.h (LDR_SYMBOL_INFO, LdrpLoadUserModuleSymbols): Add.
(LdrLoadModuleSymbols): Remove.
* include/ntos/kdbgsyms.h (ST_FILENAME, ST_FUNCTION,
ST_LINENUMBER): Add.
(SYMBOL). Make Name an ANSI_STRING.
(IMAGE_SYMBOL_INFO, AreSymbolsParsed): Add.
* lib/ntdll/ldr/startup.c (LdrInitializeThunk): Call
LdrpLoadUserModuleSymbols() not LdrLoadModuleSymbols().
* lib/ntdll/ldr/utils.c (LdrLoadModuleSymbols): Rename to
LdrpLoadUserModuleSymbols.
(LdrpLoadUserModuleSymbols): Use DebugDbgLoadSymbols debug control code.
(LdrLoadDll): assert if out of memory.
(LdrLoadDll): Call
LdrpLoadUserModuleSymbols(), not LdrLoadModuleSymbols().
* lib/ntdll/string/ctype.c (_pctype): #undef.
* ntoskrnl/dbg/dbgctrl.c (NtSystemDebugControl): Call
LdrLoadUserModuleSymbols on DebugDbgLoadSymbols.
* ntoskrnl/include/internal/ldr.h (LdrGetAddressInformation): Add.
* ntoskrnl/include/internal/module.h (MODULE_TEXT_SECTION): Make SymbolInfo
an IMAGE_SYMBOL_INFO.
* ntoskrnl/ke/i386/exp.c (LdrGetAddressInformation): Add prototype.
(print_address): Change #ifdef KDBG to #ifdef DBG.
(KiDoubleFaultHandler, KiDumpTrapFrame, KeDumpStackFrames): Dump
one stack frame per line.
* ntoskrnl/ke/i386/multiboot.S: Create pagetables for more kernel
address space so larger modules can be passed from the boot loader.
* ntoskrnl/ke/i386/usertrap.c (LdrGetAddressInformation): Add prototype.
(print_user_address): Print symbols using LdrGetAddressInformation().
* ntoskrnl/ldr/loader.c (SYMBOLFILE_HEADER, IMAGE_SYMBOL_INFO_CACHE,
STAB_ENTRY, N_FUN, N_SLINE, N_SO, SymbolListHead): Add.
(TAG_SYM_BUF): Remove.
(LdrInitDebug): Remove unneeded code.
(LdrInit1): Prepare for loading symbols.
(LdrpReadLine, HexL, LdrpParseLine, LdrpLoadModuleSymbolsFromBuffer,
LdrpLoadUserModuleSymbolsFromBuffer): Remove.
(LdrpParseImageSymbols, LdrpGetFileName, LdrpGetFunctionName,
LdrpGetLineNumber, LdrGetAddressInformation, LdrpLookupUserSymbolInfo): Add.
(LdrpLoadModuleSymbols, LdrInitializeBootStartDriver): Change to use new
symbol structures.
(LdrLoadUserModuleSymbols): Cache symbol buffers.
(LdrUnloadModuleSymbols): Implement.
(LdrLoadModule, LdrUnloadModule): Change #ifdef KDBG to #ifdef DBG.
(LdrPEProcessModule): Split a line into two lines.
(LdrPEProcessModule): Setup for loading symbols.
* ntoskrnl/ldr/sysdll.c (LdrpMapSystemDll): Open with FILE_SHARE_READ.
* ntoskrnl/ps/process.c (PiFreeSymbols): Call LdrUnloadModuleSymbols() to
free symbols.
(PiDeleteProcess): Change #ifdef KDBG to #ifdef DBG.
* ntoskrnl/rtl/ctype.c (_pctype): #undef.
* ntoskrnl/rtl/string.c (strncpy): Terminate destination string.
* tools/Makefile (rsym): Add target.
* tools/helper.mk: Include config and use -g if DBG = 1.
2002-07-13 Casper S. Hornstrup <chorns@users.sourceforge.net>
* Makefile (install_before): Install system.hiv to correct location.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* subsys/win32k/include/callback.h: Fixed callback argument
definitions.
* subsys/win32k/ntuser/winpos.c: Implemented some more of the windows
sizing/moving code.
* subsys/win32k/ntuser/painting.c: Implemented some more of the
window painting code.
* subsys/win32k/objects/coord.c: Implemented LPtoDP and DPtoLP.
* subsys/win32k/objects/region.c: Added stubs for some more
region functions.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/ps/process.c (NtCreateProcess): Duplicate the
process desktop handle as well.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/se/token.c: Don't call the ZwXXX variant of
system calls when in system context.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* ntoskrnl/Makefile: Added file with MDA output code.
* ntoskrnl/kd/kdebug.c: Recognize MDA as a destination for
debug output.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* lib/user32/windows/defwnd.c: Implemented some more of the
default window handler.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* lib/user32/misc/stubs.c: Removed some stubs to seperate files.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* lib/user32/user32.def: Export ScreenToClient otherwise we
get problems when code in user32 tries to call it.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* include/win32k/region.h: Added prototypes for some missing
region functions.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* include/win32k/ntuser.h: Added prototypes for some missing
NtUserXXX functions.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* include/user32/wininternal.h: Added some constants for
private GetDCEx styles that WINE needs.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* include/user32/callback.h: Fixed callbacks for messages with
parameters.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* include/napi/win32.h (W32THREAD): Added pointer to the
thread's desktop.
* include/napi/win32.h (W32PROCESS): Removed handle table,
added a pointer to the process's window station.
* subsys/win32k/ntuser/guicheck.c (W32kGuiCheck): Reference
a process's window station on the first win32k system call. Reference
a thread's desktop on the first win32k system call.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* include/messages.h: Added some missing WM_XXX constants.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* drivers/dd/ide/makefile: Compiling with debugging messages
needs libgcc to be linked in.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* iface/addsys/genw32k.c: Generate a variable with the
number of system calls.
* iface/native/genntdll.c: Generate a proper stack frame for
the user system call stubs.
* ntoskrnl/ke/i386/syscall.S: Generate a proper stack frame for
the handler for system calls.
2002-07-04 David Welch <welch@computer2.darkstar.org>
* Makefile: Build the GUI startup application.
* subsys/system/gstart/gstart.c: Application to start up
the GUI.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* tools/helper.mk: Make an import library a proper target
depending on the .def file.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* subsys/win32k/ntuser/window.c (NtUserGetWindowLong): Began
implementation.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* subsys/win32k/misc/object.c (ObmCreateHandle): Return the
correct handle value.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* subsys/win32k/makefile: Make win32k depend on the file containing
the service table.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/stkswitch.S (KeSwitchStackAndRet,
KePushAndStackSwitchAndSysRet): Push one value only.
* ntoskrnl/ps/w32call.c (NtCallbackReturn, NtW32Call): Moved
these functions to a new file. Restore the old trap frame after
returning from a callback.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* lib/user32/windows/message.c (CallWindowProcA, CallWindowProcW):
Convert message to Unicode or ASCII if necessary.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* include/user32/callback.h: Added WM_CREATE and WM_NCCALCSIZE
callbacks.
* lib/user32/windows/window.c (User32SendCREATEMessageForKernel,
User32SendNCCREATEMessageForKernel): Implemented.
* subsys/win32k/ntuser/callback.c (W32kSendCREATEMessage):
Implemented.
2002-06-18 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* include/structs.h: Added Unicode and ASCII versions of
CREATESTRUCT.
2002-06-16 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* tools/helper.mk: Make the install target depend on all the
files to be installed.
2002-06-16 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ps/thread.c (NtCallbackReturn): Set TSS.Esp0 to the
top of the old stack.
* ntoskrnl/ps/thread.c (NtW32Call): Set TSS.Esp0 to the top of
the new stack. Free the callback stack correctly. Don't copy
portion of the trap frame that doesn't exist in non-v86-mode
interrupts.
* ntoskrnl/ps/thread.c (PsFreeCallbackStack): New function to
free a stack allocated with PsAllocateCallbackStack.
2002-06-16 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* drivers/dd/null/makefile: Commented out local LDFLAGS as
these cause bad relocations in the stripped image.
2002-06-16 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* config: Corrected spelling error.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* subsys/system/winlogon/winlogon.c (WinMain): Check for
failure when creating a window system.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ob/handle.c (ObDuplicateObject): Added this internal
function for duplicating objects.
* ntoskrnl/ps/process.c (NtCreateProcess): Duplicate the parent
process's window station to the child process.
* ntoskrnl/ps/process.c (PsInitProcessManagement): Initialize the
first process's window station.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/mm/marea.c (MmCreateMemoryArea): Initialise
page operation structure members.
* ntoskrnl/mm/pageop.c (MmReleasePageOp, MmGetPageOp): Increment
or decrement the page operation count in the memory area.
* ntoskrnl/mm/virtual.c (MmNotPresentFaultVirtualMemory,
MmPageOutVirtualMemory): Check for a deleted memory area before
handling the fault.
* ntoskrnl/mm/virtual.c (MmFreeVirtualMemory): Wait for all
page operations to finish before freeing the memory area.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/syscall.S (interrupt_handler2e): Corrected
test for previous mode, upper 16-bit of CS on the stack after an
interrupt are arbitary.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* lib/user32/misc/winsta.c: Cleaned up indentation.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* apps/tests/winhello/winhello.c (WinMain, MainWndProc):
Cleaned up formatting, some more error checks.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/mm/virtual.c (MmSecureVirtualMemory,
MmUnsecureVirtualMemory, NtQueryVirtualMemory): Corrected indentation.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3
correctly.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/include/internal/ps.h: Added KTHREAD_STACK_LIMIT definition.
* ntoskrnl/ke/i386/tskswitch.S (Ki386ContextSwitch): Force all the
pages of the kernel stack to be accessible from this process.
2002-06-04 David Welch <welch@cwcom.net>
* ntoskrnl/cc/view.c (ReadCacheSegmentChain): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcRosCreateCacheSegment): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/cc/copy.c (CcFreeCachePage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/include/internal/ps.h (KPROCESS): Changed type of
page directory base to PHYSICAL_ADDRESS.
* ntoskrnl/include/internal/i386/mm.h: Changed prototypes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeFreeStackPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kthread.c (KeInitializeThread): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/process.c (KeAttachProcess, KeDetachProcess): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/ke/kernel.c (PcrPages, KeApplicationProcessorInit): Changes
to use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MM_ALLOCATION_REQUEST): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmReleasePageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/balance.c (MmRequestPageMemoryConsumer): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmFreeContinuousPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/cont.c (MmAllocateContinuousAlignedMemory): Changes to
use PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/freelist.c (MmTransferOwnershipPage,
MmGetLRUFirstUserPage, MmGetLRUNextUserPage, MmGetContinuousPages,
MmInitializePageList, MmSetFlagsPage, MmSetRmapListHeadPage,
MmGetRmapListHeadPage, MmMarkPageMapped, MmMarkPageUnmapped,
MmGetFlagsPage, MmSetSavedSwapEntryPage, MmGetSavedSwapEntryPage,
MmReferencePage, MmGetReferenceCountPage, MmIsUsablePage,
MmDereferencePage, MmGetLockCountPage, MmLockPage, MmUnlockPage,
MmAllocPage): Changes to use PHYSICAL_ADDRESS type for physical
addresses.
* ntoskrnl/mm/iospace.c (MmMapIoSpace): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/kmap.c (ExAllocatePage, MiZeroPage, MiCopyFromUserPage,
ExAllocatePageWithPhysPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/marea.c (MmFreeMemoryArea): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mdl.c (MmUnlockPages, MmMapLockedPages,
MmProbeAndLockPages): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/mm.c (MmSharedDataPagePhysicalAddress,
MmCommitPagedPoolAddress, MmNotPresentFault): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/mminit.c (MmInitVirtualMemory): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/ncache.c (MmAllocateNonCachedMemory,
MmFreeNonCachedPage): Changes to use PHYSICAL_ADDRESS type for
physical addresses.
* ntoskrnl/mm/npool.c (grow_kernel_pool): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/rmap.c (MmPageOutPhysicalAddress, MmInsertRmap,
MmDeleteAllRmaps, MmDeleteRmap): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/section.c (MiReadPage, MmNotPresentFaultSectionView,
MmAccessFaultSectionView, MmPageOutDeleteMapping,
MmPageOutSectionView, MmFreeSectionPage): Changes to use
PHYSICAL_ADDRESS type for physical addresses.
* ntoskrnl/mm/slab.c (ExGrowSlabCache): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/virtual.c (MmPageOutVirtualMemory,
MmNotPresentFaultVirtualMemory, MmFreeVirtualMemoryPage): Changes to
use PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/wset.c (MmTrimUserMemory): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/mm/page.c (Mmi386ReleaseMmInfo, MmCopyMmInfo,
MmGetPhysicalAddressForProcess, MmCreateVirtualMapping,
MmCreateVirtualMappingUnsafe, MmCreateVirtualMappingForProcess,
MmDeleteVirtualMapping): Changes to use PHYSICAL_ADDRESS type for
physical address.
* ntoskrnl/ps/process (PsInitProcessManagment): Changes to use
PHYSICAL_ADDRESS type for physical address.
* ntoskrnl/ps/thread.c (PsAllocateCallbackStack): Changes to use
PHYSICAL_ADDRESS type for physical address.
2002-06-04 David Welch <welch@cwcom.net>
* Lots of change since the ChangeLog was last updated.
2001-03-18 David Welch <welch@cwcom.net>
* ntoskrnl/ke/apc.c (KiDeliverApc): Bug fix.
* ntoskrnl/ke/apc.c (KeInsertQueueApc): More comments.
* ntoskrnl/ke/catch.c (KiDispatchException): Bug fix.
* ntoskrnl/ke/timer.c (KeDelayExecutionThread): Don't use removed
function KeAddTimeoutThread.
* ntoskrnl/ke/timer.c (KeAddTimeoutThread): Removed.
* ntoskrnl/ke/wait.c (KeWaitForSingleObject, KeWaitForMultipleObjects):
Don't use KeAddTimeoutThread.
* ntoskrnl/mm/freelist.c (MmAllocateContiguousAlignedMemory): Bug fix
* ntoskrnl/mm/freelist.c (MmAllocatePage): Allocate from the top
memory.
2001-03-17 David Welch <welch@cwcom.net>
* ntoskrnl/ke/catch.c (KiDispatchException): Implementation of
exception handling, user-mode only.
2001-03-16 David Welch <welch@cwcom.net>
* include/ddk/zw.h: Corrected declarations of NtCreateProfile,
NtQueryIntervalProfile, NtSetIntervalProfile.
* include/ddk/zwtypes.h: Added definitions of KPROFILE_SOURCE.
* ntoskrnl/include/internal/ke.h: Added the interrupted EIP as a
parameter to KiUpdateSystemTime for profiling purposes.
* ntoskrnl/include/internal/nt: Added declaration for profiling
support initialization.
* ntoskrnl/ke/timer.c (KiUpdateSystemTime, KeExpireTimers): Call
the profiling code on a timer interrupt with the interrupt EIP.
* ntoskrnl/ke/i386/irq.c (KiDispatchInterrupt): Pass the interrupted
EIP to KiUpdateSystemTime.
* ntoskrnl/mm/virtual.c (NtReadVirtualMemory, NtWriteVirtualMemory):
Release the MDLs used properly.
* ntoskrnl/nt/nt.c: Call the profiling support initialization.
* ntoskrnl/nt/ntevent.c (NtCreateEvent): Don't try copying the
ObjectAttributes parameter if it is NULL.
* ntoskrnl/nt/profile.c: Implemented profiling.
2001-03-16 David Welch <welch@cwcom.net>
* ntoskrnl/include/internal/safe.h: Corrected typo.
* ntoskrnl/nt/ntevent.c (NtCreateEvent, NtOpenEvent, NtQueryEvent):
Corrected typos.
* ntoskrnl/rtl/mem.c: Missing header file.
2001-03-16 David Welch <welch@cwcom.net>
* ntoskrnl/include/internal/safe.h: Add definitions for handling
potentially unsafe pointers.
2001-03-16 David Welch <welch@cwcom.net>
* ntoskrnl/include/internal/mm.h: Removed MmSafeCopyToUser and
MmSafeCopyFromUser as source files need these but don't want internal
mm definitions.
* ntoskrnl/nt/ntevent.c (NtCreateEvent, NtOpenEvent, NtPulseEvent,
NtQueryEvent, NtResetEvent, NtSetEvent): Copy data to and from
user mode safely.
* ntoskrnl/rtl/mem.c (MmCopyToCaller, MmCopyFromCaller): Helper
functions for copying data to and from potentially unsafe pointers.
2000-12-23 David Welch <welch@cwcom.net>
* All task switching is done in software.
* Beginnings of v86 mode support.
2000-12-22 David Welch <welch@cwcom.net>
* ntoskrnl/ps/kill.c (PiTerminateProcessThreads): Drop
PiThreadListLock before calling PsTerminateOtherThread
2000-12-16 David Welch <welch@cwcom.net>
* ntoskrnl/ex/fmutex.c (ExReleaseFastMutexUnsafe): Only set the
fast mutex's owner back to NULL if it is being released
2000-12-10 David Welch <welch@cwcom.net>
* ntoskrnl/ke/i386/vm86_sup.S (Ki386RetToV86Mode): Added function
to do the raw switch to v86 mode.
* ntoskrnl/include/internal/vm86.h: Definitions for the v86 mode
support.
2000-12-10 David Welch <welch@cwcom.net>
* ntoskrnl/ke/i386/trap.s (PsBeginThreadWithContextInternal): Moved
to ntoskrnl/ke/i386/bswitch.S.
* ntoskrnl/ke/i386/trap.s (interrupt_handler2e): Moved to
ntoskrnl/ke/i386/syscall.S.
* ntoskrnl/ke/i386/trap.s (old_interrupt_handler2e): Removed.
2000-12-04 David Welch <welch@cwcom.net>
* ntoskrnl/ke/i386/irq.c (KiInterruptDispatch): Record the last PC
value for a rescheduled thread.
* ntoskrnl/ke/i386/irqhand.s: Construct a primitive trap frame
in interrupt handlers.
2000-08-30 David Welch <welch@cwcom.net>
* Added calibration of KeStallExecutionProcessor timing
(code from linux 2.2.16).
* Corrected compilation bugs in user32 library.
* Corrected compilation bugs related to anonymous structs
in ndis code.
* Pass command line to kernel from loadros.
* Corrected PIC mask calculation.
2000-05-27 David Welch <welch@cwcom.net>
* Fixed issue with closing non-existent or already closed
handle.
2000-01-26 David Welch <welch@cwcom.net>
* ZwCreateProcess now maps ntdll rather than the user-mode
code.
1999-09-06 David Welch <welch@cwcom.net>
* Implemented ZwOpenProcess.
* Partially implemented killing other threads (possible memory
leaks).
* Made a start on a proper implemention of APCs (based on
article in NT insider).
1998-12-08 David Welch <welch@cwcom.net>
* Corrected bug in shell (Read two keypresses and assumed they
where the key going up and down respectively).
* Corrected race in dpc handling.
* Took out cleanup sections in ZwReadFile (now handled by the
APC).
* Disabled broken code in kernel32.

74
reactos/INSTALL Normal file
View File

@@ -0,0 +1,74 @@
1. Build environment
To build the system you need either mingw32 installed on Windows or a mingw32
cross compiler running on unix.
2. Building ReactOS
To build from Windows run 'make' (wihout the quotes) from the top directory.
To build from unix, edit rules.mak and change the PREFIX variable to the
correct value for your cross-compiler, then run 'make'.
3. Installation
The system can only be installed on the first partition on the first harddisk.
The partition must be formatted as FAT16 or FAT32. The system can only be
started from DOS and not from a Windows DOS-prompt.
ReactOS can be installed from the source distribution or from the binary
distribution. The two ways to install ReactOS are explained below.
3.1 Installation from sources
To install ReactOS after building it, type 'make install'. This will create
the directory 'reactos' in the top directory. Copy this directory to the root
of your first partition on your first harddisk. This is usually c:\ on a
Windows machine.
If you don't want to copy the files manually every time you run a 'make install',
you can specify the directory where the files are to be copied to during
installation.
In rules.mak find the variable INSTALL_DIR and change the assigned value to the
name of the directory where the files are to be copied to. If you are using
Windows this could be:
INSTALL_DIR = c:\reactos
If you are on linux this could be:
INSTALL_DIR = /mnt/windows/reactos
Save the changes to rules.mak and run 'make install' to install the files to
the new location.
3.2 Installation from binany distribution
To install ReactOS from the binary distribution, extract the archive contents
to c:\reactos. Remember to extract the files with full paths.
4. Booting ReactOS
Startup in DOS mode. 'cd' to c:\reactos and type 'boot' and press <enter>.
ReactOS will now boot and when it has booted, you are asked for a username and
password. Just press <enter> twice as ReactOS does not currently have user
validation. A simple shell is started where you can use simple commands like
'cd' and 'dir'.
You may also want to try running the enhanced shell, cmd.exe, found in
the rosapps CVS module.
5. Help
If you run into problems or have suggestions for making ReactOS better, please
surf to the address below and subscribe to one or more of the mailing lists.
http://www.reactos.com/index.php?tab=discussion&section=lists
ReactOS Development Team

787
reactos/Makefile Normal file
View File

@@ -0,0 +1,787 @@
#
# Global makefile
#
PATH_TO_TOP = .
#
# Define to build WINE modules
#
ifeq ($(ROS_BUILD_WINE),)
ROS_BUILD_WINE = no
else
ROS_BUILD_WINE = yes
endif
include $(PATH_TO_TOP)/rules.mak
# Required to run the system
COMPONENTS = iface_native iface_additional hallib ntoskrnl
# Hardware Abstraction Layers
# halx86
HALS = halx86
# Bus drivers
# acpi isapnp pci
BUS = acpi isapnp pci
# User mode libraries
# advapi32 crtdll fmifs gdi32 kernel32 libpcap packet msafd msvcrt ntdll ole32
# oleaut32 psapi rpcrt4 secur32 shell32 user32 version ws2help ws2_32 wsock32 wshirda
DLLS = advapi32 crtdll fmifs gdi32 kernel32 packet msafd msvcrt ntdll \
secur32 user32 version ws2help ws2_32 wshirda
SUBSYS = smss win32k csrss
#
# Select the server(s) you want to build
#
#SERVERS = posix linux os2
SERVERS = win32
# Boot loaders
# dos
LOADERS = dos
# Driver support libraries
#bzip2 zlib
DRIVERS_LIB = bzip2 zlib
# Kernel mode device drivers
# beep blue floppy ide keyboard mouse null parallel ramdrv serial vga vidport
DEVICE_DRIVERS = beep blue floppy ide null vga vidport
# Kernel mode input drivers
# keyboard mouclass psaux sermouse
INPUT_DRIVERS = keyboard mouclass psaux
# Kernel mode file system drivers
# cdfs ext2 fs_rec ms np vfat
FS_DRIVERS = cdfs fs_rec ms np vfat mup ntfs
# Kernel mode networking drivers
# afd ndis packet tcpip tdi wshtcpip
NET_DRIVERS = afd ndis packet tcpip tdi wshtcpip
# Kernel mode networking device drivers
# ne2000
NET_DEVICE_DRIVERS = ne2000
# Kernel mode storage drivers
# atapi cdrom class2 disk scsiport
STORAGE_DRIVERS = atapi cdrom class2 disk scsiport
# System applications
# autochk lsass services shell winlogon
SYS_APPS = autochk services shell winlogon gstart
# System services
# rpcss eventlog
SYS_SVC = rpcss eventlog
# Test applications
# alive apc args atomtest bench consume count dump_shared_data
# event file gditest hello isotest lpc mstest mutex nptest
# pteb regtest sectest shm simple thread vmtest winhello
TEST_APPS = alive apc args atomtest bench consume count dump_shared_data \
event file gditest hello isotest lpc mstest mutex nptest \
pteb regtest sectest shm simple thread tokentest vmtest winhello
# Test applications
# cabman cat net objdir partinfo pice ps stats
UTIL_APPS = cat objdir partinfo stats
#
# Win32 Subsystem support (Based on WINE)
# FIXME: Move to this its own Makefile
#
WINE_OTHER = unicode library
WINE_TOOLS = bin2res wrc winebuild
WINE_DLLS = comcat crtdll comctl32 commdlg dsound dplayx imagehlp ole32 richedit \
shlwapi shell32 shdocvw twain urlmon winspool \
rpcrt4 # needed to make rcprt4 implib
# mapi32 oleaut32 oledlg olepro32 olecli olesvr shfolder
# winmm ddraw dinput dplay serialui tapi32 urlmon wintrust
# msinfo lzexpand (missing imports)
WINE_PROGS = control expand osversioncheck regedit regsvr32 winver uninstaller
# (waiting on wrc fix for the rest of these)
# clock cmdlgtst notepad progman wcmd
# winefile winemine winetest uninstaller
ifeq ($(ROS_BUILD_WINE),yes)
WINE_MODULES = $(WINE_OTHER) $(WINE_TOOLS) $(WINE_DLLS) $(WINE_PROGS)
else
WINE_MODULES =
endif
KERNEL_DRIVERS = $(DRIVERS_LIB) $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS) \
$(NET_DRIVERS) $(NET_DEVICE_DRIVERS) $(STORAGE_DRIVERS)
all: tools dk implib $(COMPONENTS) $(HALS) $(BUS) $(DLLS) $(SUBSYS) \
$(LOADERS) $(KERNEL_DRIVERS) $(SYS_APPS) $(SYS_SVC) $(TEST_APPS) \
$(UTIL_APPS) $(WINE_MODULES)
implib: $(COMPONENTS:%=%_implib) $(HALS:%=%_implib) $(BUS:%=%_implib) \
$(DLLS:%=%_implib) $(LOADERS:%=%_implib) \
$(KERNEL_DRIVERS:%=%_implib) $(SUBSYS:%=%_implib) \
$(SYS_APPS:%=%_implib) $(SYS_SVC:%=%_implib) \
$(TEST_APPS:%=%_implib) $(UTIL_APPS:%=%_implib) \
$(WINE_MODULES:%=%_implib)
clean: tools dk_clean $(HALS:%=%_clean) \
$(COMPONENTS:%=%_clean) $(BUS:%=%_clean) $(DLLS:%=%_clean) \
$(LOADERS:%=%_clean) $(KERNEL_DRIVERS:%=%_clean) $(SUBSYS:%=%_clean) \
$(SYS_APPS:%=%_clean) $(SYS_SVC:%=%_clean) $(TEST_APPS:%=%_clean) \
$(UTIL_APPS:%=%_clean) $(NET_APPS:%=%_clean) $(WINE_MODULES:%=%_clean) \
clean_after tools_clean
clean_after:
$(RM) $(PATH_TO_TOP)/include/roscfg.h
install: tools install_dirs install_before \
$(COMPONENTS:%=%_install) $(HALS:%=%_install) $(BUS:%=%_install) \
$(DLLS:%=%_install) $(LOADERS:%=%_install) \
$(KERNEL_DRIVERS:%=%_install) $(SUBSYS:%=%_install) \
$(SYS_APPS:%=%_install) $(SYS_SVC:%=%_install) \
$(TEST_APPS:%=%_install) $(UTIL_APPS:%=%_install) \
$(WINE_MODULES:%=%_install)
dist: $(TOOLS_PATH)/rcopy$(EXE_POSTFIX) dist_clean dist_dirs \
$(HALS:%=%_dist) $(COMPONENTS:%=%_dist) $(BUS:%=%_dist) $(DLLS:%=%_dist) \
$(LOADERS:%=%_dist) $(KERNEL_DRIVERS:%=%_dist) $(SUBSYS:%=%_dist) \
$(SYS_APPS:%=%_dist) $(SYS_SVC:%=%_dist) $(TEST_APPS:%=%_dist) \
$(UTIL_APPS:%=%_dist) $(NET_APPS:%=%_dist) $(WINE_MODULES:%=%_dist)
.PHONY: all implib clean clean_before install dist
#
# System Applications
#
$(SYS_APPS): %:
make -C subsys/system/$*
$(SYS_APPS:%=%_implib): %_implib:
make -C subsys/system/$* implib
$(SYS_APPS:%=%_clean): %_clean:
make -C subsys/system/$* clean
$(SYS_APPS:%=%_dist): %_dist:
make -C subsys/system/$* dist
$(SYS_APPS:%=%_install): %_install:
make -C subsys/system/$* install
.PHONY: $(SYS_APPS) $(SYS_APPS:%=%_implib) $(SYS_APPS:%=%_clean) $(SYS_APPS:%=%_install) $(SYS_APPS:%=%_dist)
#
# System Services
#
$(SYS_SVC): %:
make -C services/$*
$(SYS_SVC:%=%_implib): %_implib:
make -C services/$* implib
$(SYS_SVC:%=%_clean): %_clean:
make -C services/$* clean
$(SYS_SVC:%=%_dist): %_dist:
make -C services/$* dist
$(SYS_SVC:%=%_install): %_install:
make -C services/$* install
.PHONY: $(SYS_SVC) $(SYS_SVC:%=%_implib) $(SYS_SVC:%=%_clean) $(SYS_SVC:%=%_install) $(SYS_SVC:%=%_dist)
#
# Test Applications
#
$(TEST_APPS): %:
make -C apps/tests/$*
$(TEST_APPS:%=%_implib): %_implib:
make -C apps/tests/$* implib
$(TEST_APPS:%=%_clean): %_clean:
make -C apps/tests/$* clean
$(TEST_APPS:%=%_dist): %_dist:
make -C apps/tests/$* dist
$(TEST_APPS:%=%_install): %_install:
make -C apps/tests/$* install
.PHONY: $(TEST_APPS) $(TEST_APPS:%=%_implib) $(TEST_APPS:%=%_clean) $(TEST_APPS:%=%_install) $(TEST_APPS:%=%_dist)
#
# Utility Applications
#
$(UTIL_APPS): %:
make -C apps/utils/$*
$(UTIL_APPS:%=%_implib): %_implib:
make -C apps/utils/$* implib
$(UTIL_APPS:%=%_clean): %_clean:
make -C apps/utils/$* clean
$(UTIL_APPS:%=%_dist): %_dist:
make -C apps/utils/$* dist
$(UTIL_APPS:%=%_install): %_install:
make -C apps/utils/$* install
.PHONY: $(UTIL_APPS) $(UTIL_APPS:%=%_implib) $(UTIL_APPS:%=%_clean) $(UTIL_APPS:%=%_install) $(UTIL_APPS:%=%_dist)
#
# Other Wine Modules
#
$(WINE_OTHER): %:
make -f makefile.ros -C $(WINE_PATH)/$*
$(WINE_OTHER:%=%_implib): %_implib:
make -f makefile.ros -C $(WINE_PATH)/$* implib
$(WINE_OTHER:%=%_clean): %_clean:
make -f makefile.ros -C $(WINE_PATH)/$* clean
$(WINE_OTHER:%=%_dist): %_dist:
make -f makefile.ros -C $(WINE_PATH)/$* dist
$(WINE_OTHER:%=%_install): %_install:
make -f makefile.ros -C $(WINE_PATH)/$* install
.PHONY: $(WINE_OTHER) $(WINE_OTHER:%=%_implib) $(WINE_OTHER:%=%_clean) $(WINE_OTHER:%=%_install) $(WINE_OTHER:%=%_dist)
#
# Wine Tools
#
$(WINE_TOOLS): %:
make -f makefile.ros -C $(WINE_PATH)/tools/$*
$(WINE_TOOLS:%=%_implib): %_implib:
make -f makefile.ros -C $(WINE_PATH)/tools/$* implib
$(WINE_TOOLS:%=%_clean): %_clean:
make -f makefile.ros -C $(WINE_PATH)/tools/$* clean
$(WINE_TOOLS:%=%_dist): %_dist:
make -f makefile.ros -C $(WINE_PATH)/tools/$* dist
$(WINE_TOOLS:%=%_install): %_install:
make -f makefile.ros -C $(WINE_PATH)/tools/$* install
.PHONY: $(WINE_DLLS) $(WINE_DLLS:%=%_implib) $(WINE_DLLS:%=%_clean) $(WINE_DLLS:%=%_install) $(WINE_DLLS:%=%_dist)
#
# Wine DLLs
#
$(WINE_DLLS): %:
make -f makefile.ros -C $(WINE_PATH)/dlls/$*
$(WINE_DLLS:%=%_implib): %_implib:
make -f makefile.ros -C $(WINE_PATH)/dlls/$* implib
$(WINE_DLLS:%=%_clean): %_clean:
make -f makefile.ros -C $(WINE_PATH)/dlls/$* clean
$(WINE_DLLS:%=%_dist): %_dist:
make -f makefile.ros -C $(WINE_PATH)/dlls/$* dist
$(WINE_DLLS:%=%_install): %_install:
make -f makefile.ros -C $(WINE_PATH)/dlls/$* install
.PHONY: $(WINE_DLLS) $(WINE_DLLS:%=%_implib) $(WINE_DLLS:%=%_clean) $(WINE_DLLS:%=%_install) $(WINE_DLLS:%=%_dist)
#
# Wine programs
#
$(WINE_PROGS): %:
make -f makefile.ros -C $(WINE_PATH)/programs/$*
$(WINE_PROGS:%=%_implib): %_implib:
make -f makefile.ros -C $(WINE_PATH)/programs/$* implib
$(WINE_PROGS:%=%_clean): %_clean:
make -f makefile.ros -C $(WINE_PATH)/programs/$* clean
$(WINE_PROGS:%=%_dist): %_dist:
make -f makefile.ros -C $(WINE_PATH)/programs/$* dist
$(WINE_PROGS:%=%_install): %_install:
make -f makefile.ros -C $(WINE_PATH)/programs/$* install
.PHONY: $(WINE_PROGS) $(WINE_PROGS:%=%_implib) $(WINE_PROGS:%=%_clean) $(WINE_PROGS:%=%_install) $(WINE_PROGS:%=%_dist)
#
# Tools
#
tools:
make -C tools
tools_implib:
tools_clean:
make -C tools clean
tools_install:
tools_dist:
.PHONY: tools tools_implib tools_clean tools_install tools_dist
#
# Developer Kits
#
dk:
$(RMKDIR) $(DK_PATH)
$(RMKDIR) $(DDK_PATH)
$(RMKDIR) $(DDK_PATH_LIB)
$(RMKDIR) $(DDK_PATH_INC)
$(RMKDIR) $(SDK_PATH)
$(RMKDIR) $(SDK_PATH_LIB)
$(RMKDIR) $(SDK_PATH_INC)
$(RMKDIR) $(XDK_PATH)
$(RMKDIR) $(XDK_PATH_LIB)
$(RMKDIR) $(XDK_PATH_INC)
dk_implib:
# WARNING! Be very sure that there are no important files
# in these directories before cleaning them!!!
dk_clean:
$(RM) $(DDK_PATH_LIB)/*.a
# $(RM) $(DDK_PATH_INC)/*.h
$(RMDIR) $(DDK_PATH_LIB)
# $(RMDIR) $(DDK_PATH_INC)
$(RM) $(SDK_PATH_LIB)/*.a
# $(RM) $(SDK_PATH_INC)/*.h
$(RMDIR) $(SDK_PATH_LIB)
# $(RMDIR) $(SDK_PATH_INC)
$(RM) $(XDK_PATH_LIB)/*.a
# $(RM) $(XDK_PATH_INC)/*.h
$(RMDIR) $(XDK_PATH_LIB)
# $(RMDIR) $(XDK_PATH_INC)
dk_install:
dk_dist:
.PHONY: dk dk_implib dk_clean dk_install dk_dist
#
# Interfaces
#
iface_native:
make -C iface/native
iface_native_implib:
iface_native_clean:
make -C iface/native clean
iface_native_install:
iface_native_dist:
iface_additional:
make -C iface/addsys
iface_additional_implib:
iface_additional_clean:
make -C iface/addsys clean
iface_additional_install:
iface_additional_dist:
.PHONY: iface_native iface_native_implib iface_native_clean iface_native_install \
iface_native_dist \
iface_additional iface_additional_implib iface_additional_clean \
iface_additional_install iface_additional_dist
#
# Bus driver rules
#
$(BUS): %:
make -C drivers/bus/$*
$(BUS:%=%_implib): %_implib:
make -C drivers/bus/$* implib
$(BUS:%=%_clean): %_clean:
make -C drivers/bus/$* clean
$(BUS:%=%_install): %_install:
make -C drivers/bus/$* install
$(BUS:%=%_dist): %_dist:
make -C drivers/bus/$* dist
.PHONY: $(BUS) $(BUS:%=%_implib) $(BUS:%=%_clean) \
$(BUS:%=%_install) $(BUS:%=%_dist)
#
# Driver support libraries rules
#
$(DRIVERS_LIB): %:
make -C drivers/lib/$*
$(DRIVERS_LIB:%=%_implib): %_implib:
make -C drivers/lib/$* implib
$(DRIVERS_LIB:%=%_clean): %_clean:
make -C drivers/lib/$* clean
$(DRIVERS_LIB:%=%_install): %_install:
make -C drivers/lib/$* install
$(DRIVERS_LIB:%=%_dist): %_dist:
make -C drivers/lib/$* dist
.PHONY: $(DRIVERS_LIB) $(DRIVERS_LIB:%=%_implib) $(DRIVERS_LIB:%=%_clean) \
$(DRIVERS_LIB:%=%_install) $(DRIVERS_LIB:%=%_dist)
#
# Device driver rules
#
$(DEVICE_DRIVERS): %:
make -C drivers/dd/$*
$(DEVICE_DRIVERS:%=%_implib): %_implib:
make -C drivers/dd/$* implib
$(DEVICE_DRIVERS:%=%_clean): %_clean:
make -C drivers/dd/$* clean
$(DEVICE_DRIVERS:%=%_install): %_install:
make -C drivers/dd/$* install
$(DEVICE_DRIVERS:%=%_dist): %_dist:
make -C drivers/dd/$* dist
.PHONY: $(DEVICE_DRIVERS) $(DEVICE_DRIVERS:%=%_implib) $(DEVICE_DRIVERS:%=%_clean) \
$(DEVICE_DRIVERS:%=%_install) $(DEVICE_DRIVERS:%=%_dist)
#
# Input driver rules
#
$(INPUT_DRIVERS): %:
make -C drivers/input/$*
$(INPUT_DRIVERS:%=%_implib): %_implib:
make -C drivers/input/$* implib
$(INPUT_DRIVERS:%=%_clean): %_clean:
make -C drivers/input/$* clean
$(INPUT_DRIVERS:%=%_install): %_install:
make -C drivers/input/$* install
$(INPUT_DRIVERS:%=%_dist): %_dist:
make -C drivers/input/$* dist
.PHONY: $(INPUT_DRIVERS) $(INPUT_DRIVERS:%=%_implib) $(INPUT_DRIVERS:%=%_clean)\
$(INPUT_DRIVERS:%=%_install) $(INPUT_DRIVERS:%=%_dist)
$(FS_DRIVERS): %:
make -C drivers/fs/$*
$(FS_DRIVERS:%=%_implib): %_implib:
make -C drivers/fs/$* implib
$(FS_DRIVERS:%=%_clean): %_clean:
make -C drivers/fs/$* clean
$(FS_DRIVERS:%=%_install): %_install:
make -C drivers/fs/$* install
$(FS_DRIVERS:%=%_dist): %_dist:
make -C drivers/fs/$* dist
.PHONY: $(FS_DRIVERS) $(FS_DRIVERS:%=%_implib) $(FS_DRIVERS:%=%_clean) \
$(FS_DRIVERS:%=%_install) $(FS_DRIVERS:%=%_dist)
#
# Network driver rules
#
$(NET_DRIVERS): %:
make -C drivers/net/$*
$(NET_DRIVERS:%=%_implib): %_implib:
make -C drivers/net/$* implib
$(NET_DRIVERS:%=%_clean): %_clean:
make -C drivers/net/$* clean
$(NET_DRIVERS:%=%_install): %_install:
make -C drivers/net/$* install
$(NET_DRIVERS:%=%_dist): %_dist:
make -C drivers/net/$* dist
.PHONY: $(NET_DRIVERS) $(NET_DRIVERS:%=%_implib) $(NET_DRIVERS:%=%_clean) \
$(NET_DRIVERS:%=%_install) $(NET_DRIVERS:%=%_dist)
$(NET_DEVICE_DRIVERS): %:
make -C drivers/net/dd/$*
$(NET_DEVICE_DRIVERS:%=%_implib): %_implib:
make -C drivers/net/dd/$* implib
$(NET_DEVICE_DRIVERS:%=%_clean): %_clean:
make -C drivers/net/dd/$* clean
$(NET_DEVICE_DRIVERS:%=%_install): %_install:
make -C drivers/net/dd/$* install
$(NET_DEVICE_DRIVERS:%=%_dist): %_dist:
make -C drivers/net/dd/$* dist
.PHONY: $(NET_DEVICE_DRIVERS) $(NET_DEVICE_DRIVERS:%=%_clean) $(NET_DEVICE_DRIVERS:%=%_implib) \
$(NET_DEVICE_DRIVERS:%=%_install) $(NET_DEVICE_DRIVERS:%=%_dist)
#
# storage driver rules
#
$(STORAGE_DRIVERS): %:
make -C drivers/storage/$*
$(STORAGE_DRIVERS:%=%_implib): %_implib:
make -C drivers/storage/$* implib
$(STORAGE_DRIVERS:%=%_clean): %_clean:
make -C drivers/storage/$* clean
$(STORAGE_DRIVERS:%=%_install): %_install:
make -C drivers/storage/$* install
$(STORAGE_DRIVERS:%=%_dist): %_dist:
make -C drivers/storage/$* dist
.PHONY: $(STORAGE_DRIVERS) $(STORAGE_DRIVERS:%=%_clean) \
$(STORAGE_DRIVERS:%=%_install) $(STORAGE_DRIVERS:%=%_dist)
#
# Kernel loaders
#
$(LOADERS): %:
make -C loaders/$*
$(LOADERS:%=%_implib): %_implib:
$(LOADERS:%=%_clean): %_clean:
make -C loaders/$* clean
$(LOADERS:%=%_install): %_install:
make -C loaders/$* install
$(LOADERS:%=%_dist): %_dist:
make -C loaders/$* dist
.PHONY: $(LOADERS) $(LOADERS:%=%_implib) $(LOADERS:%=%_clean) $(LOADERS:%=%_install) \
$(LOADERS:%=%_dist)
#
# Required system components
#
ntoskrnl:
make -C ntoskrnl
ntoskrnl_implib:
make -C ntoskrnl implib
ntoskrnl_clean:
make -C ntoskrnl clean
ntoskrnl_install:
make -C ntoskrnl install
ntoskrnl_dist:
make -C ntoskrnl dist
.PHONY: ntoskrnl ntoskrnl_implib ntoskrnl_clean ntoskrnl_install ntoskrnl_dist
#
# Hardware Abstraction Layer import library
#
hallib:
make -C hal/hal
hallib_implib:
make -C hal/hal implib
hallib_clean:
make -C hal/hal clean
hallib_install:
make -C hal/hal install
hallib_dist:
make -C hal/hal dist
.PHONY: hallib hallib_implib hallib_clean hallib_install hallib_dist
#
# Hardware Abstraction Layers
#
$(HALS): %:
make -C hal/$*
$(HALS:%=%_implib): %_implib:
make -C hal/$* implib
$(HALS:%=%_clean): %_clean:
make -C hal/$* clean
$(HALS:%=%_install): %_install:
make -C hal/$* install
$(HALS:%=%_dist): %_dist:
make -C hal/$* dist
.PHONY: $(HALS) $(HALS:%=%_implib) $(HALS:%=%_clean) $(HALS:%=%_install) $(HALS:%=%_dist)
#
# Required DLLs
#
$(DLLS): %:
make -C lib/$*
$(DLLS:%=%_implib): %_implib:
make -C lib/$* implib
$(DLLS:%=%_clean): %_clean:
make -C lib/$* clean
$(DLLS:%=%_install): %_install:
make -C lib/$* install
$(DLLS:%=%_dist): %_dist:
make -C lib/$* dist
.PHONY: $(DLLS) $(DLLS:%=%_implib) $(DLLS:%=%_clean) $(DLLS:%=%_install) $(DLLS:%=%_dist)
#
# Subsystem support modules
#
$(SUBSYS): %:
make -C subsys/$*
$(SUBSYS:%=%_implib): %_implib:
make -C subsys/$* implib
$(SUBSYS:%=%_clean): %_clean:
make -C subsys/$* clean
$(SUBSYS:%=%_install): %_install:
make -C subsys/$* install
$(SUBSYS:%=%_dist): %_dist:
make -C subsys/$* dist
.PHONY: $(SUBSYS) $(SUBSYS:%=%_implib) $(SUBSYS:%=%_clean) $(SUBSYS:%=%_install) \
$(SUBSYS:%=%_dist)
#
# Create an installation
#
install_clean:
$(RM) $(INSTALL_DIR)/system32/drivers/*.*
$(RM) $(INSTALL_DIR)/system32/config/*.*
$(RM) $(INSTALL_DIR)/system32/*.*
$(RM) $(INSTALL_DIR)/symbols/*.*
$(RM) $(INSTALL_DIR)/media/fonts/*.*
$(RM) $(INSTALL_DIR)/media/*.*
$(RM) $(INSTALL_DIR)/bin/*.*
$(RM) $(INSTALL_DIR)/*.com
$(RM) $(INSTALL_DIR)/*.bat
$(RMDIR) $(INSTALL_DIR)/system32/drivers
$(RMDIR) $(INSTALL_DIR)/system32/config
$(RMDIR) $(INSTALL_DIR)/system32
$(RMDIR) $(INSTALL_DIR)/symbols
$(RMDIR) $(INSTALL_DIR)/media/fonts
$(RMDIR) $(INSTALL_DIR)/media
$(RMDIR) $(INSTALL_DIR)/bin
$(RMDIR) $(INSTALL_DIR)
install_dirs:
$(RMKDIR) $(INSTALL_DIR)
$(RMKDIR) $(INSTALL_DIR)/bin
$(RMKDIR) $(INSTALL_DIR)/media
$(RMKDIR) $(INSTALL_DIR)/media/fonts
$(RMKDIR) $(INSTALL_DIR)/symbols
$(RMKDIR) $(INSTALL_DIR)/system32
$(RMKDIR) $(INSTALL_DIR)/system32/config
$(RMKDIR) $(INSTALL_DIR)/system32/drivers
install_before:
$(CP) bootc.lst $(INSTALL_DIR)/bootc.lst
$(CP) boot.bat $(INSTALL_DIR)/boot.bat
$(CP) aboot.bat $(INSTALL_DIR)/aboot.bat
$(CP) system.hiv $(INSTALL_DIR)/system32/config/system.hiv
$(CP) media/fonts/helb____.ttf $(INSTALL_DIR)/media/fonts/helb____.ttf
$(CP) media/fonts/timr____.ttf $(INSTALL_DIR)/media/fonts/timr____.ttf
.PHONY: install_clean install_dirs install_before
#
# Make a distribution saveset
#
dist_clean:
$(RM) $(DIST_DIR)/symbols/*.sym
$(RM) $(DIST_DIR)/drivers/*.sys
$(RM) $(DIST_DIR)/subsys/*.exe
$(RM) $(DIST_DIR)/dlls/*.dll
$(RM) $(DIST_DIR)/apps/*.exe
$(RM) $(DIST_DIR)/*.exe
$(RMDIR) $(DIST_DIR)/symbols
$(RMDIR) $(DIST_DIR)/subsys
$(RMDIR) $(DIST_DIR)/drivers
$(RMDIR) $(DIST_DIR)/dlls
$(RMDIR) $(DIST_DIR)/apps
$(RMDIR) $(DIST_DIR)
dist_dirs:
$(RMKDIR) $(DIST_DIR)
$(RMKDIR) $(DIST_DIR)/apps
$(RMKDIR) $(DIST_DIR)/dlls
$(RMKDIR) $(DIST_DIR)/drivers
$(RMKDIR) $(DIST_DIR)/subsys
$(RMKDIR) $(DIST_DIR)/symbols
.PHONY: dist_clean dist_dirs
etags:
find . -name "*.[ch]" -print | etags --language=c -
# EOF

15
reactos/NEWS Normal file
View File

@@ -0,0 +1,15 @@
0.0.14: Converted to PE format
All system libraries are now dlls
0.0.13: Mostly bugfixes (I think)
0.0.12: Added support for multiple processes (not really tested)
System calls
kernel32 now compiles (only as a static library)
Fixed invalid tss bug (hopefully)
Added section support
Added some of the ZwxxxVirtual calls
Added prototype caching functions (only the Minix fsd actually
uses them)
Added handle access and type checking
Prototype APC implementation (no support for user APCs)

24
reactos/README Normal file
View File

@@ -0,0 +1,24 @@
About Reactos
1. What is Reactos
A project aiming to make an approximate clone of Windows NT, compatible
with most Windows applications.
The project has a website at http://www.reactos.com/
2. Building Reactos
See the INSTALL file for more details.
3. More information
See the doc subdirectory for some sparse notes
4. Who is responsible
See the CREDITS file
5. Recent developments
See the NEWS file

3
reactos/aboot.bat Normal file
View File

@@ -0,0 +1,3 @@
loadros system32\ntoskrnl.exe system32\hal.dll system32\drivers\acpi.sys /DEBUGPORT=SCREEN bootc.lst
rem comment added and changed for no reason

View File

@@ -0,0 +1,21 @@
# $Id: Makefile,v 1.6 2002/06/02 19:24:57 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = alive
TARGET_SDKLIBS = kernel32.a user32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,48 @@
/* $Id: alive.c,v 1.2 2001/03/26 21:30:20 ea Exp $
*
*/
#include <windows.h>
#include <stdlib.h>
HANDLE StandardOutput = INVALID_HANDLE_VALUE;
CHAR Message [80];
DWORD CharactersToWrite = 0;
DWORD WrittenCharacters = 0;
INT d = 0, h = 0, m = 0, s = 0;
int
main (int argc, char * argv [])
{
StandardOutput = GetStdHandle (STD_OUTPUT_HANDLE);
if (INVALID_HANDLE_VALUE == StandardOutput)
{
return (EXIT_FAILURE);
}
while (TRUE)
{
/* Prepare the message and update it */
CharactersToWrite =
wsprintf (
Message,
"Alive for %dd %dh %d' %d\" \r",
d, h, m, s
);
WriteConsole (
StandardOutput,
Message,
CharactersToWrite,
& WrittenCharacters,
NULL
);
/* suspend the execution for 1s */
Sleep (1000);
/* increment seconds */
++ s;
if (60 == s) { s = 0; ++ m; }
if (60 == m) { m = 0; ++ h; }
if (24 == h) { h = 0; ++ d; }
}
return (EXIT_SUCCESS);
}
/* EOF */

View File

@@ -0,0 +1,87 @@
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#include <ddk/ntddk.h>
HANDLE OutputHandle;
HANDLE InputHandle;
VOID STDCALL
ApcRoutine(PVOID Context,
PIO_STATUS_BLOCK IoStatus,
ULONG Reserved)
{
printf("(apc.exe) ApcRoutine(Context %p)\n", Context);
}
int main(int argc, char* argv[])
{
NTSTATUS Status;
HANDLE FileHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING FileName;
IO_STATUS_BLOCK IoStatus;
CHAR Buffer[256];
HANDLE EventHandle;
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
printf("APC test program\n");
EventHandle = CreateEventW(NULL,
FALSE,
FALSE,
NULL);
if (EventHandle == INVALID_HANDLE_VALUE)
{
printf("Failed to create event\n");
return 0;
}
printf("Opening file\n");
RtlInitUnicodeString(&FileName,
L"\\C:\\a.txt");
InitializeObjectAttributes(&ObjectAttributes,
&FileName,
0,
NULL,
NULL);
printf("Creating file\n");
FileHandle = CreateFileW(L"C:\\a.txt",
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (FileHandle == INVALID_HANDLE_VALUE)
{
printf("Open failed\n");
return 0;
}
printf("Reading file\n");
Status = ZwReadFile(FileHandle,
NULL,
(PIO_APC_ROUTINE)ApcRoutine,
(PVOID)0xdeadbeef,
&IoStatus,
Buffer,
256,
NULL,
NULL);
if (!NT_SUCCESS(Status))
{
printf("Read failed\n");
}
printf("Waiting\n");
WaitForSingleObjectEx(EventHandle, INFINITE, TRUE);
printf("Returned from wait\n");
ZwClose(FileHandle);
printf("Program finished\n");
return 0;
}

View File

@@ -0,0 +1,21 @@
# $Id: makefile,v 1.9 2002/06/02 19:24:57 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = apc
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,39 @@
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int main(int argc, char* argv[])
{
int i;
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
printf("GetCommandLineA() %s\n",GetCommandLineA());
debug_printf("GetCommandLineA() %s\n",GetCommandLineA());
debug_printf("argc %d\n", argc);
for (i=0; i<argc; i++)
{
debug_printf("Argv[%d]: %x\n",i,argv[i]);
debug_printf("Argv[%d]: '%s'\n",i,argv[i]);
}
return 0;
}

View File

@@ -0,0 +1,19 @@
# $Id: makefile,v 1.15 2002/06/02 19:24:57 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = args
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,114 @@
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <ddk/ntddk.h>
#define BUFFER_SIZE 256
int main(int argc, char* argv[])
{
PRTL_ATOM_TABLE AtomTable = NULL;
RTL_ATOM AtomA = -1, AtomB = -1, AtomC = -1;
NTSTATUS Status;
WCHAR Buffer[BUFFER_SIZE];
ULONG NameLength, Data1, Data2;
printf("Atom table test app\n\n");
printf("RtlCreateAtomTable()\n");
Status = RtlCreateAtomTable(37,
&AtomTable);
printf(" Status 0x%08lx\n", Status);
if (NT_SUCCESS(Status))
{
printf(" AtomTable %p\n", AtomTable);
printf("RtlAddAtomToAtomTable()\n");
Status = RtlAddAtomToAtomTable(AtomTable,
L"TestAtomA",
&AtomA);
printf(" Status 0x%08lx\n", Status);
if (NT_SUCCESS(Status))
{
printf(" AtomA 0x%x\n", AtomA);
}
printf("RtlAddAtomToAtomTable()\n");
Status = RtlAddAtomToAtomTable(AtomTable,
L"TestAtomB",
&AtomB);
printf(" Status 0x%08lx\n", Status);
if (NT_SUCCESS(Status))
{
printf(" AtomB 0x%x\n", AtomB);
}
printf("RtlLookupAtomInAtomTable()\n");
Status = RtlLookupAtomInAtomTable(AtomTable,
L"TestAtomA",
&AtomC);
printf(" Status 0x%08lx\n", Status);
if (NT_SUCCESS(Status))
{
printf(" AtomC 0x%x\n", AtomC);
}
printf("RtlPinAtomInAtomTable()\n");
Status = RtlPinAtomInAtomTable(AtomTable,
AtomC);
printf(" Status 0x%08lx\n", Status);
printf("RtlPinAtomInAtomTable()\n");
Status = RtlPinAtomInAtomTable(AtomTable,
AtomC);
printf(" Status 0x%08lx\n", Status);
// printf("RtlDeleteAtomFromAtomTable()\n");
// Status = RtlDeleteAtomFromAtomTable(AtomTable,
// AtomC);
// printf(" Status 0x%08lx\n", Status);
// printf("RtlEmptyAtomTable()\n");
// Status = RtlEmptyAtomTable(AtomTable,
// TRUE);
// printf(" Status 0x%08lx\n", Status);
// printf("RtlLookupAtomInAtomTable()\n");
// Status = RtlLookupAtomInAtomTable(AtomTable,
// L"TestAtomA",
// &AtomC);
// printf(" Status 0x%08lx\n", Status);
printf("RtlQueryAtomInAtomTable()\n");
NameLength = sizeof(WCHAR) * BUFFER_SIZE;
Status = RtlQueryAtomInAtomTable(AtomTable,
AtomC,
&Data1,
&Data2,
Buffer,
&NameLength);
printf(" Status 0x%08lx\n", Status);
if (NT_SUCCESS(Status))
{
printf(" RefCount %ld\n", Data1);
printf(" PinCount %ld\n", Data2);
printf(" NameLength %lu\n", NameLength);
printf(" AtomName: %S\n", Buffer);
}
printf("RtlDestroyAtomTable()\n");
RtlDestroyAtomTable(AtomTable);
printf("Atom table test app finished\n");
}
return(0);
}

View File

@@ -0,0 +1,21 @@
# $Id: makefile,v 1.5 2002/06/02 19:24:57 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = atomtest
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,8 @@
/*
*
*/
int main(int argc, char* argv[])
{
}

View File

@@ -0,0 +1,82 @@
#include <stdio.h>
#include <windows.h>
#define NR_THREADS (30)
DWORD WINAPI
thread_main1(LPVOID param)
{
printf("Thread 1 running (Counter %lu)\n", (DWORD)param);
SleepEx(INFINITE, TRUE);
return 0;
}
DWORD WINAPI
thread_main2(LPVOID param)
{
printf("Thread 2 running (Counter %lu)\n", (DWORD)param);
Sleep(INFINITE);
return 0;
}
int main (void)
{
HANDLE hThread;
DWORD i=0;
DWORD id;
#if 1
printf("Creating %d threads...\n",NR_THREADS*2);
for (i=0;i<NR_THREADS;i++)
{
CreateThread(NULL,
0,
thread_main1,
(LPVOID)i,
0,
&id);
/* CreateThread(NULL,
0,
thread_main2,
(LPVOID)i,
0,
&id);*/
}
printf("All threads created...\n");
/*
* Waiting for threads is not implemented yet.
* If you want to see all threads running, uncomment the
* call to SuspendThread(). The test application will
* freeze after all threads are created.
*/
/* SuspendThread (GetCurrentThread()); */
#else
printf("Creating thread...\n");
hThread = CreateThread(NULL,
0,
thread_main1,
(LPVOID)i,
0,
&id);
printf("Thread created. Waiting for termination...\n");
WaitForSingleObject (hThread,
-1);
CloseHandle (hThread);
printf("Thread terminated...\n");
#endif
printf("Exiting\n");
return 0;
}

View File

@@ -0,0 +1,21 @@
# $Id: makefile,v 1.10 2002/06/02 19:24:57 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = bench-thread
TARGET_SDKLIBS = kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,19 @@
# $Id: Makefile,v 1.7 2002/06/02 19:24:57 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = consume
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <string.h>
#include <windows.h>
#define SIZE (65*1024*1024)
ULONG x[SIZE / 4096];
int main()
{
int i;
PUCHAR BaseAddress;
BaseAddress = VirtualAlloc(NULL,
SIZE,
MEM_COMMIT,
PAGE_READONLY);
if (BaseAddress == NULL)
{
printf("Failed to allocate virtual memory");
return(1);
}
printf("BaseAddress %p\n", BaseAddress);
for (i = 0; i < (SIZE / 4096); i++)
{
printf("%.8x ", i*4096);
x[i] = BaseAddress[i*4096];
}
return(0);
}

View File

@@ -0,0 +1,21 @@
# $Id: Makefile,v 1.6 2002/06/02 19:24:58 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = count
TARGET_SDKLIBS = kernel32.a user32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,15 @@
/* $Id: count.c,v 1.1 2001/03/26 21:30:20 ea Exp $
*
*/
#include <stdlib.h>
int n = 0;
int
main (int argc, char * argv [])
{
while (1) printf ("%d ", n ++ );
return (0);
}
/* EOF */

View File

@@ -0,0 +1,51 @@
#include <stdio.h>
#include <ntddk.h>
int main()
{
int i;
printf("TickCountLow: %x\n",
SharedUserData->TickCountLow);
printf("Drives: ");
for (i = 0; i < 26; i++)
{
printf("%c", (SharedUserData->DosDeviceMap & (1 << i))?'1':'0');
}
printf("\n");
for (i = 0; i < 26; i++)
{
if (SharedUserData->DosDeviceMap & (1 << i))
{
printf("%c: ", 'A'+i);
switch(SharedUserData->DosDeviceDriveType[i])
{
case DOSDEVICE_DRIVE_UNKNOWN:
printf("Unknown\n");
break;
case DOSDEVICE_DRIVE_CALCULATE:
printf("No root\n");
break;
case DOSDEVICE_DRIVE_REMOVABLE:
printf("Removable\n");
break;
case DOSDEVICE_DRIVE_FIXED:
printf("Fixed\n");
break;
case DOSDEVICE_DRIVE_REMOTE:
printf("Remote\n");
break;
case DOSDEVICE_DRIVE_CDROM:
printf("CD-ROM\n");
break;
case DOSDEVICE_DRIVE_RAMDISK:
printf("Ram disk\n");
break;
default:
printf("undefined type\n");
break;
}
}
}
printf("\n\n");
}

View File

@@ -0,0 +1,20 @@
# $Id: makefile,v 1.6 2002/06/02 19:24:58 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = dump_shared_data
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,33 @@
#include <windows.h>
#include <stdio.h>
HANDLE events[2];
DWORD WINAPI thread( LPVOID crap )
{
SetEvent( events[0] );
if( crap )
SetEvent( events[1] );
return 1;
}
int main( void )
{
DWORD id, Status;
printf( "Creating events\n" );
events[0] = CreateEvent( 0, TRUE, FALSE, 0 );
events[1] = CreateEvent( 0, TRUE, FALSE, 0 );
printf( "Created events\n" );
CreateThread( 0, 0, thread, 0, 0, &id );
printf( "WaitForSingleObject %s\n", ( WaitForSingleObject( events[0], INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) );
ResetEvent( events[0] );
CreateThread( 0, 0, thread, 0, 0, &id );
printf( "WaitForMultipleObjects with waitall = FALSE %s\n", ( WaitForMultipleObjects( 2, events, FALSE, INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) );
ResetEvent( events[0] );
CreateThread( 0, 0, thread, (void *)1, 0, &id );
Status = WaitForMultipleObjects( 2, events, TRUE, INFINITE );
printf( "WaitForMultipleObjects with waitall = TRUE %s\n", ( Status == WAIT_OBJECT_0 || Status == WAIT_OBJECT_0 + 1 ? "worked" : "failed" ) );
ResetEvent( events[0] );
printf( "WaitForSingleObject with timeout %s\n", ( WaitForSingleObject( events[0], 100 ) == WAIT_TIMEOUT ? "worked" : "failed" ) );
return 0;
}

View File

@@ -0,0 +1,21 @@
# $Id: makefile,v 1.7 2002/06/02 19:24:58 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = event
TARGET_SDKLIBS = kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,19 @@
# $Id: Makefile,v 1.8 2002/06/02 19:24:58 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = file
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,54 @@
/***********************************************************
* File read/write test utility *
**********************************************************/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
HANDLE file;
char buffer[4096];
DWORD wrote;
int c;
file = CreateFile("test.dat",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
0,
0);
if (file == INVALID_HANDLE_VALUE)
{
printf("Error opening file (Status %x)\n", GetLastError());
return 1;
}
for( c = 0; c < sizeof( buffer ); c++ )
buffer[c] = (char)c;
printf("Writing file\n");
if (WriteFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
printf("Error writing file (Status %x)\n", GetLastError());
exit(2);
}
printf("Reading file\n");
SetFilePointer( file, 0, 0, FILE_BEGIN );
if (ReadFile( file, buffer, 4096, &wrote, NULL) == FALSE)
{
printf("Error reading file (Status %x)\n", GetLastError());
exit(3);
}
for( c = 0; c < sizeof( buffer ); c++ )
if( buffer[c] != (char)c )
{
printf( "Error: data read back is not what was written\n" );
CloseHandle( file );
return 0;
}
printf("Finished, works fine\n");
CloseHandle( file );
return 0;
}

View File

@@ -0,0 +1,328 @@
/*
* gditest
dec 26, 2001 -- gditest bug fix by Richard Campbell
*/
#include <windows.h>
extern BOOL STDCALL GdiDllInitialize(HANDLE hInstance, DWORD Event, LPVOID Reserved);
void __stdcall Background (HDC Desktop)
{
HPEN Pen;
int x, y;
Pen = CreatePen(PS_SOLID, 1, RGB(64, 64, 128));
SelectObject (Desktop, Pen);
MoveToEx (Desktop, 0, 0, NULL);
LineTo (Desktop, 640, 480);
for (y = 479, x = 0; x < 640; x+=2)
{
MoveToEx (Desktop, 0, 0, NULL);
LineTo (Desktop, x, y);
}
for (y = 0, x = 639; y < 480; y+=2)
{
MoveToEx (Desktop, 0, 0, NULL);
LineTo (Desktop, x, y);
}
}
void gditest( void ){
HDC Desktop, MyDC, DC24;
HPEN RedPen, GreenPen, BluePen, WhitePen;
HBITMAP MyBitmap, DIB24;
HFONT hf, tf;
BITMAPINFOHEADER BitInf;
BITMAPINFO BitPalInf;
// Set up a DC called Desktop that accesses DISPLAY
Desktop = CreateDCA("DISPLAY", NULL, NULL, NULL);
if (Desktop == NULL){
printf("Can't create desktop\n");
return;
}
// Background
Background (Desktop);
// Create a blue pen and select it into the DC
BluePen = CreatePen(PS_SOLID, 8, RGB(0, 0, 0xff));
SelectObject(Desktop, BluePen);
// Draw a shape on the DC
MoveToEx(Desktop, 50, 50, NULL);
LineTo(Desktop, 200, 60);
LineTo(Desktop, 200, 300);
LineTo(Desktop, 50, 50);
MoveToEx(Desktop, 50, 50, NULL);
LineTo(Desktop, 200, 50);
WhitePen = CreatePen(PS_SOLID, 3, RGB(0xff, 0xff, 0xff));
SelectObject(Desktop, WhitePen);
MoveToEx(Desktop, 20, 70, NULL);
LineTo(Desktop, 500, 70);
MoveToEx(Desktop, 70, 20, NULL);
LineTo(Desktop, 70, 150);
// Test font support
GreenPen = CreatePen(PS_SOLID, 3, RGB(0, 0xff, 0));
RedPen = CreatePen(PS_SOLID, 3, RGB(0xff, 0, 0));
hf = CreateFontA(24, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Helmet");
SelectObject(Desktop, hf);
SetTextColor(Desktop, RGB(0xff, 0, 0));
TextOutA(Desktop, 70, 70, "React", 5);
SetTextColor(Desktop, RGB(0, 0xff, 0));
TextOutA(Desktop, 140, 70, "OS", 2);
tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
SelectObject(Desktop, tf);
SetTextColor(Desktop, RGB(0xff, 0xff, 0xff));
TextOutA(Desktop, 70, 90, "This is a test of ReactOS text, using the FreeType 2 library!", 61);
// TEST 1: Copy from the VGA into a device compatible DC, draw on it, then blt it to the VGA again
MyDC = CreateCompatibleDC(Desktop);
MyBitmap = CreateCompatibleBitmap(Desktop, 151, 251);
SelectObject(MyDC, MyBitmap);
BitBlt(MyDC, 0, 0, 151, 251, Desktop, 50, 50, SRCCOPY); // can we say 151, 251 since bottom corner is not inclusive?
SelectObject(MyDC, GreenPen);
Rectangle(MyDC, 10, 10, 50, 50);
// TEST 2: Copy from the device compatible DC into a 24BPP bitmap, draw on it, then blt to the VGA again
BitInf.biSize = sizeof(BITMAPINFOHEADER);
BitInf.biWidth = 152;
BitInf.biHeight = -252; // it's top down (since BI_RGB is used, the sign is operative of direction)
BitInf.biPlanes = 1;
BitInf.biBitCount = 24;
BitInf.biCompression = BI_RGB;
BitInf.biSizeImage = 0;
BitInf.biXPelsPerMeter = 0;
BitInf.biYPelsPerMeter = 0;
BitInf.biClrUsed = 0;
BitInf.biClrImportant = 0;
BitPalInf.bmiHeader = BitInf;
DIB24 = (HBITMAP) CreateDIBSection(NULL, &BitPalInf, DIB_RGB_COLORS, NULL, NULL, 0);
DC24 = CreateCompatibleDC(NULL);
SelectObject(DC24, DIB24);
BitBlt(DC24, 0, 0, 101, 201, MyDC, 0, 0, SRCCOPY);
SelectObject(DC24, RedPen);
Rectangle(DC24, 80, 90, 100, 110);
MoveToEx(DC24, 80, 90, NULL);
LineTo(DC24, 100, 110);
BitBlt(Desktop, 200, 200, 110, 120, DC24, 0, 0, SRCCOPY);
Sleep( 10000 ); // fixme delay only 10000 (for 10 seconds)
// Free up everything
DeleteDC(Desktop);
DeleteDC(MyDC);
}
void DumpRgnData( HRGN hRgn )
{
int size, ret, i;
LPRGNDATA rgnData;
size = GetRegionData( hRgn, 0, NULL );
if( size == 0 ){
printf("GetRegionData returned 0\n");
return;
}
rgnData = (LPRGNDATA) malloc( size );
ret = GetRegionData( hRgn, size, rgnData );
if( ret == 0 ){
printf("GetRegionData( hRgn, size, rgnData ) returned 0\n");
return;
}
printf("Bounds: left=%d top=%d right=%d bottom=%d, count: %d, type: %i\n\n",
rgnData->rdh.rcBound.left, rgnData->rdh.rcBound.top, rgnData->rdh.rcBound.right, rgnData->rdh.rcBound.bottom,
rgnData->rdh.nCount, rgnData->rdh.iType);
printf("Rects:\t i \t left \t top \t right \t bottom\n");
for ( i = 0; i < rgnData->rdh.nCount; i++ ) {
PRECT pr = (PRECT) rgnData->Buffer + i;
printf("\t %d \t %d \t %d \t %d \t %d\n", i, pr->left, pr->top, pr->right, pr->bottom );
}
printf("\n");
}
void rgntest( void )
{
HRGN hRgn1, hRgn2, hRgn3;
RECT Rect;
int i;
hRgn1 = CreateRectRgn( 1, 2, 100, 101 );
if( hRgn1 == NULL ) {
printf("Failed at hRgn1 = CreateRectRgn( 1, 2, 100, 101 )\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("GetRgnBox( hRgn1, &Rect ): i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn1 );
hRgn2 = CreateRectRgn( 51, 53, 150, 152 );
if( hRgn2 == NULL ) {
printf("Failed at hRgn2 = CreateRectRgn( 51, 53, 150, 152 )\n");
return;
}
i = GetRgnBox( hRgn2, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn2, &Rect )\n");
return;
}
printf("GetRgnBox( hRgn2, &Rect ): i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn2 );
if( EqualRgn( hRgn1, hRgn2 ) == TRUE ){
printf("\t hRgn1, hRgn2 are equal\n");
}
else{
printf("\t hRgn1, hRgn2 are NOT equal\n\n");
}
i = OffsetRgn(hRgn1,50,51);
if( i==ERROR ){
printf("Failed OffsetRgn(hRgn1,50,51)\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After offset\nGetRgnBox( hRgn1, &Rect ): i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
if( EqualRgn( hRgn1, hRgn2 ) == TRUE ){
printf("\t hRgn1, hRgn2 are equal after offset\n");
}
else{
printf("\t hRgn1, hRgn2 are NOT equal after offset!\n\n");
}
i = SetRectRgn(hRgn1, 10, 11, 110, 111 );
if( i==0 ){
printf("Failed SetRectRgn(hRgn1... )\n");
return;
}
i = GetRgnBox( hRgn1, &Rect );
if( i==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("after SetRectRgn(hRgn1, 10, 11, 110, 111 ):\n i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
hRgn3 = CreateRectRgn( 1, 1, 1, 1);
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_AND ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_OR ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_DIFF );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_DIFF ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_DIFF ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn3, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn3, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn3, hRgn1, hRgn2, RGN_XOR ): \nGetRgnBox( hRgn3, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn3 );
i = CombineRgn( hRgn1, hRgn3, hRgn2, RGN_COPY );
if( i==ERROR ){
printf("Fail: CombineRgn( hRgn1, hRgn3, hRgn2, RGN_COPY ). LastError: %d\n", GetLastError);
return;
}
if( GetRgnBox( hRgn1, &Rect )==0 ){
printf("Failed GetRgnBox( hRgn1, &Rect )\n");
return;
}
printf("After CombineRgn( hRgn1, hRgn3, hRgn2, RGN_COPY ): \nGetRgnBox( hRgn1, &Rect ): CR_i=%d, left=%d top=%d right=%d bottom=%d\n\n",
i, Rect.left, Rect.top, Rect.right, Rect.bottom );
DumpRgnData( hRgn1 );
DeleteObject( hRgn1 );
DeleteObject( hRgn2 );
DeleteObject( hRgn3 );
printf("region test finished\n");
}
int main (int argc, char* argv[])
{
printf("Entering GDITest..\n");
printf("use gditest for older tests\n");
printf("use gditest 1 for region test\n");
GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
if( argc < 2 )
gditest();
else {
if( !strncmp( argv[1], "1", 1 ) ) {
rgntest();
}
}
return 0;
}

View File

@@ -0,0 +1,21 @@
# $Id: makefile,v 1.8 2002/06/02 19:24:58 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = gditest
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,8 @@
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
printf("Hello world\n");
return(0);
}

View File

@@ -0,0 +1,19 @@
# $Id: makefile,v 1.16 2002/06/02 19:24:59 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = hello
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,229 @@
/*
* isotest - display cdrom information
*/
#include <windows.h>
//#include <winioctl.h>
#include <stdio.h>
#include <stdlib.h>
void HexDump(char *buffer, ULONG size)
{
ULONG offset = 0;
unsigned char *ptr;
while (offset < (size & ~15))
{
ptr = (unsigned char*)((ULONG)buffer + offset);
printf("%08lx %02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx-%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
offset,
ptr[0],
ptr[1],
ptr[2],
ptr[3],
ptr[4],
ptr[5],
ptr[6],
ptr[7],
ptr[8],
ptr[9],
ptr[10],
ptr[11],
ptr[12],
ptr[13],
ptr[14],
ptr[15]);
printf(" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
isprint(ptr[0])?ptr[0]:'.',
isprint(ptr[1])?ptr[1]:'.',
isprint(ptr[2])?ptr[2]:'.',
isprint(ptr[3])?ptr[3]:'.',
isprint(ptr[4])?ptr[4]:'.',
isprint(ptr[5])?ptr[5]:'.',
isprint(ptr[6])?ptr[6]:'.',
isprint(ptr[7])?ptr[7]:'.',
isprint(ptr[8])?ptr[8]:'.',
isprint(ptr[9])?ptr[9]:'.',
isprint(ptr[10])?ptr[10]:'.',
isprint(ptr[11])?ptr[11]:'.',
isprint(ptr[12])?ptr[12]:'.',
isprint(ptr[13])?ptr[13]:'.',
isprint(ptr[14])?ptr[14]:'.',
isprint(ptr[15])?ptr[15]:'.');
offset += 16;
}
ptr = (unsigned char*)((ULONG)buffer + offset);
if (offset < size)
{
printf("%08lx ", offset);
while (offset < size)
{
printf(" %02hx", *ptr);
offset++;
ptr++;
}
}
printf("\n\n");
}
#ifndef EVENT_ALL_ACCESS
#define EVENT_ALL_ACCESS (0x1f0003L)
#endif
BOOL
ReadBlock(HANDLE FileHandle,
PVOID Buffer,
PLARGE_INTEGER Offset,
ULONG Length,
PULONG BytesRead)
{
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE EventHandle;
InitializeObjectAttributes(&ObjectAttributes,
NULL, 0, NULL, NULL);
Status = NtCreateEvent(&EventHandle,
EVENT_ALL_ACCESS,
&ObjectAttributes,
TRUE,
FALSE);
if (!NT_SUCCESS(Status))
{
printf("NtCreateEvent() failed\n");
return(FALSE);
}
Status = NtReadFile(FileHandle,
EventHandle,
NULL,
NULL,
&IoStatusBlock,
Buffer,
Length,
Offset,
NULL);
if (Status == STATUS_PENDING)
{
NtWaitForSingleObject(EventHandle, FALSE, NULL);
Status = IoStatusBlock.Status;
}
NtClose(EventHandle);
if (Status != STATUS_PENDING && BytesRead != NULL)
{
*BytesRead = IoStatusBlock.Information;
}
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{
printf("ReadBlock() failed (Status: %lx)\n", Status);
return(FALSE);
}
return(TRUE);
}
int main (int argc, char *argv[])
{
HANDLE hDisk;
DWORD dwRead;
DWORD i;
char *Buffer;
CHAR Filename[80];
LARGE_INTEGER FilePosition;
if (argc != 2)
{
printf("Usage: isotest [Drive:]\n");
return 0;
}
strcpy(Filename, "\\\\.\\");
strcat(Filename, argv[1]);
hDisk = CreateFile(Filename,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hDisk == INVALID_HANDLE_VALUE)
{
printf("CreateFile(): Invalid disk handle!\n");
return 0;
}
Buffer = (char*)malloc(2048);
if (Buffer == NULL)
{
CloseHandle(hDisk);
printf("Out of memory!\n");
return 0;
}
memset(Buffer, 0, 2048);
FilePosition.QuadPart = 16 * 2048;
#if 0
SetLastError(NO_ERROR);
SetFilePointer(hDisk,
FilePosition.u.LowPart,
&FilePosition.u.HighPart,
FILE_BEGIN);
if (GetLastError() != NO_ERROR)
{
CloseHandle(hDisk);
free(Buffer);
printf("SetFilePointer() failed!\n");
return 0;
}
if (ReadFile(hDisk,
Buffer,
2048,
&dwRead,
NULL) == FALSE)
{
CloseHandle(hDisk);
free(Buffer);
printf("ReadFile() failed!\n");
return 0;
}
#endif
if (ReadBlock(hDisk,
Buffer,
&FilePosition,
2048,
&dwRead) == FALSE)
{
CloseHandle(hDisk);
free(Buffer);
#if 0
printf("ReadBlock() failed!\n");
#endif
return 0;
}
HexDump(Buffer, 128);
CloseHandle(hDisk);
free(Buffer);
return 0;
}
/* EOF */

View File

@@ -0,0 +1,23 @@
# $Id: makefile,v 1.2 2002/06/02 19:24:59 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = isotest
#TARGET_CFLAGS = -fnative_struct
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,205 @@
/* $Id: conport.c,v 1.6 2000/04/25 23:22:46 ea Exp $
*
* reactos/apps/lpc/conport.c
*
* To be run in a real WNT 4.0 system with
* "\SmApiPort" as argument. Do not try to
* connect to "\Windows\ApiPort" since that
* reboots immeditely.
*
* Use Russinovich' HandleEx to verify
* conport.exe owns two unnamed LPC ports:
* the one created by kernel32.dll connecting
* to csrss.exe, and one connected to here.
*
* 19990627 (Emanuele Aliberti)
* Initial implementation.
* 19990704 (EA)
* Dump object's attributes moved in dumpinfo.c.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define PROTO_LPC
#include <ddk/ntddk.h>
#include "dumpinfo.h"
#define LPC_CONNECT_FLAG1 0x00000001
#define LPC_CONNECT_FLAG2 0x00000010
#define LPC_CONNECT_FLAG3 0x00000100
#define LPC_CONNECT_FLAG4 0x00001000
#define LPC_CONNECT_FLAG5 0x00010000
NTSTATUS
(STDCALL * ConnectPort)(
OUT PHANDLE PortHandle,
IN PUNICODE_STRING PortName,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN DWORD Unknown3,
IN DWORD Unknown4,
IN DWORD Unknown5,
IN DWORD Unknown6,
IN ULONG Flags
);
NTSTATUS
(STDCALL * QueryObject)(
IN HANDLE ObjectHandle,
IN CINT ObjectInformationClass,
OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
(STDCALL * YieldExecution)(VOID);
#define BUF_SIZE 1024
#define MAXARG 1000000
VOID
TryConnectPort(char *port_name)
{
DWORD Status = 0;
HANDLE Port = 0;
int i;
UNICODE_STRING PortName;
OBJECT_ATTRIBUTES ObjectAttributes;
WORD Name [BUF_SIZE] = {0};
int dwx = 0;
char * port_name_save = port_name;
/*
* Convert the port's name to Unicode.
*/
for (
PortName.Length = 0;
( *port_name
&& (PortName.Length < BUF_SIZE)
);
)
{
Name[PortName.Length++] = (WORD) *port_name++;
}
Name[PortName.Length] = 0;
PortName.Length = PortName.Length * sizeof (WORD);
PortName.MaximumLength = PortName.Length + sizeof (WORD);
PortName.Buffer = (PWSTR) Name;
/*
* Prepare the port object attributes.
*/
ObjectAttributes.Length =
sizeof (OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory =
NULL;
ObjectAttributes.ObjectName =
NULL /*& PortName */;
ObjectAttributes.Attributes =
OBJ_CASE_INSENSITIVE;
ObjectAttributes.SecurityDescriptor =
NULL;
ObjectAttributes.SecurityQualityOfService =
NULL;
/*
* Try to issue a connection request.
*/
Port = 0;
Status = ConnectPort(
& Port, /* & PortHandle */
& PortName, /* & PortName */
& ObjectAttributes, /* & PortAttributes */
NULL, /* & SecurityQos */
NULL, /* & SectionInfo */
NULL, /* & MapInfo */
NULL, /* & MaxMessageSize */
LPC_CONNECT_FLAG5 /* & ConnectInfoLength */
);
if (Status == STATUS_SUCCESS)
{
DumpInfo(
Name,
Status,
"connected",
Port
);
/* Hot waiting */
for (dwx=0; dwx<MAXARG; ++dwx)
{
YieldExecution();
}
if (FALSE == CloseHandle(Port))
{
printf(
"Could not close the port handle %08X.\n",
Port
);
}
return;
}
printf(
"Connection to port \"%s\" failed (Status = %08X).\n",
port_name_save,
Status
);
}
main( int argc, char * argv[] )
{
HINSTANCE ntdll;
if (argc != 2)
{
printf("WNT LPC Port Connector\n");
printf("Usage: %s [port_name]\n",argv[0]);
exit(EXIT_FAILURE);
}
printf("LoadLibrary(NTDLL)\n");
ntdll = LoadLibrary("NTDLL");
if (ntdll == NULL)
{
printf("Could not load NTDLL\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtConnectPort)\n");
ConnectPort = (VOID*) GetProcAddress(
ntdll,
"NtConnectPort"
);
if (ConnectPort == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtConnectPort\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtQueryObject)\n");
QueryObject = (VOID*) GetProcAddress(
ntdll,
"NtQueryObject"
);
if (QueryObject == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtQueryObject\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
YieldExecution = (VOID*) GetProcAddress(
ntdll,
"NtYieldExecution"
);
if (YieldExecution == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtYieldExecution\n");
return EXIT_FAILURE;
}
printf("TryConnectPort(%s)\n",argv[1]);
TryConnectPort(argv[1]);
printf("Done\n");
return EXIT_SUCCESS;
}
/* EOF */

View File

@@ -0,0 +1,192 @@
/* $Id: creport.c,v 1.2 1999/07/17 23:10:12 ea Exp $
*
* reactos/apps/lpc/creport.c
*
* To be run in a real WNT 4.0 system to
* create an LPC named port.
*
* Use Russinovich' HandleEx to verify
* creport.exe owns the named LPC port
* you asked to create.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define PROTO_LPC
#include <ddk/ntddk.h>
#include "dumpinfo.h"
#define LPC_CONNECT_FLAG1 0x00000001
#define LPC_CONNECT_FLAG2 0x00000010
#define LPC_CONNECT_FLAG3 0x00000100
#define LPC_CONNECT_FLAG4 0x00001000
#define LPC_CONNECT_FLAG5 0x00010000
NTSTATUS
(STDCALL * CreatePort)(
/*OUT PHANDLE PortHandle,*/
PVOID Buffer,
IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL,
IN ACCESS_MASK DesiredAccess,
IN DWORD Unknown3,
IN ULONG Flags
);
NTSTATUS
(STDCALL * QueryObject)(
IN HANDLE ObjectHandle,
IN CINT ObjectInformationClass,
OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
(STDCALL * YieldExecution)(VOID);
#define BUF_SIZE 1024
#define MAXARG 5000000
VOID
TryCreatePort(char *port_name)
{
DWORD Status = 0;
HANDLE Port = 0;
int i;
UNICODE_STRING PortName;
OBJECT_ATTRIBUTES ObjectAttributes;
WORD Name [BUF_SIZE] = {0};
int dwx = 0;
char * port_name_save = port_name;
/*
* Convert the port's name to Unicode.
*/
for (
PortName.Length = 0;
( *port_name
&& (PortName.Length < BUF_SIZE)
);
)
{
Name[PortName.Length++] = (WORD) *port_name++;
}
Name[PortName.Length] = 0;
PortName.Length = PortName.Length * sizeof (WORD);
PortName.MaximumLength = PortName.Length + sizeof (WORD);
PortName.Buffer = (PWSTR) Name;
/*
* Prepare the port object attributes.
*/
ObjectAttributes.Length =
sizeof (OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory =
NULL;
ObjectAttributes.ObjectName =
& PortName;
ObjectAttributes.Attributes =
0; //OBJ_CASE_INSENSITIVE --> STATUS_INVALID_PARAMETER ==> case sensitive!;
ObjectAttributes.SecurityDescriptor =
NULL;
ObjectAttributes.SecurityQualityOfService =
NULL;
/*
* Try to issue a connection request.
*/
Port = 0;
Status = CreatePort(
& Port,
& ObjectAttributes,
0, /* ACCESS_MASK? */
0, /* Unknown3 */
LPC_CONNECT_FLAG5
);
if (Status == STATUS_SUCCESS)
{
DumpInfo(
Name,
Status,
"created",
Port
);
/* Hot waiting */
for (dwx=0; dwx<MAXARG; ++dwx)
{
YieldExecution();
}
if (FALSE == CloseHandle(Port))
{
printf(
"Could not close the port handle %08X.\n",
Port
);
}
return;
}
printf(
"Creating port \"%s\" failed (Status = %08X).\n",
port_name_save,
Status
);
}
main( int argc, char * argv[] )
{
HINSTANCE ntdll;
if (argc != 2)
{
printf("WNT LPC Port Creator\n");
printf("Usage: %s [port_name]\n",argv[0]);
exit(EXIT_FAILURE);
}
printf("LoadLibrary(NTDLL)\n");
ntdll = LoadLibrary("NTDLL");
if (ntdll == NULL)
{
printf("Could not load NTDLL\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtCreatePort)\n");
CreatePort = (VOID*) GetProcAddress(
ntdll,
"NtCreatePort"
);
if (CreatePort == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtCreatePort\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtQueryObject)\n");
QueryObject = (VOID*) GetProcAddress(
ntdll,
"NtQueryObject"
);
if (QueryObject == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtQueryObject\n");
return EXIT_FAILURE;
}
printf("GetProcAddress(NTDLL.NtYieldExecution)\n");
YieldExecution = (VOID*) GetProcAddress(
ntdll,
"NtYieldExecution"
);
if (YieldExecution == NULL)
{
FreeLibrary(ntdll);
printf("Could not find NTDLL.NtYieldExecution\n");
return EXIT_FAILURE;
}
printf("TryCreatePort(%s)\n",argv[1]);
TryCreatePort(argv[1]);
printf("Done\n");
return EXIT_SUCCESS;
}
/* EOF */

View File

@@ -0,0 +1,239 @@
/* $Id: dumpinfo.c,v 1.2 1999/07/17 23:10:12 ea Exp $
*
* reactos/apps/lpc/dumpinfo.c
*
* ReactOS Operating System
*
* Dump a kernel object's attributes by its handle.
*
* 19990627 (Emanuele Aliberti)
* Initial implementation.
* 19990704 (EA)
* Added code to find the basic information buffer size
* for the LPC port object.
* 19990710 (EA)
*
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ddk/ntddk.h>
#define BUF_SIZE 1024
#define MAX_BASIC_INFO_SIZE 512
extern
NTSTATUS
(STDCALL * QueryObject)(
IN HANDLE ObjectHandle,
IN CINT ObjectInformationClass,
OUT PVOID ObjectInformation,
IN ULONG Length,
OUT PULONG ResultLength
);
extern
NTSTATUS
(STDCALL * QueryInformationPort)(
IN HANDLE PortHandle,
IN CINT PortInformationClass, /* guess */
OUT PVOID PortInformation, /* guess */
IN ULONG PortInformationLength, /* guess */
OUT PULONG ReturnLength /* guess */
);
/*
static
VOID
DumpBuffer(
char *Name,
BYTE *buffer,
ULONG size
)
{
register ULONG i = 0;
printf("%s [%d] = ",Name,size);
for ( i = 0;
i != size;
++i
)
{
printf("%02X",buffer[i]);
}
printf("\n");
}
*/
VOID
DumpInfo (
LPCWSTR Name,
NTSTATUS Status,
LPCWSTR Comment,
HANDLE Port
)
{
BYTE ObjectInformation [BUF_SIZE] = {0};
ULONG ResultLength;
wprintf(
L"Port \"%s\" %s:\n",
Name,
Comment
);
printf("\tStatus = %08X\n",Status);
printf("\tPort = %08X\n\n",Port);
/*
* Query object information.
*/
printf("Basic Information:\n");
Status = QueryObject(
Port,
ObjectBasicInformation,
ObjectInformation,
sizeof (LPC_PORT_BASIC_INFORMATION),
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
PLPC_PORT_BASIC_INFORMATION i;
i = (PLPC_PORT_BASIC_INFORMATION) ObjectInformation;
printf( "\tUnknown01 = 0x%08X\n", i->Unknown0 );
printf( "\tUnknown02 = 0x%08X\n", i->Unknown1 );
printf( "\tUnknown03 = 0x%08X\n", i->Unknown2 );
printf( "\tUnknown04 = 0x%08X\n", i->Unknown3 );
printf( "\tUnknown05 = 0x%08X\n", i->Unknown4 );
printf( "\tUnknown06 = 0x%08X\n", i->Unknown5 );
printf( "\tUnknown07 = 0x%08X\n", i->Unknown6 );
printf( "\tUnknown08 = 0x%08X\n", i->Unknown7 );
printf( "\tUnknown09 = 0x%08X\n", i->Unknown8 );
printf( "\tUnknown10 = 0x%08X\n", i->Unknown9 );
printf( "\tUnknown11 = 0x%08X\n", i->Unknown10 );
printf( "\tUnknown12 = 0x%08X\n", i->Unknown11 );
printf( "\tUnknown13 = 0x%08X\n", i->Unknown12 );
printf( "\tUnknown14 = 0x%08X\n", i->Unknown13 );
}
else
{
printf("\tStatus = %08X\n",Status);
}
printf("Type Information:\n");
Status = QueryObject(
Port,
ObjectTypeInformation,
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
OBJECT_TYPE_INFORMATION * i;
i = (OBJECT_TYPE_INFORMATION *) ObjectInformation;
wprintf(
L"\tName: \"%s\"\n",
(i->Name.Length ? i->Name.Buffer : L"")
);
/*
FIXME: why this always raise an access violation exception?
wprintf(
L"\tType: \"%s\"\n",
(i->Type.Length ? i->Type.Buffer : L"")
);
/**/
printf(
"\tTotal Handles: %d\n",
i->TotalHandles
);
printf(
"\tReference Count: %d\n",
i->ReferenceCount
);
}
else
{
printf("\tStatus = %08X\n",Status);
}
printf("Name Information:\n");
Status = QueryObject(
Port,
ObjectNameInformation,
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
OBJECT_NAME_INFORMATION * i;
i = (OBJECT_NAME_INFORMATION *) ObjectInformation;
wprintf(
L"\tName: \"%s\"\n",
(i->Name.Length ? i->Name.Buffer : L"")
);
}
else
{
printf("\tStatus = %08X\n",Status);
}
printf("Data Information:\n");
Status = QueryObject(
Port,
ObjectDataInformation,
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
OBJECT_DATA_INFORMATION * i;
i = (OBJECT_DATA_INFORMATION *) ObjectInformation;
printf(
"\tInherit Handle: %s\n",
(i->bInheritHandle ? "TRUE" : "FALSE")
);
printf(
"\tProtect from Close: %s\n",
(i->bProtectFromClose ? "TRUE" : "FALSE")
);
}
else
{
printf("\tStatus = %08X\n",Status);
}
//---
printf("Port Information:\n");
/* Status = QueryInformationPort(
Port,
1, /* info class * /
ObjectInformation,
sizeof ObjectInformation,
& ResultLength
);
if (Status == STATUS_SUCCESS)
{
DWORD * i = ObjectInformation;
int j = 0;
while (j < ResultLength / sizeof (DWORD))
{
printf("\t%08X\n",i[j]);
++j;
}
}
else
{
printf("\tStatus = %08X\n",Status);
}
*/
}
/* EOF */

View File

@@ -0,0 +1,8 @@
VOID
DumpInfo (
LPCWSTR Name,
NTSTATUS Status,
LPCWSTR Comment,
HANDLE Port
);

View File

@@ -0,0 +1,94 @@
/* $Id: lpcclt.c,v 1.8 2002/02/24 17:44:22 ea Exp $
*
* DESCRIPTION: Simple LPC Client
* PROGRAMMER: David Welch
*/
#include <ddk/ntddk.h>
#include <windows.h>
#include <napi/lpc.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "lpctest.h"
const char * MyName = "LPC-CLI";
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int main(int argc, char* argv[])
{
UNICODE_STRING PortName;
NTSTATUS Status;
HANDLE PortHandle;
LPC_MAX_MESSAGE Request;
ULONG ConnectInfo;
ULONG ConnectInfoLength = 0;
SECURITY_QUALITY_OF_SERVICE Sqos;
printf("%s: Lpc test client\n", MyName);
RtlInitUnicodeString(&PortName, TEST_PORT_NAME_U);
printf("%s: Connecting to port \"%s\"...\n", MyName, TEST_PORT_NAME);
ConnectInfoLength = 0;
ZeroMemory (& Sqos, sizeof Sqos);
Status = NtConnectPort(&PortHandle,
&PortName,
& Sqos,
0,
0,
0,
NULL,
&ConnectInfoLength);
if (!NT_SUCCESS(Status))
{
printf("%s: NtConnectPort() failed with status = 0x%08X.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Connected to \"%s\" with anonymous port 0x%x.\n", MyName, TEST_PORT_NAME, PortHandle);
ZeroMemory(& Request, sizeof Request);
strcpy(Request.Data, GetCommandLineA());
Request.Header.DataSize = strlen(Request.Data);
Request.Header.MessageSize = sizeof(LPC_MESSAGE_HEADER) +
Request.Header.DataSize;
printf("%s: Sending to port 0x%x message \"%s\"...\n",
MyName,
PortHandle,
(char *) Request.Data);
Status = NtRequestPort(PortHandle,
&Request.Header);
if (!NT_SUCCESS(Status))
{
printf("%s: NtRequestPort(0x%x) failed with status = 0x%8X.\n",
MyName,
PortHandle,
Status);
return EXIT_FAILURE;
}
printf("%s: Sending datagram to port 0x%x succeeded.\n", MyName, PortHandle);
Sleep(2000);
printf("%s: Disconnecting...", MyName);
NtClose (PortHandle);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,140 @@
/* $Id: lpcsrv.c,v 1.8 2002/02/24 17:44:22 ea Exp $
*
* DESCRIPTION: Simple LPC Server
* PROGRAMMER: David Welch
*/
#include <ddk/ntddk.h>
#include <windows.h>
#include <napi/lpc.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "lpctest.h"
static const char * MyName = "LPC-SRV";
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int main(int argc, char* argv[])
{
UNICODE_STRING PortName;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
HANDLE NamedPortHandle;
HANDLE PortHandle;
LPC_MAX_MESSAGE ConnectMsg;
printf("%s: Lpc test server\n", MyName);
RtlInitUnicodeString(&PortName, TEST_PORT_NAME_U);
InitializeObjectAttributes(&ObjectAttributes,
&PortName,
0,
NULL,
NULL);
printf("%s: Creating port \"%s\"...\n", MyName, TEST_PORT_NAME);
Status = NtCreatePort(&NamedPortHandle,
&ObjectAttributes,
0,
0,
0);
if (!NT_SUCCESS(Status))
{
printf("%s: NtCreatePort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Port \"%s\" created (0x%x).\n\n", MyName, TEST_PORT_NAME, NamedPortHandle);
for (;;)
{
printf("%s: Listening for connections requests on port 0x%x...\n", MyName, NamedPortHandle);
Status = NtListenPort(NamedPortHandle,
&ConnectMsg.Header);
if (!NT_SUCCESS(Status))
{
printf("%s: NtListenPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Received connection request 0x%08x on port 0x%x.\n", MyName,
ConnectMsg.Header.MessageId, NamedPortHandle);
printf("%s: Request from: PID=%x, TID=%x.\n", MyName,
ConnectMsg.Header.Cid.UniqueProcess, ConnectMsg.Header.Cid.UniqueThread);
printf("%s: Accepting connection request 0x%08x...\n", MyName,
ConnectMsg.Header.MessageId);
Status = NtAcceptConnectPort(&PortHandle,
NamedPortHandle,
& ConnectMsg.Header,
TRUE,
0,
NULL);
if (!NT_SUCCESS(Status))
{
printf("%s: NtAcceptConnectPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Connection request 0x%08x accepted as port 0x%x.\n", MyName,
ConnectMsg.Header.MessageId, PortHandle);
printf("%s: Completing connection for port 0x%x (0x%08x).\n", MyName,
PortHandle, ConnectMsg.Header.MessageId);
Status = NtCompleteConnectPort(PortHandle);
if (!NT_SUCCESS(Status))
{
printf("%s: NtCompleteConnectPort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
printf("%s: Entering server loop for port 0x%x...\n", MyName, PortHandle);
for(;;)
{
LPC_MAX_MESSAGE Request;
Status = NtReplyWaitReceivePort(PortHandle,
0,
NULL,
&Request.Header);
if (!NT_SUCCESS(Status))
{
printf("%s: NtReplyWaitReceivePort() failed with status = 0x%08lX.\n", MyName, Status);
return EXIT_FAILURE;
}
if (LPC_DATAGRAM == PORT_MESSAGE_TYPE(Request))
{
printf("%s: Datagram message contents are <%s>.\n",
MyName,
Request.Data);
}
else
{
printf("%s: Message with type %d received on port 0x%x.\n", MyName,
PORT_MESSAGE_TYPE(Request), PortHandle);
NtClose(PortHandle);
printf("%s: Connected port 0x%x closed.\n\n", MyName, PortHandle);
break;
}
}
}
return EXIT_SUCCESS;
}
/* EOF */

View File

@@ -0,0 +1,5 @@
#ifndef _LPCTEST_H
#define _LPCTEST_H
#define TEST_PORT_NAME "\\TestPort"
#define TEST_PORT_NAME_U L"\\TestPort"
#endif

View File

@@ -0,0 +1,45 @@
#
#
#
PATH_TO_TOP = ../../..
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS= lpcsrv.o
CLT_OBJECTS= lpcclt.o
PROGS= lpcsrv.exe lpcclt.exe
BASE_CFLAGS = -I$(PATH_TO_TOP)/include
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) lpcsrv.o lpcsrv.exe lpcsrv.sym lpcclt.o lpcclt.exe lpcsrv.sym
.phony: implib clean
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
lpcsrv.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o lpcsrv.exe
$(NM) --numeric-sort lpcsrv.exe > lpcsrv.sym
lpcclt.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o lpcclt.exe
$(NM) --numeric-sort lpcclt.exe > lpcclt.sym

View File

@@ -0,0 +1,45 @@
#
#
#
PATH_TO_TOP = ../../..
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS = msserver.o
CLT_OBJECTS = msclient.o
PROGS = msserver.exe msclient.exe
BASE_CFLAGS = -I$(PATH_TO_TOP)/include
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
msserver.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o msserver.exe
$(NM) --numeric-sort msserver.exe > msserver.sym
msclient.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o msclient.exe
$(NM) --numeric-sort msclient.exe > msclient.sym

View File

@@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <tchar.h>
#define BUFSIZE 1024
#define MAILSLOT_TIMEOUT 1000
int main(int argc, char *argv[])
{
HANDLE hMailslot;
LPSTR lpszMailslotName = "\\\\.\\MAILSLOT\\mymailslot";
LPSTR lpszTestMessage = "Mailslot test message!";
DWORD cbLength, cbWritten;
hMailslot = CreateFile(lpszMailslotName,
GENERIC_WRITE,
FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
printf("hMailslot %x\n", (DWORD)hMailslot);
if (hMailslot == INVALID_HANDLE_VALUE)
{
printf("CreateFile() failed\n");
return 0;
}
cbLength = (ULONG)strlen(lpszTestMessage)+1;
WriteFile(hMailslot,
lpszTestMessage,
cbLength,
&cbWritten,
NULL);
CloseHandle(hMailslot);
return 0;
}
/* EOF */

View File

@@ -0,0 +1,40 @@
#include <windows.h>
int main(int argc, char *argv[])
{
HANDLE hMailslot;
CHAR chBuf[512];
BOOL fResult;
DWORD cbRead;
LPTSTR lpszMailslotName = "\\\\.\\mailslot\\mymailslot";
hMailslot = CreateMailslot(lpszMailslotName,
512,
MAILSLOT_WAIT_FOREVER,
NULL);
for (;;)
{
fResult = ReadFile(hMailslot,
chBuf,
512,
&cbRead,
NULL);
if (fResult == FALSE)
{
printf("ReadFile() failed!\n");
CloseHandle(hMailslot);
return 0;
}
printf("Data read: %s\n", chBuf);
}
CloseHandle(hMailslot);
return 0;
}
/* EOF */

View File

@@ -0,0 +1,22 @@
#
# $Id: makefile,v 1.2 2002/06/02 19:24:59 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = mutex
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,116 @@
#include <ddk/ntddk.h>
#include <windows.h>
#include <string.h>
#include <stdio.h>
HANDLE OutputHandle;
HANDLE InputHandle;
HANDLE hThread[2];
DWORD dwCounter = 0;
HANDLE hMutex;
void dprintf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
DWORD WINAPI thread1(LPVOID crap)
{
DWORD dwError = 0;
DWORD i;
dprintf("Thread 1 running!\n");
for (i = 0; i < 10; i++)
{
dwError = WaitForSingleObject(hMutex, INFINITE);
if (dwError == WAIT_FAILED)
{
dprintf("Thread2: WaitForSingleObject failed!\n");
return 1;
}
else if (dwError == WAIT_ABANDONED_0)
{
dprintf("Thread2: WaitForSingleObject returned WAIT_ABANDONED_0\n");
}
dprintf("Thread1: dwCounter : %lu -->", dwCounter);
dwCounter++;
dprintf(" %lu\n", dwCounter);
ReleaseMutex(hMutex);
}
return 1;
}
DWORD WINAPI thread2(LPVOID crap)
{
DWORD dwError = 0;
DWORD i;
dprintf("Thread 2 running!\n");
for (i = 0; i < 10; i++)
{
dwError = WaitForSingleObject(hMutex, INFINITE);
if (dwError == WAIT_FAILED)
{
dprintf("Thread2: WaitForSingleObject failed!\n");
return 1;
}
else if (dwError == WAIT_ABANDONED_0)
{
dprintf("Thread2: WaitForSingleObject returned WAIT_ABANDONED_0\n");
}
dprintf("Thread2: dwCounter : %lu -->", dwCounter);
dwCounter++;
dprintf(" %lu\n", dwCounter);
ReleaseMutex(hMutex);
}
return 1;
}
int main(int argc, char* argv[])
{
DWORD dwError;
DWORD id1,id2;
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
dprintf("Calling CreateMutex()\n");
hMutex = CreateMutexW(NULL, FALSE, L"TestMutex");
if (hMutex == INVALID_HANDLE_VALUE)
{
dprintf("CreateMutex() failed! Error: %lu\n", GetLastError);
return 0;
}
dprintf("CreateMutex() succeeded!\n");
hThread[0] = CreateThread(0, 0, thread1, 0, 0, &id1);
hThread[1] = CreateThread(0, 0, thread2, 0, 0, &id2);
dprintf("Calling WaitForMultipleObject()\n");
dwError = WaitForMultipleObjects(2, hThread, TRUE, INFINITE);
dprintf("WaitForMultipleObject() Error: %lu\n", dwError);
CloseHandle(hThread[0]);
CloseHandle(hThread[1]);
CloseHandle(hMutex);
return 0;
}

View File

@@ -0,0 +1,44 @@
#
#
#
PATH_TO_TOP = ../../..
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS = npserver.o
CLT_OBJECTS = npclient.o
PROGS = npserver.exe npclient.exe
BASE_CFLAGS = -I$(PATH_TO_TOP)/include
LIBS = $(SDK_PATH_LIB)/kernel32.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
npserver.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o npserver.exe
$(NM) --numeric-sort npserver.exe > npserver.sym
npclient.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o npclient.exe
$(NM) --numeric-sort npclient.exe > npclient.sym

View File

@@ -0,0 +1,100 @@
#include <windows.h>
VOID MyErrExit(LPTSTR Message)
{
// MessageBox(NULL, Message, NULL, MB_OK);
puts(Message);
ExitProcess(0);
}
int main(int argc, char *argv[])
{
HANDLE hPipe;
LPVOID lpvMessage;
CHAR chBuf[512];
BOOL fSuccess;
DWORD cbRead, cbWritten, dwMode;
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe";
// Try to open a named pipe; wait for it, if necessary.
while (1)
{
hPipe = CreateFile(
lpszPipename, // pipe name
GENERIC_READ | // read and write access
GENERIC_WRITE,
0, // no sharing
NULL, // no security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
// Break if the pipe handle is valid.
if (hPipe != INVALID_HANDLE_VALUE)
break;
// Exit if an error other than ERROR_PIPE_BUSY occurs.
if (GetLastError() != ERROR_PIPE_BUSY)
MyErrExit("Could not open pipe");
// All pipe instances are busy, so wait for 20 seconds.
if (! WaitNamedPipe(lpszPipename, 20000) )
MyErrExit("Could not open pipe");
}
// The pipe connected; change to message-read mode.
dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState(
hPipe, // pipe handle
&dwMode, // new pipe mode
NULL, // don't set maximum bytes
NULL); // don't set maximum time
if (!fSuccess)
MyErrExit("SetNamedPipeHandleState");
// Send a message to the pipe server.
lpvMessage = (argc > 1) ? argv[1] : "default message";
fSuccess = WriteFile(
hPipe, // pipe handle
lpvMessage, // message
strlen(lpvMessage) + 1, // message length
&cbWritten, // bytes written
NULL); // not overlapped
if (! fSuccess)
MyErrExit("WriteFile");
do
{
// Read from the pipe.
fSuccess = ReadFile(
hPipe, // pipe handle
chBuf, // buffer to receive reply
512, // size of buffer
&cbRead, // number of bytes read
NULL); // not overlapped
if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
break;
// Reply from the pipe is written to STDOUT.
if (! WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
chBuf, cbRead, &cbWritten, NULL))
{
break;
}
} while (! fSuccess); // repeat loop if ERROR_MORE_DATA
CloseHandle(hPipe);
return 0;
}

View File

@@ -0,0 +1,120 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <tchar.h>
#define BUFSIZE 1024
#define PIPE_TIMEOUT 1000
VOID InstanceThread (LPVOID);
VOID
GetAnswerToRequest(LPTSTR lpRequest,
LPTSTR lpReply,
LPDWORD lpcbReplyBytes)
{
}
VOID MyErrExit(LPTSTR Message)
{
// MessageBox(NULL, Message, NULL, MB_OK);
puts(Message);
ExitProcess(0);
}
int xx = 0;
int main(int argc, char *argv[])
{
BOOL fConnected;
DWORD dwThreadId;
HANDLE hPipe, hThread;
LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe");
// for (;;)
// {
hPipe = CreateNamedPipe(lpszPipename,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
BUFSIZE,
BUFSIZE,
PIPE_TIMEOUT,
NULL);
if (hPipe == INVALID_HANDLE_VALUE)
{
printf("CreateNamedPipe() failed\n");
return 0;
}
fConnected = ConnectNamedPipe(hPipe,
NULL) ? TRUE : (GetLastError () ==
ERROR_PIPE_CONNECTED);
if (fConnected)
{
printf("Pipe connected!\n");
DisconnectNamedPipe(hPipe);
#if 0
hThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) InstanceThread,
(LPVOID) hPipe,
0,
&dwThreadId);
if (hThread == NULL)
MyErrExit("CreateThread");
#endif
}
else
{
// CloseHandle(hPipe);
}
// }
CloseHandle(hPipe);
return 0;
}
VOID InstanceThread (LPVOID lpvParam)
{
CHAR chRequest[BUFSIZE];
CHAR chReply[BUFSIZE];
DWORD cbBytesRead, cbReplyBytes, cbWritten;
BOOL fSuccess;
HANDLE hPipe;
hPipe = (HANDLE)lpvParam;
while (1)
{
fSuccess = ReadFile(hPipe,
chRequest,
BUFSIZE,
&cbBytesRead,
NULL);
if (!fSuccess || cbBytesRead == 0)
break;
GetAnswerToRequest(chRequest, chReply, &cbReplyBytes);
fSuccess = WriteFile(hPipe,
chReply,
cbReplyBytes,
&cbWritten,
NULL);
if (!fSuccess || cbReplyBytes != cbWritten)
break;
}
FlushFileBuffers(hPipe);
DisconnectNamedPipe(hPipe);
CloseHandle(hPipe);
}

View File

@@ -0,0 +1,21 @@
# $Id: Makefile,v 1.8 2002/06/02 19:25:00 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = pteb
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,23 @@
#include <ntos.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int x;
PTEB Teb;
printf("TEB dumpper\n");
__asm__("movl %%fs:0x18, %0\n\t"
: "=a" (x)
: /* no inputs */);
printf("fs[0x18] %x\n", x);
Teb = (PTEB)x;
printf("StackBase: 0x%08lX\n", Teb->Tib.StackBase);
printf("StackLimit: 0x%08lX\n", Teb->Tib.StackLimit);
printf("DeallocationStack: 0x%08lX\n", Teb->DeallocationStack);
return(0);
}

View File

@@ -0,0 +1,22 @@
#
# $Id: makefile,v 1.7 2002/06/02 19:25:00 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = regtest
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,882 @@
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#include <ddk/ntddk.h>
HANDLE OutputHandle;
HANDLE InputHandle;
void dprintf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
void do_enumeratekey(PWSTR Name)
{
ULONG Index,Length,i;
KEY_BASIC_INFORMATION KeyInformation[5];
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE hKey1;
UNICODE_STRING KeyName;
RtlInitUnicodeString(&KeyName, Name);
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("NtEnumerateKey : \n");
Index=0;
while(Status == STATUS_SUCCESS)
{
Status=NtEnumerateKey(hKey1,Index++,KeyBasicInformation
,&KeyInformation[0], sizeof(KeyInformation)
,&Length);
if(Status== STATUS_SUCCESS)
{
dprintf("\tSubKey Name = ");
for (i=0;i<KeyInformation[0].NameLength/2;i++)
dprintf("%C",KeyInformation[0].Name[i]);
dprintf("\n");
}
}
NtClose(hKey1);
}
void test1(void)
{
HKEY hKey = NULL,hKey1;
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
UNICODE_STRING KeyName;
ULONG Index,Length,i;
KEY_BASIC_INFORMATION KeyInformation[5];
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
dprintf("NtOpenKey \\Registry : ");
RtlInitUnicodeString(&KeyName, L"\\Registry");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
if(Status==0)
{
dprintf("NtQueryKey : ");
Status=NtQueryKey(hKey1,KeyBasicInformation
,&KeyInformation[0], sizeof(KeyInformation)
,&Length);
dprintf("\t\t\t\t\tStatus =%x\n",Status);
if (Status == STATUS_SUCCESS)
{
dprintf("\tKey Name = ");
for (i=0;i<KeyInformation[0].NameLength/2;i++)
dprintf("%C",KeyInformation[0].Name[i]);
dprintf("\n");
}
dprintf("NtEnumerateKey : \n");
Index=0;
while(Status == STATUS_SUCCESS)
{
Status=NtEnumerateKey(hKey1,Index++,KeyBasicInformation
,&KeyInformation[0], sizeof(KeyInformation)
,&Length);
if(Status== STATUS_SUCCESS)
{
dprintf("\tSubKey Name = ");
for (i=0;i<KeyInformation[0].NameLength/2;i++)
dprintf("%C",KeyInformation[0].Name[i]);
dprintf("\n");
}
}
dprintf("NtClose : ");
Status = NtClose( hKey1 );
dprintf("\t\t\t\t\tStatus =%x\n",Status);
}
NtClose(hKey);
dprintf("NtOpenKey \\Registry\\Machine : ");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\t\tStatus =%x\n",Status);
dprintf("NtOpenKey System\\Setup : ");
RtlInitUnicodeString(&KeyName, L"System\\Setup");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, hKey1 , NULL);
Status = NtOpenKey ( &hKey, KEY_READ , &ObjectAttributes);
dprintf("\t\t\tStatus =%x\n",Status);
if(Status==0)
{
dprintf("NtQueryValueKey : ");
RtlInitUnicodeString(&KeyName, L"CmdLine");
Status=NtQueryValueKey(hKey,&KeyName,KeyValueFullInformation
,&KeyValueInformation[0], sizeof(KeyValueInformation)
,&Length);
dprintf("\t\t\t\tStatus =%x\n",Status);
if (Status == STATUS_SUCCESS)
{
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
,KeyValueInformation[0].DataOffset
,KeyValueInformation[0].DataLength
,KeyValueInformation[0].NameLength);
for (i=0;i<10 && i<KeyValueInformation[0].NameLength/2;i++)
dprintf("%C",KeyValueInformation[0].Name[i]);
dprintf("\n");
dprintf("\t\tType = %d\n",KeyValueInformation[0].Type);
if (KeyValueInformation[0].Type == REG_SZ)
dprintf("\t\tValue = %S\n",KeyValueInformation[0].Name+1
+KeyValueInformation[0].NameLength/2);
}
dprintf("NtEnumerateValueKey : \n");
Index=0;
while(Status == STATUS_SUCCESS)
{
Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
,&KeyValueInformation[0], sizeof(KeyValueInformation)
,&Length);
if(Status== STATUS_SUCCESS)
{
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
,KeyValueInformation[0].DataOffset
,KeyValueInformation[0].DataLength
,KeyValueInformation[0].NameLength);
for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
dprintf("%C",KeyValueInformation[0].Name[i]);
dprintf(", Type = %d\n",KeyValueInformation[0].Type);
if (KeyValueInformation[0].Type == REG_SZ)
dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
+KeyValueInformation[0].DataOffset));
}
}
dprintf("NtClose : ");
Status = NtClose( hKey );
dprintf("\t\t\t\t\tStatus =%x\n",Status);
}
NtClose( hKey1 );
}
void test2(void)
{
HKEY hKey,hKey1;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Index,Length,i;
char Buffer[10];
DWORD Result;
dprintf("NtCreateKey volatile: \n");
dprintf(" \\Registry\\Machine\\Software\\test2reactos: ");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL,REG_OPTION_VOLATILE,NULL);
dprintf("\t\tStatus=%x\n",Status);
NtClose(hKey);
do_enumeratekey(L"\\Registry\\Machine\\Software");
dprintf(" ...\\test2 :");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtCreateKey ( &hKey1, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL,REG_OPTION_VOLATILE,NULL);
dprintf("\t\t\t\t\tStatus=%x\n",Status);
dprintf(" ...\\TestVolatile :");
RtlInitUnicodeString(&KeyName, L"TestVolatile");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, hKey1, NULL);
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL,REG_OPTION_VOLATILE,NULL);
dprintf("\t\t\t\tStatus=%x\n",Status);
NtClose(hKey1);
RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
dprintf("NtSetValueKey reg_sz: ");
Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
dprintf("\t\t\t\tStatus=%x\n",Status);
RtlInitUnicodeString(&ValueName, L"TestDWORD");
dprintf("NtSetValueKey reg_dword: ");
Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
dprintf("\t\t\tStatus=%x\n",Status);
NtClose(hKey);
dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
if(Status==0)
{
dprintf("NtEnumerateValueKey : \n");
Index=0;
while(Status == STATUS_SUCCESS)
{
Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
,&KeyValueInformation[0], sizeof(KeyValueInformation)
,&Length);
if(Status== STATUS_SUCCESS)
{
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
,KeyValueInformation[0].DataOffset
,KeyValueInformation[0].DataLength
,KeyValueInformation[0].NameLength);
for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
dprintf("%C",KeyValueInformation[0].Name[i]);
dprintf(", Type = %d\n",KeyValueInformation[0].Type);
if (KeyValueInformation[0].Type == REG_SZ)
dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
+KeyValueInformation[0].DataOffset));
}
}
}
NtClose(hKey);
dprintf("delete \\Registry\\Machine\\software\\test2reactos ?");
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
dprintf("NtOpenKey : ");
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dprintf("NtDeleteKey : ");
Status=NtDeleteKey(hKey);
dprintf("\t\t\t\tStatus =%x\n",Status);
NtClose(hKey);
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos\\test2");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
dprintf("NtOpenKey : ");
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dprintf("NtDeleteKey : ");
Status=NtDeleteKey(hKey);
dprintf("\t\t\t\tStatus =%x\n",Status);
NtClose(hKey);
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test2reactos");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
dprintf("NtOpenKey : ");
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dprintf("NtDeleteKey : ");
Status=NtDeleteKey(hKey);
dprintf("\t\t\t\tStatus =%x\n",Status);
NtClose(hKey);
}
void test3(void)
{
HKEY hKey,hKey1;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Index,Length,i;
char Buffer[10];
DWORD Result;
dprintf("NtCreateKey non volatile: \n");
dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
dprintf("\t\tStatus=%x\n",Status);
NtClose(hKey);
do_enumeratekey(L"\\Registry\\Machine\\Software");
dprintf("NtOpenKey: ");
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\tStatus=%x\n",Status);
NtClose(hKey);
dprintf(" ...\\test3 :");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
dprintf("\t\t\t\t\tStatus=%x\n",Status);
dprintf("NtOpenKey: ");
Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\tStatus=%x\n",Status);
NtClose(hKey);
dprintf(" ...\\testNonVolatile :");
RtlInitUnicodeString(&KeyName, L"TestNonVolatile");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, hKey1, NULL);
Status = NtCreateKey ( &hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL,REG_OPTION_NON_VOLATILE,NULL);
dprintf("\t\t\t\tStatus=%x\n",Status);
NtClose(hKey1);
RtlInitUnicodeString(&ValueName, L"TestREG_SZ");
dprintf("NtSetValueKey reg_sz: ");
Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"Test Reg_sz",24);
dprintf("\t\t\t\tStatus=%x\n",Status);
RtlInitUnicodeString(&ValueName, L"TestDWORD");
dprintf("NtSetValueKey reg_dword: ");
Status=NtSetValueKey(hKey,&ValueName,0,REG_DWORD,(PVOID)"reac",4);
dprintf("\t\t\tStatus=%x\n",Status);
NtClose(hKey);
dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
if(Status==0)
{
dprintf("NtEnumerateValueKey : \n");
Index=0;
while(Status == STATUS_SUCCESS)
{
Status=NtEnumerateValueKey(hKey,Index++,KeyValueFullInformation
,&KeyValueInformation[0], sizeof(KeyValueInformation)
,&Length);
if(Status== STATUS_SUCCESS)
{
dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
,KeyValueInformation[0].DataOffset
,KeyValueInformation[0].DataLength
,KeyValueInformation[0].NameLength);
for (i=0;i<KeyValueInformation[0].NameLength/2;i++)
dprintf("%C",KeyValueInformation[0].Name[i]);
dprintf(", Type = %d\n",KeyValueInformation[0].Type);
if (KeyValueInformation[0].Type == REG_SZ)
dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation[0]
+KeyValueInformation[0].DataOffset));
}
}
}
NtClose(hKey);
dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
dprintf("NtOpenKey : ");
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dprintf("NtDeleteKey : ");
Status=NtDeleteKey(hKey);
dprintf("\t\t\t\tStatus =%x\n",Status);
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos\\test3");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
dprintf("NtOpenKey : ");
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dprintf("NtDeleteKey : ");
Status=NtDeleteKey(hKey);
dprintf("\t\t\t\tStatus =%x\n",Status);
NtClose(hKey);
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
dprintf("NtOpenKey : ");
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dprintf("NtDeleteKey : ");
Status=NtDeleteKey(hKey);
dprintf("\t\t\t\tStatus =%x\n",Status);
NtClose(hKey);
}
void test4(void)
{
HKEY hKey = NULL,hKey1;
DWORD dwDisposition;
DWORD dwError;
DWORD RegDataType, RegDataSize;
BOOL GlobalFifoEnable;
HKEY hPortKey;
DWORD RegDisposition;
WCHAR szClass[260];
DWORD cchClass;
DWORD cSubKeys;
DWORD cchMaxSubkey;
DWORD cchMaxClass;
DWORD cValues;
DWORD cchMaxValueName;
DWORD cbMaxValueData;
DWORD cbSecurityDescriptor;
FILETIME ftLastWriteTime;
SYSTEMTIME LastWriteTime;
dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"System\\Setup",
0,
KEY_ALL_ACCESS,
&hKey1);
dprintf("\t\tdwError =%x\n",dwError);
if (dwError == ERROR_SUCCESS)
{
dprintf("RegQueryInfoKeyW: ");
cchClass=260;
dwError = RegQueryInfoKeyW(hKey1
, szClass, &cchClass, NULL, &cSubKeys
, &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
, &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
dprintf ("\t\t\t\tdwError %x\n", dwError);
FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
,LastWriteTime.wMonth
,LastWriteTime.wDay
,LastWriteTime.wYear
,LastWriteTime.wHour
,LastWriteTime.wMinute
,LastWriteTime.wSecond
,LastWriteTime.wMilliseconds
);
}
dprintf ("RegOpenKeyExW: ");
dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"System\\ControlSet001\\Services\\Serial",
0,
KEY_ALL_ACCESS,
&hKey);
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
RegDataSize = sizeof(GlobalFifoEnable);
if (dwError == ERROR_SUCCESS)
{
dprintf ("RegQueryValueExW: ");
dwError = RegQueryValueExW(hKey,
L"ForceFifoEnable",
NULL,
&RegDataType,
(PBYTE)&GlobalFifoEnable,
&RegDataSize);
dprintf("\t\t\t\tdwError =%x\n",dwError);
if (dwError == 0)
{
dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
,RegDataType
,RegDataSize
,GlobalFifoEnable);
}
}
dprintf ("RegCreateKeyExW: ");
dwError = RegCreateKeyExW(hKey,
L"Parameters\\Serial001",
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hPortKey,
&RegDisposition
);
dprintf ("\t\t\t\tdwError %x\n", dwError);
dprintf ("RegCreateKeyExW: ");
dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
L"Software\\test4reactos\\test",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisposition);
dprintf ("\t\t\t\tdwError %x ", dwError);
dprintf ("dwDisposition %x\n", dwDisposition);
if (dwError == ERROR_SUCCESS)
{
dprintf ("RegSetValueExW: ");
dwError = RegSetValueExW (hKey,
L"TestValue",
0,
REG_SZ,
(BYTE*)L"TestString",
20);
dprintf ("\t\t\t\tdwError %x\n", dwError);
dprintf ("RegCloseKey: ");
dwError = RegCloseKey (hKey);
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
}
dprintf ("\n\n");
hKey = NULL;
dprintf ("RegCreateKeyExW: ");
dwError = RegCreateKeyExW (HKEY_LOCAL_MACHINE,
L"software\\Test",
0,
NULL,
REG_OPTION_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisposition);
dprintf ("\t\t\t\tdwError %x ", dwError);
dprintf ("dwDisposition %x\n", dwDisposition);
if (dwError == ERROR_SUCCESS)
{
dprintf("RegQueryInfoKeyW: ");
cchClass=260;
dwError = RegQueryInfoKeyW(hKey
, szClass, &cchClass, NULL, &cSubKeys
, &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
, &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
dprintf ("\t\t\t\tdwError %x\n", dwError);
FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
,LastWriteTime.wMonth
,LastWriteTime.wDay
,LastWriteTime.wYear
,LastWriteTime.wHour
,LastWriteTime.wMinute
,LastWriteTime.wSecond
,LastWriteTime.wMilliseconds
);
dprintf ("RegCloseKey: ");
dwError = RegCloseKey (hKey);
dprintf ("\t\t\t\t\tdwError %x\n", dwError);
}
dprintf ("\nTests done...\n");
}
void test5(void)
{
HKEY hKey,hKey1;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Index,Length,i;
char Buffer[10];
DWORD Result;
dprintf("NtOpenKey : \n");
dprintf(" \\Registry\\Machine\\Software\\reactos : ");
RtlInitUnicodeString(&KeyName,L"\\Registry\\Machine\\Software\\reactos");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
dprintf("\t\tStatus=%x\n",Status);
dprintf("NtFlushKey : \n");
Status = NtFlushKey(hKey);
dprintf("\t\tStatus=%x\n",Status);
dprintf("NtCloseKey : \n");
Status=NtClose(hKey);
dprintf("\t\tStatus=%x\n",Status);
}
/* registry link create test */
void test6(void)
{
HKEY hKey;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
NTSTATUS Status;
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
ULONG Index,Length,i;
char Buffer[10];
DWORD Result;
dprintf("Create target key\n");
dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Reactos\n");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Reactos");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtCreateKey(&hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL, REG_OPTION_VOLATILE,NULL);
dprintf(" NtCreateKey() called (Status %lx)\n",Status);
if (!NT_SUCCESS(Status))
return;
dprintf("Create target value\n");
dprintf(" Value: TestValue = 'Test String'\n");
RtlInitUnicodeString(&ValueName, L"TestValue");
Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"TestString",22);
dprintf(" NtSetValueKey() called (Status %lx)\n",Status);
if (!NT_SUCCESS(Status))
return;
dprintf("Close target key\n");
NtClose(hKey);
dprintf("Create link key\n");
dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Test");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE | OBJ_OPENLINK,
NULL,
NULL);
Status = NtCreateKey(&hKey,
KEY_ALL_ACCESS | KEY_CREATE_LINK,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK,
NULL);
dprintf(" NtCreateKey() called (Status %lx)\n",Status);
if (!NT_SUCCESS(Status))
return;
dprintf("Create link value\n");
dprintf(" Value: SymbolicLinkValue = '\\Registry\\Machine\\SOFTWARE\\Reactos'\n");
RtlInitUnicodeString(&ValueName, L"SymbolicLinkValue");
Status=NtSetValueKey(hKey,&ValueName,0,REG_LINK,(PVOID)L"\\Registry\\Machine\\SOFTWARE\\Reactos",68);
dprintf(" NtSetValueKey() called (Status %lx)\n",Status);
if (!NT_SUCCESS(Status))
{
dprintf("Creating link value failed! Test failed!\n");
NtClose(hKey);
return;
}
dprintf("Close link key\n");
NtClose(hKey);
dprintf("Open link key\n");
dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Test");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE | OBJ_OPENIF
, NULL, NULL);
Status = NtCreateKey(&hKey, KEY_ALL_ACCESS , &ObjectAttributes
,0,NULL, REG_OPTION_VOLATILE, NULL);
dprintf(" NtCreateKey() called (Status %lx)\n",Status);
if (!NT_SUCCESS(Status))
return;
dprintf("Query value\n");
dprintf(" Value: TestValue\n");
RtlInitUnicodeString(&ValueName, L"TestValue");
Status=NtQueryValueKey(hKey,
&ValueName,
KeyValueFullInformation,
&KeyValueInformation[0],
sizeof(KeyValueInformation),
&Length);
dprintf(" NtQueryValueKey() called (Status %lx)\n",Status);
if (Status == STATUS_SUCCESS)
{
dprintf(" Value: Type %d DataLength %d NameLength %d Name '",
KeyValueInformation[0].Type,
KeyValueInformation[0].DataLength,
KeyValueInformation[0].NameLength);
for (i=0; i < KeyValueInformation[0].NameLength / sizeof(WCHAR); i++)
dprintf("%C",KeyValueInformation[0].Name[i]);
dprintf("'\n");
if (KeyValueInformation[0].Type == REG_SZ)
dprintf(" Value '%S'\n",
KeyValueInformation[0].Name+1
+KeyValueInformation[0].NameLength/2);
}
dprintf("Close link key\n");
NtClose(hKey);
dprintf("Test successful!\n");
}
/* registry link delete test */
void test7(void)
{
HKEY hKey;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName,ValueName;
NTSTATUS Status;
dprintf("Open link key\n");
dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Test");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK,
NULL,
NULL);
Status = NtCreateKey(&hKey,
KEY_ALL_ACCESS,
&ObjectAttributes,
0,
NULL,
REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK,
NULL);
dprintf(" NtCreateKey() called (Status %lx)\n",Status);
if (!NT_SUCCESS(Status))
{
dprintf("Could not open the link key. Please run the link create test first!\n");
return;
}
dprintf("Delete link value\n");
RtlInitUnicodeString(&ValueName, L"SymbolicLinkValue");
Status = NtDeleteValueKey(hKey,
&ValueName);
dprintf(" NtDeleteValueKey() called (Status %lx)\n",Status);
dprintf("Delete link key\n");
Status=NtDeleteKey(hKey);
dprintf(" NtDeleteKey() called (Status %lx)\n",Status);
dprintf("Close link key\n");
NtClose(hKey);
}
void test8(void)
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
NTSTATUS Status;
LONG dwError;
TOKEN_PRIVILEGES NewPrivileges;
HANDLE Token,hKey;
LUID Luid;
BOOLEAN bRes;
Status=NtOpenProcessToken(GetCurrentProcess()
,TOKEN_ADJUST_PRIVILEGES,&Token);
// ,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
dprintf("\t\t\t\tStatus =%x\n",Status);
// bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
// dprintf("\t\t\t\tbRes =%x\n",bRes);
NewPrivileges.PrivilegeCount = 1;
NewPrivileges.Privileges[0].Luid = Luid;
// NewPrivileges.Privileges[0].Luid.u.LowPart=18;
// NewPrivileges.Privileges[0].Luid.u.HighPart=0;
NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Status = NtAdjustPrivilegesToken(
bRes = AdjustTokenPrivileges(
Token,
FALSE,
&NewPrivileges,
0,
NULL,
NULL
);
dprintf("\t\t\t\tbRes =%x\n",bRes);
// Status=NtClose(Token);
// dprintf("\t\t\t\tStatus =%x\n",Status);
RtlInitUnicodeString(&KeyName,L"test5");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtLoadKey(HKEY_LOCAL_MACHINE,&ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
dwError=RegLoadKey(HKEY_LOCAL_MACHINE,"def"
,"test5");
dprintf("\t\t\t\tdwError =%x\n",dwError);
dprintf("NtOpenKey \\Registry\\Machine : ");
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
dprintf("\t\t\tStatus =%x\n",Status);
RtlInitUnicodeString(&KeyName,L"test5");
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
, NULL, NULL);
Status = NtLoadKey(hKey,&ObjectAttributes);
dprintf("\t\t\t\tStatus =%x\n",Status);
}
int main(int argc, char* argv[])
{
char Buffer[10];
DWORD Result;
AllocConsole();
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
while(1)
{
dprintf("choose test :\n");
dprintf(" 0=Exit\n");
dprintf(" 1=Ntxxx read functions\n");
dprintf(" 2=Ntxxx write functions : volatile keys\n");
dprintf(" 3=Ntxxx write functions : non volatile keys\n");
dprintf(" 4=Regxxx functions\n");
dprintf(" 5=FlushKey \n");
dprintf(" 6=Registry link create test\n");
dprintf(" 7=Registry link delete test\n");
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
switch (Buffer[0])
{
case '0':
return(0);
case '1':
test1();
break;
case '2':
test2();
break;
case '3':
test3();
break;
case '4':
test4();
break;
case '5':
test5();
break;
case '6':
test6();
break;
case '7':
test7();
break;
#if 0
case '8':
test8();
break;
#endif
}
}
return 0;
}

View File

@@ -0,0 +1,19 @@
# $Id: Makefile,v 1.3 2002/06/02 19:25:00 chorns Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = sectest
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,72 @@
/* $Id: sectest.c,v 1.1 2002/05/13 20:15:33 chorns Exp $ */
#define UNICODE
#define _UNICODE
#include <windows.h>
int main(int argc, char* argv[])
{
HANDLE hFile;
HANDLE Section;
PVOID BaseAddress;
printf("Section Test\n");
hFile = CreateFile(_T("sectest.txt"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
0,
0);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("Failed to create file (err=%d)", GetLastError());
return 1;
}
Section = CreateFileMapping(
hFile,
NULL,
PAGE_READWRITE,
0,
4096,
NULL);
if (Section == NULL)
{
printf("Failed to create section (err=%d)", GetLastError());
return 1;
}
printf("Mapping view of section\n");
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
0,
0,
4096);
printf("BaseAddress %x\n", (UINT) BaseAddress);
if (BaseAddress == NULL)
{
printf("Failed to map section (%d)\n", GetLastError());
return 1;
}
printf("Clearing section\n");
FillMemory(BaseAddress, 4096, ' ');
printf("Copying test data to section\n");
strcpy(BaseAddress, "test data");
if (!UnmapViewOfFile(BaseAddress))
{
printf("Failed to unmap view of file (%d)\n", GetLastError());
return 1;
}
if (!CloseHandle(hFile))
{
printf("Failed to close file (%d)\n", GetLastError());
return 1;
}
return 0;
}

View File

@@ -0,0 +1,47 @@
#
#
#
PATH_TO_TOP = ../../..
include $(PATH_TO_TOP)/rules.mak
SRV_OBJECTS= shmsrv.o
CLT_OBJECTS= shmclt.o
PROGS= shmsrv.exe shmclt.exe
BASE_CFLAGS = -I$(PATH_TO_TOP)/include
LIBS = $(SDK_PATH_LIB)/kernel32.a \
$(SDK_PATH_LIB)/ntdll.a
all: $(PROGS)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
install: $(PROGS:%=$(INSTALL_DIR)/bin/%)
$(PROGS:%=$(INSTALL_DIR)/bin/%): $(INSTALL_DIR)/bin/%: %
$(CP) $* $(INSTALL_DIR)/bin/$*
dist: $(PROGS:%=$(DIST_DIR)/apps/%)
$(PROGS:%=$(DIST_DIR)/apps/%): $(DIST_DIR)/apps/%: %
$(CP) $* $(DIST_DIR)/apps/$*
shmsrv.exe: $(SRV_OBJECTS) $(LIBS)
$(CC) $(SRV_OBJECTS) $(LIBS) -o shmsrv.exe
$(NM) --numeric-sort shmsrv.exe > shmsrv.sym
shmclt.exe: $(CLT_OBJECTS) $(LIBS)
$(CC) $(CLT_OBJECTS) $(LIBS) -o shmclt.exe
$(NM) --numeric-sort shmsrv.exe > shmclt.sym
# EOF

View File

@@ -0,0 +1,61 @@
#include <ddk/ntddk.h>
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
HANDLE OutputHandle;
HANDLE InputHandle;
void debug_printf(char* fmt, ...)
{
va_list args;
char buffer[255];
va_start(args,fmt);
vsprintf(buffer,fmt,args);
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
va_end(args);
}
int
main(int argc, char* argv[])
{
HANDLE Section;
PVOID BaseAddress;
char buffer[256];
printf("Shm test server\n");
Section = OpenFileMappingW (
// PAGE_EXECUTE_READWRITE, invalid parameter
FILE_MAP_WRITE,
FALSE,
L"TestSection"
);
if (Section == NULL)
{
printf("Failed to open section (err=%d)", GetLastError());
return 1;
}
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
0,
0,
8192);
if (BaseAddress == NULL)
{
printf("Failed to map section (err=%d)\n", GetLastError());
return 1;
}
printf("BaseAddress %x\n", (UINT) BaseAddress);
printf("Copying from section\n");
strcpy(buffer, BaseAddress);
printf("Copyed <%s>\n", buffer);
// for(;;);
return 0;
}

View File

@@ -0,0 +1,53 @@
/* $Id: shmsrv.c,v 1.5 2000/06/29 23:35:10 dwelch Exp $
*
* FILE : reactos/apps/shm/shmsrv.c
* AUTHOR: David Welch
*/
#include <ddk/ntddk.h>
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
HANDLE Section;
PVOID BaseAddress;
printf("Shm test server\n");
Section = CreateFileMappingW (
(HANDLE) 0xFFFFFFFF,
NULL,
PAGE_READWRITE,
0,
8192,
L"TestSection"
);
if (Section == NULL)
{
printf("Failed to create section (err=%d)", GetLastError());
return 1;
}
printf("Mapping view of section\n");
BaseAddress = MapViewOfFile(Section,
FILE_MAP_ALL_ACCESS,
0,
0,
8192);
printf("BaseAddress %x\n", (UINT) BaseAddress);
if (BaseAddress == NULL)
{
printf("Failed to map section\n");
}
printf("Copying to section\n");
printf("Copying %s\n", GetCommandLineA());
strcpy(BaseAddress, GetCommandLineA());
Sleep(INFINITE);
return 0;
}

View File

@@ -0,0 +1,20 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = windows
TARGET_NAME = simple
TARGET_SDKLIBS = kernel32.a gdi32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,15 @@
/*
* The simplest Windows program you will ever write.
*
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
*
* Colin Peters <colinp at ma.kcom.ne.jp>, July 1, 2001.
*/
#include <windows.h>
int STDCALL
WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
MessageBox (NULL, "Hello, Windows!", "Hello", MB_OK);
return 0;
}

View File

@@ -0,0 +1,21 @@
# $Id: makefile,v 1.1 2002/06/17 06:01:17 sedwards Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = tcpsvr
TARGET_SDKLIBS = kernel32.a ws2_32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,173 @@
/* tcpServer.c
*
* Simple Winsock TCP server test.
* Later will be used as base for ReactOS telnetd
*
* HISTORY:
* 6-15-02 - Added Winsock support to UNIX tcp test
* 6-16-02 - Removed Unix support
* 6-17-02 - Added extra comments to code
*
*/
#include <winsock2.h>
#include <stdio.h>
#undef ERROR
#define SUCCESS 0
#define ERROR 1
#define END_LINE 0x0A
#define SERVER_PORT 23
#define MAX_MSG 100
/* function readline */
int read_line();
int main (int argc, char *argv[]) {
WORD wVersionRequested;
WSADATA WsaData;
INT Status;
int sd, newSd, cliLen;
struct sockaddr_in cliAddr, servAddr;
char line[MAX_MSG];
wVersionRequested = MAKEWORD(2, 2);
Status = WSAStartup(wVersionRequested, &WsaData);
if (Status != 0) {
printf("Could not initialize winsock dll.\n");
return FALSE;
}
/* create socket */
sd = socket(AF_INET, SOCK_STREAM, 0);
if(sd<0) {
perror("cannot open socket ");
WSACleanup();
return ERROR;
}
/* bind server port */
servAddr.sin_family = AF_INET;
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
servAddr.sin_port = htons(SERVER_PORT);
if(bind(sd, (struct sockaddr *) &servAddr, sizeof(servAddr))<0) {
perror("cannot bind port ");
WSACleanup();
return ERROR;
}
listen(sd,5);
while(1) {
printf("%s: \n
To start test, Please telnet to localhost (127.0.0.1) port 23 \n
When connected input raw data followed by End of Line\n
Test is now running on TCP port %u\n",argv[0],SERVER_PORT);
cliLen = sizeof(cliAddr);
newSd = accept(sd, (struct sockaddr *) &cliAddr, &cliLen);
if(newSd<0) {
perror("cannot accept connection ");
WSACleanup();
return ERROR;
}
/* init line */
memset(line,0x0,MAX_MSG);
/* receive segments */
while(read_line(newSd,line)!=ERROR) {
printf("%s: received from %s:TCP%d : %s\n", argv[0],
inet_ntoa(cliAddr.sin_addr),
ntohs(cliAddr.sin_port), line);
/* init line */
memset(line,0x0,MAX_MSG);
} /* while(read_line) */
} /* while (1) */
}
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING */
/* this function is experimental.. I don't know yet if it works */
/* correctly or not. Use Steven's readline() function to have */
/* something robust. */
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING */
/* rcv_line is my function readline(). Data is read from the socket when */
/* needed, but not byte after bytes. All the received data is read. */
/* This means only one call to recv(), instead of one call for */
/* each received byte. */
/* You can set END_CHAR to whatever means endofline for you. (0x0A is \n)*/
/* read_lin returns the number of bytes returned in line_to_return */
int read_line(int newSd, char *line_to_return) {
static int rcv_ptr=0;
static char rcv_msg[MAX_MSG];
static int n;
int offset;
offset=0;
while(1) {
if(rcv_ptr==0) {
/* read data from socket */
memset(rcv_msg,0x0,MAX_MSG); /* init buffer */
n = recv(newSd, rcv_msg, MAX_MSG, 0); /* wait for data */
if (n<0) {
perror(" cannot receive data ");
return ERROR;
} else if (n==0) {
printf(" connection closed by client\n");
close(newSd);
WSACleanup();
return ERROR;
}
}
/* if new data read on socket */
/* OR */
/* if another line is still in buffer */
/* copy line into 'line_to_return' */
while(*(rcv_msg+rcv_ptr)!=END_LINE && rcv_ptr<n) {
memcpy(line_to_return+offset,rcv_msg+rcv_ptr,1);
offset++;
rcv_ptr++;
}
/* end of line + end of buffer => return line */
if(rcv_ptr==n-1) {
/* set last byte to END_LINE */
*(line_to_return+offset)=END_LINE;
rcv_ptr=0;
return ++offset;
}
/* end of line but still some data in buffer => return line */
if(rcv_ptr <n-1) {
/* set last byte to END_LINE */
*(line_to_return+offset)=END_LINE;
rcv_ptr++;
return ++offset;
}
/* end of buffer but line is not ended => */
/* wait for more data to arrive on socket */
if(rcv_ptr == n) {
rcv_ptr = 0;
}
} /* while */
}

View File

@@ -0,0 +1,11 @@
#include <stdio.h>
int
main (void)
{
int i;
puts ("This should print \"wow = I\" for I from 0 to 39 inclusive.");
for (i = 0; i < 40; i++)
printf ("%s = %d\n", "wow", i);
return 0;
}

View File

@@ -0,0 +1,53 @@
#include <stdio.h>
#include <string.h>
int
main (void)
{
FILE *f;
int i;
const char filename[] = "/tmp/bug3.test";
f = fopen(filename, "w+");
for (i=0; i<9000; i++)
putc ('x', f);
fseek (f, 8180L, 0);
fwrite ("Where does this text go?", 1, 24, f);
fflush (f);
rewind (f);
for (i=0; i<9000; i++)
{
int j;
if ((j = getc(f)) != 'x')
{
if (i != 8180)
{
printf ("Test FAILED!");
return 1;
}
else
{
char buf[25];
buf[0] = j;
fread (buf + 1, 1, 23, f);
buf[24] = '\0';
if (strcmp (buf, "Where does this text go?") != 0)
{
printf ("%s\nTest FAILED!\n", buf);
return 1;
}
i += 23;
}
}
}
fclose(f);
remove(filename);
puts ("Test succeeded.");
return 0;
}

View File

@@ -0,0 +1,73 @@
#
#
#
PATH_TO_TOP = ../..
PROGS= test-stdio tst-printf tstdiomisc bug2 bug3 \
temptest test-fseek test_rdwr testfsd time_t
all: $(PROGS:%=%.exe)
.phony: all
implib:
clean:
- $(RM) *.o *.exe *.sym
.phony: implib clean
install: # $(PROGS:%=$(FLOPPY_DIR)/apps/%.exe)
$(PROGS:%=$(FLOPPY_DIR)/apps/%.exe): $(FLOPPY_DIR)/apps/%.exe: %.exe
dist: $(PROGS:%=$(DIST_DIR)/apps/%.exe)
$(PROGS:%=$(DIST_DIR)/apps/%.exe): $(DIST_DIR)/apps/%.exe: %.exe
$(CP) $*.exe $(DIST_DIR)/apps/$*.exe
bug2.exe: bug2.c
$(CC) bug2.c -lkernel32 -o bug2.exe
$(NM) --numeric-sort bug2.exe > bug2.sym
bug3.exe: bug3.c
$(CC) bug3.c -lkernel32 -o bug3.exe
$(NM) --numeric-sort bug3.exe > bug3.sym
temptest.exe: temptest.c
$(CC) temptest.c -lkernel32 -o temptest.exe
$(NM) --numeric-sort temptest.exe > temptest.sym
test-fseek.exe: test-fseek.c
$(CC) test-fseek.c -lkernel32 -o test-fseek.exe
$(NM) --numeric-sort test-fseek.exe > test-fseek.sym
test-fwrite.exe: test-fwrite.c
$(CC) test-fwrite.c -lkernel32 -o test-fwrite.exe
$(NM) --numeric-sort test-fwrite.exe > test-fwrite.sym
test_rdwr.exe: test_rdwr.c
$(CC) test_rdwr.c -lkernel32 -o test_rdwr.exe
$(NM) --numeric-sort test_rdwr.exe > test_rdwr.sym
test-stdio.exe: test-stdio.c
$(CC) test-stdio.c -lkernel32 -o test-stdio.exe
$(NM) --numeric-sort test-stdio.exe > test-stdio.sym
tst-printf.exe: tst-printf.c
$(CC) tst-printf.c -lkernel32 -o tst-printf.exe
$(NM) --numeric-sort tst-printf.exe > tst-printf.sym
tstdiomisc.exe: tstdiomisc.c
$(CC) tstdiomisc.c -lkernel32 -o tstdiomisc.exe
$(NM) --numeric-sort tstdiomisc.exe > tstdiomisc.sym
testfsd.exe: testfsd.c testsuite.c
$(CC) testfsd.c testsuite.c -lkernel32 -o testfsd.exe
$(NM) --numeric-sort testfsd.exe > testfsd.sym
time_t.exe: time_t.c
$(CC) time_t.c -lkernel32 -o time_t.exe
$(NM) --numeric-sort time_t.exe > time_t.sym
include ../../rules.mak

View File

@@ -0,0 +1,27 @@
#include <stdio.h>
#include <string.h>
char *files[500];
int
main (int argc, char *argv[])
{
FILE *fp;
int i;
for (i = 0; i < 500; i++) {
files[i] = tempnam (NULL, "file");
if (files[i] == NULL) {
printf ("tempnam failed\n");
exit (1);
}
printf ("file: %s\n", files[i]);
fp = fopen (files[i], "w");
fclose (fp);
}
for (i = 0; i < 500; i++)
remove (files[i]);
exit (0);
}

View File

@@ -0,0 +1,85 @@
/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <stdio.h>
#define TESTFILE "/tmp/test.dat"
int
main (void)
{
FILE *fp;
int i, j;
puts ("\nFile seek test");
fp = fopen (TESTFILE, "w");
if (fp == NULL)
{
perror (TESTFILE);
return 1;
}
for (i = 0; i < 256; i++)
putc (i, fp);
if (freopen (TESTFILE, "r", fp) != fp)
{
perror ("Cannot open file for reading");
return 1;
}
for (i = 1; i <= 255; i++)
{
printf ("%3d\n", i);
fseek (fp, (long) -i, SEEK_END);
if ((j = getc (fp)) != 256 - i)
{
printf ("SEEK_END failed %d\n", j);
break;
}
if (fseek (fp, (long) i, SEEK_SET))
{
puts ("Cannot SEEK_SET");
break;
}
if ((j = getc (fp)) != i)
{
printf ("SEEK_SET failed %d\n", j);
break;
}
if (fseek (fp, (long) i, SEEK_SET))
{
puts ("Cannot SEEK_SET");
break;
}
if (fseek (fp, (long) (i >= 128 ? -128 : 128), SEEK_CUR))
{
puts ("Cannot SEEK_CUR");
break;
}
if ((j = getc (fp)) != (i >= 128 ? i - 128 : i + 128))
{
printf ("SEEK_CUR failed %d\n", j);
break;
}
}
fclose (fp);
remove (TESTFILE);
puts ((i > 255) ? "Test succeeded." : "Test FAILED!");
return (i > 255) ? 0 : 1;
}

View File

@@ -0,0 +1,68 @@
#include <stdio.h>
#include <string.h>
int
main (int argc, char *argv[])
{
FILE *f = tmpfile ();
char obuf[99999], ibuf[sizeof obuf];
char *line;
size_t linesz;
if (! f)
{
perror ("tmpfile");
return 1;
}
if (fputs ("line\n", f) == EOF)
{
perror ("fputs");
return 1;
}
memset (obuf, 'z', sizeof obuf);
memset (ibuf, 'y', sizeof ibuf);
if (fwrite (obuf, sizeof obuf, 1, f) != 1)
{
perror ("fwrite");
return 1;
}
rewind (f);
line = NULL;
linesz = 0;
if (getline (&line, &linesz, f) != 5)
{
perror ("getline");
return 1;
}
if (strcmp (line, "line\n"))
{
puts ("Lines differ. Test FAILED!");
return 1;
}
if (fread (ibuf, sizeof ibuf, 1, f) != 1)
{
perror ("fread");
return 1;
}
if (memcmp (ibuf, obuf, sizeof ibuf))
{
puts ("Buffers differ. Test FAILED!");
return 1;
}
asprintf (&line, "\
GDB is free software and you are welcome to distribute copies of it\n\
under certain conditions; type \"show copying\" to see the conditions.\n\
There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
");
puts ("Test succeeded.");
return 0;
}

View File

@@ -0,0 +1,55 @@
#include <stdio.h>
#include <string.h>
int main()
{
char msg1[] = "testing _write\n";
char msg2[] = "testing putchar.";
char msg3[] = "testing printf.";
char tmpbuf[255];
FILE* f1;
write(1, msg1, strlen(msg1));
write(1, msg2, strlen(msg2));
putchar('o'); putchar('k'); putchar('\n');
write(1, msg3, strlen(msg3));
printf("ok\n");
printf("Testing fopen\n");
f1 = fopen("tmp.txt","w+b");
if (f1 == NULL)
{
printf("fopen failed\n");
return(1);
}
printf("Testing fwrite\n");
if (fwrite(msg1, 1, strlen(msg1)+1, f1) != (strlen(msg1)+1))
{
printf("fwrite failed\n");
return(1);
}
printf("Testing fread\n");
fseek(f1, 0, SEEK_SET);
if (fread(tmpbuf, 1, strlen(msg1)+1, f1) != (strlen(msg1)+1))
{
printf("fread failed\n");
return(1);
}
if (strcmp(tmpbuf,msg1) != 0)
{
printf("fread failed, data corrupt\n");
return(1);
}
printf("Testing fclose\n");
if (fclose(f1) != 0)
{
printf("fclose failed\n");
return(1);
}
return(0);
}

View File

@@ -0,0 +1,129 @@
/* Copyright (C) 1991, 1992, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main (int argc, char **argv)
{
static const char hello[] = "Hello, world.\n";
static const char replace[] = "Hewwo, world.\n";
static const size_t replace_from = 2, replace_to = 4;
char filename[FILENAME_MAX];
char *name = strrchr (*argv, '/');
char buf[BUFSIZ];
FILE *f;
int lose = 0;
if (name != NULL)
++name;
else
name = *argv;
(void) sprintf (filename, "/tmp/%s.test", name);
f = fopen (filename, "w+");
if (f == NULL)
{
perror (filename);
exit (1);
}
(void) fputs (hello, f);
rewind (f);
(void) fgets (buf, sizeof (buf), f);
rewind (f);
(void) fputs (buf, f);
rewind (f);
{
size_t i;
for (i = 0; i < replace_from; ++i)
{
int c = getc (f);
if (c == EOF)
{
printf ("EOF at %Zu.\n", i);
lose = 1;
break;
}
else if (c != hello[i])
{
printf ("Got '%c' instead of '%c' at %Zu.\n",
(unsigned char) c, hello[i], i);
lose = 1;
break;
}
}
}
{
long int where = ftell (f);
if (where == (long int) replace_from)
{
register size_t i;
for (i = replace_from; i < replace_to; ++i)
if (putc(replace[i], f) == EOF)
{
printf ("putc('%c') got %s at %Zu.\n",
replace[i], strerror (errno), i);
lose = 1;
break;
}
}
else if (where == -1L)
{
printf ("ftell got %s (should be at %Zu).\n",
strerror (errno), replace_from);
lose = 1;
}
else
{
printf ("ftell returns %lu; should be %Zu.\n", where, replace_from);
lose = 1;
}
}
if (!lose)
{
rewind (f);
if (fgets (buf, sizeof (buf), f) == NULL)
{
printf ("fgets got %s.\n", strerror(errno));
lose = 1;
}
else if (strcmp (buf, replace))
{
printf ("Read \"%s\" instead of \"%s\".\n", buf, replace);
lose = 1;
}
}
if (lose)
printf ("Test FAILED! Losing file is \"%s\".\n", filename);
else
{
(void) remove (filename);
puts ("Test succeeded.");
}
exit (lose ? EXIT_FAILURE : EXIT_SUCCESS);
}

View File

@@ -0,0 +1,315 @@
/* $Id: testfsd.c,v 1.4 2001/07/04 03:07:54 rex Exp $
*
* FILE: testFSD.c
* PURPOSE: A test set for the File System Driver
* PROJECT: ReactOS kernel
* COPYRIGHT: See COPYING in the top level directory
* PROGRAMMER: Rex Jolliff (rex@lvcablemodem.com)
*
*/
#include <errno.h>
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include "testsuite.h"
const char *rootDir = "c:\\";
const char *systemRootDir = "c:\\ReactOS";
const char *systemDllDir = "c:\\ReactOS\\System32";
const char *bogusRootFile = "c:\\bogus";
const char *bogusDirAndFile = "c:\\bogus\\bogus";
const char *bogusSystemRootFile = "c:\\ReactOS\\bogus";
const char *bogusSystemDllFile = "c:\\ReactOS\\System32\\bogus";
const char *shortFile = "c:\\ReactOS\\boot.bat";
const char *longFile = "c:\\ReactOS\\loadros.com";
void testOpenExistant (void)
{
HANDLE fileHandle;
fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile (systemRootDir, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile (systemDllDir, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
}
void testOpenNonExistant (void)
{
DWORD status;
HANDLE fileHandle;
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_FILE_NOT_FOUND);
CloseHandle (fileHandle);
fileHandle = CreateFile (bogusDirAndFile, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_PATH_NOT_FOUND);
CloseHandle (fileHandle);
fileHandle = CreateFile (bogusSystemRootFile, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_FILE_NOT_FOUND);
CloseHandle (fileHandle);
fileHandle = CreateFile (bogusSystemDllFile, GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_FILE_NOT_FOUND);
CloseHandle (fileHandle);
}
void testCreateExistant (void)
{
DWORD status;
HANDLE fileHandle;
fileHandle = CreateFile (rootDir, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_ALREADY_EXISTS);
fileHandle = CreateFile (systemRootDir, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_ALREADY_EXISTS);
fileHandle = CreateFile (systemDllDir, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_ALREADY_EXISTS);
}
void testCreateNonExistant (void)
{
DWORD status;
HANDLE fileHandle;
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile (bogusSystemRootFile, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile (bogusSystemDllFile, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
#if 0
fileHandle = CreateFile (bogusDirAndFile, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle == INVALID_HANDLE_VALUE);
status = GetLastError ();
ASSERT (status == ERROR_PATH_NOT_FOUND);
CloseHandle (fileHandle);
#endif
}
void testDeleteFiles (void)
{
BOOL returnValue;
HANDLE fileHandle;
fileHandle = CreateFile ("bogus", GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
returnValue = DeleteFile ("bogus");
ASSERT_MSG (returnValue,
"Delete of bogus failed, error:%d",
GetLastError ());
#if 0
returnValue = DeleteFile (bogusRootFile);
ASSERT_MSG (returnValue,
"Delete of %s failed, error:%d",
bogusRootFile,
GetLastError ());
returnValue = DeleteFile (bogusRootFile);
ASSERT_MSG (!returnValue,
"2nd Delete of %s succeeded but should fail",
bogusRootFile);
returnValue = DeleteFile (bogusSystemRootFile);
ASSERT_MSG (returnValue,
"Delete of %s failed, error:%d",
bogusSystemRootFile,
GetLastError ());
returnValue = DeleteFile (bogusSystemRootFile);
ASSERT_MSG (!returnValue,
"2nd Delete of %s succeeded but should fail",
bogusSystemRootFile);
returnValue = DeleteFile (bogusSystemDllFile);
ASSERT_MSG (returnValue,
"Delete of %s failed, error:%d",
bogusSystemDllFile,
GetLastError ());
returnValue = DeleteFile (bogusSystemDllFile);
ASSERT_MSG (!returnValue,
"2nd Delete of %s succeeded but should fail",
bogusSystemDllFile);
returnValue = DeleteFile (bogusDirAndFile);
ASSERT_MSG (!returnValue,
"Delete of %s succeded but should fail",
bogusDirAndFile);
#endif
}
void testOpenWithBlankPathElements (void)
{
HANDLE fileHandle;
fileHandle = CreateFile ("c:", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile ("c:\\\\", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile ("c:\\\\reactos\\", GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile ("c:\\reactos\\\\", GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile ("c:\\reactos\\\\system32\\", GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile ("c:\\reactos\\system32\\\\", GENERIC_READ, 0, 0,
OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
}
void testReadOnInvalidHandle (void)
{
BOOL returnValue;
char buffer [256];
DWORD bytesRead;
returnValue = ReadFile (INVALID_HANDLE_VALUE,
buffer,
256,
&bytesRead,
NULL);
ASSERT_MSG (!returnValue,
"Read from invalid handle succeeded but should fail",0);
ASSERT (GetLastError () != ENOFILE);
}
void testReadOnZeroLengthFile (void)
{
BOOL returnValue;
HANDLE fileHandle;
char buffer [256];
DWORD bytesRead;
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0,
CREATE_NEW, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
CloseHandle (fileHandle);
fileHandle = CreateFile (bogusRootFile, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
returnValue = ReadFile (fileHandle, buffer, 256, &bytesRead, NULL);
ASSERT_MSG (!returnValue,
"Read from zero length file succeeded but should fail",0);
ASSERT (GetLastError () != ERROR_HANDLE_EOF);
CloseHandle (fileHandle);
returnValue = DeleteFile (bogusRootFile);
ASSERT_MSG (returnValue,
"Delete of %s failed, error:%d",
bogusRootFile,
GetLastError ());
}
void testReadOnShortFile (void)
{
BOOL returnValue;
HANDLE fileHandle;
char buffer [256];
DWORD bytesRead;
fileHandle = CreateFile (shortFile, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
returnValue = ReadFile (fileHandle,
buffer,
256,
&bytesRead,
NULL);
ASSERT_MSG (returnValue,
"Read from short length file failed, error:%d",
GetLastError ());
ASSERT (bytesRead > 0 && bytesRead < 256);
CloseHandle (fileHandle);
}
void testReadOnLongFile (void)
{
BOOL returnValue;
HANDLE fileHandle;
char buffer [256];
DWORD bytesRead;
int count;
fileHandle = CreateFile (longFile, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
ASSERT (fileHandle != INVALID_HANDLE_VALUE);
for (count = 0; count < 20; count++)
{
returnValue = ReadFile (fileHandle,
buffer,
256,
&bytesRead,
NULL);
ASSERT_MSG (returnValue,
"Read from short length file failed, error:%d",
GetLastError ());
ASSERT (bytesRead == 256);
}
CloseHandle (fileHandle);
}
int main (void)
{
TEST_RUNNER testRunner;
TEST_SUITE testsToRun [] =
{
ADD_TEST (testOpenExistant),
ADD_TEST (testOpenNonExistant),
ADD_TEST (testCreateExistant),
ADD_TEST (testCreateNonExistant),
ADD_TEST (testDeleteFiles),
/* ADD_TEST (testOverwriteExistant),*/
/* ADD_TEST (testOverwriteNonExistant),*/
ADD_TEST (testOpenWithBlankPathElements),
ADD_TEST (testReadOnInvalidHandle),
ADD_TEST (testReadOnZeroLengthFile),
ADD_TEST (testReadOnShortFile),
ADD_TEST (testReadOnLongFile),
/* ADD_TEST (test), */
END_TESTS
};
memset (&testRunner, 0, sizeof (TEST_RUNNER));
tsRunTests (&testRunner, testsToRun);
tsReportResults (&testRunner);
}

View File

@@ -0,0 +1,65 @@
#include <windows.h>
#include <stdio.h>
#include "testsuite.h"
static PTEST_RUNNER iTestRunner = 0;
void tsRunTests (PTEST_RUNNER pTestRunner, PTEST_SUITE pTests)
{
int testIndex;
iTestRunner = pTestRunner;
for (testIndex = 0; pTests [testIndex].testFunc != 0; testIndex++)
{
pTests [testIndex].testFunc ();
pTestRunner->tests++;
}
}
void tsReportResults (PTEST_RUNNER pTestRunner)
{
printf ("\nTotal of %d tests.\n"
"Assertions: %d\n"
" Assertions which passed: %d\n"
" Assertions which failed: %d\n",
pTestRunner->tests,
pTestRunner->assertions,
pTestRunner->successes,
pTestRunner->failures);
if (pTestRunner->failures == 0)
{
printf ("\n*** OK ***\n");
}
else
{
printf ("\n*** FAIL ***\n");
}
}
void tsDoAssertion (BOOL pTest,
PCHAR pTestText,
PCHAR pFunction,
int pLine,
...)
{
va_list ap;
iTestRunner->assertions++;
if (!pTest)
{
va_start (ap, pLine);
printf ("%s(%d): ", pFunction, pLine);
vprintf (pTestText, ap);
printf ("\n");
va_end(ap);
iTestRunner->failures++;
}
else
{
iTestRunner->successes++;
}
}

View File

@@ -0,0 +1,44 @@
#ifndef H_TESTSUITE_H
#define H_TESTSUITE_H
struct TestSuite
{
char *name;
void (*testFunc)(void);
};
typedef struct TestSuite TEST_SUITE, *PTEST_SUITE;
#define ADD_TEST(x) {#x, x}
#define END_TESTS {0, 0}
#define COUNT_TESTS(x) (sizeof x/sizeof (struct TestSuite))
struct TestRunner
{
int tests;
int assertions;
int failures;
int successes;
};
typedef struct TestRunner TEST_RUNNER, *PTEST_RUNNER;
void tsDoAssertion (BOOL pTest,
PCHAR pTestText,
PCHAR pFunction,
int pLine,
...);
#ifdef ASSERT
#undef ASSERT
#endif
#define ASSERT(x) tsDoAssertion (x, "assertion \"" ## #x ## "\" failed", __FUNCTION__, __LINE__)
#define ASSERT_MSG(x,y,a...) tsDoAssertion (x, y, __FUNCTION__, __LINE__,a)
void tsRunTests (PTEST_RUNNER pTestRunner, PTEST_SUITE pTests);
void tsReportResults (PTEST_RUNNER pTestRunner);
#endif

View File

@@ -0,0 +1,12 @@
#include <stdio.h>
#include <time.h>
int main(void)
{
struct tm *ptr;
time_t lt;
lt = time(NULL);
ptr = localtime(&lt);
printf(asctime(ptr));
}

View File

@@ -0,0 +1,311 @@
/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef BSD
#include </usr/include/stdio.h>
#define EXIT_SUCCESS 0
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
#include <float.h>
void rfg1 (void);
void rfg2 (void);
void
fmtchk (const char *fmt)
{
(void) fputs(fmt, stdout);
(void) printf(":\t`");
(void) printf(fmt, 0x12);
(void) printf("'\n");
}
void
fmtst1chk (const char *fmt)
{
(void) fputs(fmt, stdout);
(void) printf(":\t`");
(void) printf(fmt, 4, 0x12);
(void) printf("'\n");
}
void
fmtst2chk (const char *fmt)
{
(void) fputs(fmt, stdout);
(void) printf(":\t`");
(void) printf(fmt, 4, 4, 0x12);
(void) printf("'\n");
}
/* This page is covered by the following copyright: */
/* (C) Copyright C E Chew
*
* Feel free to copy, use and distribute this software provided:
*
* 1. you do not pretend that you wrote it
* 2. you leave this copyright notice intact.
*/
/*
* Extracted from exercise.c for glibc-1.05 bug report by Bruce Evans.
*/
#define DEC -123
#define INT 255
#define UNS (~0)
/* Formatted Output Test
*
* This exercises the output formatting code.
*/
void
fp_test (void)
{
int i, j, k, l;
char buf[7];
char *prefix = buf;
char tp[20];
puts("\nFormatted output test");
printf("prefix 6d 6o 6x 6X 6u\n");
strcpy(prefix, "%");
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
for (k = 0; k < 2; k++) {
for (l = 0; l < 2; l++) {
strcpy(prefix, "%");
if (i == 0) strcat(prefix, "-");
if (j == 0) strcat(prefix, "+");
if (k == 0) strcat(prefix, "#");
if (l == 0) strcat(prefix, "0");
printf("%5s |", prefix);
strcpy(tp, prefix);
strcat(tp, "6d |");
printf(tp, DEC);
strcpy(tp, prefix);
strcat(tp, "6o |");
printf(tp, INT);
strcpy(tp, prefix);
strcat(tp, "6x |");
printf(tp, INT);
strcpy(tp, prefix);
strcat(tp, "6X |");
printf(tp, INT);
strcpy(tp, prefix);
strcat(tp, "6u |");
printf(tp, UNS);
printf("\n");
}
}
}
}
printf("%10s\n", (char *) NULL);
printf("%-10s\n", (char *) NULL);
}
int
main (int argc, char *argv[])
{
static char shortstr[] = "Hi, Z.";
static char longstr[] = "Good morning, Doctor Chandra. This is Hal. \
I am ready for my first lesson today.";
fmtchk("%.4x");
fmtchk("%04x");
fmtchk("%4.4x");
fmtchk("%04.4x");
fmtchk("%4.3x");
fmtchk("%04.3x");
fmtst1chk("%.*x");
fmtst1chk("%0*x");
fmtst2chk("%*.*x");
fmtst2chk("%0*.*x");
#ifndef BSD
printf("bad format:\t\"%b\"\n");
printf("nil pointer (padded):\t\"%10p\"\n", (void *) NULL);
#endif
printf("decimal negative:\t\"%d\"\n", -2345);
printf("octal negative:\t\"%o\"\n", -2345);
printf("hex negative:\t\"%x\"\n", -2345);
printf("long decimal number:\t\"%ld\"\n", -123456L);
printf("long octal negative:\t\"%lo\"\n", -2345L);
printf("long unsigned decimal number:\t\"%lu\"\n", -123456L);
printf("zero-padded LDN:\t\"%010ld\"\n", -123456L);
printf("left-adjusted ZLDN:\t\"%-010ld\"\n", -123456);
printf("space-padded LDN:\t\"%10ld\"\n", -123456L);
printf("left-adjusted SLDN:\t\"%-10ld\"\n", -123456L);
printf("zero-padded string:\t\"%010s\"\n", shortstr);
printf("left-adjusted Z string:\t\"%-010s\"\n", shortstr);
printf("space-padded string:\t\"%10s\"\n", shortstr);
printf("left-adjusted S string:\t\"%-10s\"\n", shortstr);
printf("null string:\t\"%s\"\n", (char *)NULL);
printf("limited string:\t\"%.22s\"\n", longstr);
printf("e-style >= 1:\t\"%e\"\n", 12.34);
printf("e-style >= .1:\t\"%e\"\n", 0.1234);
printf("e-style < .1:\t\"%e\"\n", 0.001234);
printf("e-style big:\t\"%.60e\"\n", 1e20);
printf ("e-style == .1:\t\"%e\"\n", 0.1);
printf("f-style >= 1:\t\"%f\"\n", 12.34);
printf("f-style >= .1:\t\"%f\"\n", 0.1234);
printf("f-style < .1:\t\"%f\"\n", 0.001234);
printf("g-style >= 1:\t\"%g\"\n", 12.34);
printf("g-style >= .1:\t\"%g\"\n", 0.1234);
printf("g-style < .1:\t\"%g\"\n", 0.001234);
printf("g-style big:\t\"%.60g\"\n", 1e20);
printf (" %6.5f\n", .099999999860301614);
printf (" %6.5f\n", .1);
printf ("x%5.4fx\n", .5);
printf ("%#03x\n", 1);
{
double d = FLT_MIN;
int niter = 17;
while (niter-- != 0)
printf ("%.17e\n", d / 2);
fflush (stdout);
}
printf ("%15.5e\n", 4.9406564584124654e-324);
#define FORMAT "|%12.4f|%12.4e|%12.4g|\n"
printf (FORMAT, 0.0, 0.0, 0.0);
printf (FORMAT, 1.0, 1.0, 1.0);
printf (FORMAT, -1.0, -1.0, -1.0);
printf (FORMAT, 100.0, 100.0, 100.0);
printf (FORMAT, 1000.0, 1000.0, 1000.0);
printf (FORMAT, 10000.0, 10000.0, 10000.0);
printf (FORMAT, 12345.0, 12345.0, 12345.0);
printf (FORMAT, 100000.0, 100000.0, 100000.0);
printf (FORMAT, 123456.0, 123456.0, 123456.0);
#undef FORMAT
{
char buf[20];
printf ("sprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n",
sprintf (buf, "%30s", "foo"), sizeof (buf), buf);
}
fp_test ();
printf ("%e should be 1.234568e+06\n", 1234567.8);
printf ("%f should be 1234567.800000\n", 1234567.8);
printf ("%g should be 1.23457e+06\n", 1234567.8);
printf ("%g should be 123.456\n", 123.456);
printf ("%g should be 1e+06\n", 1000000.0);
printf ("%g should be 10\n", 10.0);
printf ("%g should be 0.02\n", 0.02);
{
double x=1.0;
printf("%.17f\n",(1.0/x/10.0+1.0)*x-x);
}
puts ("--- Should be no further output. ---");
rfg1 ();
rfg2 ();
{
char buf[200];
int result;
sprintf(buf,"%*s%*s%*s",-1,"one",-20,"two",-30,"three");
result = strcmp (buf,
"onetwo three ");
puts (result != 0 ? "Test failed!" : "Test ok.");
return result != 0;
}
}
void
rfg1 (void)
{
char buf[100];
sprintf (buf, "%5.s", "xyz");
if (strcmp (buf, " ") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " ");
sprintf (buf, "%5.f", 33.3);
if (strcmp (buf, " 33") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 33");
sprintf (buf, "%8.e", 33.3e7);
if (strcmp (buf, " 3e+08") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 3e+08");
sprintf (buf, "%8.E", 33.3e7);
if (strcmp (buf, " 3E+08") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 3E+08");
sprintf (buf, "%.g", 33.3);
if (strcmp (buf, "3e+01") != 0)
printf ("got: '%s', expected: '%s'\n", buf, "3e+01");
sprintf (buf, "%.G", 33.3);
if (strcmp (buf, "3E+01") != 0)
printf ("got: '%s', expected: '%s'\n", buf, "3E+01");
}
void
rfg2 (void)
{
int prec;
char buf[100];
prec = 0;
sprintf (buf, "%.*g", prec, 3.3);
if (strcmp (buf, "3") != 0)
printf ("got: '%s', expected: '%s'\n", buf, "3");
prec = 0;
sprintf (buf, "%.*G", prec, 3.3);
if (strcmp (buf, "3") != 0)
printf ("got: '%s', expected: '%s'\n", buf, "3");
prec = 0;
sprintf (buf, "%7.*G", prec, 3.33);
if (strcmp (buf, " 3") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 3");
prec = 3;
sprintf (buf, "%04.*o", prec, 33);
if (strcmp (buf, " 041") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 041");
prec = 7;
sprintf (buf, "%09.*u", prec, 33);
if (strcmp (buf, " 0000033") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 0000033");
prec = 3;
sprintf (buf, "%04.*x", prec, 33);
if (strcmp (buf, " 021") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 021");
prec = 3;
sprintf (buf, "%04.*X", prec, 33);
if (strcmp (buf, " 021") != 0)
printf ("got: '%s', expected: '%s'\n", buf, " 021");
}

View File

@@ -0,0 +1,56 @@
#include <stdio.h>
int
t1 (void)
{
int n = -1;
sscanf ("abc ", "abc %n", &n);
printf ("t1: count=%d\n", n);
return n != 5;
}
int
t2 (void)
{
int result = 0;
int n;
long N;
int retval;
#define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \
VAR = -1; \
retval = sscanf (INPUT, FORMAT, &VAR); \
printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \
INPUT, FORMAT, retval, (long int) VAR); \
result |= retval != EXP_RES || VAR != EXP_VAL
SCAN ("12345", "%ld", N, 1, 12345);
SCAN ("12345", "%llllld", N, 0, -1);
SCAN ("12345", "%LLLLLd", N, 0, -1);
SCAN ("test ", "%*s%n", n, 0, 4);
SCAN ("test ", "%2*s%n", n, 0, -1);
SCAN ("12 ", "%l2d", n, 0, -1);
SCAN ("12 ", "%2ld", N, 1, 12);
n = -1;
N = -1;
retval = sscanf ("1 1", "%d %Z", &n, &N);
printf ("sscanf (\"1 1\", \"%%d %%Z\", &n, &N) => %d, n = %d, N = %ld\n", \
retval, n, N); \
result |= retval != 1 || n != 1 || N != -1;
return result;
}
int
main (int argc, char *argv[])
{
int result = 0;
result |= t1 ();
result |= t2 ();
result |= fflush (stdout) == EOF;
return result;
}

View File

@@ -0,0 +1,102 @@
/*
* Simple program to display the Windows System Metrics.
*
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
*
* Robert Dickenson <robd@reactos.org>, July 11, 2002.
*/
#include <stdio.h>
#include <windows.h>
int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
fprintf(stderr,"Windows System Metric:\t Value\n");
fprintf(stderr," SM_ARRANGE:\t\t %d\n", GetSystemMetrics(SM_ARRANGE));
fprintf(stderr," SM_CLEANBOOT:\t %d\n", GetSystemMetrics(SM_CLEANBOOT));
// fprintf(stderr," SM_CMONITORS:\t %d\n", GetSystemMetrics(SM_CMONITORS));
fprintf(stderr," SM_CMOUSEBUTTONS:\t %d\n", GetSystemMetrics(SM_CMOUSEBUTTONS));
fprintf(stderr," SM_CXBORDER:\t %d\n", GetSystemMetrics(SM_CXBORDER));
fprintf(stderr," SM_CYBORDER:\t %d\n", GetSystemMetrics(SM_CYBORDER));
fprintf(stderr," SM_CXCURSOR:\t %d\n", GetSystemMetrics(SM_CXCURSOR));
fprintf(stderr," SM_CYCURSOR:\t %d\n", GetSystemMetrics(SM_CYCURSOR));
fprintf(stderr," SM_CXDLGFRAME:\t %d\n", GetSystemMetrics(SM_CXDLGFRAME));
fprintf(stderr," SM_CYDLGFRAME:\t %d\n", GetSystemMetrics(SM_CYDLGFRAME));
fprintf(stderr," SM_CXDOUBLECLK:\t %d\n", GetSystemMetrics(SM_CXDOUBLECLK));
fprintf(stderr," SM_CYDOUBLECLK:\t %d\n", GetSystemMetrics(SM_CYDOUBLECLK));
fprintf(stderr," SM_CXDRAG:\t\t %d\n", GetSystemMetrics(SM_CXDRAG));
fprintf(stderr," SM_CYDRAG:\t\t %d\n", GetSystemMetrics(SM_CYDRAG));
fprintf(stderr," SM_CXEDGE:\t\t %d\n", GetSystemMetrics(SM_CXEDGE));
fprintf(stderr," SM_CYEDGE:\t\t %d\n", GetSystemMetrics(SM_CYEDGE));
fprintf(stderr," SM_CXFIXEDFRAME:\t %d\n", GetSystemMetrics(SM_CXFIXEDFRAME));
fprintf(stderr," SM_CYFIXEDFRAME:\t %d\n", GetSystemMetrics(SM_CYFIXEDFRAME));
fprintf(stderr," SM_CXFRAME:\t\t %d\n", GetSystemMetrics(SM_CXFRAME));
fprintf(stderr," SM_CYFRAME:\t\t %d\n", GetSystemMetrics(SM_CYFRAME));
fprintf(stderr," SM_CXFULLSCREEN:\t %d\n", GetSystemMetrics(SM_CXFULLSCREEN));
fprintf(stderr," SM_CYFULLSCREEN:\t %d\n", GetSystemMetrics(SM_CYFULLSCREEN));
fprintf(stderr," SM_CXHSCROLL:\t %d\n", GetSystemMetrics(SM_CXHSCROLL));
fprintf(stderr," SM_CYHSCROLL:\t %d\n", GetSystemMetrics(SM_CYHSCROLL));
fprintf(stderr," SM_CXHTHUMB:\t %d\n", GetSystemMetrics(SM_CXHTHUMB));
fprintf(stderr," SM_CXICON:\t\t %d\n", GetSystemMetrics(SM_CXICON));
fprintf(stderr," SM_CYICON:\t\t %d\n", GetSystemMetrics(SM_CYICON));
fprintf(stderr," SM_CXICONSPACING:\t %d\n", GetSystemMetrics(SM_CXICONSPACING));
fprintf(stderr," SM_CYICONSPACING:\t %d\n", GetSystemMetrics(SM_CYICONSPACING));
fprintf(stderr," SM_CXMAXIMIZED:\t %d\n", GetSystemMetrics(SM_CXMAXIMIZED));
fprintf(stderr," SM_CYMAXIMIZED:\t %d\n", GetSystemMetrics(SM_CYMAXIMIZED));
fprintf(stderr," SM_CXMAXTRACK:\t %d\n", GetSystemMetrics(SM_CXMAXTRACK));
fprintf(stderr," SM_CYMAXTRACK:\t %d\n", GetSystemMetrics(SM_CYMAXTRACK));
fprintf(stderr," SM_CXMENUCHECK:\t %d\n", GetSystemMetrics(SM_CXMENUCHECK));
fprintf(stderr," SM_CYMENUCHECK:\t %d\n", GetSystemMetrics(SM_CYMENUCHECK));
fprintf(stderr," SM_CXMENUSIZE:\t %d\n", GetSystemMetrics(SM_CXMENUSIZE));
fprintf(stderr," SM_CYMENUSIZE:\t %d\n", GetSystemMetrics(SM_CYMENUSIZE));
fprintf(stderr," SM_CXMIN:\t\t %d\n", GetSystemMetrics(SM_CXMIN));
fprintf(stderr," SM_CYMIN:\t\t %d\n", GetSystemMetrics(SM_CYMIN));
fprintf(stderr," SM_CXMINIMIZED:\t %d\n", GetSystemMetrics(SM_CXMINIMIZED));
fprintf(stderr," SM_CYMINIMIZED:\t %d\n", GetSystemMetrics(SM_CYMINIMIZED));
fprintf(stderr," SM_CXMINSPACING:\t %d\n", GetSystemMetrics(SM_CXMINSPACING));
fprintf(stderr," SM_CYMINSPACING:\t %d\n", GetSystemMetrics(SM_CYMINSPACING));
fprintf(stderr," SM_CXMINTRACK:\t %d\n", GetSystemMetrics(SM_CXMINTRACK));
fprintf(stderr," SM_CYMINTRACK:\t %d\n", GetSystemMetrics(SM_CYMINTRACK));
fprintf(stderr," SM_CXSCREEN:\t %d\n", GetSystemMetrics(SM_CXSCREEN));
fprintf(stderr," SM_CYSCREEN:\t %d\n", GetSystemMetrics(SM_CYSCREEN));
fprintf(stderr," SM_CXSIZE:\t\t %d\n", GetSystemMetrics(SM_CXSIZE));
fprintf(stderr," SM_CYSIZE:\t\t %d\n", GetSystemMetrics(SM_CYSIZE));
fprintf(stderr," SM_CXSIZEFRAME:\t %d\n", GetSystemMetrics(SM_CXSIZEFRAME));
fprintf(stderr," SM_CYSIZEFRAME:\t %d\n", GetSystemMetrics(SM_CYSIZEFRAME));
fprintf(stderr," SM_CXSMICON:\t %d\n", GetSystemMetrics(SM_CXSMICON));
fprintf(stderr," SM_CYSMICON:\t %d\n", GetSystemMetrics(SM_CYSMICON));
fprintf(stderr," SM_CXSMSIZE:\t %d\n", GetSystemMetrics(SM_CXSMSIZE));
fprintf(stderr," SM_CYSMSIZE:\t %d\n", GetSystemMetrics(SM_CYSMSIZE));
// fprintf(stderr," SM_CXVIRTUALSCREEN:\t %d\n", GetSystemMetrics(SM_CXVIRTUALSCREEN));
// fprintf(stderr," SM_CYVIRTUALSCREEN:\t %d\n", GetSystemMetrics(SM_CYVIRTUALSCREEN));
fprintf(stderr," SM_CXVSCROLL:\t %d\n", GetSystemMetrics(SM_CXVSCROLL));
fprintf(stderr," SM_CYVSCROLL:\t %d\n", GetSystemMetrics(SM_CYVSCROLL));
fprintf(stderr," SM_CYCAPTION:\t %d\n", GetSystemMetrics(SM_CYCAPTION));
fprintf(stderr," SM_CYKANJIWINDOW:\t %d\n", GetSystemMetrics(SM_CYKANJIWINDOW));
fprintf(stderr," SM_CYMENU:\t\t %d\n", GetSystemMetrics(SM_CYMENU));
fprintf(stderr," SM_CYSMCAPTION:\t %d\n", GetSystemMetrics(SM_CYSMCAPTION));
fprintf(stderr," SM_CYVTHUMB:\t %d\n", GetSystemMetrics(SM_CYVTHUMB));
fprintf(stderr," SM_DBCSENABLED:\t %d\n", GetSystemMetrics(SM_DBCSENABLED));
fprintf(stderr," SM_DEBUG:\t\t %d\n", GetSystemMetrics(SM_DEBUG));
// fprintf(stderr," SM_IMMENABLED:\t %d\n", GetSystemMetrics(SM_IMMENABLED));
fprintf(stderr," SM_MENUDROPALIGNMENT: %d\n", GetSystemMetrics(SM_MENUDROPALIGNMENT));
fprintf(stderr," SM_MIDEASTENABLED:\t %d\n", GetSystemMetrics(SM_MIDEASTENABLED));
fprintf(stderr," SM_MOUSEPRESENT:\t %d\n", GetSystemMetrics(SM_MOUSEPRESENT));
#ifndef _MSC_VER
fprintf(stderr," SM_MOUSEWHEELPRESENT: %d\n", GetSystemMetrics(SM_MOUSEWHEELPRESENT));
#endif
fprintf(stderr," SM_NETWORK:\t\t %d\n", GetSystemMetrics(SM_NETWORK));
fprintf(stderr," SM_PENWINDOWS:\t %d\n", GetSystemMetrics(SM_PENWINDOWS));
// fprintf(stderr," SM_REMOTESESSION:\t %d\n", GetSystemMetrics(SM_REMOTESESSION));
fprintf(stderr," SM_SECURE:\t\t %d\n", GetSystemMetrics(SM_SECURE));
// fprintf(stderr," SM_SAMEDISPLAYFORMAT: %d\n", GetSystemMetrics(SM_SAMEDISPLAYFORMAT));
fprintf(stderr," SM_SHOWSOUNDS:\t %d\n", GetSystemMetrics(SM_SHOWSOUNDS));
fprintf(stderr," SM_SLOWMACHINE:\t %d\n", GetSystemMetrics(SM_SLOWMACHINE));
fprintf(stderr," SM_SWAPBUTTON:\t %d\n", GetSystemMetrics(SM_SWAPBUTTON));
// fprintf(stderr," SM_XVIRTUALSCREEN: %d\n", GetSystemMetrics(SM_XVIRTUALSCREEN));
// fprintf(stderr," SM_YVIRTUALSCREEN: %d\n", GetSystemMetrics(SM_YVIRTUALSCREEN));
return 0;
}

View File

@@ -0,0 +1,20 @@
PATH_TO_TOP = ../../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = GetSysMetrics
TARGET_SDKLIBS = user32.a
TARGET_OBJECTS = $(TARGET_NAME).o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View File

@@ -0,0 +1,37 @@
/*
* This example demonstrates dynamical loading of (internal) Win32 DLLS.
* I dont know why this was called hello5 in the wine tree - sedwards
*/
#include <stdio.h>
#include <windows.h>
int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
SYSTEM_INFO si;
void CALLBACK (*fnGetSystemInfo)(LPSYSTEM_INFO si);
HMODULE kernel32;
kernel32 = LoadLibrary("KERNEL32");
if (kernel32<32) {
fprintf(stderr,"FATAL: could not load KERNEL32!\n");
return 0;
}
fnGetSystemInfo = (void*)GetProcAddress(kernel32,"GetSystemInfo");
if (!fnGetSystemInfo) {
fprintf(stderr,"FATAL: could not find GetSystemInfo!\n");
return 0;
}
fnGetSystemInfo(&si);
fprintf(stderr,"QuerySystemInfo returns:\n");
fprintf(stderr," wProcessorArchitecture: %d\n",si.u.s.wProcessorArchitecture);
fprintf(stderr," dwPageSize: %ld\n",si.dwPageSize);
fprintf(stderr," lpMinimumApplicationAddress: %p\n",si.lpMinimumApplicationAddress);
fprintf(stderr," lpMaximumApplicationAddress: %p\n",si.lpMaximumApplicationAddress);
fprintf(stderr," dwActiveProcessorMask: %ld\n",si.dwActiveProcessorMask);
fprintf(stderr," dwNumberOfProcessors: %ld\n",si.dwNumberOfProcessors);
fprintf(stderr," dwProcessorType: %ld\n",si.dwProcessorType);
fprintf(stderr," dwAllocationGranularity: %ld\n",si.dwAllocationGranularity);
fprintf(stderr," wProcessorLevel: %d\n",si.wProcessorLevel);
fprintf(stderr," wProcessorRevision: %d\n",si.wProcessorRevision);
return 0;
}

View File

@@ -0,0 +1,26 @@
#
#
#
PATH_TO_TOP = ../../../..
PROGS = GetSystemInfo
OBJECTS = GetSystemInfo.o
LIBS =
CFLAGS =
all: $(PROGS:%=%.exe)
.phony: all
clean:
- $(RM) *.o *.coff *.exe *.sym
.phony: clean
GetSystemInfo.exe: $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) $(LIBS) -o GetSystemInfo.exe
$(NM) --numeric-sort GetSystemInfo.exe > GetSystemInfo.sym
include $(PATH_TO_TOP)/rules.mak

View File

@@ -0,0 +1,26 @@
# 10-11-01 Steven Edwards <Steven.Edwards@KnowledgeSentry.net>
# Mutex Benchmarks from the Wineserver Linux Kernel Module
#
PATH_TO_TOP = ../../../..
PROGS = fivemutex rapidmutex
all: $(PROGS:%=%.exe)
.phony: all
clean:
- $(RM) *.o *.exe *.sym
.phony: clean
fivemutex.exe: fivemutex.c
$(CC) fivemutex.c -lkernel32 -o fivemutex.exe
$(NM) --numeric-sort fivemutex.exe > fivemutex.sym
rapidmutex.exe: rapidmutex.c
$(CC) rapidmutex.c -lkernel32 -o rapidmutex.exe
$(NM) --numeric-sort rapidmutex.exe > rapidmutex.sym
include $(PATH_TO_TOP)/rules.mak

View File

@@ -0,0 +1,124 @@
/* fivemutex.c: hungry philosophers problem
*
* (c) Copyright D.W.Howells 2000.
* All rights reserved
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define ERR(X,Y) do { if (X) { perror(""Y""); return 1; } } while(0)
#define RUNLENGTH 4
int count[5];
const char *names[] = {
"five/1", "five/2", "five/3", "five/4", "five/5"
};
DWORD WINAPI child(LPVOID tparam)
{
HANDLE left, right, first, second;
const char *lname, *rname;
int pid = (int) tparam;
int wt;
lname = names[pid%5];
rname = names[(pid+1)%5];
/* create a mutex */
left = CreateMutex(NULL,0,lname); ERR(!left,"create left");
right = CreateMutex(NULL,0,rname); ERR(!left,"create right");
printf("[%d] left: %p [%s]\n",pid,left,lname);
printf("[%d] right: %p [%s]\n",pid,right,rname);
/* pick the forks up in numerical order, else risk starvation */
if (pid%5 < (pid+1)%5) {
first = left;
second = right;
}
else {
first = right;
second = left;
}
for (;;) {
/* grab the left mutex */
wt = WaitForMultipleObjects(1,&first,0,INFINITE);
if (wt!=WAIT_OBJECT_0)
goto wait_failed;
/* grab the right mutex */
wt = WaitForMultipleObjects(1,&second,0,INFINITE);
if (wt!=WAIT_OBJECT_0)
goto wait_failed;
/* got it */
count[pid]++;
/* pass the mutexes */
ERR(!ReleaseMutex(left),"release left");
ERR(!ReleaseMutex(right),"release right");
continue;
wait_failed:
switch (wt) {
case WAIT_OBJECT_0+1:
printf("[%d] obtained mutex __1__\n",pid);
exit(1);
case WAIT_ABANDONED_0:
case WAIT_ABANDONED_0+1:
printf("[%d] abandoned wait\n",pid);
continue;
case WAIT_TIMEOUT:
printf("[%d] wait timed out\n",pid);
exit(1);
default:
ERR(1,"WaitForMultipleObjects");
}
return 1;
}
/* close the handles */
ERR(!CloseHandle(left),"close left");
ERR(!CloseHandle(right),"close right");
return 0;
}
int main()
{
HANDLE hThread[5];
DWORD tid;
int loop;
for (loop=0; loop<5; loop++) {
hThread[loop] = CreateThread(NULL, /* thread attributes */
0, /* stack size */
child, /* start address */
(void*)loop, /* parameter */
0, /* creation flags */
&tid /* thread ID */
);
if (!hThread[loop])
{
ERR(1,"CreateThread");
}
}
WaitForMultipleObjects(5,hThread,0,RUNLENGTH*1000);
for (loop=0; loop<5; loop++)
TerminateThread(hThread[loop],0);
for (loop=0; loop<5; loop++)
printf("[%d] ate %d times (%d times per second)\n",
loop,count[loop],count[loop]/RUNLENGTH
);
return 0;
}

View File

@@ -0,0 +1,89 @@
/* rapidmutex.c: rapid mutex passing test client [Win32 threaded]
*
* (c) Copyright D.W.Howells 2000.
* All rights reserved
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define ERR(X,Y) do { if (X) { perror(Y); return 1; } } while(0)
#define RUNLENGTH 4
int count[5];
DWORD WINAPI child(LPVOID tparam)
{
HANDLE mymutex;
int pid = (int) tparam;
/* create a mutex */
mymutex = CreateMutex(NULL,0,"wibble");
ERR(!mymutex,"create mutex");
printf("[%d] Handle: %p\n",pid,mymutex);
for (;;) {
/* grab the mutex */
switch (WaitForMultipleObjects(1,&mymutex,0,INFINITE))
{
case WAIT_OBJECT_0:
/* got it */
count[pid]++;
/* pass the mutex */
ERR(!ReleaseMutex(mymutex),"release mutex");
break;
case WAIT_OBJECT_0+1:
printf("[%d] obtained mutex __1__\n",pid);
exit(0);
case WAIT_ABANDONED_0:
case WAIT_ABANDONED_0+1:
printf("[%d] abandoned wait\n",pid);
exit(0);
case WAIT_TIMEOUT:
printf("[%d] wait timed out\n",pid);
exit(0);
default:
ERR(1,"WaitForMultipleObjects");
}
}
return 0;
}
int main()
{
HANDLE hThread[5];
DWORD tid;
int loop;
for (loop=0; loop<5; loop++) {
hThread[loop] =
CreateThread(NULL, /* thread attributes */
0, /* stack size */
child, /* start address */
(void*)loop, /* parameter */
0, /* creation flags */
&tid /* thread ID */
);
if (!hThread[loop])
{
ERR(1,"CreateThread");
}
}
WaitForMultipleObjects(5,hThread,0,RUNLENGTH*1000);
for (loop=0; loop<5; loop++)
TerminateThread(hThread[loop],0);
for (loop=0; loop<5; loop++)
printf("[%d] obtained the mutex %d times"
" (%d times per second)\n",
loop,count[loop],count[loop]/RUNLENGTH
);
return 0;
}

View File

@@ -0,0 +1,26 @@
#
#
#
PATH_TO_TOP = ../../../..
PROGS = Parent_Child
OBJECTS = Parent_Child.o
LIBS = $(PATH_TO_TOP)/dk/w32/lib/gdi32.a
CFLAGS =
all: $(PROGS:%=%.exe)
.phony: all
clean:
- $(RM) *.o *.coff *.exe *.sym
.phony: clean
Parent_Child.exe: $(OBJECTS)
$(CC) $(CFLAGS) -Wl,--subsystem,windows $(OBJECTS) $(LIBS) -o Parent_Child.exe
$(NM) --numeric-sort Parent_Child.exe > Parent_Child.sym
include $(PATH_TO_TOP)/rules.mak

View File

@@ -0,0 +1,151 @@
#include <stdio.h>
#include <windows.h>
/* Win32 counterpart for CalcChildScroll16 is not implemented */
/* even in MS Visual C++ */
// #include "windef.h"
// #include "wingdi.h"
/*#include <wine/winuser16.h>*/
void Write (HDC dc, int x, int y, char *s)
{
SetBkMode(dc, TRANSPARENT);
TextOut (dc, x, y, s, strlen (s));
}
LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
{
static short xChar, yChar;
static RECT rectHola;
static char* strHola = "Hola";
HDC dc;
PAINTSTRUCT ps;
TEXTMETRIC tm;
switch (msg){
case WM_CREATE:
dc = GetDC (wnd);
GetTextMetrics (dc, &tm);
xChar = tm.tmAveCharWidth;
yChar = tm.tmHeight;
GetTextExtentPoint32( dc, strHola, strlen(strHola), ((LPSIZE)&rectHola) + 1 );
OffsetRect( &rectHola, xChar, yChar );
ReleaseDC (wnd, dc);
break;
case WM_HSCROLL:
case WM_VSCROLL:
InvalidateRect(wnd, &rectHola, TRUE );
// ScrollChildren(wnd, msg, w, l);
return 0;
case WM_PAINT:
dc = BeginPaint (wnd, &ps);
Write (dc, xChar, yChar, strHola);
EndPaint (wnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (wnd, msg, w, l);
}
return 0l;
}
LRESULT CALLBACK WndProc2 (HWND wnd, UINT msg, WPARAM w, LPARAM l)
{
static short xChar, yChar;
static RECT rectInfo;
char buf[128];
HDC dc;
PAINTSTRUCT ps;
TEXTMETRIC tm;
switch (msg){
case WM_CREATE:
dc = GetDC (wnd);
GetTextMetrics (dc, &tm);
xChar = tm.tmAveCharWidth;
yChar = tm.tmHeight;
ReleaseDC (wnd, dc);
break;
case WM_PAINT:
dc = BeginPaint (wnd, &ps);
sprintf(buf,"ps.rcPaint = {left = %d, top = %d, right = %d, bottom = %d}",
ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
rectInfo.left = rectInfo.top = 0;
GetTextExtentPoint32 (dc, buf, strlen(buf), ((LPSIZE)&rectInfo) + 1 );
OffsetRect (&rectInfo, xChar, yChar );
Write (dc, xChar, yChar, buf);
EndPaint (wnd, &ps);
break;
case WM_MOVE:
case WM_SIZE:
InvalidateRect( wnd, &rectInfo, TRUE );
/*CalcChildScroll16( (UINT16)GetParent(wnd), SB_BOTH );*/
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (wnd, msg, w, l);
}
return 0l;
}
int PASCAL WinMain (HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
HWND wnd,wnd2;
MSG msg;
WNDCLASS class;
char className[] = "class"; /* To make sure className >= 0x10000 */
char class2Name[] = "class2";
char winName[] = "Test app";
if (!prev){
class.style = CS_HREDRAW | CS_VREDRAW;
class.lpfnWndProc = WndProc;
class.cbClsExtra = 0;
class.cbWndExtra = 0;
class.hInstance = inst;
class.hIcon = LoadIcon (0, IDI_APPLICATION);
class.hCursor = LoadCursor (0, IDC_ARROW);
class.hbrBackground = GetStockObject (WHITE_BRUSH);
class.lpszMenuName = NULL;
class.lpszClassName = className;
if (!RegisterClass (&class))
return FALSE;
}
wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
0, inst, 0);
if (!prev){
class.lpfnWndProc = WndProc2;
class.lpszClassName = class2Name;
class.hbrBackground = GetStockObject(GRAY_BRUSH);
if (!RegisterClass (&class))
return FALSE;
}
wnd2= CreateWindow (class2Name,"Child window", WS_CAPTION | WS_CHILD | WS_THICKFRAME,
50, 50, 350, 100, wnd, 0, inst, 0);
ShowWindow (wnd, show);
UpdateWindow (wnd);
ShowWindow (wnd2, show);
UpdateWindow (wnd2);
while (GetMessage (&msg, 0, 0, 0)){
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return 0;
}

View File

@@ -0,0 +1,36 @@
#
#
#
PATH_TO_TOP = ../../../..
PROGS = guitest
OBJECTS = guitest.o
LIBS = $(PATH_TO_TOP)/dk/w32/lib/gdi32.a
CFLAGS =
all: $(PROGS:%=%.exe)
.phony: all
clean:
- $(RM) *.o *.exe *.sym
.phony: clean
install: $(PROGS:%=$(FLOPPY_DIR)/apps/tests/%.exe)
$(PROGS:%=$(FLOPPY_DIR)/apps/tests/%.exe): $(FLOPPY_DIR)/apps/tests/%.exe: %.exe
$(CP) $*.exe $(FLOPPY_DIR)/apps/$*.exe
dist: $(PROGS:%=../../$(DIST_DIR)/apps/tests/%.exe)
$(PROGS:%=../../$(DIST_DIR)/apps/tests/%.exe): ../../$(DIST_DIR)/apps/tests/%.exe: %.exe
$(CP) $*.exe ../../$(DIST_DIR)/apps/$*.exe
guitest.exe: $(OBJECTS)
$(CC) $(CFLAGS) -Wl,--subsystem,windows $(OBJECTS) $(LIBS) -o guitest.exe
$(NM) --numeric-sort guitest.exe > guitest.sym
include $(PATH_TO_TOP)/rules.mak

View File

@@ -0,0 +1,751 @@
/* Windows GUI Behaviour Tester */
/* by Ove K<>ven */
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <windows.h>
#include "guitest.rc"
/* checks to include */
#define LOGGING /* can be undefined under Wine and use -debugmsg +message instead */
#define MAIN_STYLE WS_OVERLAPPEDWINDOW|WS_HSCROLL
#define MAIN_EXSTYLE 0
#undef TEST_DESTROY_MAIN
#define SHOW_SUB
#undef TEST_DIALOG
#define RESIZE_DIALOG
#undef TEST_SUBDIALOG
#undef TEST_COMMCTL
/************************/
/*** GLOBAL VARIABLES ***/
/************************/
HINSTANCE hInst;
DWORD StartTime;
HWND hListBox,hMainWnd,hSubWnd;
HWND hButton[4]={0,0,0,0};
HWND hDialog=0,hGroup=0,hSubDlg=0;
WNDPROC wndButton[4],wndDialog,wndGroup,wndSubDlg;
BOOL Clicked=0,Ready=0;
int State=0,Rec=0;
#define STATE_CREATE 0
#define STATE_DESTROY 1
#define STATE_SHOW 2
#define STATE_UPDATE 3
#define STATE_DIALOG 4
#define STATE_TEST 5
#define STATE_DIRECT 6
#define STATE_DISPATCH 7
#define STATE_RECURS 8
char*StateName[]={
"Creat",
"Destr",
"Show ",
"Updat",
"Dialg",
"Test ",
"Call ",
"Disp ",
"RCall"
};
static char wclassname[] = "GUITestClass";
static char wcclassname[] = "GUITestChildClass";
static char winname[] = "GUITest";
/**************************/
/*** LOGGING FACILITIES ***/
/**************************/
struct MSGNAMES {
int msg;
char*name;
} MsgNames[]={
#define MSG(x) {x,#x},
#define MSG2(x,y) {y,#x},
#define ENDMSG {0}
/* we get these in CreateWindow */
MSG(WM_GETMINMAXINFO)
MSG(WM_NCCREATE)
MSG(WM_NCCALCSIZE)
MSG(WM_CREATE)
MSG(WM_PARENTNOTIFY)
/* we get these in ShowWindow */
MSG(WM_SHOWWINDOW)
MSG(WM_WINDOWPOSCHANGING)
MSG(WM_QUERYNEWPALETTE)
MSG(WM_ACTIVATEAPP)
MSG(WM_NCACTIVATE)
MSG(WM_GETTEXT)
MSG(WM_ACTIVATE)
MSG(WM_SETFOCUS)
MSG(WM_NCPAINT)
MSG(WM_ERASEBKGND)
MSG(WM_WINDOWPOSCHANGED)
MSG(WM_SIZE)
MSG(WM_MOVE)
/* we get these in DestroyWindow */
MSG(WM_KILLFOCUS)
MSG(WM_DESTROY)
MSG(WM_NCDESTROY)
/* we get these directly sent */
MSG(WM_NCHITTEST)
MSG(WM_SETCURSOR)
MSG(WM_MOUSEACTIVATE)
MSG(WM_CHILDACTIVATE)
MSG(WM_COMMAND)
MSG(WM_SYSCOMMAND)
/* posted events */
MSG(WM_MOUSEMOVE)
MSG(WM_NCMOUSEMOVE)
MSG(WM_PAINT)
MSG(WM_LBUTTONDOWN)
MSG(WM_LBUTTONUP)
MSG(WM_LBUTTONDBLCLK)
MSG(WM_NCLBUTTONDOWN)
MSG(WM_NCLBUTTONUP)
MSG(WM_NCLBUTTONDBLCLK)
MSG(WM_KEYDOWN)
MSG(WM_KEYUP)
MSG(WM_CHAR)
#ifdef WIN32
MSG(WM_CTLCOLORBTN)
MSG(WM_CTLCOLORDLG)
MSG(WM_CTLCOLORSTATIC)
#else
MSG(WM_CTLCOLOR)
#endif
/* moving and sizing */
MSG2(WM_ENTERSIZEMOVE,0x0231)
MSG2(WM_EXITSIZEMOVE,0x0232)
#ifdef WIN32
MSG(WM_SIZING)
#endif
/* menus/dialog boxes */
MSG(WM_CANCELMODE)
MSG(WM_ENABLE)
MSG(WM_SETFONT)
MSG(WM_INITDIALOG)
MSG(WM_GETDLGCODE)
MSG(WM_ENTERIDLE)
/* scroll bars */
MSG(WM_HSCROLL)
MSG(WM_VSCROLL)
/* getting these from Wine but not from Windows */
MSG2(WM_SETVISIBLE,0x0009) /* unheard of in BC++ 4.52 */
#ifdef WIN32
MSG(WM_CAPTURECHANGED)
#endif
ENDMSG};
struct MSGNAMES ButMsgs[]={
MSG(BM_SETSTATE)
MSG(BM_SETSTYLE)
ENDMSG};
char*MsgName(UINT msg,HWND hWnd)
{
int i;
static char buffer[64],wclass[64];
GetClassName(hWnd,wclass,sizeof(wclass));
#define MSGSEARCH(msgs) { \
for (i=0; msgs[i].name&&msgs[i].msg!=msg; i++); \
if (msgs[i].name) return msgs[i].name; \
}
if (!stricmp(wclass,"Button")) MSGSEARCH(ButMsgs);
MSGSEARCH(MsgNames);
/* WM_USER */
if (msg>=WM_USER) {
sprintf(buffer,"WM_USER+%04x{%s}",msg-WM_USER,wclass);
return buffer;
}
/* message not found */
sprintf(buffer,"%04x{%s}",msg,wclass);
return buffer;
}
char*WndName(HWND hWnd,int state)
{
static char buffer[16];
if (!hWnd) return "0000";
if (hWnd==hMainWnd || (state==STATE_CREATE && !hMainWnd)) return "main";
if (hWnd==hSubWnd || (state==STATE_CREATE && !hSubWnd)) return "chld";
if (hWnd==hDialog || (state==STATE_DIALOG && !hDialog)) return "tdlg";
if (hWnd==hGroup) return "tgrp";
if (hWnd==hButton[0]) return "but1";
if (hWnd==hButton[1]) return "but2";
if (hWnd==hButton[2]) return "but3";
if (hWnd==hButton[3]) return "but4";
if (hWnd==hSubDlg || (state==STATE_CREATE && !hSubDlg)) return "sdlg";
if (hDialog) {
int id=GetDlgCtrlID(hWnd);
if (id) {
sprintf(buffer,"dlgitem(%d)",id);
return buffer;
}
}
sprintf(buffer,"%04x",hWnd);
return buffer;
}
void Log(const char*fmt)
{
#ifdef LOGGING
if (!Clicked) SendMessage(hListBox,LB_ADDSTRING,0,(LPARAM)fmt);
#endif
}
void Logf(const char*fmt,...)
{
va_list par;
static char buffer[256];
va_start(par,fmt);
vsprintf(buffer,fmt,par);
va_end(par);
Log(buffer);
}
void LogChildOrder(HWND hWnd)
{
HWND hWndChild = GetWindow(hWnd,GW_CHILD);
static char buffer[256];
strcpy(buffer,"child list:");
while (hWndChild) {
strcat(strcat(buffer," "),WndName(hWndChild,State));
hWndChild=GetWindow(hWndChild,GW_HWNDNEXT);
}
Log(buffer);
}
void LogMessage(int state,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam,char*name)
{
static char buffer[256];
DWORD tick=GetTickCount()-StartTime;
char*msgname=MsgName(msg,hWnd);
if (!name) name=WndName(hWnd,state);
switch (msg) {
case WM_SETFOCUS:
case WM_KILLFOCUS:
case WM_SETCURSOR:
Logf("%04d[%s(%d):%s]%s(%s,%08x)",tick,StateName[state],Rec,
name,msgname,WndName((HWND)wParam,State),lParam);
break;
#ifdef WIN32
case WM_ENTERIDLE:
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
Logf("%04d[%s(%d):%s]%s(%08x,%s)",tick,StateName[state],Rec,
name,msgname,wParam,WndName((HWND)lParam,State));
break;
#else
case WM_ENTERIDLE:
case WM_CTLCOLOR:
Logf("%04d[%s(%d):%s]%s(%08x,%04x:%s)",tick,StateName[state],Rec,
name,msgname,wParam,HIWORD(lParam),WndName((HWND)LOWORD(lParam),State));
break;
#endif
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS*pos=(WINDOWPOS*)lParam;
#ifdef WIN32
Logf("%04d[%s(%d):%s]%s(%08x,%p)",tick,StateName[state],Rec,
name,msgname,wParam,pos);
#else
Logf("%04d[%s(%d):%s]%s(%04x,%p)",tick,StateName[state],Rec,
name,msgname,wParam,pos);
#endif
strcpy(buffer,"FLAGS:");
if (pos->flags&SWP_DRAWFRAME) strcat(buffer," DRAWFRAME");
if (pos->flags&SWP_HIDEWINDOW) strcat(buffer," HIDEWINDOW");
if (pos->flags&SWP_NOACTIVATE) strcat(buffer," NOACTIVATE");
if (pos->flags&SWP_NOCOPYBITS) strcat(buffer," NOCOPYBITS");
if (pos->flags&SWP_NOMOVE) strcat(buffer," NOMOVE");
if (pos->flags&SWP_NOOWNERZORDER) strcat(buffer," NOOWNERZORDER");
if (pos->flags&SWP_NOSIZE) strcat(buffer," NOSIZE");
if (pos->flags&SWP_NOREDRAW) strcat(buffer," NOREDRAW");
if (pos->flags&SWP_NOZORDER) strcat(buffer," NOZORDER");
if (pos->flags&SWP_SHOWWINDOW) strcat(buffer," SHOWWINDOW");
Log(buffer);
}
break;
case WM_SYSCOMMAND:
{
char*cmd=NULL;
switch (wParam&0xFFF0) {
#define CASE(x) case SC_##x: cmd=#x; break;
CASE(CLOSE)
CASE(DEFAULT)
CASE(HOTKEY)
CASE(HSCROLL)
CASE(KEYMENU)
CASE(MAXIMIZE)
CASE(MINIMIZE)
CASE(MOUSEMENU)
CASE(MOVE)
CASE(NEXTWINDOW)
CASE(PREVWINDOW)
CASE(RESTORE)
CASE(SCREENSAVE)
CASE(SIZE)
CASE(TASKLIST)
CASE(VSCROLL)
#undef CASE
}
if (cmd) {
Logf("%04d[%s(%d):%s]%s(%s+%x,%08x)",tick,StateName[state],Rec,
name,msgname,cmd,wParam&0xF,lParam);
} else goto GENERIC_MSG;
}
break;
case WM_HSCROLL:
case WM_VSCROLL:
{
char*cmd=NULL;
switch (LOWORD(wParam)) {
#define CASE(x) case SB_##x: cmd=#x; break;
#define CASE2(h,v) case SB_##h: if (msg==WM_HSCROLL) cmd=#h; else cmd=#v; break;
CASE(BOTTOM)
CASE(ENDSCROLL)
CASE2(LINELEFT,LINEUP)
CASE2(LINERIGHT,LINEDOWN)
CASE2(PAGELEFT,PAGEUP)
CASE2(PAGERIGHT,PAGEDOWN)
CASE(THUMBPOSITION)
CASE(THUMBTRACK)
CASE(TOP)
#undef CASE
}
if (cmd) {
#ifdef WIN32
Logf("%04d[%s(%d):%s]%s(%s,%04x,%s)",tick,StateName[state],Rec,
name,msgname,cmd,HIWORD(wParam),WndName((HWND)lParam,State));
#else
Logf("%04d[%s(%d):%s]%s(%04x,%04x,%s)",tick,StateName[state],Rec,
name,msgname,cmd,LOWORD(lParam),WndName((HWND)HIWORD(lParam),State));
#endif
} else goto GENERIC_MSG;
}
break;
default:
GENERIC_MSG:
#ifdef WIN32
Logf("%04d[%s(%d):%s]%s(%08x,%08x)",tick,StateName[state],Rec,
name,msgname,wParam,lParam);
#else
Logf("%04d[%s(%d):%s]%s(%04x,%08x)",tick,StateName[state],Rec,
name,msgname,wParam,lParam);
#endif
}
}
/***************************/
/*** GRAPHICS FACILITIES ***/
/***************************/
void Paint(HWND hWnd)
{
HDC dc;
PAINTSTRUCT ps;
dc=BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
}
void FillPattern(HWND hWnd,HDC pdc)
{
HDC dc=pdc?pdc:GetDC(hWnd);
HBRUSH oldbrush;
RECT rect;
if (!dc) {
Logf("failed to acquire DC for window %s",WndName(hWnd,State));
return;
} else {
Logf("acquired DC for %s window %s, painting",
IsWindowVisible(hWnd)?"visible":"invisible",WndName(hWnd,State));
}
GetClientRect(hWnd,&rect);
oldbrush=SelectObject(dc,GetStockObject(LTGRAY_BRUSH));
PatBlt(dc,0,0,rect.right,rect.bottom,PATCOPY);
SelectObject(dc,oldbrush);
if (!pdc) ReleaseDC(hWnd,dc);
}
void PaintPattern(HWND hWnd)
{
HDC dc;
PAINTSTRUCT ps;
dc=BeginPaint(hWnd,&ps);
FillPattern(hWnd,dc);
EndPaint(hWnd,&ps);
}
/*************************/
/*** WINDOW PROCEDURES ***/
/*************************/
/* MAIN WINDOW */
LRESULT FAR CALLBACK _export MainWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult=0;
RECT rect;
int OldState=State;
State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
switch (msg) {
case WM_NCHITTEST:
lResult=DefWindowProc(hWnd,msg,wParam,lParam);
break;
case WM_LBUTTONDOWN:
case WM_CHAR:
if (!Clicked) {
SetParent(hListBox,hWnd);
GetClientRect(hWnd,&rect);
MoveWindow(hListBox,0,0,rect.right,rect.bottom,TRUE);
ShowWindow(hListBox,SW_SHOW);
SetFocus(hListBox);
Clicked=TRUE;
}
break;
case WM_SIZE:
GetClientRect(hWnd,&rect);
if (Clicked) {
MoveWindow(hListBox,0,0,rect.right,rect.bottom,TRUE);
}
MoveWindow(hSubWnd,0,rect.bottom/2,rect.right,rect.bottom-(rect.bottom/2),TRUE);
break;
case WM_PAINT:
Paint(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
lResult=DefWindowProc(hWnd,msg,wParam,lParam);
}
State=OldState; Rec--;
return lResult;
}
/* CHILD WINDOW */
LRESULT FAR CALLBACK _export SubWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult=0;
RECT rect;
int OldState=State;
State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
switch (msg) {
case WM_PAINT:
Paint(hWnd);
break;
default:
lResult=DefWindowProc(hWnd,msg,wParam,lParam);
}
State=OldState; Rec--;
return lResult;
}
BOOL FAR CALLBACK _export SubDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
/* SUBCLASSED CONTROLS */
LRESULT FAR CALLBACK _export SubClassWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult=0;
RECT rect;
int OldState=State;
int But=-1;
if (hWnd==hButton[0]) But=0; else
if (hWnd==hButton[1]) But=1; else
if (hWnd==hButton[2]) But=2; else
if (hWnd==hButton[3]) But=3;
State=STATE_RECURS; Rec++;
if (!Clicked) {
LogMessage(OldState,hWnd,msg,wParam,lParam,NULL);
if (But!=-1) {
lResult=CallWindowProc((FARPROC)wndButton[But],hWnd,msg,wParam,lParam);
if (msg==WM_LBUTTONUP) {
LogChildOrder(GetParent(hWnd));
}
}
else if (hWnd==hDialog) {
lResult=CallWindowProc((FARPROC)wndDialog,hWnd,msg,wParam,lParam);
}
else if (hWnd==hSubDlg) {
lResult=CallWindowProc((FARPROC)wndSubDlg,hWnd,msg,wParam,lParam);
}
else if (hWnd==hGroup) {
lResult=CallWindowProc((FARPROC)wndGroup,hWnd,msg,wParam,lParam);
if (msg==WM_SETFOCUS) {
/* create subdialog */
if (hSubDlg) {
#if 0
SetRect(&rect,0,0,1,1);
InvalidateRect(hWnd,&rect,FALSE);
#endif
} else {
#ifdef TEST_SUBDIALOG
State=STATE_CREATE;
hSubDlg=CreateDialog(hInst,MAKEINTRESOURCE(2),hWnd,(FARPROC)SubDialogProc);
State=STATE_RECURS;
#else
#ifdef RESIZE_DIALOG
GetWindowRect(GetParent(hWnd),&rect);
rect.right++;
SetWindowPos(GetParent(hWnd),0,0,0,
rect.right-rect.left,rect.bottom-rect.top,
SWP_NOMOVE|SWP_NOZORDER);
#endif
#endif
}
}
}
}
State=OldState; Rec--;
return lResult;
}
/* MAIN DIALOG PROCEDURE */
BOOL FAR CALLBACK _export TestDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL bResult=0;
RECT rect;
int OldState=State;
int But=-1;
State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWndDlg,msg,wParam,lParam,"dlgp");
switch (msg) {
case WM_INITDIALOG:
hDialog = hWndDlg;
/* subclass dialog window proc */
wndDialog = (WNDPROC)SetWindowLong(hDialog,GWL_WNDPROC,(LONG)SubClassWindowProc);
Logf("dialog visible=%s",IsWindowVisible(hWndDlg)?"TRUE":"FALSE");
/* subclass OK button */
hButton[3] = GetDlgItem(hWndDlg,IDOK);
wndButton[3] = (WNDPROC)SetWindowLong(hButton[3],GWL_WNDPROC,(LONG)SubClassWindowProc);
/* subclass group box */
hGroup = GetDlgItem(hWndDlg,IDC_GROUPBOX1);
wndGroup = (WNDPROC)SetWindowLong(hGroup,GWL_WNDPROC,(LONG)SubClassWindowProc);
#ifdef RESIZE_DIALOG
GetWindowRect(hWndDlg,&rect);
rect.right--;
SetWindowPos(hWndDlg,0,0,0,
rect.right-rect.left,rect.bottom-rect.top,
SWP_NOMOVE|SWP_NOZORDER);
// ShowWindow(GetDlgItem(hWndDlg,IDCANCEL),SW_HIDE);
#endif
bResult=TRUE; /* we don't do SetFocus */
break;
case WM_PAINT:
PaintPattern(hWndDlg);
bResult=TRUE;
break;
case WM_COMMAND:
EndDialog(hWndDlg,LOWORD(wParam));
bResult=TRUE;
break;
case WM_CLOSE:
EndDialog(hWndDlg,IDCANCEL);
bResult=TRUE;
break;
case WM_NCDESTROY:
hDialog = 0;
break;
}
State=OldState; Rec--;
return bResult;
}
/* SUBDIALOG PROCEDURE */
BOOL FAR CALLBACK _export SubDialogProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL bResult=0;
RECT rect;
int OldState=State;
int But=-1;
State=STATE_RECURS; Rec++;
if (!Clicked) LogMessage(OldState,hWndDlg,msg,wParam,lParam,NULL);
switch (msg) {
case WM_INITDIALOG:
hSubDlg = hWndDlg;
/* subclass dialog window proc */
wndSubDlg = (WNDPROC)SetWindowLong(hDialog,GWL_WNDPROC,(LONG)SubClassWindowProc);
bResult=TRUE; /* we don't do SetFocus */
break;
case WM_NCDESTROY:
hSubDlg = 0;
break;
}
State=OldState; Rec--;
return bResult;
}
/********************/
/*** MAIN PROGRAM ***/
/********************/
BOOL AppInit(void)
{
WNDCLASS wclass;
wclass.style = CS_HREDRAW|CS_VREDRAW;
wclass.lpfnWndProc = MainWindowProc;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
wclass.hInstance = hInst;
wclass.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(1));
wclass.hCursor = LoadCursor(0,IDC_ARROW);
wclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wclass.lpszMenuName = NULL;
wclass.lpszClassName = wclassname;
if (!RegisterClass(&wclass)) return FALSE;
wclass.lpfnWndProc = SubWindowProc;
wclass.lpszClassName = wcclassname;
if (!RegisterClass(&wclass)) return FALSE;
return TRUE;
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
MSG msg;
RECT rect;
hInst = hInstance;
if (!hPrevInstance)
if (!AppInit())
return 0;
StartTime=GetTickCount();
hListBox = CreateWindow("LISTBOX","Messages",WS_BORDER|WS_VSCROLL|WS_CHILD|
LBS_HASSTRINGS|LBS_NOTIFY|LBS_WANTKEYBOARDINPUT,
0,0,0,0,GetDesktopWindow(),0,hInst,0);
if (!hListBox) {
MessageBox(0,"Could not create list box","Error",MB_OK);
}
State=STATE_CREATE;
hMainWnd = CreateWindowEx(MAIN_EXSTYLE,wclassname,winname,MAIN_STYLE,
CW_USEDEFAULT,0,400,300,0,0,hInst,0);
if (!hMainWnd) return 0;
State=STATE_SHOW;
ShowWindow(hMainWnd,nCmdShow);
#ifdef TEST_DESTROY_MAIN
State=STATE_DESTROY;
DestroyWindow(hMainWnd);
State=STATE_DIRECT;
while (GetMessage(&msg,0,0,0)) {
TranslateMessage(&msg);
State=STATE_DISPATCH;
DispatchMessage(&msg);
State=STATE_DIRECT;
}
State=STATE_CREATE;
hMainWnd = CreateWindowEx(MAIN_EXSTYLE,wclassname,winname,MAIN_STYLE,
CW_USEDEFAULT,0,400,300,0,0,hInst,0);
if (!hMainWnd) return 0;
State=STATE_SHOW;
ShowWindow(hMainWnd,nCmdShow);
#endif
/* update, so no WM_PAINTs are pending */
State=STATE_UPDATE;
// UpdateWindow(hMainWnd);
Ready=TRUE;
/* fill client area with a pattern */
FillPattern(hMainWnd,0);
/* create subwindow */
State=STATE_CREATE;
GetClientRect(hMainWnd,&rect);
hSubWnd = CreateWindow(wcclassname,winname,WS_CHILD|WS_BORDER|WS_CLIPSIBLINGS,
0,rect.bottom/2,rect.right,rect.bottom-(rect.bottom/2),hMainWnd,0,hInst,0);
if (!hSubWnd) return 0;
/* create buttons */
hButton[0] = CreateWindow("BUTTON","1",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,
8,8,48,20,hMainWnd,0,hInst,0);
hButton[1] = CreateWindow("BUTTON","2",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,
32,12,48,20,hMainWnd,0,hInst,0);
hButton[2] = CreateWindow("BUTTON","3",WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,
56,16,48,20,hMainWnd,0,hInst,0);
/* subclass them */
wndButton[0] = (WNDPROC)SetWindowLong(hButton[0],GWL_WNDPROC,(LONG)SubClassWindowProc);
wndButton[1] = (WNDPROC)SetWindowLong(hButton[1],GWL_WNDPROC,(LONG)SubClassWindowProc);
wndButton[2] = (WNDPROC)SetWindowLong(hButton[2],GWL_WNDPROC,(LONG)SubClassWindowProc);
/* show them */
State=STATE_UPDATE;
UpdateWindow(hButton[0]);
LogChildOrder(hMainWnd);
Logf("but1 visible=%d",IsWindowVisible(hButton[0]));
/* now reparent the button to our (invisible) subwindow */
State=STATE_TEST;
/* in different order, seeing who gets topmost */
SetParent(hButton[0],hSubWnd);
SetParent(hButton[2],hSubWnd);
SetParent(hButton[1],hSubWnd);
LogChildOrder(hSubWnd);
/* the button should now be invisible */
Logf("but1 visible=%d",IsWindowVisible(hButton[0]));
/* see if we can draw on them */
FillPattern(hButton[0],0);
#ifdef SHOW_SUB
State=STATE_SHOW;
ShowWindow(hSubWnd,SW_SHOWNORMAL);
State=STATE_UPDATE;
UpdateWindow(hSubWnd);
FillPattern(hSubWnd,0);
// InvalidateRect(hMainWnd,NULL,TRUE);
Logf("but1 visible=%d",IsWindowVisible(hButton[0]));
#endif
#ifdef TEST_DIALOG
State=STATE_DIALOG;
DialogBox(hInst,MAKEINTRESOURCE(1),hMainWnd,(FARPROC)TestDialogProc);
#endif
#ifdef TEST_COMMCTL
{
DWORD arr[16];
CHOOSECOLOR cc={sizeof(cc),0,hInst,0,arr,0};
ChooseColor(&cc);
}
#endif
State=STATE_DIRECT;
while (GetMessage(&msg,0,0,0)) {
TranslateMessage(&msg);
State=STATE_DISPATCH;
DispatchMessage(&msg);
State=STATE_DIRECT;
}
return 0;
}

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