Commit in reactos on MAIN
include/ntos/zwtypes.h+6-61.41 -> 1.42
lib/psapi/misc/stubs.c+1-281.9 -> 1.10
              /win32.c+164-271.13 -> 1.14
ntoskrnl/ex/sysinfo.c+6-61.56 -> 1.57
w32api/include/ddk/ntapi.h+4-41.9 -> 1.10
+181-71
5 modified files
1. fixed field names of the SYSTEM_PAGEFILE_INFORMATION structure
2. implemented EnumPageFilesA/W()

reactos/include/ntos
zwtypes.h 1.41 -> 1.42
diff -u -r1.41 -r1.42
--- zwtypes.h	30 Oct 2004 22:18:16 -0000	1.41
+++ zwtypes.h	6 Nov 2004 01:42:04 -0000	1.42
@@ -474,12 +474,12 @@
 typedef
 struct _SYSTEM_PAGEFILE_INFORMATION
 {
-	ULONG		RelativeOffset;
-	ULONG		CurrentSizePages;
-	ULONG		TotalUsedPages;
-	ULONG		PeakUsedPages;
-	UNICODE_STRING	PagefileFileName;
-	
+	ULONG	NextEntryOffset;
+	ULONG	TotalSize;
+	ULONG	TotalInUse;
+	ULONG	PeakUsage;
+	UNICODE_STRING	PageFileName;
+
 } SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
 
 // SystemCacheInformation (21)

reactos/lib/psapi/misc
stubs.c 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- stubs.c	5 Nov 2004 23:53:06 -0000	1.9
+++ stubs.c	6 Nov 2004 01:42:04 -0000	1.10
@@ -1,36 +1,9 @@
-/* $Id: stubs.c,v 1.9 2004/11/05 23:53:06 weiden Exp $ */
+/* $Id: stubs.c,v 1.10 2004/11/06 01:42:04 weiden Exp $ */
 #include "precomp.h"
 
 #define NDEBUG
 #include <debug.h>
 
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA pCallbackRoutine,
-               LPVOID lpContext)
-{
-  DPRINT1("PSAPI: EnumPageFilesA is UNIMPLEMENTED!\n");
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
-EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW pCallbackRoutine,
-               LPVOID lpContext)
-{
-  DPRINT1("PSAPI: EnumPageFilesW is UNIMPLEMENTED!\n");
-  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-  return FALSE;
-}
-
 
 /*
  * @unimplemented

reactos/lib/psapi/misc
win32.c 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- win32.c	5 Nov 2004 23:53:06 -0000	1.13
+++ win32.c	6 Nov 2004 01:42:04 -0000	1.14
@@ -1,4 +1,4 @@
-/* $Id: win32.c,v 1.13 2004/11/05 23:53:06 weiden Exp $
+/* $Id: win32.c,v 1.14 2004/11/06 01:42:04 weiden Exp $
  */
 /*
  * COPYRIGHT:   See COPYING in the top level directory
@@ -935,15 +935,15 @@
                          DWORD nSize)
 {
   PUNICODE_STRING ImageFileName;
-  ULONG BufferSize;
+  SIZE_T BufferSize;
   NTSTATUS Status;
+  DWORD Ret = 0;
 
   BufferSize = sizeof(UNICODE_STRING) + (nSize * sizeof(WCHAR));
 
   ImageFileName = (PUNICODE_STRING)LocalAlloc(LMEM_FIXED, BufferSize);
   if(ImageFileName != NULL)
   {
-    DWORD Ret;
     Status = NtQueryInformationProcess(hProcess,
                                        ProcessImageFileName,
                                        ImageFileName,
@@ -957,22 +957,17 @@
       lpImageFileName[ImageFileName->Length / sizeof(WCHAR)] = L'\0';
       Ret = ImageFileName->Length / sizeof(WCHAR);
     }
+    else if(Status == STATUS_INFO_LENGTH_MISMATCH)
+    {
+      /* XP sets this error code for some reason if the buffer is too small */
+      SetLastError(ERROR_INSUFFICIENT_BUFFER);
+    }
     else
     {
-      if(Status == STATUS_INFO_LENGTH_MISMATCH)
-      {
-        /* XP sets this error code for some reason if the buffer is too small */
-        SetLastError(ERROR_INSUFFICIENT_BUFFER);
-      }
-      else
-      {
-        SetLastErrorByStatus(Status);
-      }
-      Ret = 0;
+      SetLastErrorByStatus(Status);
     }
 
     LocalFree((HLOCAL)ImageFileName);
