[Winpt-commits] r334 - trunk/PTD
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Nov 27 13:00:46 CET 2011
Author: twoaday
Date: 2011-11-27 13:00:45 +0100 (Sun, 27 Nov 2011)
New Revision: 334
Removed:
trunk/PTD/resource.h
trunk/PTD/wptDNSKeys.cpp
trunk/PTD/wptDNSKeys.h
Modified:
trunk/PTD/ChangeLog
trunk/PTD/Makefile.am
trunk/PTD/PTD.cpp
trunk/PTD/PTD.def
trunk/PTD/resource.rc
trunk/PTD/versioninfo.rc.in
Log:
2011-11-27 Timo Schulz <twoaday at gmx.net>
* wptDNSKeys.{cpp,h}: Moved to source folder.
* resource.h: Removed.
* PTD.cpp: Several minor cleanups.
* PTD.def: Removed unused exports.
Modified: trunk/PTD/ChangeLog
===================================================================
--- trunk/PTD/ChangeLog 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/ChangeLog 2011-11-27 12:00:45 UTC (rev 334)
@@ -1,3 +1,10 @@
+2011-11-27 Timo Schulz <twoaday at gmx.net>
+
+ * wptDNSKeys.{cpp,h}: Moved to source folder.
+ * resource.h: Removed.
+ * PTD.cpp: Several minor cleanups.
+ * PTD.def: Removed unused exports.
+
2007-01-16 Timo Schulz <twoaday at gmx.net>
* wptFileDisk.cpp: Removed.
Modified: trunk/PTD/Makefile.am
===================================================================
--- trunk/PTD/Makefile.am 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/Makefile.am 2011-11-27 12:00:45 UTC (rev 334)
@@ -18,25 +18,19 @@
AM_CPPFLAGS = -I$(top_srcdir)/w32gpgme -I$(top_srcdir)/Include \
-I$(top_srcdir)/Gnupg \
-DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL -DPTD_EXPORTS
-AM_CFLAGS = -fexceptions $(GPGME_CFLAGS) -shared
-AM_CXXFLAGS = -fexceptions $(GPGME_CFLAGS) -shared
+#AM_CFLAGS = -fexceptions $(GPGME_CFLAGS) -shared
+AM_CXXFLAGS = -fstack-protector-all -fexceptions $(GPGME_CFLAGS) -shared
AM_LDFLAGS = -mwindows
PTD_SOURCES = \
PTD.def \
resource.rc \
- resource.h \
- PTD.cpp \
- wptDNSKeys.cpp wptDNSKeys.h
+ PTD.cpp
-PTD_LDADD = $(srcdir)/PTD.def -L../Gnupg -lgnupg $(W32LIBS) \
- -lgdi32
-resource.o: resource.rc resource.h versioninfo.rc
+PTD_LDADD = $(srcdir)/PTD.def -L../Gnupg -lgnupg $(W32LIBS)
+resource.o: resource.rc versioninfo.rc
+
.rc.o:
$(WINDRES) -I $(srcdir) -I . `test -f '$<' || echo '$(srcdir)/'`$< $@
-
-
-
-
Modified: trunk/PTD/PTD.cpp
===================================================================
--- trunk/PTD/PTD.cpp 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/PTD.cpp 2011-11-27 12:00:45 UTC (rev 334)
@@ -83,7 +83,7 @@
/* Return the last selected window */
extern "C" HWND
-PTD_get_curr_hwnd (void)
+PTD_get_current_window (void)
{
return curr_focus;
}
@@ -115,6 +115,8 @@
* As a result we need to ignore those windows to prevent failured
* in the code.
*/
+
+ // FIXME: I doubt this is working for Windows 7
shell_traywnd = FindWindowEx (NULL, NULL, "Shell_TrayWnd", NULL);
rebar_w32 = FindWindowEx (shell_traywnd, NULL, "ReBarWindow32", NULL);
mstask_swc = FindWindowEx (rebar_w32, NULL, "MSTaskSwWClass", NULL);
@@ -131,7 +133,7 @@
/* Remove the CTB hook from the system and reset all variables. */
extern "C" void
-PTD_delete (void)
+PTD_delete_hook (void)
{
if (!cbt_hook)
return;
@@ -144,12 +146,17 @@
/* Return if the CTB hook is currently used. */
extern "C" int
-PTD_is_used (void)
+PTD_is_hook_used (void)
{
return shell_traywnd && cbt_hook;
}
-
+/* From the MSDN:
+ * "Typically, an application uses this function to play back a series
+ * of mouse and keyboard messages recorded previously by the
+ * JournalRecordProc hook procedure. As long as a JournalPlaybackProc
+ * hook procedure is installed, regular mouse and keyboard input is disabled."
+ */
static LRESULT CALLBACK
PTD_playback_proc (int code, WPARAM wparam, LPARAM lparam)
{
@@ -157,7 +164,7 @@
if (code == HC_SKIP) {
keyidx++;
- if (keyidx == nkeys) {
+ if (keyidx >= nkeys) {
UnhookWindowsHookEx (journ_hook);
journ_hook = NULL;
}
@@ -174,7 +181,7 @@
em->message = journ_keys[keyidx] & 0x4000 ? WM_SYSKEYDOWN : WM_KEYDOWN;
else
em->message = journ_keys[keyidx] & 0x4000 ? WM_SYSKEYUP : WM_KEYUP;
- em->paramL = LOBYTE( journ_keys[keyidx] )
+ em->paramL = LOBYTE (journ_keys[keyidx])
| (MapVirtualKey (LOBYTE (journ_keys[keyidx]), 0) << 8);
em->paramH = 1;
em->time = GetTickCount ();
@@ -187,19 +194,20 @@
extern "C" BOOL
-PTD_keyb_send (UINT *keys, UINT n_keys)
+PTD_keyboard_send_keys (UINT *keys, UINT n_keys)
{
MSG msg;
journ_keys = keys;
keyidx = 0;
- nkeys = n_keys;
+ nkeys = n_keys;
+ /* Return immediately if there is an active hook */
if (journ_hook)
return FALSE;
- while (GetAsyncKeyState (VK_MENU) & 0x8000
- || GetAsyncKeyState (VK_SHIFT) & 0x8000
- || GetAsyncKeyState (VK_CONTROL) & 0x8000) {
+ while (GetAsyncKeyState (VK_MENU) & 0x8000 ||
+ GetAsyncKeyState (VK_SHIFT) & 0x8000 ||
+ GetAsyncKeyState (VK_CONTROL) & 0x8000) {
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
PostMessage (msg.hwnd, msg.message, msg.wParam, msg.lParam);
@@ -231,28 +239,17 @@
}
-/*FILE *fp;*/
-
+/* Main entry point for the DLL */
extern "C" BOOL WINAPI
DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserv)
{
switch (reason) {
- case DLL_PROCESS_ATTACH:
+ case DLL_PROCESS_ATTACH:
+ /* Handle to the attached process */
glob_hinst = hinst;
- /*
- fp = fopen ("attach_pid.txt", "a+b");
- if (fp != NULL) {
- fprintf (fp, "[+ %lu]\r\n", GetCurrentProcessId());
- fclose (fp);
- }*/
break;
case DLL_PROCESS_DETACH:
- /*fp = fopen ("attach_pid.txt", "a+b");
- if (fp != NULL) {
- fprintf (fp, "[- %lu]\r\n", GetCurrentProcessId());
- fclose (fp);
- }*/
break;
case DLL_THREAD_ATTACH:
Modified: trunk/PTD/PTD.def
===================================================================
--- trunk/PTD/PTD.def 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/PTD.def 2011-11-27 12:00:45 UTC (rev 334)
@@ -4,10 +4,10 @@
EXPORTS
PTD_initialize @201
- PTD_delete @202
- PTD_is_used @203
- PTD_keyb_send @204
- PTD_get_curr_hwnd @205
+ PTD_delete_hook @202
+ PTD_is_hook_used @203
+ PTD_keyboard_send_keys @204
+ PTD_get_current_window @205
gpg_use_armor_filter @210
gpg_armor_filter @211
@@ -31,6 +31,3 @@
gpg_release_kbnode @221
gpg_walk_kbnode @222
-; gpg_md_hash_file @500
- gpg_md_selftest @507
-
Deleted: trunk/PTD/resource.h
===================================================================
--- trunk/PTD/resource.h 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/resource.h 2011-11-27 12:00:45 UTC (rev 334)
@@ -1,15 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by ptd.rc
-//
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
Modified: trunk/PTD/resource.rc
===================================================================
--- trunk/PTD/resource.rc 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/resource.rc 2011-11-27 12:00:45 UTC (rev 334)
@@ -1,72 +1,6 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Deutsch (Deutschland) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
-#ifdef _WIN32
-LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifndef _MAC
-/////////////////////////////////////////////////////////////////////////////
-//
// Version
//
#include "versioninfo.rc"
-#endif // !_MAC
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // Deutsch (Deutschland) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
Modified: trunk/PTD/versioninfo.rc.in
===================================================================
--- trunk/PTD/versioninfo.rc.in 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/versioninfo.rc.in 2011-11-27 12:00:45 UTC (rev 334)
@@ -50,4 +50,3 @@
VALUE "Translation", 0x407, 1200
END
END
-
Deleted: trunk/PTD/wptDNSKeys.cpp
===================================================================
--- trunk/PTD/wptDNSKeys.cpp 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/wptDNSKeys.cpp 2011-11-27 12:00:45 UTC (rev 334)
@@ -1,191 +0,0 @@
-/* wptDNSKeys.cpp - Support for retrieving keys via DNS
- * Copyright (C) 2006 Timo Schulz
- *
- * This file is part of WinPT.
- *
- * WinPT 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 2 of the License, or
- * (at your option) any later version.
- *
- * WinPT 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 WinPT; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <windows.h>
-#include <windns.h>
-
-#include "wptDNSKeys.h"
-
-
-/* typedef for the function signature. */
-typedef DNS_STATUS (*dns_query_fnc) (LPSTR, WORD, DWORD, PIP4_ARRAY,
- PDNS_RECORD*, PVOID *);
-
-typedef void (*dns_record_list_free_fnc) (PDNS_RECORD, DNS_FREE_TYPE);
-
-/* function pointer. */
-static dns_query_fnc dns_query = NULL;
-static dns_record_list_free_fnc dns_record_free = NULL;
-
-/* hinstance handle to the DLL. */
-static HINSTANCE dns_api = NULL;
-
-/* 1 if the DNS api is not available. */
-static int dns_failed = 0;
-
-
-
-/* Initialize the DNS sub system. We do this via dynamic loading
- because older NT/9X systems do not have this API. */
-static int
-dns_init (void)
-{
- if (dns_query)
- return 0;
- if (dns_failed)
- return -1;
- dns_api = LoadLibrary ("dnsapi");
- if (!dns_api) {
- dns_failed = 1;
- return -1;
- }
- dns_query = (dns_query_fnc)GetProcAddress (dns_api, "DnsQuery_A");
- if (!dns_query) {
- dns_failed = 1;
- return -1;
- }
- dns_record_free = (dns_record_list_free_fnc)
- GetProcAddress (dns_api, "DnsRecordListFree");
- if (!dns_record_free) {
- dns_failed = 1;
- return -1;
- }
- return 0;
-}
-
-
-/* Cleanup static structs. */
-void
-dns_cleanup (void)
-{
- if (dns_api != NULL)
- FreeLibrary (dns_api);
- dns_api = NULL;
- dns_failed = 0;
-}
-
-
-/* build a DNS name for the PKA lookup. */
-static char*
-email_get_pka_addr (const char *uid)
-{
- const char *fmt = "._pka.";
- char *bo;
- char *pka;
- int pos=0;
-
- /* check that the @uid really contains an email address. */
- if ((bo=strchr (uid, '<')) && strchr (uid, '>'))
- uid += (bo-uid+1);
- if (!strchr (uid, '@'))
- return NULL;
-
- /* create the user at _pka.domain-part.tlp string. */
- pka = (char*)calloc (1, strlen (uid)+strlen (fmt)+1);
- while (uid && *uid != '@')
- pka[pos++] = *uid++;
- uid++;
- strcat (pka, fmt); pos += strlen (fmt);
- while (uid && *uid && *uid != '>')
- pka[pos++] = *uid++;
- return pka;
-}
-
-
-/* Convert the returned data from the PKA (txt) record. */
-pka_info_t
-parse_pka_data (const char *data)
-{
- enum pka_col_t { COL_VER=1, COL_FPR, COL_URI };
- pka_info_t pka;
- char *p;
- int pos = 1;
-
- if (strncmp (data, "v=pka1;", 8))
- return NULL;
- pka = (pka_info_t)calloc (1, sizeof *pka);
- p = strtok ((char*)data, ";");
- while (p != NULL) {
- switch (pos) {
- case COL_VER:
- pka->ver = 1;
- break;
-
- case COL_FPR:
- pka->fpr = strdup (p+strlen ("fpr="));
- break;
-
- case COL_URI: /* optional */
- pka->uri = strdup (p+strlen ("uri="));
- break;
-
- default:
- break;
- }
- pos++;
- }
- if (pos != 3) {
- dns_free_pka_record (pka);
- pka = NULL;
- }
- return pka;
-}
-
-
-/* Retrieve a PKA record from the DNS.
- @userid is used to extract the email address. */
-extern "C" int
-dns_get_pka_record (const char *userid, pka_info_t *r_pka)
-{
- DNS_STATUS err;
- DNS_RECORD *rec;
- char *addr;
-
- *r_pka = NULL;
- if (dns_init ())
- return -1;
- addr = email_get_pka_addr (userid);
- if (!addr)
- return -1;
- err = dns_query (addr, DNS_TYPE_TEXT, 0, NULL, &rec, NULL);
- if (err) {
- free (addr);
- return -1;
- }
- *r_pka = parse_pka_data (rec->Data.Txt.pStringArray[0]);
-
- dns_record_free (rec, DnsFreeRecordList);
- free (addr);
- return 0;
-}
-
-
-/* Release the memory of the @pka structure. */
-extern "C" void
-dns_free_pka_record (pka_info_t pka)
-{
- if (pka->fpr != NULL)
- free (pka->fpr);
- pka->fpr = NULL;
- if (pka->uri != NULL)
- free (pka->uri);
- pka->uri = NULL;
- free (pka);
-}
Deleted: trunk/PTD/wptDNSKeys.h
===================================================================
--- trunk/PTD/wptDNSKeys.h 2009-10-13 10:51:21 UTC (rev 333)
+++ trunk/PTD/wptDNSKeys.h 2011-11-27 12:00:45 UTC (rev 334)
@@ -1,41 +0,0 @@
-/* wptDNSKeys.h - Support for retrieving keys via DNS
- * Copyright (C) 2006 Timo Schulz
- *
- * This file is part of WinPT.
- *
- * WinPT 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 2 of the License, or
- * (at your option) any later version.
- *
- * WinPT 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 WinPT; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-#ifndef WPT_DNSKEYS_H
-#define WPT_DNSKEYS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct pka_info_s {
- int ver; /* version */
- char *fpr; /* key fingerprint */
- char *uri; /* if != NULL URL to fetch the key. */
-};
-typedef struct pka_info_s *pka_info_t;
-
-int dns_get_pka_record (const char *userid, pka_info_t *r_pka);
-void dns_free_pka_record (pka_info_t pka);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
More information about the Winpt-commits
mailing list