go my file uploader

This commit is contained in:
AirDog46
2025-05-13 19:45:22 +03:00
commit c5fab8aa94
708 changed files with 343216 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
1.3
* Added Growl support
1.2
* Added ability to log events to a file
1.1
* Fixed memory leak
1.0
* Initial release

View File

@@ -0,0 +1,214 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (Australia) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,0
PRODUCTVERSION 1,3,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "0c0904b0"
BEGIN
VALUE "CompanyName", "wj32"
VALUE "FileDescription", "Extended Notifications for Process Hacker"
VALUE "FileVersion", "1.3"
VALUE "InternalName", "ExtendedNotifications"
VALUE "LegalCopyright", "Licensed under the GNU GPL, v3."
VALUE "OriginalFilename", "ExtendedNotifications.dll"
VALUE "ProductName", "Extended Notifications for Process Hacker"
VALUE "ProductVersion", "1.3"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0xc09, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROCESSES DIALOGEX 0, 0, 255, 229
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Processes"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "You can configure processes for which notifications are displayed. Wildcards can be used, and ordering is considered.",IDC_STATIC,7,7,241,19
LISTBOX IDC_LIST,7,30,187,118,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Move up",IDC_MOVEUP,198,30,50,14
PUSHBUTTON "Move down",IDC_MOVEDOWN,198,47,50,14
EDITTEXT IDC_TEXT,7,152,147,12,ES_AUTOHSCROLL
CONTROL "Include",IDC_INCLUDE,"Button",BS_AUTORADIOBUTTON,163,153,39,10
CONTROL "Exclude",IDC_EXCLUDE,"Button",BS_AUTORADIOBUTTON,207,153,41,10
PUSHBUTTON "Add/Update",IDC_ADD,145,168,50,14
PUSHBUTTON "Remove",IDC_REMOVE,198,168,50,14
LTEXT "Examples:\nnote*.exe\nC:\\Windows\\system32\\cmd.exe\nC:\\Windows\\*",IDC_STATIC,7,186,241,36
END
IDD_SERVICES DIALOGEX 0, 0, 255, 229
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Services"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "You can configure services for which notifications are displayed. Wildcards can be used, and ordering is considered.",IDC_STATIC,7,7,241,19
LISTBOX IDC_LIST,7,30,187,118,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Move up",IDC_MOVEUP,198,30,50,14
PUSHBUTTON "Move down",IDC_MOVEDOWN,198,47,50,14
EDITTEXT IDC_TEXT,7,152,147,12,ES_AUTOHSCROLL
CONTROL "Include",IDC_INCLUDE,"Button",BS_AUTORADIOBUTTON,163,153,39,10
CONTROL "Exclude",IDC_EXCLUDE,"Button",BS_AUTORADIOBUTTON,207,153,41,10
PUSHBUTTON "Add/Update",IDC_ADD,145,168,50,14
PUSHBUTTON "Remove",IDC_REMOVE,198,168,50,14
LTEXT "Examples:\nWdi*\nseclogon",IDC_STATIC,7,186,241,36
END
IDD_LOGGING DIALOGEX 0, 0, 255, 229
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Logging"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "File",IDC_STATIC,7,7,241,53
LTEXT "Log all events to this file (leave blank to disable this feature):",IDC_STATIC,13,18,196,8
EDITTEXT IDC_LOGFILENAME,13,29,178,12,ES_AUTOHSCROLL
PUSHBUTTON "Browse...",IDC_BROWSE,194,28,50,14
LTEXT "Changes will require a restart of Process Hacker.",IDC_STATIC,14,45,157,8
END
IDD_GROWL DIALOGEX 0, 0, 255, 229
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Growl"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "Send notifications to Growl",IDC_ENABLEGROWL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,101,10
LTEXT "gntp-send license:",IDC_STATIC,7,23,60,8
EDITTEXT IDC_LICENSE,7,34,241,188,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_PROCESSES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 248
TOPMARGIN, 7
BOTTOMMARGIN, 222
END
IDD_SERVICES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 248
TOPMARGIN, 7
BOTTOMMARGIN, 222
END
IDD_LOGGING, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 248
TOPMARGIN, 7
BOTTOMMARGIN, 222
END
IDD_GROWL, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 248
TOPMARGIN, 7
BOTTOMMARGIN, 222
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
//
IDD_GROWL AFX_DIALOG_LAYOUT
BEGIN
0
END
#endif // English (Australia) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{80E791B8-AC98-407E-8FF9-5154AF50E887}</ProjectGuid>
<RootNamespace>ExtendedNotifications</RootNamespace>
<Keyword>Win32Proj</Keyword>
<ProjectName>ExtendedNotifications</ProjectName>
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\Plugins.props" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Debug32</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Release64</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Release32</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Debug64</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>ws2_32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="filelog.c" />
<ClCompile Include="gntp-send\growl.c" />
<ClCompile Include="gntp-send\tcp.c" />
<ClCompile Include="main.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="extnoti.h" />
<ClInclude Include="gntp-send\growl.h" />
<ClInclude Include="gntp-send\md5.h" />
<ClInclude Include="gntp-send\tcp.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ExtendedNotifications.rc" />
</ItemGroup>
<ItemGroup>
<None Include="CHANGELOG.txt" />
<None Include="gntp-send\LICENSE.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="filelog.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="gntp-send\growl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="gntp-send\tcp.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="extnoti.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gntp-send\growl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gntp-send\tcp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="gntp-send\md5.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ExtendedNotifications.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="CHANGELOG.txt" />
<None Include="gntp-send\LICENSE.txt" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,30 @@
#ifndef EXTNOTI_H
#define EXTNOTI_H
#define PLUGIN_NAME L"ProcessHacker.ExtendedNotifications"
#define SETTING_NAME_ENABLE_GROWL (PLUGIN_NAME L".EnableGrowl")
#define SETTING_NAME_LOG_FILENAME (PLUGIN_NAME L".LogFileName")
#define SETTING_NAME_PROCESS_LIST (PLUGIN_NAME L".ProcessList")
#define SETTING_NAME_SERVICE_LIST (PLUGIN_NAME L".ServiceList")
// main
typedef enum _FILTER_TYPE
{
FilterInclude,
FilterExclude
} FILTER_TYPE;
typedef struct _FILTER_ENTRY
{
FILTER_TYPE Type;
PPH_STRING Filter;
} FILTER_ENTRY, *PFILTER_ENTRY;
// filelog
VOID FileLogInitialization(
VOID
);
#endif