-    return Ret;
   }
 
   return 0;
@@ -989,15 +984,15 @@
                          DWORD nSize)
 {
   PUNICODE_STRING ImageFileName;
-  ULONG BufferSize;
+  SIZE_T BufferSize;
   NTSTATUS Status;
+  DWORD Ret = 0;
 
   BufferSize = sizeof(UNICODE_STRING) + (nSize * sizeof(WCHAR));
 
   ImageFileName = (PUNICODE_STRING)LocalAlloc(LMEM_FIXED, BufferSize);
   if(ImageFileName != NULL)
   {
-    DWORD Ret;
     Status = NtQueryInformationProcess(hProcess,
                                        ProcessImageFileName,
                                        ImageFileName,
@@ -1018,26 +1013,168 @@
       lpImageFileName[ImageFileName->Length / sizeof(WCHAR)] = '\0';
       Ret = ImageFileName->Length / sizeof(WCHAR);
     }
+    else if(Status == STATUS_INFO_LENGTH_MISMATCH)
+    {
+      /* XP sets this error code for some reason if the buffer is too small */
+      SetLastError(ERROR_INSUFFICIENT_BUFFER);
+    }
     else
     {
-      if(Status == STATUS_INFO_LENGTH_MISMATCH)
+      SetLastErrorByStatus(Status);
+    }
+
+    LocalFree((HLOCAL)ImageFileName);
+  }
+
+  return 0;
+}
+
+
+typedef struct _INTERNAL_ENUM_PAGE_FILES_CONTEXT
+{
+  PENUM_PAGE_FILE_CALLBACKA pCallbackRoutine;
+  LPVOID lpContext;
+} INTERNAL_ENUM_PAGE_FILES_CONTEXT, *PINTERNAL_ENUM_PAGE_FILES_CONTEXT;
+
+
+static BOOL
+InternalAnsiPageFileCallback(LPVOID pContext,
+                             PENUM_PAGE_FILE_INFORMATION pPageFileInfo,
+                             LPCWSTR lpFilename)
+{
+  size_t slen;
+  LPSTR AnsiFileName;
+  PINTERNAL_ENUM_PAGE_FILES_CONTEXT Context = (PINTERNAL_ENUM_PAGE_FILES_CONTEXT)pContext;
+  
+  slen = wcslen(lpFilename);
+  
+  AnsiFileName = (LPSTR)LocalAlloc(LMEM_FIXED, (slen + 1) * sizeof(CHAR));
+  if(AnsiFileName != NULL)
+  {
+    BOOL Ret;
+    
+    WideCharToMultiByte(CP_ACP,
+                        0,
+                        lpFilename,
+                        -1, /* only works if the string is NULL-terminated!!! */
+                        AnsiFileName,
+                        (slen + 1) * sizeof(CHAR),
+                        NULL,
+                        NULL);
+    
+    Ret = Context->pCallbackRoutine(Context->lpContext, pPageFileInfo, AnsiFileName);
+    
+    LocalFree((HLOCAL)AnsiFileName);
+    
+    return Ret;
+  }
+
+  return FALSE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA pCallbackRoutine,
+               LPVOID lpContext)
+{
+  INTERNAL_ENUM_PAGE_FILES_CONTEXT Context;
+  
+  Context.pCallbackRoutine = pCallbackRoutine;
+  Context.lpContext = lpContext;
+  
+  return EnumPageFilesW(InternalAnsiPageFileCallback, &Context);
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+STDCALL
+EnumPageFilesW(PENUM_PAGE_FILE_CALLBACKW pCallbackRoutine,
+               LPVOID lpContext)
+{
+  NTSTATUS Status;
+  PVOID Buffer;
+  ULONG BufferSize = 0;
+  BOOL Ret = FALSE;
+
+  for(;;)
+  {
+    BufferSize += 0x1000;
+    Buffer = LocalAlloc(LMEM_FIXED, BufferSize);
+    if(Buffer == NULL)
+    {
+      return FALSE;
+    }
+
+    Status = NtQuerySystemInformation(SystemPagefileInformation,
+                                      Buffer,
+                                      BufferSize,
+                                      NULL);
+    if(Status == STATUS_INFO_LENGTH_MISMATCH)
+    {
+      LocalFree((HLOCAL)Buffer);
+    }
+    else
+    {
+      break;
+    }
+  }
+
+  if(NT_SUCCESS(Status))
+  {
+    ENUM_PAGE_FILE_INFORMATION Information;
+    PSYSTEM_PAGEFILE_INFORMATION pfi = (PSYSTEM_PAGEFILE_INFORMATION)Buffer;
+    ULONG Offset = 0;
+
+    do
+    {
+      PWCHAR Colon;
+
+      pfi = (PSYSTEM_PAGEFILE_INFORMATION)((ULONG_PTR)pfi + Offset);
+
+      Information.cb = sizeof(Information);
+      Information.Reserved = 0;
+      Information.TotalSize = pfi->TotalSize;
+      Information.TotalInUse = pfi->TotalInUse;
+      Information.PeakUsage = pfi->PeakUsage;
+
+      /* strip the \??\ prefix from the file name. We do this by searching for the first
+         : character and then just change Buffer to point to the previous character. */
+
+      Colon = wcschr(pfi->PageFileName.Buffer, L':');
+      if(Colon != NULL)
       {
-        /* XP sets this error code for some reason if the buffer is too small */
-        SetLastError(ERROR_INSUFFICIENT_BUFFER);
+        pfi->PageFileName.Buffer = --Colon;
       }
-      else
+
+      /* FIXME - looks like the PageFileName string is always NULL-terminated on win.
+                 At least I haven't encountered a different case so far, we should
+                 propably manually NULL-terminate the string here... */
+
+      if(!pCallbackRoutine(lpContext, &Information, pfi->PageFileName.Buffer))
       {
-        SetLastErrorByStatus(Status);
+        break;
       }
-      Ret = 0;
-    }
 
-    LocalFree((HLOCAL)ImageFileName);
-    return Ret;
+      Offset = pfi->NextEntryOffset;
+    } while(Offset != 0);
+
+    Ret = TRUE;
+  }
+  else
+  {
+    SetLastErrorByStatus(Status);
   }
 
-  return 0;
+  LocalFree((HLOCAL)Buffer);
+
+  return Ret;
 }
 
 /* EOF */
