Updater/gfxinfo local sync

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4635 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
dmex
2011-09-06 05:41:53 +00:00
parent 64bbf7c539
commit d455bbe28a
7 changed files with 227 additions and 556 deletions
@@ -5,6 +5,7 @@
#include <graph.h>
#include <windowsx.h>
#include <process.h>
#include "adl_defines.h"
#include "adl_sdk.h"
@@ -89,7 +90,7 @@ INT_PTR CALLBACK MainWndProc(
__in LPARAM lParam
);
INT_PTR CALLBACK EtpEtwSysPanelDlgProc(
INT_PTR CALLBACK MainPanelDlgProc(
__in HWND hwndDlg,
__in UINT uMsg,
__in WPARAM wParam,
+17 -361
View File
@@ -835,14 +835,6 @@ extern "C" {
#define NVAPI_INTERFACE extern NvStatus __cdecl
#if defined(WIN32) || defined(_WIN32)
#define __nvapi_deprecated_function(NewFunction, FirstRelease) __declspec(deprecated("Do not use this function - it is deprecated in release " #FirstRelease ". Instead, use " #NewFunction "."))
#define __nvapi_deprecated_datatype(FirstRelease) __declspec(deprecated("Do not use this data type - it is deprecated in release " #FirstRelease "."))
#else
#define __nvapi_deprecated_function(NewFunction, FirstRelease)
#define __nvapi_deprecated_datatype(FirstRelease)
#endif
/* 64-bit types for compilers that support them, plus some obsolete variants */
#if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64)
@@ -2492,127 +2484,6 @@ NVAPI_INTERFACE NvAPI_D3D_GetCurrentSLIState(IUnknown *pDevice, NV_GET_CURRENT_S
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
#if defined(_D3D9_H_)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D9_RegisterResource
//
//! DESCRIPTION: This API binds a resource (surface/texture) so that it can be retrieved
//! internally by NVAPI.
//!
// SUPPORTED OS: Windows XP and higher
//! \param [in] pResource surface/texture
//!
//! \return ::NVAPI_OK, ::NVAPI_ERROR
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D9_RegisterResource(IDirect3DResource9* pResource);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D9_UnregisterResource
//
//! DESCRIPTION: This API unbinds a resource (surface/texture) after use.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] pResource surface/texture
//!
//! \return ::NVAPI_OK, ::NVAPI_ERROR
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D9_UnregisterResource(IDirect3DResource9* pResource);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D9_AliasSurfaceAsTexture
//
//! \fn NvAPI_D3D9_AliasSurfaceAsTexture(IDirect3DDevice9* pDev,
//! IDirect3DSurface9* pSurface,
//! IDirect3DTexture9 **ppTexture,
//! DWORD dwFlag);
//! DESCRIPTION: Create a texture that is an alias of a surface registered with NvAPI. The
//! new texture can be bound with IDirect3DDevice9::SetTexture(). Note that the texture must
//! be unbound before drawing to the surface again.
//! Unless the USE_SUPER flag is passed, MSAA surfaces will be resolved before
//! being used as a texture. MSAA depth buffers are resolved with a point filter,
//! and non-depth MSAA surfaces are resolved with a linear filter.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] pDev The D3D device that owns the objects
//! \param [in] pSurface Pointer to a surface that has been registered with NvAPI
//! to which a texture alias is to be provided
//! \param [out] ppTexture Fill with the texture created
//! \param [in] dwFlag NVAPI_ALIAS_SURFACE_FLAG to describe how to handle the texture
//!
//! \retval ::NVAPI_OK completed request
//! \retval ::NVAPI_INVALID_POINTER A null pointer was passed as an argument
//! \retval ::NVAPI_INVALID_ARGUMENT One of the arguments was invalid, probably dwFlag.
//! \retval ::NVAPI_UNREGISTERED_RESOURCE pSurface has not been registered with NvAPI
//! \retval ::NVAPI_ERROR error occurred
//
///////////////////////////////////////////////////////////////////////////////
//! \ingroup dx
//! See NvAPI_D3D9_AliasSurfaceAsTexture().
typedef enum {
NVAPI_ALIAS_SURFACE_FLAG_NONE = 0x00000000,
NVAPI_ALIAS_SURFACE_FLAG_USE_SUPER = 0x00000001, //!< Use the surface's msaa buffer directly as a texture, rather than resolving. (This is much slower, but potentially has higher quality.)
NVAPI_ALIAS_SURFACE_FLAG_MASK = 0x00000001
} NVAPI_ALIAS_SURFACE_FLAG;
//! \ingroup dx
NVAPI_INTERFACE NvAPI_D3D9_AliasSurfaceAsTexture(IDirect3DDevice9* pDev,
IDirect3DSurface9* pSurface,
IDirect3DTexture9 **ppTexture,
DWORD dwFlag);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D9_StretchRectEx
//
//! DESCRIPTION: This API copies the contents of the source resource to the destination
//! resource. This function can convert
//! between a wider range of surfaces than
//! IDirect3DDevice9::StretchRect. For example, it can copy
//! from a depth/stencil surface to a texture.
//!
//! The source and destination resources *must* be registered
//! with NvAPI before being used with NvAPI_D3D9_StretchRectEx().
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] pDevice The D3D device that owns the objects.
//! \param [in] pSourceResource Pointer to the source resource.
//! \param [in] pSrcRect Defines the rectangle on the source to copy from. If NULL, copy from the entire resource.
//! \param [in] pDestResource Pointer to the destination resource.
//! \param [in] pDstRect Defines the rectangle on the destination to copy to. If NULL, copy to the entire resource.
//! \param [in] Filter Choose a filtering method: D3DTEXF_NONE, D3DTEXF_POINT, D3DTEXF_LINEAR.
//!
//! \retval ::NVAPI_OK completed request
//! \retval ::NVAPI_INVALID_POINTER An invalid pointer was passed as an argument (probably NULL)
//! \retval ::NVAPI_INVALID_ARGUMENT One of the arguments was invalid
//! \retval ::NVAPI_UNREGISTERED_RESOURCE a resource was passed in without being registered
//! \retval ::NVAPI_ERROR error occurred
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D9_StretchRectEx(IDirect3DDevice9 * pDevice,
IDirect3DResource9 * pSourceResource,
CONST RECT * pSourceRect,
IDirect3DResource9 * pDestResource,
CONST RECT * pDestRect,
D3DTEXTUREFILTERTYPE Filter);
#endif //if defined(_D3D9_H_)
///////////////////////////////////////////////////////////////////////////////
@@ -7462,14 +7333,6 @@ NVAPI_INTERFACE NvAPI_VIO_EnumDataFormats(NvVioHandle hVioHandle,
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_GPU_GetTachReading(NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue);
//
// NV_GET_SCALING_CAPS
//
@@ -7503,7 +7366,6 @@ NVAPI_INTERFACE NvAPI_GPU_GetTachReading(NvPhysicalGpuHandle hPhysicalGPU, NvU32
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_SYS_GetDisplayIdFromGpuAndOutputId(NvPhysicalGpuHandle hPhysicalGpu, NvU32 outputId, NvU32* displayId);
///////////////////////////////////////////////////////////////////////////////
// FUNCTION NAME: NvAPI_SYS_GetGpuAndOutputIdFromDisplayId
//
@@ -7529,7 +7391,6 @@ NVAPI_INTERFACE NvAPI_SYS_GetDisplayIdFromGpuAndOutputId(NvPhysicalGpuHandle hPh
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_SYS_GetGpuAndOutputIdFromDisplayId(NvU32 displayId, NvPhysicalGpuHandle *hPhysicalGpu, NvU32 *outputId);
// SUPPORTED OS: Windows XP and higher
///////////////////////////////////////////////////////////////////////////////
//
@@ -7554,8 +7415,6 @@ NVAPI_INTERFACE NvAPI_SYS_GetGpuAndOutputIdFromDisplayId(NvU32 displayId, NvPhys
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DISP_GetDisplayIdByDisplayName(const char *displayName, NvU32* displayId);
// SUPPORTED OS: Windows XP and higher
///////////////////////////////////////////////////////////////////////////////
//
@@ -7576,10 +7435,6 @@ NVAPI_INTERFACE NvAPI_DISP_GetDisplayIdByDisplayName(const char *displayName, Nv
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DISP_GetGDIPrimaryDisplayId(NvU32* displayId);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_GPU_GetECCStatusInfo
@@ -7666,11 +7521,13 @@ NVAPI_INTERFACE NvAPI_GPU_GetECCStatusInfo(NvPhysicalGpuHandle hPhysicalGpu,
typedef struct
{
NvU32 version; //!< Structure version
struct {
struct
{
NvU64 singleBitErrors; //!< Number of single-bit ECC errors detected since last boot
NvU64 doubleBitErrors; //!< Number of double-bit ECC errors detected since last boot
} current;
struct {
struct
{
NvU64 singleBitErrors; //!< Number of single-bit ECC errors detected since last counter reset
NvU64 doubleBitErrors; //!< Number of double-bit ECC errors detected since last counter reset
} aggregate;
@@ -7782,12 +7639,13 @@ NVAPI_INTERFACE NvAPI_GPU_GetECCConfigurationInfo(NvPhysicalGpuHandle hPhysicalG
//!
//! \ingroup gpuecc
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_GPU_SetECCConfiguration(NvPhysicalGpuHandle hPhysicalGpu, NvU8 bEnable,
NvU8 bEnableImmediately);
NVAPI_INTERFACE NvAPI_GPU_SetECCConfiguration(
NvPhysicalGpuHandle hPhysicalGpu,
NvU8 bEnable,
NvU8 bEnableImmediately
);
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)
//#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_D3D_SetFPSIndicatorState
@@ -7804,10 +7662,9 @@ NVAPI_INTERFACE NvAPI_GPU_SetECCConfiguration(NvPhysicalGpuHandle hPhysicalGpu,
//!
//! \ingroup dx
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_D3D_SetFPSIndicatorState(IUnknown *pDev, NvU8 doEnable);
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__)
//NVAPI_INTERFACE NvAPI_D3D_SetFPSIndicatorState(IUnknown *pDev, NvU8 doEnable);
typedef NvStatus (__cdecl *P_NvAPI_D3D_SetFPSIndicatorState)(NvU8 doEnable);
P_NvAPI_D3D_SetFPSIndicatorState NvAPI_SetFPSIndicatorState;
@@ -8262,148 +8119,6 @@ NVAPI_INTERFACE NvAPI_DRS_EnumProfiles(NvDRSSessionHandle hSession, NvU32 index,
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_GetNumProfiles(NvDRSSessionHandle hSession, NvU32 *numProfiles);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_CreateApplication
//
//! DESCRIPTION: This API adds an executable name to a profile.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the session handle.
//! \param [in] hProfile Input profile handle.
//! \param [in] *pApplication Input NVDRS_APPLICATION struct with the executable name to be added.
//!
//! \retval ::NVAPI_OK SUCCESS
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_CreateApplication(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_APPLICATION *pApplication);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_DeleteApplicationEx
//
//! DESCRIPTION: This API removes an executable from a profile.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession - Input to the session handle.
//! \param [in] hProfile - Input profile handle.
//! \param [in] *pApp - Input all the information about the application to be removed.
//!
//! \retval ::NVAPI_OK SUCCESS
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS If the path provided could refer to two different executables,
//! this error will be returned.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_DeleteApplicationEx(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NVDRS_APPLICATION *pApp);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_DeleteApplication
//
//! DESCRIPTION: This API removes an executable name from a profile.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSessionPARAMETERS Input to the session handle.
//! \param [in] hProfile Input profile handle.
//! \param [in] appName Input the executable name to be removed.
//!
//! \retval ::NVAPI_OK SUCCESS
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS If the path provided could refer to two different executables,
//! this error will be returned
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_DeleteApplication(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvAPI_UnicodeString appName);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_GetApplicationInfo
//
//! DESCRIPTION: This API gets information about the given application. The input application name
//! must match exactly what the Profile has stored for the application.
//! This function is better used to retrieve application information from a previous
//! enumeration.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the session handle.
//! \param [in] hProfile Input profile handle.
//! \param [in] appName Input application name.
//! \param [out] *pApplication Returns NVDRS_APPLICATION struct with all the attributes.
//!
//! \return This API can return any of the error codes enumerated in #NvStatus.
//! If there are return error codes with specific meaning for this API,
//! they are listed below.
//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS The application name could not
// single out only one executable.
//! \retval ::NVAPI_EXECUTABLE_NOT_FOUND No application with that name is found on the profile.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_GetApplicationInfo(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvAPI_UnicodeString appName, NVDRS_APPLICATION *pApplication);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_EnumApplications
//
//! DESCRIPTION: This API enumerates all the applications in a given profile from the starting index to the maximum length.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the session handle.
//! \param [in] hProfile Input profile handle.
//! \param [in] startIndex Indicates starting index for enumeration.
//! \param [in,out] *appCount Input maximum length of the passed in arrays. Returns the actual length.
//! \param [out] *pApplication Returns NVDRS_APPLICATION struct with all the attributes.
//!
//! \retval ::NVAPI_OK SUCCESS
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//! \retval ::NVAPI_END_ENUMERATION startIndex exceeds the total appCount.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_EnumApplications(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 startIndex, NvU32 *appCount, NVDRS_APPLICATION *pApplication);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_FindApplicationByName
//
//! DESCRIPTION: This API searches the application and the associated profile for the given application name.
//! If a fully qualified path is provided, this function will always return the profile
//! the driver will apply upon running the application (on the path provided).
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the hSession handle
//! \param [in] appName Input appName. For best results, provide a fully qualified path of the type
//! c:\\Folder1\\Folder2\\App.exe
//! \param [out] *phProfile Returns profile handle.
//! \param [out] *pApplication Returns NVDRS_APPLICATION struct pointer.
//!
//! \return This API can return any of the error codes enumerated in #NvStatus.
//! If there are return error codes with specific meaning for this API,
//! they are listed below:
//! \retval ::NVAPI_APPLICATION_NOT_FOUND If App not found
//! \retval ::NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS If the input appName was not fully qualified, this error might return in the case of multiple matches
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_FindApplicationByName(NvDRSSessionHandle hSession, NvAPI_UnicodeString appName, NvDRSProfileHandle *phProfile, NVDRS_APPLICATION *pApplication);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_SetSetting
@@ -8443,8 +8158,6 @@ NVAPI_INTERFACE NvAPI_DRS_SetSetting(NvDRSSessionHandle hSession, NvDRSProfileHa
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_GetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId, NVDRS_SETTING *pSetting);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_EnumSettings
@@ -8525,7 +8238,6 @@ NVAPI_INTERFACE NvAPI_DRS_EnumAvailableSettingValues(NvU32 settingId, NvU32 *pMa
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_GetSettingIdFromName(NvAPI_UnicodeString settingName, NvU32 *pSettingId);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_GetSettingNameFromId
@@ -8565,65 +8277,6 @@ NVAPI_INTERFACE NvAPI_DRS_GetSettingNameFromId(NvU32 settingId, NvAPI_UnicodeStr
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_DeleteProfileSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_RestoreAllDefaults
//
//! DESCRIPTION: This API restores the whole system to predefined(default) values.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the session handle.
//!
//! \retval ::NVAPI_OK SUCCESS if the profile is found
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_RestoreAllDefaults(NvDRSSessionHandle hSession);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_RestoreProfileDefaults
//
//! DESCRIPTION: This API restores the given profile to predefined(default) values.
//! Any and all user specified modifications will be removed.
//! If the whole profile was set by the user, the profile will be removed.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the session handle.
//! \param [in] hProfile Input profile handle.
//!
//! \retval ::NVAPI_OK SUCCESS if the profile is found
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//! \retval ::NVAPI_PROFILE_REMOVED SUCCESS, and the hProfile is no longer valid.
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_RestoreProfileDefault(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_RestoreProfileDefaultSetting
//
//! DESCRIPTION: This API restores the given profile setting to predefined(default) values.
//!
// SUPPORTED OS: Windows XP and higher
//!
//! \param [in] hSession Input to the session handle.
//! \param [in] hProfile Input profile handle.
//! \param [in] settingId Input settingId.
//!
//! \retval ::NVAPI_OK SUCCESS if the profile is found
//! \retval ::NVAPI_ERROR For miscellaneous errors.
//!
//! \ingroup drsapi
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_DRS_RestoreProfileDefaultSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId);
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: NvAPI_DRS_GetBaseProfile
@@ -8671,7 +8324,10 @@ typedef enum _NVAPI_GPU_PERF_DECREASE
//!
//! \ingroup gpu
///////////////////////////////////////////////////////////////////////////////
NVAPI_INTERFACE NvAPI_GPU_GetPerfDecreaseInfo(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NvU32 *pPerfDecrInfo);
//NVAPI_INTERFACE NvAPI_GPU_GetPerfDecreaseInfo(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NvU32 *pPerfDecrInfo);
typedef NvStatus (__cdecl *P_NvAPI_GPU_GetPerfDecreaseInfo)(__in NvPhysicalGpuHandle hPhysicalGpu, __inout NVAPI_GPU_PERF_DECREASE *pPerfDecrInfo);
P_NvAPI_GPU_GetPerfDecreaseInfo NvAPI_GetPerfDecreaseInfo;
#ifndef __NVAPI_EMPTY_SAL
+73 -26
View File
@@ -23,13 +23,6 @@
#include "gfxinfo.h"
static NTSTATUS WindowThreadStart(
__in PVOID Parameter
);
static VOID GfxSetAlwaysOnTop(
VOID
);
static BOOLEAN AlwaysOnTop;
static PH_EVENT InitializedEvent = PH_EVENT_INIT;
@@ -37,23 +30,31 @@ static HWND GpuGraphHandle;
static HWND CoreGraphHandle;
static HWND MemGraphHandle;
HANDLE GfxThreadHandle = NULL;
HWND GfxWindowHandle = NULL;
HWND GfxPanelWindowHandle = NULL;
NvPhysicalGpuHandle physHandle = NULL;
NvDisplayHandle dispHandle = NULL;
static PH_GRAPH_STATE GpuGraphState;
static PH_GRAPH_STATE MemGraphState;
static PH_GRAPH_STATE CoreGraphState;
static RECT NormalGraphTextMargin = { 5, 5, 5, 5 };
static RECT NormalGraphTextPadding = { 3, 3, 3, 3 };
static VOID NTAPI GfxUpdateHandler(
__in_opt PVOID Parameter,
__in_opt PVOID Context
);
PH_GFX_TYPE GraphicsType = Default;
static NTSTATUS WindowThreadStart(
__in PVOID Parameter
);
static VOID GfxSetAlwaysOnTop(
VOID
);
HANDLE GfxThreadHandle = NULL;
HWND GfxWindowHandle = NULL;
HWND GfxPanelWindowHandle = NULL;
NvPhysicalGpuHandle physHandle = NULL;
NvDisplayHandle dispHandle = NULL;
PH_CIRCULAR_BUFFER_FLOAT GpuHistory;
PH_CIRCULAR_BUFFER_ULONG MemHistory;
@@ -71,8 +72,8 @@ FLOAT GfxCoreClockCount;
FLOAT GfxMemoryClockCount;
FLOAT GfxShaderClockCount;
static RECT NormalGraphTextMargin = { 5, 5, 5, 5 };
static RECT NormalGraphTextPadding = { 3, 3, 3, 3 };
PH_GFX_TYPE GraphicsType = Default;
NVAPI_GPU_PERF_DECREASE perfStatus = NV_GPU_PERF_DECREASE_NONE;
INT_PTR CALLBACK MainWndProc(
__in HWND hwndDlg,
@@ -454,7 +455,7 @@ INT_PTR CALLBACK MainWndProc(
PluginInstance->DllBase,
MAKEINTRESOURCE(IDD_SYSGFX_PANEL),
hwndDlg,
EtpEtwSysPanelDlgProc
MainPanelDlgProc
);
SetWindowPos(
@@ -625,7 +626,7 @@ INT_PTR CALLBACK MainWndProc(
return FALSE;
}
INT_PTR CALLBACK EtpEtwSysPanelDlgProc(
INT_PTR CALLBACK MainPanelDlgProc(
__in HWND hwndDlg,
__in UINT uMsg,
__in WPARAM wParam,
@@ -639,8 +640,47 @@ INT_PTR CALLBACK EtpEtwSysPanelDlgProc(
SetDlgItemText(hwndDlg, IDC_ZREADS_V, PhFormatString(L"%s\u00b0", PhaFormatUInt64(GfxCoreTempCount, TRUE)->Buffer)->Buffer);
SetDlgItemText(hwndDlg, IDC_ZREADBYTES_V, PhFormatString(L"%s\u00b0", PhaFormatUInt64(GfxBoardTempCount, TRUE)->Buffer)->Buffer);
//SetDlgItemText(hwndDlg, IDC_ZWRITES_V, PhaFormatUInt64(EtDiskWriteCount, TRUE)->Buffer);
//SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, PhaFormatSize(EtDiskWriteDelta.Value, -1)->Buffer);
switch (perfStatus)
{
case NV_GPU_PERF_DECREASE_NONE:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"No Slowdown detected.");
}
break;
case NV_GPU_PERF_DECREASE_REASON_THERMAL_PROTECTION:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"Thermal slowdown/shutdown/POR thermal protection.");
}
break;
case NV_GPU_PERF_DECREASE_REASON_POWER_CONTROL:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"Power capping / pstate cap ");
}
break;
case NV_GPU_PERF_DECREASE_REASON_AC_BATT:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"AC->BATT event");
}
break;
case NV_GPU_PERF_DECREASE_REASON_API_TRIGGERED:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"API triggered slowdown");
}
break;
case NV_GPU_PERF_DECREASE_REASON_INSUFFICIENT_POWER:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"Power connector missing");
}
break;
default:
case NV_GPU_PERF_DECREASE_REASON_UNKNOWN:
{
SetDlgItemText(hwndDlg, IDC_ZWRITEBYTES_V, L"Unknown reason");
}
break;
}
SetDlgItemText(hwndDlg, IDC_ZRECEIVES_V, PhFormatString(L"%.2f MHz", GfxCoreClockCount)->Buffer);
SetDlgItemText(hwndDlg, IDC_ZRECEIVEBYTES_V, PhFormatString(L"%.2f MHz", GfxMemoryClockCount)->Buffer);
SetDlgItemText(hwndDlg, IDC_ZSENDS_V, PhFormatString(L"%.2f MHz", GfxShaderClockCount)->Buffer);
@@ -877,11 +917,10 @@ VOID GetGfxUsages(VOID)
LogEvent(L"gfxinfo: (GetGfxUsages) NvAPI_GetUsages failed (%s)", status);
}
status = NvAPI_GetMemoryInfo(dispHandle, &memInfo);
if (NV_SUCCESS(status))
if (NV_SUCCESS((status = NvAPI_GetMemoryInfo(dispHandle, &memInfo))))
{
UINT totalMemory = memInfo.Values[0];
//UINT sharedMemory = memInfo.Values[3];
UINT freeMemory = memInfo.Values[4];
ULONG usedMemory = max(totalMemory - freeMemory, 0);
@@ -895,6 +934,11 @@ VOID GetGfxUsages(VOID)
{
LogEvent(L"gfxinfo: (GetGfxUsages) NvAPI_GetMemoryInfo failed (%s)", status);
}
if (!NV_SUCCESS((status = NvAPI_GetPerfDecreaseInfo(physHandle, &perfStatus))))
{
LogEvent(L"gfxinfo: (GetGfxUsages) NvAPI_GetMemoryInfo failed (%s)", status);
}
}
break;
case AtiGraphics:
@@ -1069,7 +1113,6 @@ VOID InitGfx(VOID)
#else
module = LoadLibrary(L"atiadlxx.dll");
#endif
if (module != NULL)
{
GraphicsType = AtiGraphics;
@@ -1108,12 +1151,16 @@ VOID InitGfx(VOID)
NvAPI_GetMemoryInfo = (P_NvAPI_GetMemoryInfo)NvAPI_QueryInterface(0x774AA982);
NvAPI_GetPhysicalGPUsFromDisplay = (P_NvAPI_GetPhysicalGPUsFromDisplay)NvAPI_QueryInterface(0x34EF9506);
// Driver Info Functions
// Driver Functions
NvAPI_GetFullName = (P_NvAPI_GPU_GetFullName)NvAPI_QueryInterface(0xCEEE8E9F);
NvAPI_GetAllClocks = (P_NvAPI_GPU_GetAllClocks)NvAPI_QueryInterface(0x1BD69F49);
NvAPI_GetThermalSettings = (P_NvAPI_GPU_GetThermalSettings)NvAPI_QueryInterface(0xE3640A56);
NvAPI_GetCoolerSettings = (P_NvAPI_GPU_GetCoolerSettings)NvAPI_QueryInterface(0xDA141340);
NvAPI_GetDisplayDriverVersion = (P_NvAPI_GetDisplayDriverVersion)NvAPI_QueryInterface(0xF951A4D1);
NvAPI_GetPerfDecreaseInfo = (P_NvAPI_GPU_GetPerfDecreaseInfo)NvAPI_QueryInterface(0x7F7F4600);
// Broken?
NvAPI_SetFPSIndicatorState = (P_NvAPI_D3D_SetFPSIndicatorState)NvAPI_QueryInterface(0xA776E8DB);
{
NvStatus status = NvAPI_Initialize();
@@ -102,28 +102,23 @@ BEGIN
GROUPBOX "Memory Controller",IDC_GROUPCONTROLLER,7,117,355,53,0,WS_EX_TRANSPARENT
END
IDD_SYSGFX_PANEL DIALOGEX 0, 0, 246, 58
IDD_SYSGFX_PANEL DIALOGEX 0, 0, 246, 57
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Temperatures",IDC_STATIC,0,0,118,58
GROUPBOX "Temperatures",IDC_STATIC,0,0,118,37
LTEXT "Core",IDC_STATIC,8,11,16,8
LTEXT "Board",IDC_STATIC,8,22,20,8
LTEXT ".",IDC_STATIC,8,33,8,8
LTEXT ".",IDC_STATIC,8,44,8,8
RTEXT "Static",IDC_ZREADS_V,55,11,54,8,SS_ENDELLIPSIS
RTEXT "Static",IDC_ZREADBYTES_V,71,22,38,8,SS_ENDELLIPSIS
RTEXT ".",IDC_ZWRITES_V,55,33,54,8,SS_ENDELLIPSIS
RTEXT ".",IDC_ZWRITEBYTES_V,71,44,38,8,SS_ENDELLIPSIS
GROUPBOX "Clock Speeds",IDC_STATIC,122,0,124,58
LTEXT "PerfDecreaseInfo:",IDC_ZWRITEBYTES_V,2,39,102,8,SS_ENDELLIPSIS
GROUPBOX "Clock Speeds",IDC_STATIC,122,0,123,49
LTEXT "Core",IDC_STATIC,130,11,19,8
LTEXT "Memory",IDC_STATIC,130,23,28,8
LTEXT "Shader",IDC_STATIC,130,34,25,8
LTEXT ".",IDC_STATIC,130,44,8,8
RTEXT ".",IDC_ZRECEIVES_V,182,11,54,8,SS_ENDELLIPSIS
RTEXT ".",IDC_ZRECEIVEBYTES_V,181,23,55,8,SS_ENDELLIPSIS
RTEXT ".",IDC_ZSENDS_V,182,34,54,8,SS_ENDELLIPSIS
RTEXT ".",IDC_ZSENDBYTES_V,198,44,38,8,SS_ENDELLIPSIS
END
IDD_OPTIONS DIALOGEX 0, 0, 215, 70
+15 -15
View File
@@ -89,22 +89,22 @@ END
// Dialog
//
IDD_OUTPUT DIALOGEX 0, 0, 280, 225
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
IDD_OUTPUT DIALOGEX 0, 0, 253, 204
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Update Check"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Close",IDOK,222,198,50,15
PUSHBUTTON "Update",IDC_DOWNLOAD,168,198,50,15,WS_DISABLED
CONTROL 105,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,192,3,85,23
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,6,180,270,12
CONTROL "Ready",IDC_STATUSTEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,6,168,103,9
CONTROL "Checking...",IDC_MESSAGE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,6,6,158,9
CONTROL "Released:",IDC_RELDATE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,6,18,155,9
CONTROL "Size:",IDC_DLSIZE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,102,200,60,9
CONTROL "Speed:",IDC_SPEEDTEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,6,210,92,9
CONTROL "Remaining:",IDC_RTIMETEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,6,198,92,9
EDITTEXT IDC_EDIT1,6,30,270,132,ES_MULTILINE | ES_AUTOHSCROLL,WS_EX_LEFTSCROLLBAR
DEFPUSHBUTTON "Close",IDOK,197,182,50,15
PUSHBUTTON "Update",IDC_DOWNLOAD,145,182,50,15,WS_DISABLED
CONTROL 105,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE,158,7,89,26
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,153,240,14
CONTROL "Ready",IDC_STATUSTEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,7,142,152,9
CONTROL "Checking...",IDC_MESSAGE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,7,7,110,9
CONTROL "Released:",IDC_RELDATE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,7,17,114,9
CONTROL "Size:",IDC_DLSIZE,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | NOT WS_VISIBLE | WS_GROUP,7,28,58,9
CONTROL "Speed:",IDC_SPEEDTEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,149,169,98,9
CONTROL "Remaining:",IDC_RTIMETEXT,"Static",SS_SIMPLE | SS_NOPREFIX | SS_WORDELLIPSIS | WS_GROUP,7,169,133,9
EDITTEXT IDC_EDIT1,7,43,240,97,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY,WS_EX_LEFTSCROLLBAR
END
IDD_OPTIONS DIALOGEX 0, 0, 198, 82
@@ -133,9 +133,9 @@ BEGIN
IDD_OUTPUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 273
RIGHTMARGIN, 247
TOPMARGIN, 7
BOTTOMMARGIN, 218
BOTTOMMARGIN, 197
END
IDD_OPTIONS, DIALOG
+109 -140
View File
@@ -48,12 +48,10 @@ static PH_HASH_ALGORITHM HashAlgorithm = Md5HashAlgorithm;
#pragma region AutoCheck Thread
static void __cdecl SilentWorkerThreadStart(
static void SilentWorkerThreadStart(
__in PVOID Parameter
)
{
DWORD dwBytes = 0;
if (!ConnectionAvailable())
return;
@@ -115,19 +113,12 @@ static void __cdecl SilentWorkerThreadStart(
#pragma endregion
void DownloadChangelogText(
static void DownloadChangelogText(
__in PVOID Parameter
)
{
INT result = 0;
HWND hwndDlg = (HWND)Parameter;
DWORD
dwTotalReadSize = 0,
dwContentLen = 0,
dwBytesRead = 0,
dwBytesWritten = 0;
if (!InitializeConnection(L"processhacker.svn.sourceforge.net", L"/viewvc/processhacker/2.x/trunk/CHANGELOG.txt"))//?revision=4612"))
return;
@@ -135,26 +126,23 @@ void DownloadChangelogText(
if (HttpSendRequest(NetRequest, NULL, 0, NULL, 0))
{
PSTR data;
UPDATER_XML_DATA xmlData;
PPH_STRING localVersion;
ULONG localMajorVersion = 0;
ULONG localMinorVersion = 0;
WCHAR pWideString[512];
// Read the resulting xml into our buffer.
// Read the page into our buffer.
if (!ReadRequestString(NetRequest, &data, NULL))
return;
else
{
PPH_STRING str = PhCreateStringFromAnsi(data);
SetDlgItemText(hwndDlg, IDC_EDIT1, str->Buffer);
SetDlgItemText(hwndDlg, IDC_EDIT1, PhGetString(str));
PhDereferenceObject(str);
PhFree(data);
}
PhFree(data);
}
PhUpdaterState = Downloading;
}
@@ -166,12 +154,6 @@ static void WorkerThreadStart(
{
INT result = 0;
HWND hwndDlg = (HWND)Parameter;
DWORD
dwTotalReadSize = 0,
dwContentLen = 0,
dwBytesRead = 0,
dwBytesWritten = 0;
if (!InitializeConnection(UPDATE_URL, UPDATE_FILE))
return;
@@ -213,12 +195,13 @@ static void WorkerThreadStart(
result = CompareVersions(xmlData.MajorVersion, xmlData.MinorVersion, localMajorVersion, localMinorVersion);
PhSwapReference(&RemoteHashString, xmlData.Hash);
PhDereferenceObject(localVersion);
if (result > 0)
{
PPH_STRING summaryText;
summaryText = PhFormatString(L"Process Hacker %u.%u is available.", xmlData.MajorVersion, xmlData.MinorVersion);
summaryText = PhFormatString(L"Process Hacker %u.%u", xmlData.MajorVersion, xmlData.MinorVersion);
SetDlgItemText(hwndDlg, IDC_MESSAGE, summaryText->Buffer);
PhDereferenceObject(summaryText);
@@ -251,8 +234,32 @@ static void WorkerThreadStart(
PhDereferenceObject(summaryText);
}
PhDereferenceObject(localVersion);
FreeXmlData(&xmlData);
{
PPH_STRING sText = PhFormatString(L"\\\\%s", LocalFileNameString->Buffer);
PPH_STRING autoDbghelpPath = PhGetKnownLocation(CSIDL_DESKTOP, sText->Buffer);
PhDereferenceObject(sText);
if (LocalFilePathString)
PhDereferenceObject(LocalFilePathString);
DisposeFileHandles();
LocalFilePathString = autoDbghelpPath;
// Create output file
if ((TempFileHandle = CreateFile(
LocalFilePathString->Buffer,
GENERIC_WRITE,
FILE_SHARE_WRITE,
0, // handle cannot be inherited
CREATE_ALWAYS, // if file exists, delete it
FILE_ATTRIBUTE_NORMAL,
0)) == INVALID_HANDLE_VALUE)
{
LogEvent(PhFormatString(L"Updater: (InitializeFile) CreateFile failed (%d)", GetLastError()));
}
}
}
else
{
@@ -261,12 +268,8 @@ static void WorkerThreadStart(
}
DisposeConnection();
DownloadChangelogText(hwndDlg);
PhUpdaterState = Downloading;
return;
}
#pragma endregion
@@ -284,12 +287,11 @@ static void DownloadWorkerThreadStart(
dwBufLen = sizeof(dwContentLen);
BOOL nReadFile = FALSE;
PH_HASH_CONTEXT hashContext;
HWND hwndDlg = (HWND)Parameter;
HWND hwndProgress = GetDlgItem(hwndDlg, IDC_PROGRESS);
HWND hwndDlg = (HWND)Parameter,
hwndProgress = GetDlgItem(hwndDlg, IDC_PROGRESS);
PPH_STRING uriPath = PhFormatString(DOWNLOAD_PATH, LocalFileNameString->Buffer);
PH_HASH_CONTEXT hashContext;
if (!ConnectionAvailable())
return;
@@ -300,28 +302,27 @@ static void DownloadWorkerThreadStart(
return;
}
if (!InitializeFile())
return;
Updater_SetStatusText(hwndDlg, L"Connecting");
if (HttpSendRequest(NetRequest, NULL, 0, NULL, 0))
{
CHAR buffer[BUFFER_LEN];
//Now do the actual read of the file
DWORD dwStartTicks = GetTickCount();
DWORD dwCurrentTicks = dwStartTicks;
DWORD dwLastTotalBytes = 0;
DWORD dwLastTotalBytes = 0,
dwNowTicks = 0,
dwTimeTaken = 0;
// Zero the buffer.
RtlZeroMemory(buffer, BUFFER_LEN);
// Initialize hash algorithm.
PhInitializeHash(&hashContext, HashAlgorithm);
if (HttpQueryInfo(NetRequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwContentLen, &dwBufLen, 0))
{
// Reset Progressbar state.
PhSetWindowStyle(hwndProgress, PBS_MARQUEE, 0);
// Initialize hash algorithm.
PhInitializeHash(&hashContext, HashAlgorithm);
while (nReadFile = InternetReadFile(NetRequest, buffer, BUFFER_LEN, &dwBytesRead))
{
@@ -345,7 +346,7 @@ static void DownloadWorkerThreadStart(
}
// Zero the buffer.
RtlZeroMemory(buffer, BUFFER_LEN);
RtlZeroMemory(buffer, dwBytesRead);
// Check dwBytesRead are the same dwBytesWritten length returned by WriteFile.
if (dwBytesRead != dwBytesWritten)
@@ -357,69 +358,68 @@ static void DownloadWorkerThreadStart(
// Update our total bytes downloaded
dwTotalReadSize += dwBytesRead;
// Calculate the transfer rate and download speed.
dwNowTicks = GetTickCount();
dwTimeTaken = dwNowTicks - dwCurrentTicks;
//Update the transfer rate and estimated time every second.
if (dwTimeTaken > 1000)
{
// Calculate the percentage of our total bytes downloaded per the length.
int dlProgress = (int)(((double)dwTotalReadSize / (double)dwContentLen) * 100);
double KbPerSecond = ((double)(dwTotalReadSize) - (double)(dwLastTotalBytes)) / ((double)(dwTimeTaken));
PPH_STRING dlCurrent = PhFormatSize(dwTotalReadSize, -1);
//PPH_STRING dlLength = PhFormatSize(dwContentLen, -1);
PPH_STRING str = PhFormatString(L"Downloaded: %d%% (%s)", dlProgress, dlCurrent->Buffer);
//Setup for the next time around the loop
dwCurrentTicks = dwNowTicks;
dwLastTotalBytes = dwTotalReadSize;
Updater_SetStatusText(hwndDlg, str->Buffer);
PhDereferenceObject(str);
//PhDereferenceObject(dlLength);
PhDereferenceObject(dlCurrent);
PostMessage(hwndProgress, PBM_SETPOS, dlProgress, 0);
}
{
// Calculate the transfer rate and download speed.
DWORD dwNowTicks = GetTickCount();
DWORD dwTimeTaken = dwNowTicks - dwCurrentTicks;
//Update the transfer rate and estimated time left every second.
if (dwTimeTaken > 1000)
//Update the estimated time left
if (dwTotalReadSize)
{
double KbPerSecond = ((double)(dwTotalReadSize) - (double)(dwLastTotalBytes)) / ((double)(dwTimeTaken));
//Setup for the next time around the loop
dwCurrentTicks = dwNowTicks;
dwLastTotalBytes = dwTotalReadSize;
DWORD dwSecondsLeft;
PPH_STRING rstr;
PPH_STRING str;
//Update the estimated time left
if (dwTotalReadSize)
dwSecondsLeft = (DWORD)(((double)dwNowTicks - dwStartTicks) / dwTotalReadSize * (dwContentLen - dwTotalReadSize) / 1000);
str = PhFormatSize(dwContentLen - dwLastTotalBytes, -1);
rstr = PhFormatString(L"Remaning: %s %ds", str->Buffer, dwSecondsLeft);
SetDlgItemText(hwndDlg, IDC_RTIMETEXT, rstr->Buffer);
PhDereferenceObject(rstr);
PhDereferenceObject(str);
}
{
PPH_STRING str;
if (KbPerSecond < 1)
{
DWORD dwSecondsLeft = (DWORD) (((double)dwNowTicks - dwStartTicks) / dwTotalReadSize * (dwContentLen - dwTotalReadSize) / 1000);
//SetTimeLeft(dwSecondsLeft, dwTotalBytesRead + m_dwStartPos, dwFileSize + m_dwStartPos);
PPH_STRING str = PhFormatString(L"Remaning: %ds", dwSecondsLeft);
SetDlgItemText(hwndDlg, IDC_RTIMETEXT, str->Buffer);
PhDereferenceObject(str);
str = PhFormatString(L"Speed: %0.0f Bps", KbPerSecond * 1024);
}
else if (KbPerSecond < 10)
{
str = PhFormatString(L"Speed: %0.2f KB/s", KbPerSecond);
}
else
{
str = PhFormatString(L"Speed: %0.0f KB/s", KbPerSecond);
}
{
PPH_STRING str;
SetDlgItemText(hwndDlg, IDC_SPEEDTEXT, str->Buffer);
PhDereferenceObject(str);
}
{
// Calculate the percentage of our total bytes downloaded per the length.
INT dlProgress = (int)(((double)dwTotalReadSize / (double)dwContentLen) * 100);
if (KbPerSecond < 1)
{
str = PhFormatString(L"Speed: %0.0f Bps", KbPerSecond * 1024);
}
else if (KbPerSecond < 10)
{
str = PhFormatString(L"Speed: %0.2f KB/s", KbPerSecond);
}
else
{
str = PhFormatString(L"Speed: %0.0f KB/s", KbPerSecond);
}
PPH_STRING dlCurrent = PhFormatSize(dwTotalReadSize, -1);
PPH_STRING dlLength = PhFormatSize(dwContentLen, -1);
PPH_STRING str = PhFormatString(L"Downloaded: %s of %s (%d%%)", dlCurrent->Buffer, dlLength->Buffer, dlProgress);
SetDlgItemText(hwndDlg, IDC_SPEEDTEXT, str->Buffer);
PhDereferenceObject(str);
}
Updater_SetStatusText(hwndDlg, str->Buffer);
PostMessage(hwndProgress, PBM_SETPOS, dlProgress, 0);
PhDereferenceObject(str);
PhDereferenceObject(dlLength);
PhDereferenceObject(dlCurrent);
}
}
}
@@ -588,8 +588,15 @@ INT_PTR CALLBACK MainWndProc(
PhSetWindowStyle(GetDlgItem(hwndDlg, IDC_PROGRESS), PBS_MARQUEE, PBS_MARQUEE);
PostMessage(GetDlgItem(hwndDlg, IDC_PROGRESS), PBM_SETMARQUEE, TRUE, 75);
// Star our Downloader thread
_beginthread(DownloadWorkerThreadStart, 0, hwndDlg);
{
// Star our Downloader thread
_beginthread(DownloadWorkerThreadStart, 0, hwndDlg);
}
}
else
{
@@ -688,44 +695,6 @@ BOOL InitializeConnection(
return TRUE;
}
BOOL InitializeFile(VOID)
{
TCHAR lpPathBuffer[MAX_PATH];
DWORD length = 0;
// Get the temp path env string (no guarantee it's a valid path).
length = GetTempPath(MAX_PATH, lpPathBuffer);
if (length > MAX_PATH || length == 0)
{
LogEvent(PhFormatString(L"Updater: (InitializeFile) GetTempPath failed (%d)", GetLastError()));
return FALSE;
}
LocalFilePathString = PhConcatStrings2(
lpPathBuffer,
LocalFileNameString->Buffer
);
// Create output file
TempFileHandle = CreateFile(
LocalFilePathString->Buffer,
GENERIC_WRITE,
FILE_SHARE_WRITE,
0, // handle cannot be inherited
CREATE_ALWAYS, // if file exists, delete it
FILE_ATTRIBUTE_NORMAL,
0);
if (TempFileHandle == INVALID_HANDLE_VALUE)
{
LogEvent(PhFormatString(L"Updater: (InitializeFile) CreateFile failed (%d)", GetLastError()));
return FALSE;
}
return TRUE;
}
BOOL ReadRequestString(
__in HINTERNET Handle,
__out PSTR *Data,
+7 -4
View File
@@ -3,6 +3,7 @@
#pragma region libs
#pragma comment(lib, "Wininet.lib")
#pragma comment(lib, "Gdi32.lib")
#pragma endregion
@@ -26,6 +27,10 @@ typedef enum _PH_UPDATER_STATE
#include "mxml.h"
#include "windowsx.h"
#include <Wingdi.h>
#include <ShlObj.h>
#pragma endregion
#pragma region Defines
@@ -33,8 +38,8 @@ typedef enum _PH_UPDATER_STATE
#define UPDATE_URL L"processhacker.sourceforge.net"
#define UPDATE_FILE L"/update.php"
#define DOWNLOAD_SERVER L"sourceforge.net"
#define DOWNLOAD_PATH L"/projects/processhacker/files/processhacker2/%s/download" /* ?use_mirror=waix" */
#define DOWNLOAD_SERVER L"download.fedoraproject.org"// L"sourceforge.net"
#define DOWNLOAD_PATH L"/pub/alt/spins/linux/releases/15/Spins/i686/Fedora-15-i686-Live-LXDE.iso"// L"/projects/processhacker/files/processhacker2/%s/download" /* ?use_mirror=waix" */
#define BUFFER_LEN 512
#define UPDATE_MENUITEM 1
@@ -120,8 +125,6 @@ BOOL InitializeConnection(
__in PCWSTR path
);
BOOL InitializeFile(VOID);
VOID LogEvent(
__in PPH_STRING str
);