View File

@@ -0,0 +1,79 @@
/*
* Process Hacker Extended Notifications -
* file logging
*
* Copyright (C) 2010 wj32
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#include <phdk.h>
#include "extnoti.h"
VOID NTAPI LoggedCallback(
_In_opt_ PVOID Parameter,
_In_opt_ PVOID Context
);
PPH_FILE_STREAM LogFileStream = NULL;
PH_CALLBACK_REGISTRATION LoggedCallbackRegistration;
VOID FileLogInitialization(
VOID
)
{
NTSTATUS status;
PPH_STRING fileName;
fileName = PhaGetStringSetting(SETTING_NAME_LOG_FILENAME);
if (fileName->Length != 0)
{
status = PhCreateFileStream(
&LogFileStream,
fileName->Buffer,
FILE_GENERIC_WRITE,
FILE_SHARE_READ,
FILE_OPEN_IF,
PH_FILE_STREAM_APPEND | PH_FILE_STREAM_UNBUFFERED
);
if (NT_SUCCESS(status))
{
PhRegisterCallback(
&PhLoggedCallback,
LoggedCallback,
NULL,
&LoggedCallbackRegistration
);
}
}
}
VOID NTAPI LoggedCallback(
_In_opt_ PVOID Parameter,
_In_opt_ PVOID Context
)
{
PPH_LOG_ENTRY logEntry = Parameter;
PhWriteStringFormatAsUtf8FileStream(
LogFileStream,
L"%s: %s\r\n",
PhaFormatDateTime(NULL)->Buffer,
PH_AUTO_T(PH_STRING, PhFormatLogEntry(logEntry))->Buffer
);
}

View File

@@ -0,0 +1,26 @@
[The "BSD licence"]
Copyright (c) 2009-2010 Yasuhiro Matsumoto
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,544 @@
#define _CRT_RAND_S
#include <phdk.h>
#include <winsock2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "md5.h"
#include "tcp.h"
#include "growl.h"
static const char hex_table[] = "0123456789ABCDEF";
static char* string_to_hex_alloc(const char* str, int len) {
int n, l;
char* tmp = (char*)PhAllocateSafe(len * 2 + 1);
if (tmp) {
memset(tmp, 0, len * 2 + 1);
for (l = 0, n = 0; l < len; l++) {
tmp[n++] = hex_table[(str[l] & 0xF0) >> 4];
tmp[n++] = hex_table[str[l] & 0x0F];
}
}
return tmp;
}
int growl_init_ = 0;
/* dmex: modified to use latest Winsock version */
int growl_init()
{
if (growl_init_ == 0)
{
#ifdef _WIN32
WSADATA wsaData;
if (WSAStartup(WINSOCK_VERSION, &wsaData) != 0)
{
return -1;
}
#endif
growl_init_ = 1;
}
return 1;
}
void growl_shutdown()
{
if (growl_init_ == 1)
{
#ifdef _WIN32
WSACleanup();
#endif
}
}
/* dmex: modified to use a version of rand with security enhancements */
char* gen_salt_alloc(int count)
{
char* salt = (char*)PhAllocateSafe(count + 1);
if (salt)
{
int n;
int randSeed = 0;
rand_s(&randSeed);
for (n = 0; n < count; n++)
salt[n] = (randSeed % 255) + 1;
salt[n] = 0;
}
return salt;
}
char* gen_password_hash_alloc(const char* password, const char* salt) {
md5_context md5ctx;
char md5tmp[20];
char* md5digest;
memset(md5tmp, 0, sizeof(md5tmp));
md5_starts(&md5ctx);
md5_update(&md5ctx, (uint8_t*)password, (uint32_t)strlen(password));
md5_update(&md5ctx, (uint8_t*)salt, (uint32_t)strlen(salt));
md5_finish(&md5ctx, (uint8_t*)md5tmp);
md5_starts(&md5ctx);
md5_update(&md5ctx, (uint8_t*)md5tmp, 16);
md5_finish(&md5ctx, (uint8_t*)md5tmp);
md5digest = string_to_hex_alloc(md5tmp, 16);
return md5digest;
}
char *growl_generate_authheader_alloc(const char*const password)
{
char* salt;
char* salthash;
char* keyhash;
char* authheader = NULL;
if (password) {
salt = gen_salt_alloc(8);
if (salt) {
keyhash = gen_password_hash_alloc(password, salt);
if (keyhash) {
salthash = string_to_hex_alloc(salt, 8);
if (salthash) {
authheader = (char*)PhAllocateSafe(strlen(keyhash) + strlen(salthash) + 7);
if (authheader) {
sprintf(authheader, " MD5:%s.%s", keyhash, salthash);
}
PhFree(salthash);
}
PhFree(keyhash);
}
PhFree(salt);
}
}
return authheader;
}
/* dmex: modified to use INVALID_SOCKET */
int growl_tcp_register( const char *const server , const char *const appname , const char **const notifications , const int notifications_count ,
const char *const password, const char* const icon )
{
SOCKET sock = INVALID_SOCKET;
int i=0;
char *authheader;
char *iconid = NULL;
FILE *iconfile = NULL;
size_t iconsize;
uint8_t buffer[1024];
growl_init();
authheader = growl_generate_authheader_alloc(password);
sock = growl_tcp_open(server);
if (sock == INVALID_SOCKET) goto leave;
if (icon) {
size_t bytes_read;
md5_context md5ctx;
char md5tmp[20];
iconfile = fopen(icon, "rb");
if (iconfile) {
fseek(iconfile, 0, SEEK_END);
iconsize = ftell(iconfile);
fseek(iconfile, 0, SEEK_SET);
memset(md5tmp, 0, sizeof(md5tmp));
md5_starts(&md5ctx);
while (!feof(iconfile)) {
bytes_read = fread(buffer, 1, 1024, iconfile);
if (bytes_read) md5_update(&md5ctx, buffer, (uint32_t)bytes_read);
}
fseek(iconfile, 0, SEEK_SET);
md5_finish(&md5ctx, md5tmp);
iconid = string_to_hex_alloc(md5tmp, 16);
}
}
growl_tcp_write(sock, "GNTP/1.0 REGISTER NONE %s", authheader ? authheader : "");
growl_tcp_write(sock, "Application-Name: %s", appname);
if(iconid)
{
growl_tcp_write(sock, "Application-Icon: x-growl-resource://%s", iconid);
}
else if(icon)
{
growl_tcp_write(sock, "Application-Icon: %s", icon );
}
growl_tcp_write(sock, "Notifications-Count: %d", notifications_count);
growl_tcp_write(sock, "" );
for(i=0;i<notifications_count;i++)
{
growl_tcp_write(sock, "Notification-Name: %s", notifications[i]);
growl_tcp_write(sock, "Notification-Display-Name: %s", notifications[i]);
growl_tcp_write(sock, "Notification-Enabled: True" );
if(iconid)
{
growl_tcp_write(sock, "Notification-Icon: x-growl-resource://%s", iconid);
}
else if(icon)
{
growl_tcp_write(sock, "Notification-Icon: %s", icon );
}
growl_tcp_write(sock, "" );
}
if (iconid)
{
growl_tcp_write(sock, "Identifier: %s", iconid);
growl_tcp_write(sock, "Length: %d", iconsize);
growl_tcp_write(sock, "" );
while (!feof(iconfile))
{
size_t bytes_read = fread(buffer, 1, 1024, iconfile);
if (bytes_read) growl_tcp_write_raw(sock, buffer, (int)bytes_read);
}
growl_tcp_write(sock, "" );
}
growl_tcp_write(sock, "" );
while (1)
{
char* line = growl_tcp_read(sock);
if (!line) {
growl_tcp_close(sock);
sock = INVALID_SOCKET;
goto leave;
}
else
{
int len = (int)strlen(line);
/* fprintf(stderr, "%s\n", line); */
if (strncmp(line, "GNTP/1.0 -ERROR", 15) == 0)
{
if (strncmp(line + 15, " NONE", 5) != 0)
{
fprintf(stderr, "failed to register notification\n");
PhFree(line);
goto leave;
}
}
PhFree(line);
if (len == 0) break;
}
}
growl_tcp_close(sock);
sock = 0;
leave:
if (iconfile) fclose(iconfile);
if (iconid) PhFree(iconid);
if (authheader) PhFree(authheader);
return (sock == 0) ? 0 : INVALID_SOCKET;
}
/* dmex: modified to use INVALID_SOCKET */
int growl_tcp_notify( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const password, const char* const url, const char* const icon)
{
SOCKET sock = INVALID_SOCKET;
char *authheader = growl_generate_authheader_alloc(password);
char *iconid = NULL;
FILE *iconfile = NULL;
size_t iconsize;
uint8_t buffer[1024];
growl_init();
sock = growl_tcp_open(server);
if (sock == INVALID_SOCKET) goto leave;
if (icon)
{
size_t bytes_read;
md5_context md5ctx;
char md5tmp[20];
iconfile = fopen(icon, "rb");
if (iconfile)
{
fseek(iconfile, 0, SEEK_END);
iconsize = ftell(iconfile);
fseek(iconfile, 0, SEEK_SET);
memset(md5tmp, 0, sizeof(md5tmp));
md5_starts(&md5ctx);
while (!feof(iconfile))
{
bytes_read = fread(buffer, 1, 1024, iconfile);
if (bytes_read) md5_update(&md5ctx, buffer, (uint32_t)bytes_read);
}
fseek(iconfile, 0, SEEK_SET);
md5_finish(&md5ctx, md5tmp);
iconid = string_to_hex_alloc(md5tmp, 16);
}
}
growl_tcp_write(sock, "GNTP/1.0 NOTIFY NONE %s", authheader ? authheader : "");
growl_tcp_write(sock, "Application-Name: %s", appname);
growl_tcp_write(sock, "Notification-Name: %s", notify);
growl_tcp_write(sock, "Notification-Title: %s", title);
growl_tcp_write(sock, "Notification-Text: %s", message);
if(iconid)
{
growl_tcp_write(sock, "Notification-Icon: x-growl-resource://%s", iconid);
}
else if(icon)
{
growl_tcp_write(sock, "Notification-Icon: %s", icon );
}
if (url) growl_tcp_write(sock, "Notification-Callback-Target: %s", url );
if (iconid)
{
growl_tcp_write(sock, "Identifier: %s", iconid);
growl_tcp_write(sock, "Length: %d", iconsize);
growl_tcp_write(sock, "");
while (!feof(iconfile))
{
size_t bytes_read = fread(buffer, 1, 1024, iconfile);
if (bytes_read) growl_tcp_write_raw(sock, buffer, (int)bytes_read);
}
growl_tcp_write(sock, "" );
}
growl_tcp_write(sock, "");
while (1)
{
char* line = growl_tcp_read(sock);
if (!line)
{
growl_tcp_close(sock);
sock = INVALID_SOCKET;
goto leave;
} else
{
int len = (int)strlen(line);
/* fprintf(stderr, "%s\n", line); */
if (strncmp(line, "GNTP/1.0 -ERROR", 15) == 0)
{
if (strncmp(line + 15, " NONE", 5) != 0)
{
fprintf(stderr, "failed to post notification\n");
PhFree(line);
goto leave;
}
}
PhFree(line);
if (len == 0) break;
}
}
growl_tcp_close(sock);
sock = 0;
leave:
if (iconfile) fclose(iconfile);
if (iconid) PhFree(iconid);
if (authheader) PhFree(authheader);
return (sock == 0) ? 0 : INVALID_SOCKET;
}
int growl( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const icon , const char *const password , const char *url )
{
int rc = growl_tcp_register( server , appname , (const char **const)&notify , 1 , password, icon );
if( rc == 0 )
{
rc = growl_tcp_notify( server, appname, notify, title, message , password, url, icon );
}
return rc;
}
void growl_append_md5( unsigned char *const data , const int data_length , const char *const password )
{
md5_context md5ctx;
char md5tmp[20];
memset(md5tmp, 0, sizeof(md5tmp));
md5_starts(&md5ctx);
md5_update(&md5ctx, (uint8_t*)data, data_length );
if(password != NULL)
{
md5_update(&md5ctx, (uint8_t*)password, (uint32_t)strlen(password));
}
md5_finish(&md5ctx, (uint8_t*)md5tmp);
memcpy( data + data_length , md5tmp , 16 );
}
int growl_udp_register( const char *const server , const char *const appname , const char **const notifications , const int notifications_count , const char *const password )
{
int register_header_length = 22+(int)strlen(appname);
unsigned char *data;
int pointer = 0;
int rc = 0;
int i=0;
uint8_t GROWL_PROTOCOL_VERSION = 1;
uint8_t GROWL_TYPE_REGISTRATION = 0;
uint16_t appname_length = ntohs((u_short)strlen(appname));
uint8_t _notifications_count = notifications_count;
uint8_t default_notifications_count = notifications_count;
uint8_t j;
growl_init();
for(i=0;i<notifications_count;i++)
{
register_header_length += 3 + (int)strlen(notifications[i]);
}
data = (unsigned char*)PhAllocateSafe(register_header_length);
if (!data) return -1;
memset( data , 0 , register_header_length );
pointer = 0;
memcpy( data + pointer , &GROWL_PROTOCOL_VERSION , 1 );
pointer++;
memcpy( data + pointer , &GROWL_TYPE_REGISTRATION , 1 );
pointer++;
memcpy( data + pointer , &appname_length , 2 );
pointer += 2;
memcpy( data + pointer , &_notifications_count , 1 );
pointer++;
memcpy( data + pointer, &default_notifications_count , 1 );
pointer++;
sprintf( (char*)data + pointer , "%s" , appname );
pointer += (int)strlen(appname);
for(i=0;i<notifications_count;i++)
{
uint16_t notify_length = ntohs((u_short)strlen(notifications[i]));
memcpy( data + pointer, &notify_length , 2 );
pointer +=2;
sprintf( (char*)data + pointer , "%s" , notifications[i] );
pointer += (int)strlen(notifications[i]);
}
for(j=0;j<notifications_count;j++)
{
memcpy( data + pointer , &j , 1 );
pointer++;
}
growl_append_md5( data , pointer , password );
pointer += 16;
rc = growl_tcp_datagram( server , data , pointer );
PhFree(data);
return rc;
}
int growl_udp_notify( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const password )
{
int notify_header_length = 28 + (int)(strlen(appname)+strlen(notify)+strlen(message)+strlen(title));
unsigned char *data = (unsigned char*)PhAllocateSafe(notify_header_length);
int pointer = 0;
int rc = 0;
uint8_t GROWL_PROTOCOL_VERSION = 1;
uint8_t GROWL_TYPE_NOTIFICATION = 1;
uint16_t flags = ntohs(0);
uint16_t appname_length = ntohs((u_short)strlen(appname));
uint16_t notify_length = ntohs((u_short)strlen(notify));
uint16_t title_length = ntohs((u_short)strlen(title));
uint16_t message_length = ntohs((u_short)strlen(message));
if (!data) return -1;
growl_init();
memset( data , 0 , notify_header_length );
pointer = 0;
memcpy( data + pointer , &GROWL_PROTOCOL_VERSION , 1 );
pointer++;
memcpy( data + pointer , &GROWL_TYPE_NOTIFICATION , 1 );
pointer++;
memcpy( data + pointer , &flags , 2 );
pointer += 2;
memcpy( data + pointer , &notify_length , 2 );
pointer += 2;
memcpy( data + pointer , &title_length , 2 );
pointer += 2;
memcpy( data + pointer , &message_length , 2 );
pointer += 2;
memcpy( data + pointer , &appname_length , 2 );
pointer += 2;
strcpy( (char*)data + pointer , notify );
pointer += (int)strlen(notify);
strcpy( (char*)data + pointer , title );
pointer += (int)strlen(title);
strcpy( (char*)data + pointer , message );
pointer += (int)strlen(message);
strcpy( (char*)data + pointer , appname );
pointer += (int)strlen(appname);
growl_append_md5( data , pointer , password );
pointer += 16;
rc = growl_tcp_datagram( server , data , pointer );
PhFree(data);
return rc;
}
int growl_udp( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const icon , const char *const password , const char *url )
{
int rc = growl_udp_register( server , appname , (const char **const)&notify , 1 , password );
if( rc == 0 )
{
rc = growl_udp_notify( server, appname, notify, title, message , password );
}
return rc;
}
char *gntp_send_license_text =
"[The \"BSD licence\"]\r\n"
"Copyright (c) 2009-2010 Yasuhiro Matsumoto\r\n"
"All rights reserved.\r\n"
"\r\n"
"Redistribution and use in source and binary forms, with or without\r\n"
"modification, are permitted provided that the following conditions\r\n"
"are met:\r\n"
"\r\n"
" 1. Redistributions of source code must retain the above copyright\r\n"
" notice, this list of conditions and the following disclaimer.\r\n"
" 2. Redistributions in binary form must reproduce the above copyright\r\n"
" notice, this list of conditions and the following disclaimer in the\r\n"
" documentation and/or other materials provided with the distribution.\r\n"
" 3. The name of the author may not be used to endorse or promote products\r\n"
" derived from this software without specific prior written permission.\r\n"
"\r\n"
"THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r\n"
"IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r\n"
"OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r\n"
"IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r\n"
"INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r\n"
"NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n"
"DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n"
"THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n"
"(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r\n"
"THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n"
;

