Ignore:
Timestamp:
Dec 1, 1999, 7:40:49 PM (26 years ago)
Author:
sandervl
Message:

added GetProcessTimes + several fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/process.cpp

    r1893 r1924  
    1 /* $Id: process.cpp,v 1.2 1999-11-30 19:40:26 sandervl Exp $ */
     1/* $Id: process.cpp,v 1.3 1999-12-01 18:40:48 sandervl Exp $ */
    22
    33/*
     
    2929#include <win\task.h>
    3030#include <winimagebase.h>
     31#include "oslibdos.h"
    3132
    3233#define SHUTDOWN_NORETRY 1
     
    390391    }
    391392}
    392 //******************************************************************************
    393 //******************************************************************************
     393/*****************************************************************************
     394 * Name      : BOOL GetProcessTimes
     395 * Purpose   : The GetProcessTimes function obtains timing information about a specified process.
     396 * Parameters: HANDLE     hProcess       specifies the process of interest
     397 *             LPFILETIME lpCreationTime when the process was created
     398 *             LPFILETIME lpExitTime     when the process exited
     399 *             LPFILETIME lpKernelTime   time the process has spent in kernel mode
     400 *             LPFILETIME lpUserTime     time the process has spent in user mode
     401 * Variables :
     402 * Result    : TRUE / FALSE
     403 * Remark    :
     404 * Status    : UNTESTED STUB
     405 *
     406 * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
     407 *****************************************************************************/
     408
     409ULONG (WINAPI *NtdllRtlExtendedIntegerMultiply)(LARGE_INTEGER factor1,
     410                                                INT    factor2) = 0;
     411
     412BOOL WIN32API GetProcessTimes(HANDLE     hProcess,
     413                              LPFILETIME lpCreationTime,
     414                              LPFILETIME lpExitTime,
     415                              LPFILETIME lpKernelTime,
     416                              LPFILETIME lpUserTime)
     417{
     418 LARGE_INTEGER *kerneltime, *usertime;
     419
     420  dprintf(("Kernel32: GetProcessTimes(%08xh,%08xh,%08xh,%08xh,%08xh) partly implemented",
     421           hProcess,
     422           lpCreationTime,
     423           lpExitTime,
     424           lpKernelTime,
     425           lpUserTime));
     426
     427  if(!NtdllRtlExtendedIntegerMultiply) {
     428        HINSTANCE hInstance = LoadLibraryA("NTDLL.DLL");
     429        if(hInstance)
     430                *(VOID **)&NtdllRtlExtendedIntegerMultiply=(void*)GetProcAddress(hInstance, (LPCSTR)"RtlExtendedIntegerMultiply");
     431  }
     432  if(!lpCreationTime || !lpExitTime || !lpKernelTime || !lpUserTime) {
     433        SetLastError(ERROR_INVALID_PARAMETER);
     434        return FALSE;
     435  }
     436  if(hProcess != GetCurrentProcess()) {
     437        dprintf(("GetProcessTimes unknown process"));
     438        return FALSE;
     439  }
     440
     441  SystemTimeToFileTime(&ProcessPDB.creationTime, lpCreationTime);
     442  memset(lpExitTime, 0, sizeof(FILETIME));
     443  memset(lpKernelTime, 0, sizeof(FILETIME));
     444  memset(lpUserTime, 0, sizeof(FILETIME));
     445
     446  kerneltime = (LARGE_INTEGER *)lpKernelTime;
     447  usertime   = (LARGE_INTEGER *)lpUserTime;
     448  OSLibDosQueryProcTimes(GetCurrentProcessId(), &lpKernelTime->dwLowDateTime, &lpUserTime->dwLowDateTime);
     449  //TODO: Isn't correct -> (if result's high dword != 0)
     450  kerneltime->u.LowPart = NtdllRtlExtendedIntegerMultiply(*kerneltime, 10);
     451  usertime->u.LowPart   = NtdllRtlExtendedIntegerMultiply(*usertime, 10);
     452  return TRUE;
     453}
     454//******************************************************************************
     455//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.