Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/i18n/!example.txt
Binary file not shown.
Binary file modified bin/i18n/Spanish.ini
Binary file not shown.
9 changes: 5 additions & 4 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <ws2tcpip.h>
#include <windns.h>
#include <mstcpip.h>
#include <iphlpapi.h>
#include <iphlpapi.h>
#include <tcpestats.h>
#include <aclapi.h>
#include <dbt.h>
#include <fwpmu.h>
Expand All @@ -26,9 +27,9 @@
#include "rapp.h"
#include "main.h"

#include "resource.h"
DECLSPEC_SELECTANY STATIC_DATA config = {0};
#include "resource.h"

DECLSPEC_SELECTANY STATIC_DATA config = {0};
DECLSPEC_SELECTANY PROFILE_DATA profile_info = {0};

DECLSPEC_SELECTANY PR_HASHTABLE apps_table = NULL;
Expand Down
39 changes: 39 additions & 0 deletions src/listview.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,10 +999,14 @@ INT CALLBACK _app_listview_compare_callback (
PR_STRING item_text_2;
PITEM_LOG ptr_log1;
PITEM_LOG ptr_log2;
PITEM_NETWORK ptr_network1;
PITEM_NETWORK ptr_network2;
WCHAR section_name[128];
HWND hwnd;
LONG64 timestamp1 = 0;
LONG64 timestamp2 = 0;
LONG64 value1 = 0;
LONG64 value2 = 0;
ULONG context1;
ULONG context2;
LONG column_id;
Expand Down Expand Up @@ -1098,6 +1102,41 @@ INT CALLBACK _app_listview_compare_callback (
if (ptr_log2)
_r_obj_dereference (ptr_log2);
}
else if (listview_id == IDC_NETWORK && column_id >= 9 && column_id <= 11)
{
ptr_network1 = _app_network_getitem (context1);
ptr_network2 = _app_network_getitem (context2);

if (ptr_network1 && ptr_network2)
{
if (column_id == 9)
{
value1 = _InterlockedCompareExchange64 (&ptr_network1->download_speed, 0, 0);
value2 = _InterlockedCompareExchange64 (&ptr_network2->download_speed, 0, 0);
}
else if (column_id == 10)
{
value1 = _InterlockedCompareExchange64 (&ptr_network1->upload_speed, 0, 0);
value2 = _InterlockedCompareExchange64 (&ptr_network2->upload_speed, 0, 0);
}
else
{
value1 = _InterlockedCompareExchange64 (&ptr_network1->download_total, 0, 0) + _InterlockedCompareExchange64 (&ptr_network1->upload_total, 0, 0);
value2 = _InterlockedCompareExchange64 (&ptr_network2->download_total, 0, 0) + _InterlockedCompareExchange64 (&ptr_network2->upload_total, 0, 0);
}

if (value1 < value2)
result = -1;
else if (value1 > value2)
result = 1;
}

if (ptr_network1)
_r_obj_dereference (ptr_network1);

if (ptr_network2)
_r_obj_dereference (ptr_network2);
}
}

if (!result)
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,9 @@ VOID _app_tabs_init (
_r_listview_addcolumn (hwnd, tab_context->listview_id, 6, L"", -10, LVCFMT_RIGHT);
_r_listview_addcolumn (hwnd, tab_context->listview_id, 7, L"", -10, LVCFMT_RIGHT);
_r_listview_addcolumn (hwnd, tab_context->listview_id, 8, L"", -10, LVCFMT_RIGHT);
_r_listview_addcolumn (hwnd, tab_context->listview_id, 9, L"", -10, LVCFMT_RIGHT);
_r_listview_addcolumn (hwnd, tab_context->listview_id, 10, L"", -10, LVCFMT_RIGHT);
_r_listview_addcolumn (hwnd, tab_context->listview_id, 11, L"", -10, LVCFMT_RIGHT);

_r_listview_addgroup (hwnd, tab_context->listview_id, 0, L"", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);
_r_listview_addgroup (hwnd, tab_context->listview_id, 1, L"", 0, LVGS_COLLAPSIBLE, LVGS_COLLAPSIBLE);
Expand Down
19 changes: 15 additions & 4 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,21 @@ typedef struct _ITEM_NETWORK
UINT16 remote_port;
UINT16 local_port;

UINT8 protocol;

BOOLEAN is_connection;
} ITEM_NETWORK, *PITEM_NETWORK;
UINT8 protocol;

BOOLEAN is_connection;
BOOLEAN is_stats_enabled;
BOOLEAN is_stats_initialized;

volatile LONG64 download_speed;
volatile LONG64 upload_speed;
volatile LONG64 download_total;
volatile LONG64 upload_total;

ULONG64 last_bytes_in;
ULONG64 last_bytes_out;
ULONG64 last_stats_tick;
} ITEM_NETWORK, *PITEM_NETWORK;