View File

@@ -0,0 +1,33 @@
#ifndef _GROWL_H_
#define _GROWL_H_
#ifdef __cplusplus
extern "C" {
#endif
int growl( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const icon , const char *const password , const char *url );
int growl_tcp_notify( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const password, const char* const url, const char* const icon );
int growl_tcp_register( const char *const server , const char *const appname , const char **const notifications , const int notifications_count , const char *const password, const char *const icon );
int growl_udp( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const icon , const char *const password , const char *url );
int growl_udp_notify( const char *const server,const char *const appname,const char *const notify,const char *const title, const char *const message ,
const char *const password );
int growl_udp_register( const char *const server , const char *const appname , const char **const notifications , const int notifications_count , const char *const password );
int growl_init(void);
void growl_shutdown(void);
extern char *gntp_send_license_text;
#ifdef __cplusplus
}
#endif
#endif /* _GROWL_H_ */

View File

@@ -0,0 +1,26 @@
#ifndef _MD5_H_
#define _MD5_H_
#include <stdint.h>
typedef struct {
PH_HASH_CONTEXT hc;
} md5_context;
__forceinline void md5_starts(md5_context *ctx)
{
PhInitializeHash(&ctx->hc, Md5HashAlgorithm);
}
__forceinline void md5_update(md5_context *ctx, const uint8_t *input, uint32_t length)
{
PhUpdateHash(&ctx->hc, (PVOID)input, length);
}
__forceinline void md5_finish(md5_context *ctx, uint8_t digest[16])
{
if (!PhFinalHash(&ctx->hc, digest, 16, NULL))
PhRaiseStatus(STATUS_INTERNAL_ERROR);
}
#endif /* _MD5_H_ */

