mmfuncs.h: add MmGetSystemAddressForMdlSafe/MmMapLockedPagesSpecifyCache defs.
matherr.c: remove _exception struct since its already in math.h
path: simply file exsitence check
iomgr: simplify/use standard generic file mappings flags
misc.
Modified: trunk/reactos/include/ddk/mmfuncs.h
Modified: trunk/reactos/lib/crt/except/matherr.c
Modified: trunk/reactos/lib/ntdll/rtl/libsupp.c
Modified: trunk/reactos/lib/ntdll/rtl/path.c
Modified: trunk/reactos/lib/rtl/unicode.c
Modified: trunk/reactos/lib/user32/windows/accel.c
Modified: trunk/reactos/ntoskrnl/fs/notify.c
Modified: trunk/reactos/ntoskrnl/io/iomgr.c
Modified: trunk/reactos/subsys/win32k/objects/bitmaps.c
Modified: trunk/reactos/subsys/win32k/objects/pen.c

Modified: trunk/reactos/include/ddk/mmfuncs.h
--- trunk/reactos/include/ddk/mmfuncs.h	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/include/ddk/mmfuncs.h	2005-04-01 00:04:15 UTC (rev 14396)
@@ -279,6 +279,19 @@
 	(((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
 		((Mdl)->MappedSystemVa):(MmMapLockedPages((Mdl),KernelMode)))
 
+/*
+ * PVOID
+ * MmGetSystemAddressForMdlSafe(
+ *   IN PMDL  Mdl,
+ *   IN MM_PAGE_PRIORITY  Priority)
+ */
+#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \
+  ((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \
+    | MDL_SOURCE_IS_NONPAGED_POOL)) ? \
+    (_Mdl)->MappedSystemVa : \
+    (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \
+      KernelMode, MmCached, NULL, FALSE, _Priority)
+
 PVOID
 STDCALL
 MmGetSystemRoutineAddress (
@@ -425,6 +438,13 @@
 	PMDL		MemoryDescriptorList,
 	KPROCESSOR_MODE	AccessMode
 	);
+PVOID STDCALL
+MmMapLockedPagesSpecifyCache ( IN PMDL Mdl,
+                               IN KPROCESSOR_MODE AccessMode,
+                               IN MEMORY_CACHING_TYPE CacheType,
+                               IN PVOID BaseAddress,
+                               IN ULONG BugCheckOnFailure,
+                               IN MM_PAGE_PRIORITY Priority);   
 VOID
 STDCALL
 MmMapMemoryDumpMdl (

Modified: trunk/reactos/lib/crt/except/matherr.c
--- trunk/reactos/lib/crt/except/matherr.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/lib/crt/except/matherr.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -1,16 +1,8 @@
 #include "precomp.h"
+#include <math.h>
 #include <ntos/except.h>
 
 
-struct _exception {
-    int type;
-    char* name;
-    double arg1;
-    double arg2;
-    double retval;
-} ;
-
-
 int _matherr(struct _exception* e)
 {
     return 0;

Modified: trunk/reactos/lib/ntdll/rtl/libsupp.c
--- trunk/reactos/lib/ntdll/rtl/libsupp.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/lib/ntdll/rtl/libsupp.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -19,6 +19,13 @@
 
 /* FUNCTIONS ***************************************************************/
 
+KPROCESSOR_MODE
+RtlpGetMode()
+{ 
+   return UserMode; 
+}
+
+
 PVOID 
 STDCALL
 ExAllocatePool(

Modified: trunk/reactos/lib/ntdll/rtl/path.c
--- trunk/reactos/lib/ntdll/rtl/path.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/lib/ntdll/rtl/path.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -948,13 +948,10 @@
 {
 	UNICODE_STRING NtFileName;
 	OBJECT_ATTRIBUTES Attr;
+   FILE_BASIC_INFORMATION Info;
 	NTSTATUS Status;
 	CURDIR CurDir;
-	PWSTR Buffer;
 
-	/* only used by replacement code */
-	HANDLE FileHandle;
-	IO_STATUS_BLOCK StatusBlock;
 
 	if (!RtlDosPathNameToNtPathName_U (FileName,
 	                                   &NtFileName,
@@ -962,9 +959,6 @@
 	                                   &CurDir))
 		return FALSE;
 
-	/* don't forget to free it! */
-	Buffer = NtFileName.Buffer;
-
 	if (CurDir.DosPath.Length)
 		NtFileName = CurDir.DosPath;
 	else
@@ -976,24 +970,11 @@
 	                            CurDir.Handle,
 	                            NULL);
 
-	/* FIXME: not implemented yet */
-//	Status = NtQueryAttributesFile (&Attr, NULL);
+	Status = NtQueryAttributesFile (&Attr, &Info);
 
-	/* REPLACEMENT start */
-	Status = NtOpenFile (&FileHandle,
-	                     0x10001,
-	                     &Attr,
-	                     &StatusBlock,
-	                     1,
-	                     FILE_SYNCHRONOUS_IO_NONALERT);
-	if (NT_SUCCESS(Status))
-		NtClose (FileHandle);
-	/* REPLACEMENT end */
-
-	RtlFreeHeap (RtlGetProcessHeap (),
-	             0,
-	             Buffer);
-
+   RtlFreeUnicodeString(&NtFileName);
+   
+   
 	if (NT_SUCCESS(Status) ||
 	    Status == STATUS_SHARING_VIOLATION ||
 	    Status == STATUS_ACCESS_DENIED)

Modified: trunk/reactos/lib/rtl/unicode.c
--- trunk/reactos/lib/rtl/unicode.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/lib/rtl/unicode.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -2256,6 +2256,8 @@
 
 /*
  * private
+ *
+ * Creates a nullterminated UNICODE_STRING
  */
 BOOLEAN
 FASTCALL

Modified: trunk/reactos/lib/user32/windows/accel.c
--- trunk/reactos/lib/user32/windows/accel.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/lib/user32/windows/accel.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -285,6 +285,9 @@
 }
 
 
+/*
+ * @implemented
+ */
 int WINAPI CopyAcceleratorTableA
 (
  HACCEL hAccelSrc,

Modified: trunk/reactos/ntoskrnl/fs/notify.c
--- trunk/reactos/ntoskrnl/fs/notify.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/ntoskrnl/fs/notify.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -23,7 +23,6 @@
    LIST_ENTRY ListEntry;
    PSTRING FullDirectoryName;
    BOOLEAN WatchTree;
-   BOOLEAN IgnoreBuffer;
    BOOLEAN PendingChanges;
    ULONG CompletionFilter;
    LIST_ENTRY IrpQueue;
@@ -395,7 +394,7 @@
    IN BOOLEAN           WatchTree,
    IN BOOLEAN           IgnoreBuffer,
    IN ULONG          CompletionFilter,
-   IN PIRP           NotifyIrp,
+   IN PIRP           Irp,
    IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback  OPTIONAL,
 	IN	PSECURITY_SUBJECT_CONTEXT	SubjectContext		OPTIONAL
 	)
@@ -404,7 +403,7 @@
    PNOTIFY_ENTRY NotifyEntry;
    ULONG IrpBuffLen;
    
-   if (!NotifyIrp)
+   if (!Irp)
    {
       /* all other params are ignored if NotifyIrp == NULL */
       FsRtlpWatchedDirectoryWasDeleted(NotifySync, NotifyList, FsContext);
@@ -415,14 +414,14 @@
    
    ExAcquireFastMutex((PFAST_MUTEX)NotifySync);
    
-   IrpStack = IoGetCurrentIrpStackLocation(NotifyIrp);
+   IrpStack = IoGetCurrentIrpStackLocation(Irp);
    if (IrpStack->FileObject->Flags & FO_CLEANUP_COMPLETE)
    {
       ExReleaseFastMutex((PFAST_MUTEX)NotifySync);
       
-      NotifyIrp->IoStatus.Information = 0;
-      NotifyIrp->IoStatus.Status = STATUS_NOTIFY_CLEANUP;
-      IoCompleteRequest(NotifyIrp, IO_NO_INCREMENT);
+      Irp->IoStatus.Information = 0;
+      Irp->IoStatus.Status = STATUS_NOTIFY_CLEANUP;
+      IoCompleteRequest(Irp, IO_NO_INCREMENT);
       return;       
    }
    
@@ -463,12 +462,13 @@
                FSRTL_NOTIFY_TAG
                );
                
-            NotifyEntry->PrevEntry = NotifyEntry->Buffer;   
             NotifyEntry->BufferSize = IrpBuffLen;
          }
          _SEH_HANDLE
          {
-            /* ExAllocatePoolWithQuotaTag raised exception */
+            /* ExAllocatePoolWithQuotaTag raised exception but we dont care.
+               The impl. doesnt require a buffer, so well continue as usual.
+            */
          }
          _SEH_END;
       }
@@ -485,26 +485,29 @@
       /* No changes are pending. Queue the irp */
 
       /* Irp cancelation boilerplate */
-      IoSetCancelRoutine(NotifyIrp, FsRtlpNotifyCancelRoutine);
-      if (NotifyIrp->Cancel && IoSetCancelRoutine(NotifyIrp, NULL))
+      
+      /* save NotifySych for use in the cancel routine */
+      Irp->Tail.Overlay.DriverContext[3] = NotifySync;
+
+      IoSetCancelRoutine(Irp, FsRtlpNotifyCancelRoutine);
+      if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
       {              
          //irp was canceled
          ExReleaseFastMutex((PFAST_MUTEX)NotifySync);
 
-         NotifyIrp->IoStatus.Status = STATUS_CANCELLED;
-         NotifyIrp->IoStatus.Information = 0;
+         Irp->IoStatus.Status = STATUS_CANCELLED;
+         Irp->IoStatus.Information = 0;
 
-         IoCompleteRequest(NotifyIrp, IO_NO_INCREMENT);
+         IoCompleteRequest(Irp, IO_NO_INCREMENT);
          return;
       }
 
-      IoMarkIrpPending(NotifyIrp);
+      IoMarkIrpPending(Irp);
 
       //FIXME: any point in setting irp status/information before queueing?
+      Irp->IoStatus.Status = STATUS_PENDING;
       
-      /* save NotifySych for use in the cancel routine */
-      NotifyIrp->Tail.Overlay.DriverContext[3] = NotifySync;
-      InsertTailList(&NotifyEntry->IrpQueue, &NotifyIrp->Tail.Overlay.ListEntry);
+      InsertTailList(&NotifyEntry->IrpQueue, &Irp->Tail.Overlay.ListEntry);
 
       ExReleaseFastMutex((PFAST_MUTEX)NotifySync);
       return;
@@ -524,24 +527,29 @@
       -Current irp buff was not large enough
       */
      
-      NotifyIrp->IoStatus.Information = 0;
-      NotifyIrp->IoStatus.Status = STATUS_NOTIFY_ENUM_DIR;
+      Irp->IoStatus.Information = 0;
+      Irp->IoStatus.Status = STATUS_NOTIFY_ENUM_DIR;
 
    }
    else
    {
-      /* terminate last entry */
-      NotifyEntry->PrevEntry->NextEntryOffset = 0;
-      
-      //FIXME: copy data correctly to user
-      memcpy(NotifyIrp->UserBuffer, NotifyEntry->Buffer, NotifyEntry->NextEntryOffset);
+      PVOID Adr = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, LowPagePriority);
 
-      NotifyIrp->IoStatus.Information = NotifyEntry->NextEntryOffset;
-      NotifyIrp->IoStatus.Status = STATUS_SUCCESS;
+      if (Adr)
+      {
+         memcpy(Adr, NotifyEntry->Buffer, NotifyEntry->NextEntryOffset);
+         Irp->IoStatus.Information = NotifyEntry->NextEntryOffset;
+      }
+      else
+      {
+         Irp->IoStatus.Information = 0;
+      }
+
+      Irp->IoStatus.Status = STATUS_SUCCESS;
    }
    
    /* reset buffer */
