branch update for HEAD-2003050101
[reactos.git] / lib / psapi / misc / win32.c
index c19bdc3..5b0c9be 100644 (file)
@@ -17,7 +17,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ddk/ntddk.h>
-#include <internal/psapi.h>
+#include <epsapi.h>
 
 /* EmptyWorkingSet */
 BOOL STDCALL EmptyWorkingSet(HANDLE hProcess)
@@ -73,8 +73,7 @@ typedef struct _ENUM_DEVICE_DRIVERS_CONTEXT
 /* callback routine */
 NTSTATUS STDCALL EnumDeviceDriversCallback
 (
- IN ULONG ModuleCount,
- IN PSYSTEM_MODULE_ENTRY CurrentModule,
+ IN PSYSTEM_MODULE_INFORMATION CurrentModule,
  IN OUT PVOID CallbackContext
 )
 {
@@ -86,7 +85,7 @@ NTSTATUS STDCALL EnumDeviceDriversCallback
   return STATUS_INFO_LENGTH_MISMATCH;
 
  /* return current module */
- *(peddcContext->lpImageBase) = CurrentModule->BaseAddress;
+ *(peddcContext->lpImageBase) = CurrentModule->Base;
 
  /* go to next array slot */
  (peddcContext->lpImageBase) ++;
@@ -143,7 +142,7 @@ typedef struct _ENUM_PROCESSES_CONTEXT
 /* callback routine */
 NTSTATUS STDCALL EnumProcessesCallback
 (
- IN PSYSTEM_PROCESS_INFORMATION CurrentProcess,
+ IN PSYSTEM_PROCESSES CurrentProcess,
  IN OUT PVOID CallbackContext
 )
 {
@@ -165,7 +164,7 @@ NTSTATUS STDCALL EnumProcessesCallback
 }
 
 /* exported interface */
-/*
+/*!
  @brief Enumerate the process identifiers of the currently active processes
 
  @param lpidProcess Array that receives the list of process identifiers
@@ -194,7 +193,11 @@ BOOL STDCALL EnumProcesses
  }
 
  /* enumerate the process ids */
- nErrCode = PsaEnumerateProcesses(&EnumProcessesCallback, &epcContext);
+ nErrCode = PsaEnumerateProcesses
+ (
+  &EnumProcessesCallback,
+  &epcContext
+ );
 
  *lpcbNeeded = (cb - epcContext.nCount) * sizeof(DWORD);
 
@@ -305,8 +308,7 @@ typedef struct _GET_DEVICE_DRIVER_NAME_CONTEXT
 /* common callback routine */
 NTSTATUS STDCALL GetDeviceDriverNameCallback
 (
- IN ULONG ModuleCount,
- IN PSYSTEM_MODULE_ENTRY CurrentModule,
+ IN PSYSTEM_MODULE_INFORMATION CurrentModule,
  IN OUT PVOID CallbackContext
 )
 {
@@ -314,16 +316,16 @@ NTSTATUS STDCALL GetDeviceDriverNameCallback
   (PGET_DEVICE_DRIVER_NAME_CONTEXT) CallbackContext;
 
  /* module found */
- if(pgddncContext->ImageBase == CurrentModule->BaseAddress)
+ if(pgddncContext->ImageBase == CurrentModule->Base)
  {
   register PCHAR pcModuleName;
   register ULONG l;
 
   /* get the full name or just the filename part */
   if(pgddncContext->bFullName)
-   pcModuleName = &CurrentModule->Name[0];
+   pcModuleName = &CurrentModule->ImageName[0];
   else
-   pcModuleName = &CurrentModule->Name[CurrentModule->PathLength];
+   pcModuleName = &CurrentModule->ImageName[CurrentModule->ModuleNameOffset];
 
   /* get the length of the name */
   l = strlen(pcModuleName);
@@ -492,7 +494,7 @@ DWORD FASTCALL internalGetMappedFileName(
   nBufSize = nSize * sizeof(WCHAR);
  
  /* allocate the memory */
- pmsnName = malloc(nBufSize + offsetof(MEMORY_SECTION_NAME, NameBuffer));
+ pmsnName = PsaiMalloc(nBufSize + offsetof(MEMORY_SECTION_NAME, NameBuffer));
  
  if(pmsnName == NULL)
  {
@@ -527,7 +529,7 @@ DWORD FASTCALL internalGetMappedFileName(
 #if 0
 #else
    /* free the buffer */
-   free(pmsnName);
+   PsaiFree(pmsnName);
 #endif
    return 0;
   }
@@ -546,7 +548,7 @@ DWORD FASTCALL internalGetMappedFileName(
 #if 0
 #else
    /* free the buffer */
-   free(pmsnName);
+   PsaiFree(pmsnName);
 #endif
    
    if(pmsnName->SectionFileName.Length < nSize)
@@ -572,7 +574,7 @@ DWORD FASTCALL internalGetMappedFileName(
 #if 0
 #else
    /* free the buffer */
-   free(pmsnName);
+   PsaiFree(pmsnName);
 #endif
 
    if(strAnsi.Length < nSize)
@@ -589,7 +591,7 @@ DWORD FASTCALL internalGetMappedFileName(
  }
  __finally
  {
-  free(pmsnName);
+  PsaiFree(pmsnName);
  }
 #endif
 }
@@ -715,7 +717,7 @@ NTSTATUS STDCALL GetModuleInformationCallback
     UNICODE_STRING wstrUnicodeBuf;
     
     /* allocate the local buffer */
-    pwcUnicodeBuf = malloc(pwstrSource->Length);
+    pwcUnicodeBuf = PsaiMalloc(pwstrSource->Length);
 
 #if 0
     __try
@@ -767,7 +769,7 @@ NTSTATUS STDCALL GetModuleInformationCallback
     __finally
     {
      /* free the buffer */
-     free(pwcUnicodeBuf);
+     PsaiFree(pwcUnicodeBuf);
     }
 #else
      /* success */
@@ -775,7 +777,7 @@ NTSTATUS STDCALL GetModuleInformationCallback
 
 exitWithStatus:
      /* free the buffer */
-     free(pwcUnicodeBuf);
+     PsaiFree(pwcUnicodeBuf);
      return nErrCode;
 #endif
    }