typedef struct _ITEM_LOG
{
Expand Down
93 changes: 80 additions & 13 deletions src/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,15 @@ VOID _app_message_localize (
_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L"%s (%s)", _r_locale_getstring (IDS_PORT), _r_locale_getstring (IDS_DIRECTION_REMOTE)));
_r_listview_setcolumn (hwnd, tab_context->listview_id, 6, localized_string->buffer, 0);

_r_listview_setcolumn (hwnd, tab_context->listview_id, 7, _r_locale_getstring (IDS_PROTOCOL), 0);
_r_listview_setcolumn (hwnd, tab_context->listview_id, 8, _r_locale_getstring (IDS_STATE), 0);
_r_listview_setcolumn (hwnd, tab_context->listview_id, 7, _r_locale_getstring (IDS_PROTOCOL), 0);
_r_listview_setcolumn (hwnd, tab_context->listview_id, 8, _r_locale_getstring (IDS_STATE), 0);
_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L"\u2193 %s", _r_locale_getstring (IDS_UPDATE_SPEED)));
_r_listview_setcolumn (hwnd, tab_context->listview_id, 9, localized_string->buffer, 0);

_r_obj_movereference ((PVOID_PTR)&localized_string, _r_format_string (L"\u2191 %s", _r_locale_getstring (IDS_UPDATE_SPEED)));
_r_listview_setcolumn (hwnd, tab_context->listview_id, 10, localized_string->buffer, 0);

_r_listview_setcolumn (hwnd, tab_context->listview_id, 11, _r_locale_getstring (IDS_TOTAL), 0);

break;
}
Expand Down Expand Up @@ -1110,13 +1117,13 @@ LONG_PTR _app_message_custdraw (
return CDRF_DODEFAULT;
}

VOID _app_displayinfoapp_callback (
VOID _app_displayinfoapp_callback (
_In_ PITEM_APP ptr_app,
_Inout_ LPNMLVDISPINFOW lpnmlv
)
{
PR_STRING string;
LONG icon_id = 0;
PR_STRING string;
LONG icon_id = 0;

// set text
if (lpnmlv->item.mask & LVIF_TEXT)
Expand Down Expand Up @@ -1319,15 +1326,20 @@ VOID _app_displayinforule_callback (
}
}

VOID _app_displayinfonetwork_callback (
VOID _app_displayinfonetwork_callback (
_In_ PITEM_NETWORK ptr_network,
_Inout_ LPNMLVDISPINFOW lpnmlv
)
{
PITEM_APP ptr_app;
PR_STRING string;
LPCWSTR name;
LONG icon_id = 0;
PR_STRING string;
LPCWSTR name;
LONG icon_id = 0;
LONG64 bytes_value;
ULONG64 divisor;
ULONG64 decimal;
ULONG64 whole;
LPCWSTR suffix;

// set text
if (lpnmlv->item.mask & LVIF_TEXT)
Expand Down Expand Up @@ -1459,16 +1471,71 @@ VOID _app_displayinfonetwork_callback (
break;
}

case 8:
case 8:
{
name = _app_db_getconnectionstatename (ptr_network->state);

if (name)
_r_str_copy (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, name);

break;
}
}
break;
}

case 9:
case 10:
case 11:
{
if (!ptr_network->is_stats_initialized)
break;

if (lpnmlv->item.iSubItem == 9)
{
bytes_value = _InterlockedCompareExchange64 (&ptr_network->download_speed, 0, 0);
}
else if (lpnmlv->item.iSubItem == 10)
{
bytes_value = _InterlockedCompareExchange64 (&ptr_network->upload_speed, 0, 0);
}
else
{
bytes_value = _InterlockedCompareExchange64 (&ptr_network->download_total, 0, 0) + _InterlockedCompareExchange64 (&ptr_network->upload_total, 0, 0);
}

if ((ULONG64)bytes_value < 1024)
{
_r_str_printf (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, L"%" TEXT (PRIu64) L" B%s", (ULONG64)bytes_value, lpnmlv->item.iSubItem == 11 ? L"" : L"/s");
break;
}

if ((ULONG64)bytes_value < (1ULL << 20))
{
divisor = 1ULL << 10;
suffix = L"KB";
}
else if ((ULONG64)bytes_value < (1ULL << 30))
{
divisor = 1ULL << 20;
suffix = L"MB";
}
else if ((ULONG64)bytes_value < (1ULL << 40))
{
divisor = 1ULL << 30;
suffix = L"GB";
}
else
{
divisor = 1ULL << 40;
suffix = L"TB";
}

whole = (ULONG64)bytes_value / divisor;
decimal = (((ULONG64)bytes_value % divisor) * 10) / divisor;

_r_str_printf (lpnmlv->item.pszText, lpnmlv->item.cchTextMax, L"%" TEXT (PRIu64) L".%" TEXT (PRIu64) L" %s%s", whole, decimal, suffix, lpnmlv->item.iSubItem == 11 ? L"" : L"/s");

break;
}
}
}

// set image
Expand Down
Loading