-

reactos/ntoskrnl/ex
sysinfo.c 1.56 -> 1.57
diff -u -r1.56 -r1.57
--- sysinfo.c	5 Nov 2004 17:42:20 -0000	1.56
+++ sysinfo.c	6 Nov 2004 01:42:04 -0000	1.57
@@ -1,4 +1,4 @@
-/* $Id: sysinfo.c,v 1.56 2004/11/05 17:42:20 ekohl Exp $
+/* $Id: sysinfo.c,v 1.57 2004/11/06 01:42:04 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -856,12 +856,12 @@
 	UNICODE_STRING FileName; /* FIXME */
 
 	/* FIXME */
-	Spfi->RelativeOffset = 0;
+	Spfi->NextEntryOffset = 0;
 
-	Spfi->CurrentSizePages = MiFreeSwapPages + MiUsedSwapPages;
-	Spfi->TotalUsedPages = MiUsedSwapPages;
-	Spfi->PeakUsedPages = MiUsedSwapPages; /* FIXME */
-	Spfi->PagefileFileName = FileName;
+	Spfi->TotalSize = MiFreeSwapPages + MiUsedSwapPages;
+	Spfi->TotalInUse = MiUsedSwapPages;
+	Spfi->PeakUsage = MiUsedSwapPages; /* FIXME */
+	Spfi->PageFileName = FileName;
 	return (STATUS_SUCCESS);
 }
 

reactos/w32api/include/ddk
ntapi.h 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- ntapi.h	30 Oct 2004 22:18:17 -0000	1.9
+++ ntapi.h	6 Nov 2004 01:42:04 -0000	1.10
@@ -445,10 +445,10 @@
 
 typedef struct _SYSTEM_PAGEFILE_INFORMATION {
 	ULONG  NextEntryOffset;
-	ULONG  CurrentSize;
-	ULONG  TotalUsed;
-	ULONG  PeakUsed;
-	UNICODE_STRING  FileName;
+	ULONG  TotalSize;
+	ULONG  TotalInUse;
+	ULONG  PeakUsage;
+	UNICODE_STRING  PageFileName;
 } SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
 
 typedef struct _SYSTEM_INSTRUCTION_EMULATION_INFORMATION {
CVSspam 0.2.8