View File

@@ -0,0 +1,185 @@
#include <phdk.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#ifdef _WIN32
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <unistd.h>
#endif
#include "tcp.h"
int growl_tcp_parse_hostname( const char *const server , int default_port , struct sockaddr_in *const sockaddr );
void growl_tcp_write_raw( SOCKET sock, const unsigned char * data, const int data_length )
{
send(sock, data, data_length, 0);
}
void growl_tcp_write( SOCKET sock , const char *const format , ... )
{
int length;
char *output;
char *stop;
va_list ap;
va_start( ap , format );
length = vsnprintf( NULL , 0 , format , ap );
va_end(ap);
va_start(ap,format);
output = (char*)PhAllocateSafe(length+1);
if (!output) {
va_end(ap);
return;
}
vsnprintf( output , length+1 , format , ap );
va_end(ap);
while ((stop = strstr(output, "\r\n"))) strcpy(stop, stop + 1);
send( sock , output , length , 0 );
send( sock , "\r\n" , 2 , 0 );
PhFree(output);
}
char *growl_tcp_read(SOCKET sock) {
const int growsize = 80;
char c = 0;
char* line = (char*) PhAllocateSafe(growsize);
if (line) {
int len = growsize, pos = 0;
char* newline;
while (line) {
if (recv(sock, &c, 1, 0) <= 0) break;
if (c == '\r') continue;
if (c == '\n') break;
line[pos++] = c;
if (pos >= len) {
len += growsize;
newline = (char*) realloc(line, len);
if (!newline) {
PhFree(line);
return NULL;
}
line = newline;
}
}
line[pos] = 0;
}
return line;
}
/* dmex: modified to use INVALID_SOCKET and SOCKET_ERROR */
SOCKET growl_tcp_open(const char* server) {
SOCKET sock = INVALID_SOCKET;
#ifdef _WIN32
char on;
#else
int on;
#endif
struct sockaddr_in serv_addr;
if( growl_tcp_parse_hostname( server , 23053 , &serv_addr ) == -1 ) {
return INVALID_SOCKET;
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
perror("create socket");
return INVALID_SOCKET;
}
if (connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == SOCKET_ERROR) {
perror("connect");
closesocket(sock); // dmex: fixed handle leaking on error
return INVALID_SOCKET;
}
on = 1;
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) == SOCKET_ERROR) {
perror("setsockopt");
closesocket(sock); // dmex: fixed handle leaking on error
return INVALID_SOCKET;
}
return sock;
}
/* dmex: modified to use INVALID_SOCKET */
void growl_tcp_close(SOCKET sock) {
#ifdef _WIN32
if (sock != INVALID_SOCKET) closesocket(sock);
#else
if (sock > 0) close(sock);
#endif
}
int growl_tcp_parse_hostname( const char *const server , int default_port , struct sockaddr_in *const sockaddr )
{
char *hostname = PhDuplicateBytesZSafe((PSTR)server);
char *port = strchr( hostname, ':' );
struct hostent* host_ent;
if( port != NULL )
{
*port = '\0';
port++;
default_port = atoi(port);
}
host_ent = gethostbyname(hostname);
if( host_ent == NULL )
{
perror("gethostbyname");
PhFree(hostname);
return -1;
}
// dmex: fixed wrong sizeof argument
memset( sockaddr , 0 , sizeof(struct sockaddr_in) );
sockaddr->sin_family = AF_INET;
memcpy( &sockaddr->sin_addr , host_ent->h_addr , host_ent->h_length );
sockaddr->sin_port = htons(default_port);
PhFree(hostname);
return 0;
}
int growl_tcp_datagram( const char *server , const unsigned char *data , const int data_length )
{
int result;
struct sockaddr_in serv_addr;
SOCKET sock = 0;
if( growl_tcp_parse_hostname( server , 9887 , &serv_addr ) == -1 )
{
return -1;
}
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if( sock == INVALID_SOCKET )
{
return -1;
}
if( sendto(sock, (char*)data , data_length , 0 , (struct sockaddr*)&serv_addr , sizeof(serv_addr) ) > 0 )
{
result = 0;
}
else
{
result = 1;
}
closesocket(sock);
return result;
}

