JNative v1.3 project : see http://jnative.sf.net


org.xvolks.jnative.util
Class PsAPI

java.lang.Object
  extended by org.xvolks.jnative.util.PsAPI

public class PsAPI
extends java.lang.Object

$Id: PsAPI.java,v 1.5 2006/10/03 21:38:39 mdenty Exp $

PsAPI.java

This software is released under the LGPL.


Field Summary
static java.lang.String DLL_NAME
           
 
Constructor Summary
PsAPI()
           
 
Method Summary
static int[] EnumProcess(int maxSizeOfInitialBuffer)
           The EnumProcesses function retrieves the process identifier for each process object in the system.
static Pointer EnumProcessModules(HANDLE hProcessHandle, int maxSizeOfInitialBuffer)
           Retrieves a handle for each module in the specified process.
static java.lang.String GetModuleBaseName(HANDLE hProcessHandle, int hModule, int nSize)
           Retrieves the base name of the specified module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DLL_NAME

public static final java.lang.String DLL_NAME
See Also:
Constant Field Values
Constructor Detail

PsAPI

public PsAPI()
Method Detail

EnumProcess

public static int[] EnumProcess(int maxSizeOfInitialBuffer)
                         throws NativeException,
                                java.lang.IllegalAccessException

The EnumProcesses function retrieves the process identifier for each process object in the system.

         BOOL EnumProcesses(
         DWORD* pProcessIds,
         DWORD cb,
         DWORD* pBytesReturned
         );
         
         
         
         Parameters
         
         pProcessIds
         [out] Pointer to an array that receives the list of process identifiers.
         cb
         [in] Size of the pProcessIds array, in bytes.
         pBytesReturned
         [out] Number of bytes returned in the pProcessIds array.
         
         Return Values
         
         If the function succeeds, the return value is nonzero.
         
         If the function fails, the return value is zero. To get extended error information, call GetLastError.
         Remarks
         
         It is a good idea to use a large array, because it is hard to predict how many processes there will be at the time you call EnumProcesses.
         
         To determine how many processes were enumerated, divide the pBytesReturned value by sizeof(DWORD). There is no indication given when the buffer is too small to store all process identifiers. Therefore, if pBytesReturned equals cb, consider retrying the call with a larger array.
         
         To obtain process handles for the processes whose identifiers you have just obtained, call the OpenProcess function.
        
 

Throws:
NativeException
java.lang.IllegalAccessException

EnumProcessModules

public static Pointer EnumProcessModules(HANDLE hProcessHandle,
                                         int maxSizeOfInitialBuffer)
                                  throws NativeException,
                                         java.lang.IllegalAccessException
         Retrieves a handle for each module in the specified process.
         
         BOOL WINAPI EnumProcessModules(
         HANDLE hProcess,
         HMODULE* lphModule,
         DWORD cb,
         LPDWORD lpcbNeeded
         );
         
         Parameters
         
         hProcess
         [in] A handle to the process.
         lphModule
         [out] An array that receives the list of module handles.
         cb
         [in] The size of the lphModule array, in bytes.
         lpcbNeeded
         [out] The number of bytes required to store all module handles in the lphModule array.
         
         Return Values
         
         If the function succeeds, the return value is nonzero.
         
         If the function fails, the return value is zero. To get extended error information, call GetLastError.
 

Throws:
NativeException
java.lang.IllegalAccessException

GetModuleBaseName

public static java.lang.String GetModuleBaseName(HANDLE hProcessHandle,
                                                 int hModule,
                                                 int nSize)
                                          throws NativeException,
                                                 java.lang.IllegalAccessException
  Retrieves the base name of the specified module.
         
         DWORD WINAPI GetModuleBaseName(
         HANDLE hProcess,
         HMODULE hModule,
         LPTSTR lpBaseName,
         DWORD nSize
         );
         
         Parameters
         
         hProcess
         [in] Handle to the process that contains the module. To specify the current process, use GetCurrentProcess.
         
         The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access rights. For more information, see Process Security and Access Rights.
         hModule
         [in] Handle to the module. If this parameter is NULL, this function returns the name of the file used to create the calling process.
         lpBaseName
         [out] Pointer to the buffer that receives the base name of the module. If the base name is longer than maximum number of characters specified by the nSize parameter, the base name is truncated.
         nSize
         [in] Size of the lpBaseName buffer, in characters.
         
         Return Values
         
         If the function succeeds, the return value specifies the length of the string copied to the buffer, in characters.
         
         If the function fails, the return value is zero. To get extended error information, call GetLastError.
 

Throws:
NativeException
java.lang.IllegalAccessException

JNative v1.3 project : see http://jnative.sf.net