-   NotifyEntry->PrevEntry = NotifyEntry->Buffer; 
+   NotifyEntry->PrevEntry = NULL;
    NotifyEntry->NextEntryOffset = 0;
    NotifyEntry->BufferExhausted = FALSE;
    
@@ -549,7 +557,9 @@
 
    ExReleaseFastMutex((PFAST_MUTEX)NotifySync);
    
-   IoCompleteRequest(NotifyIrp, IO_NO_INCREMENT);
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   
+   /* caller must return STATUS_PENDING */
 }
 
 
@@ -671,20 +681,25 @@
    LIST_FOR_EACH_SAFE(EnumEntry, NotifyList, NotifyEntry, NOTIFY_ENTRY, ListEntry )
    {
       ASSERT(NotifyEntry->Unicode == FsRtlpIsUnicodePath(FullTargetName));
-         
+      
       /* rule out some easy cases */
-      /* FIXME: short vs. long names??? */
+      /* FIXME: short vs. long names??? lower case/upper case/mixed case? */
       if (!(FilterMatch & NotifyEntry->CompletionFilter)) continue;
       
-      FullDirLen = TargetNameOffset - (NotifyEntry->Unicode?sizeof(WCHAR):sizeof(char));
+      FullDirLen = TargetNameOffset - (NotifyEntry->Unicode ? sizeof(WCHAR) : sizeof(char));
+      if (FullDirLen == 0)
+      {
+         /* special case for root dir */
+         FullDirLen = (NotifyEntry->Unicode ? sizeof(WCHAR) : sizeof(char));
+      }
       
-      
       if (FullDirLen < NotifyEntry->FullDirectoryName->Length) continue;
       
       if (!NotifyEntry->WatchTree && FullDirLen != NotifyEntry->FullDirectoryName->Length) continue;
 
       DPRINT("NotifyEntry->FullDirectoryName: %wZ\n", NotifyEntry->FullDirectoryName);
       
+      /* FIXME: short vs. long names??? lower case/upper case/mixed case? */
       if (memcmp(NotifyEntry->FullDirectoryName->Buffer, 
             FullTargetName->Buffer, 
             NotifyEntry->FullDirectoryName->Length) != 0) continue;
@@ -751,22 +766,31 @@
          }
          else
          {
-            //FIXME: copy data to user correctly
-            CurrentEntry = (PFILE_NOTIFY_INFORMATION)Irp->UserBuffer;
+            CurrentEntry = (PFILE_NOTIFY_INFORMATION)            
+               MmGetSystemAddressForMdlSafe(Irp->MdlAddress, LowPagePriority);
+               
+            if (CurrentEntry)
+            {
+               CurrentEntry->Action = Action; 
+               CurrentEntry->NameLength = NameLenU;
+               CurrentEntry->NextEntryOffset = 0;
+
+               FsRtlpCopyName(
+                     CurrentEntry,
+                     NotifyEntry->Unicode,
+                     &RelativeName,
+                     StreamName
+                     );
+               
+               Irp->IoStatus.Information = RecordLen;
+            }
+            else
+            {
+               Irp->IoStatus.Information = 0;
+            }
             
-            CurrentEntry->Action = Action; 
-            CurrentEntry->NameLength = NameLenU;
-            CurrentEntry->NextEntryOffset = 0;
 
-            FsRtlpCopyName(
-                  CurrentEntry,
-                  NotifyEntry->Unicode,
-                  &RelativeName,
-                  StreamName
-                  );
-
             Irp->IoStatus.Status = STATUS_SUCCESS;
-            Irp->IoStatus.Information = RecordLen;
          }
          
          /* avoid holding lock while completing irp */
@@ -803,8 +827,10 @@
                       StreamName
                       );
          
-         /* adjust buffer */
-         NotifyEntry->PrevEntry->NextEntryOffset = (char*)CurrentEntry - (char*)NotifyEntry->PrevEntry;
+         if (NotifyEntry->PrevEntry)
+         {
+            NotifyEntry->PrevEntry->NextEntryOffset = (char*)CurrentEntry - (char*)NotifyEntry->PrevEntry;
+         }
          NotifyEntry->PrevEntry = CurrentEntry;
          NotifyEntry->NextEntryOffset += RecordLen;
  

Modified: trunk/reactos/ntoskrnl/io/iomgr.c
--- trunk/reactos/ntoskrnl/io/iomgr.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/ntoskrnl/io/iomgr.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -34,10 +34,10 @@
 ULONGLONG             IoOtherTransferCount = 0;
 KSPIN_LOCK   EXPORTED IoStatisticsLock = 0;
 
-static GENERIC_MAPPING IopFileMapping = {STANDARD_RIGHTS_READ | SYNCHRONIZE | FILE_READ_DATA | FILE_READ_PROPERTIES,
-					 STANDARD_RIGHTS_WRITE | SYNCHRONIZE | FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_PROPERTIES,
-					 STANDARD_RIGHTS_EXECUTE | SYNCHRONIZE | FILE_EXECUTE | FILE_READ_ATTRIBUTES,
-					 FILE_ALL_ACCESS};
+static GENERIC_MAPPING IopFileMapping = {FILE_GENERIC_READ,
+                FILE_GENERIC_WRITE,
+                FILE_GENERIC_EXECUTE,
+                FILE_ALL_ACCESS};
 
 /* FUNCTIONS ****************************************************************/
 

Modified: trunk/reactos/subsys/win32k/objects/bitmaps.c
--- trunk/reactos/subsys/win32k/objects/bitmaps.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/subsys/win32k/objects/bitmaps.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -556,8 +556,10 @@
 	COLORREF  Color,
 	UINT  FillType)
 {
-	UNIMPLEMENTED;
-	return FALSE;
+   DPRINT1("FIXME: NtGdiExtFloodFill is UNIMPLEMENTED\n");
+   
+   /* lie and say we succeded */
+	return TRUE;
 }
 
 BOOL STDCALL

Modified: trunk/reactos/subsys/win32k/objects/pen.c
--- trunk/reactos/subsys/win32k/objects/pen.c	2005-03-31 22:40:23 UTC (rev 14395)
+++ trunk/reactos/subsys/win32k/objects/pen.c	2005-04-01 00:04:15 UTC (rev 14396)
@@ -63,7 +63,7 @@
          break;
 
       default:
-         UNIMPLEMENTED;
+         DPRINT1("FIXME: IntGdiCreatePenIndirect is UNIMPLEMENTED\n");
    }
 
    PENOBJ_UnlockPen(hPen);