View File

@@ -0,0 +1,14 @@
#ifndef _TCP_H_
#define _TCP_H_
#ifdef _MSC_VER
#define __attribute__(x)
#endif
void growl_tcp_write_raw( SOCKET sock, const unsigned char * data, const int data_length );
void growl_tcp_write( SOCKET sock , const char *const format , ... ) __attribute__ ((format (printf, 2, 3)));
char* growl_tcp_read(SOCKET sock);
SOCKET growl_tcp_open(const char* server);
void growl_tcp_close(SOCKET sock);
int growl_tcp_datagram( const char *server , const unsigned char *data , const int data_length );
#endif /* _TCP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ExtendedNotifications.rc
//
#define IDD_PROCESSES 101
#define IDC_TEXT_RETURN 101
#define IDD_SERVICES 102
#define IDD_LOGGING 103
#define IDD_GROWL 104
#define IDC_INCLUDE 1006
#define IDC_EXCLUDE 1007
#define IDC_REMOVE 1008
#define IDC_ADD 1009
#define IDC_MOVEUP 1010
#define IDC_MOVEDOWN 1011
#define IDC_LIST 1012
#define IDC_TEXT 1013
#define IDC_EDIT1 1014
#define IDC_LOGFILENAME 1014
#define IDC_LICENSE 1014
#define IDC_BROWSE 1015
#define IDC_ENABLEGROWL 1016
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1017
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif