+#-----------------------------------------------------------------------------
+# This code is licensed to you under the terms of the GNU GPL, version 2 or,
+# at your option, any later version. See the LICENSE.txt file for the text of
+# the license.
+#-----------------------------------------------------------------------------
CC=gcc
CXX=g++
#COMMON_FLAGS = -m32
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Command line binary
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include "sleep.h"
#include "ui.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Data and Graph commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Data and Graph commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDDATA_H__
#define CMDDATA_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include "proxusb.h"
#include "graph.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDHF_H__
#define CMDHF_H__
int CmdHF(const char *Cmd);
-
int CmdHFTune(const char *Cmd);
#endif
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency ISO14443A commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency ISO14443A commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDHF14A_H__
#define CMDHF14A_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency ISO14443B commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency ISO14443B commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDHF14B_H__
#define CMDHF14B_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency ISO15693 commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency ISO15693 commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDHF15_H__
#define CMDHF15_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency Legic commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <string.h>
#include "proxusb.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// High frequency Legic commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDHFLEGIC_H__
#define CMDHFLEGIC_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Hardware commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Hardware commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDHW_H__
#define CMDHW_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDLF_H__
#define CMDLF_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency EM4x commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include "proxusb.h"
#include "ui.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency EM4x commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDLFEM4X_H__
#define CMDLFEM4X_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency HID commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include "proxusb.h"
#include "ui.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency HID commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDLFHID_H__
#define CMDLFHID_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency TI commands
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include "crc16.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency TI commands
+//-----------------------------------------------------------------------------
+
#ifndef CMDLFTI_H__
#define CMDLFTI_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Main command parser entry point
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Main command parser entry point
+//-----------------------------------------------------------------------------
+
#ifndef CMDMAIN_H__
#define CMDMAIN_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Command parser
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <string.h>
#include "ui.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Command parser
+//-----------------------------------------------------------------------------
+
#ifndef CMDPARSER_H__
#define CMDPARSER_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Data utilities
+//-----------------------------------------------------------------------------
+
#include <string.h>
#include <stdint.h>
#include "data.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Data utilities
+//-----------------------------------------------------------------------------
+
#ifndef DATA_H__
#define DATA_H__
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// ELF header
+//-----------------------------------------------------------------------------
+
#ifndef __ELF_H__
#define __ELF_H__
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Flashing utility functions
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Flashing utility functions
+//-----------------------------------------------------------------------------
+
#ifndef __FLASH_H__
#define __FLASH_H__
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Flashing binary
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include "sleep.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Graph utilities
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <string.h>
#include "ui.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Graph utilities
+//-----------------------------------------------------------------------------
+
#ifndef GRAPH_H__
#define GRAPH_H__
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// GUI dummy file
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
void ShowGraphWindow(void)
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// GUI functions
+//-----------------------------------------------------------------------------
+
#include "proxgui.h"
#include "proxguiqt.h"
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// GUI functions
+//-----------------------------------------------------------------------------
+
#ifdef __cplusplus
extern "C" {
#endif
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// GUI (QT)
+//-----------------------------------------------------------------------------
+
#include <iostream>
#include <QPainterPath>
#include <QBrush>
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// GUI (QT)
+//-----------------------------------------------------------------------------
+
#include <QApplication>
#include <QPushButton>
#include <QObject>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Main binary
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Main binary
+//-----------------------------------------------------------------------------
+
#ifndef PROXMARK3_H__
#define PROXMARK3_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// USB utilities
+//-----------------------------------------------------------------------------
+
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// USB utilities
+//-----------------------------------------------------------------------------
+
#ifndef PROXUSB_H__
#define PROXUSB_H__
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// platform-independant sleep macros
+//-----------------------------------------------------------------------------
+
#ifndef SLEEP_H__
#define SLEEP_H__
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Snooper binary
+//-----------------------------------------------------------------------------
+
#include "sleep.h"
#include "ui.h"
#include "proxusb.h"
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// UI utilities
+//-----------------------------------------------------------------------------
+
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
+//-----------------------------------------------------------------------------
+// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// UI utilities
+//-----------------------------------------------------------------------------
+
#ifndef UI_H__
#define UI_H__
+++ /dev/null
-//-----------------------------------------------------------------------------\r
-// Routines for the user interface when doing interactive things with prox\r
-// cards; this is basically a command line thing, in one window, and then\r
-// another window to do the graphs.\r
-// Jonathan Westhues, Sept 2005\r
-//-----------------------------------------------------------------------------\r
-#include <windows.h>\r
-#include <limits.h>\r
-#include <commctrl.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <math.h>\r
-\r
-#include "proxusb.h"\r
-#include "graph.h"\r
-#include "ui.h"\r
-#include "cmdmain.h"\r
-\r
-#define oops() do { \\r
- char line[100]; \\r
- sprintf(line, "Internal error at line %d file '%s'", __LINE__, \\r
- __FILE__); \\r
- MessageBox(NULL, line, "Error", MB_ICONERROR); \\r
- exit(-1); \\r
-} while(0)\r
-\r
-void dbp(char *str, ...)\r
-{\r
- va_list f;\r
- char buf[1024];\r
- va_start(f, str);\r
- vsprintf(buf, str, f);\r
- OutputDebugString(buf);\r
- OutputDebugString("\n");\r
-}\r
-\r
-int GraphBuffer[MAX_GRAPH_TRACE_LEN];\r
-int GraphTraceLen;\r
-int PlotGridX, PlotGridY;\r
-\r
-HPEN GreyPenLite, GreyPen, GreenPen, WhitePen, YellowPen;\r
-HBRUSH GreenBrush, YellowBrush;\r
-\r
-static int GraphStart = 0;\r
-static double GraphPixelsPerPoint = 1;\r
-\r
-static int CursorAPos;\r
-static int CursorBPos;\r
-double CursorScaleFactor = 1.0;\r
-static HPEN CursorAPen;\r
-static HPEN CursorBPen;\r
-\r
-static HWND CommandWindow;\r
-static HWND GraphWindow;\r
-static HWND ScrollbackEdit;\r
-static HWND CommandEdit;\r
-\r
-#define COMMAND_HISTORY_MAX 16\r
-static char CommandHistory[COMMAND_HISTORY_MAX][256];\r
-static int CommandHistoryPos = -1;\r
-static int CommandHistoryNext;\r
-\r
-static HFONT MyFixedFont;\r
-#define FixedFont(x) SendMessage((x), WM_SETFONT, (WPARAM)MyFixedFont, TRUE)\r
-\r
-void ExecCmd(char *cmd)\r
-{\r
-}\r
-\r
-int CommandFinished;\r
-int offset = 64;\r
-\r
-static void ResizeCommandWindow(void)\r
-{\r
- int w, h;\r
- RECT r;\r
- GetClientRect(CommandWindow, &r);\r
- w = r.right - r.left;\r
- h = r.bottom - r.top;\r
- MoveWindow(ScrollbackEdit, 10, 10, w - 20, h - 50, TRUE);\r
- MoveWindow(CommandEdit, 10, h - 29, w - 20, 22, TRUE);\r
-}\r
-\r
-void RepaintGraphWindow(void)\r
-{\r
- InvalidateRect(GraphWindow, NULL, TRUE);\r
-}\r
-\r
-static LRESULT CALLBACK\r
- CommandWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)\r
-{\r
- switch (msg) {\r
- case WM_DESTROY:\r
- case WM_QUIT:\r
- exit(0);\r
- return 0;\r
-\r
- case WM_SIZE:\r
- ResizeCommandWindow();\r
- return 0;\r
-\r
- case WM_SETFOCUS:\r
- SetFocus(CommandEdit);\r
- break;\r
-\r
- default:\r
- return DefWindowProc(hwnd, msg, wParam, lParam);\r
- }\r
-\r
- return 1;\r
-}\r
-\r
-static void PaintGraph(HDC hdc)\r
-{\r
- RECT r;\r
- HBRUSH brush;\r
- HPEN pen;\r
- char str[250];\r
- int yMin = INT_MAX;\r
- int yMax = INT_MIN;\r
- int yMean = 0;\r
- int startMax = 0;\r
- int absYMax = 1;\r
- int n = 0, i = 0;\r
-\r
- brush = GreenBrush;\r
- pen = GreenPen;\r
-\r
- GetClientRect(GraphWindow, &r);\r
- int zeroHeight = (r.top + r.bottom) >> 1;\r
-\r
- // plot X and Y grid lines\r
- if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {\r
- for(i = offset; i < r.right; i += (int)(PlotGridX * GraphPixelsPerPoint)) {\r
- SelectObject(hdc, GreyPenLite);\r
- MoveToEx(hdc, r.left + i, r.top, NULL);\r
- LineTo(hdc, r.left + i, r.bottom);\r
- }\r
- }\r
-\r
- if ((PlotGridY > 0) && ((PlotGridY * GraphPixelsPerPoint) > 1)){\r
- for(i = 0; i < ((r.top + r.bottom)>>1); i += (int)(PlotGridY * GraphPixelsPerPoint)) {\r
- SelectObject(hdc, GreyPenLite);\r
- MoveToEx(hdc, r.left, zeroHeight + i, NULL);\r
- LineTo(hdc, r.right, zeroHeight + i);\r
- MoveToEx(hdc, r.left, zeroHeight - i, NULL);\r
- LineTo(hdc, r.right, zeroHeight - i);\r
- }\r
- }\r
-\r
- // print vertical separator white line on the left of the window\r
- SelectObject(hdc, WhitePen);\r
- MoveToEx(hdc, r.left + offset, r.top, NULL);\r
- LineTo(hdc, r.left + offset, r.bottom);\r
-\r
- // print horizontal grey zero axis line\r
- SelectObject(hdc, GreyPen);\r
- MoveToEx(hdc, r.left, zeroHeight, NULL);\r
- LineTo(hdc, r.right, zeroHeight);\r
-\r
- startMax = (GraphTraceLen - (int)((r.right - r.left - offset) / GraphPixelsPerPoint));\r
- // check boundaries\r
- if(startMax < 0) startMax = 0;\r
- if(GraphStart > startMax) GraphStart = startMax;\r
- if(GraphStart < 0) GraphStart = 0;\r
-\r
-\r
- SelectObject(hdc, pen);\r
-\r
- // go over the portion of the graph to be displayed and find the largest\r
- // absolute value which will be used to auto scale the graph when displayed\r
- for(i = GraphStart; ; i++) {\r
- if(i >= GraphTraceLen) {\r
- break;\r
- }\r
- if(fabs((double)GraphBuffer[i]) > absYMax) {\r
- absYMax = (int)fabs((double)GraphBuffer[i]);\r
- }\r
- int x = offset + (int)((i - GraphStart)*GraphPixelsPerPoint);\r
- if(x > r.right) {\r
- break;\r
- }\r
- }\r
-\r
- absYMax = (int)(absYMax*1.2 + 1);\r
- SelectObject(hdc, MyFixedFont);\r
- SetTextColor(hdc, RGB(255, 255, 255));\r
- SetBkColor(hdc, RGB(0, 0, 0));\r
-\r
- // number of points that will be plotted\r
- double span = (int)((r.right - r.left) / GraphPixelsPerPoint);\r
-\r
- // one label every offset pixels, let us say\r
- int labels = (r.right - r.left - offset) / offset;\r
- if(labels <= 0) labels = 1;\r
- // round to nearest power of 2\r
- int pointsPerLabel = (int)(log(span / labels)/log(2.0));\r
- if(pointsPerLabel <= 0) pointsPerLabel = 1;\r
- pointsPerLabel = (int)pow(2.0,pointsPerLabel);\r
-\r
- // go over the graph and plot samples and labels\r
- for(i = GraphStart; ; i++) {\r
- if(i >= GraphTraceLen) {\r
- break;\r
- }\r
- int x = offset + (int)((i - GraphStart)*GraphPixelsPerPoint);\r
- if(x > r.right + GraphPixelsPerPoint) {\r
- break;\r
- }\r
-\r
- int y = GraphBuffer[i];\r
- if(y < yMin) yMin = y;\r
- if(y > yMax) yMax = y;\r
- yMean += y;\r
- n++;\r
-\r
- y = (y * (r.top - r.bottom) / (2*absYMax)) + zeroHeight;\r
- if(i == GraphStart) {\r
- MoveToEx(hdc, x, y, NULL);\r
- } else {\r
- LineTo(hdc, x, y);\r
- }\r
-\r
- if(GraphPixelsPerPoint > 10) {\r
- RECT f;\r
- f.left = x - 3;\r
- f.top = y - 3;\r
- f.right = x + 3;\r
- f.bottom = y + 3;\r
- FillRect(hdc, &f, brush);\r
- }\r
-\r
- // plot labels\r
- if(((i - GraphStart) % pointsPerLabel == 0) && i != GraphStart) {\r
- SelectObject(hdc, WhitePen);\r
- MoveToEx(hdc, x, zeroHeight - 8, NULL);\r
- LineTo(hdc, x, zeroHeight + 8);\r
-\r
- sprintf(str, "+%d", i);\r
- SIZE size;\r
- GetTextExtentPoint32(hdc, str, strlen(str), &size);\r
- TextOut(hdc, x - size.cx, zeroHeight + 8, str, strlen(str));\r
-\r
- SelectObject(hdc, pen);\r
- MoveToEx(hdc, x, y, NULL);\r
- }\r
-\r
- // plot measurement cursors\r
- if(i == CursorAPos || i == CursorBPos) {\r
- if(i == CursorAPos) {\r
- SelectObject(hdc, CursorAPen);\r
- } else {\r
- SelectObject(hdc, CursorBPen);\r
- }\r
- MoveToEx(hdc, x, r.top, NULL);\r
- LineTo(hdc, x, r.bottom);\r
-\r
- SelectObject(hdc, pen);\r
- MoveToEx(hdc, x, y, NULL);\r
- }\r
- }\r
-\r
- if(n != 0) {\r
- yMean /= n;\r
- }\r
-\r
- // print misc information at bottom of graph window\r
- sprintf(str, "@%d max=%d min=%d mean=%d n=%d/%d dt=%d [%.3f] zoom=%.3f CursorA=%d [%d] CursorB=%d [%d]",\r
- GraphStart, yMax, yMin, yMean, n, GraphTraceLen,\r
- CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor, GraphPixelsPerPoint,\r
- CursorAPos, GraphBuffer[CursorAPos], CursorBPos, GraphBuffer[CursorBPos]);\r
- TextOut(hdc, 50, r.bottom - 20, str, strlen(str));\r
-}\r
-\r
-static LRESULT CALLBACK\r
- GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)\r
-{\r
- switch (msg) {\r
- case WM_DESTROY:\r
- case WM_QUIT:\r
- GraphWindow = NULL;\r
- return DefWindowProc(hwnd, msg, wParam, lParam);\r
-\r
- case WM_SIZE:\r
- RepaintGraphWindow();\r
- return 0;\r
-\r
- case WM_PAINT: {\r
- PAINTSTRUCT ps;\r
- HDC hdc = BeginPaint(hwnd, &ps);\r
- if(GraphStart < 0) {\r
- GraphStart = 0;\r
- }\r
- // This draws the trace.\r
- PaintGraph(hdc);\r
- EndPaint(hwnd, &ps);\r
- break;\r
- }\r
- case WM_KEYDOWN:\r
- switch(wParam) {\r
- case VK_DOWN:\r
- if(GraphPixelsPerPoint <= 8) {\r
- GraphPixelsPerPoint *= 2;\r
- }\r
- break;\r
-\r
- case VK_UP:\r
- if(GraphPixelsPerPoint >= 0.01) {\r
- GraphPixelsPerPoint /= 2;\r
- }\r
- break;\r
-\r
- case VK_RIGHT:\r
- if(GraphPixelsPerPoint < 16) {\r
- GraphStart += (int)(16 / GraphPixelsPerPoint);\r
- } else {\r
- GraphStart++;\r
- }\r
- break;\r
-\r
- case VK_LEFT:\r
- if(GraphPixelsPerPoint < 16) {\r
- GraphStart -= (int)(16 / GraphPixelsPerPoint);\r
- } else {\r
- GraphStart--;\r
- }\r
- break;\r
-\r
- default:\r
- goto nopaint;\r
- }\r
- RepaintGraphWindow();\r
-nopaint:\r
- break;\r
-\r
- case WM_LBUTTONDOWN:\r
- case WM_RBUTTONDOWN: {\r
- int x = LOWORD(lParam);\r
- x -= offset;\r
- x = (int)(x / GraphPixelsPerPoint);\r
- x += GraphStart;\r
-\r
- if(msg == WM_LBUTTONDOWN) {\r
- CursorAPos = x;\r
- } else {\r
- CursorBPos = x;\r
- }\r
- RepaintGraphWindow();\r
- break;\r
- }\r
- default:\r
- return DefWindowProc(hwnd, msg, wParam, lParam);\r
- }\r
-\r
- return 1;\r
-}\r
-\r
-void PrintAndLog(char *fmt, ...)\r
-{\r
- va_list f;\r
- char str[1024];\r
- strcpy(str, "\r\n");\r
- va_start(f, fmt);\r
- vsprintf(str+2, fmt, f);\r
-\r
- static char TextBuf[1024*32];\r
- SendMessage(ScrollbackEdit, WM_GETTEXT, (WPARAM)sizeof(TextBuf),\r
- (LPARAM)TextBuf);\r
-\r
- if(strlen(TextBuf) + strlen(str) + 1 <= sizeof(TextBuf)) {\r
- strcat(TextBuf, str);\r
- } else {\r
- lstrcpyn(TextBuf, str, sizeof(TextBuf));\r
- }\r
-\r
- SendMessage(ScrollbackEdit, WM_SETTEXT, 0, (LPARAM)TextBuf);\r
- SendMessage(ScrollbackEdit, EM_LINESCROLL, 0, (LPARAM)INT_MAX);\r
-}\r
-\r
-void ShowGraphWindow(void)\r
-{\r
- if(GraphWindow) return;\r
-\r
- GraphWindow = CreateWindowEx(0, "Graph", "graphed",\r
- WS_OVERLAPPED | WS_BORDER | WS_MINIMIZEBOX | WS_SYSMENU |\r
- WS_SIZEBOX | WS_VISIBLE, 200, 150, 600, 500, NULL, NULL, NULL,\r
- NULL);\r
- if(!GraphWindow) oops();\r
-}\r
-\r
-void HideGraphWindow(void)\r
-{\r
- if(GraphWindow) {\r
- DestroyWindow(GraphWindow);\r
- GraphWindow = NULL;\r
- }\r
-}\r
-\r
-static void SetCommandEditTo(char *str)\r
-{\r
- SendMessage(CommandEdit, WM_SETTEXT, 0, (LPARAM)str);\r
- SendMessage(CommandEdit, EM_SETSEL, strlen(str), strlen(str));\r
-}\r
-\r
-void ShowGui()\r
-{\r
- WNDCLASSEX wc;\r
- memset(&wc, 0, sizeof(wc));\r
- wc.cbSize = sizeof(wc);\r
-\r
- wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC;\r
- wc.lpfnWndProc = (WNDPROC)CommandWindowProc;\r
- wc.hInstance = NULL;\r
- wc.hbrBackground = (HBRUSH)(COLOR_BTNSHADOW);\r
- wc.lpszClassName = "Command";\r
- wc.lpszMenuName = NULL;\r
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);\r
-\r
- if(!RegisterClassEx(&wc)) oops();\r
-\r
- wc.lpszClassName = "Graph";\r
- wc.lpfnWndProc = (WNDPROC)GraphWindowProc;\r
- wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);\r
-\r
- if(!RegisterClassEx(&wc)) oops();\r
-\r
- CommandWindow = CreateWindowEx(0, "Command", "prox",\r
- WS_OVERLAPPED | WS_BORDER | WS_MINIMIZEBOX | WS_SYSMENU |\r
- WS_SIZEBOX | WS_VISIBLE, 20, 20, 500, 400, NULL, NULL, NULL,\r
- NULL);\r
- if(!CommandWindow) oops();\r
-\r
- ScrollbackEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "",\r
- WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_MULTILINE |\r
- ES_AUTOVSCROLL | WS_VSCROLL, 0, 0, 0, 0, CommandWindow, NULL,\r
- NULL, NULL);\r
-\r
- CommandEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "",\r
- WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP | WS_VISIBLE |\r
- ES_AUTOHSCROLL, 0, 0, 0, 0, CommandWindow, NULL, NULL, NULL);\r
-\r
- MyFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE,\r
- ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,\r
- FF_DONTCARE, "Lucida Console");\r
- if(!MyFixedFont)\r
- MyFixedFont = (HFONT)GetStockObject(SYSTEM_FONT);\r
-\r
- FixedFont(ScrollbackEdit);\r
- FixedFont(CommandEdit);\r
-\r
- ResizeCommandWindow();\r
- SetFocus(CommandEdit);\r
-\r
- PrintAndLog(">> Started prox, built " __DATE__ " " __TIME__);\r
- PrintAndLog(">> Connected to device");\r
-\r
- GreyPenLite = CreatePen(PS_SOLID, 1, RGB(50, 50, 50));\r
- GreyPen = CreatePen(PS_SOLID, 1, RGB(100, 100, 100));\r
- GreenPen = CreatePen(PS_SOLID, 1, RGB(100, 255, 100));\r
- YellowPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 0));\r
- GreenBrush = CreateSolidBrush(RGB(100, 255, 100));\r
- YellowBrush = CreateSolidBrush(RGB(255, 255, 0));\r
- WhitePen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));\r
-\r
- CursorAPen = CreatePen(PS_DASH, 1, RGB(255, 255, 0));\r
- CursorBPen = CreatePen(PS_DASH, 1, RGB(255, 0, 255));\r
-\r
- MSG msg;\r
- for(;;) {\r
- if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {\r
- if(msg.message == WM_KEYDOWN && msg.wParam == VK_RETURN) {\r
- char got[1024];\r
- SendMessage(CommandEdit, WM_GETTEXT, (WPARAM)sizeof(got),\r
- (LPARAM)got);\r
-\r
- if(strcmp(got, "cls")==0) {\r
- SendMessage(ScrollbackEdit, WM_SETTEXT, 0, (LPARAM)"");\r
- } else {\r
- CommandReceived(got);\r
- }\r
- SendMessage(CommandEdit, WM_SETTEXT, 0, (LPARAM)"");\r
-\r
- // Insert it into the command history, unless it is\r
- // identical to the previous command in the history.\r
- int prev = CommandHistoryNext - 1;\r
- if(prev < 0) prev += COMMAND_HISTORY_MAX;\r
- if(strcmp(CommandHistory[prev], got) != 0) {\r
- strcpy(CommandHistory[CommandHistoryNext], got);\r
- CommandHistoryNext++;\r
- if(CommandHistoryNext == COMMAND_HISTORY_MAX) {\r
- CommandHistoryNext = 0;\r
- }\r
- }\r
- CommandHistoryPos = -1;\r
- } else if(msg.message == WM_KEYDOWN && msg.wParam == VK_UP &&\r
- msg.hwnd == CommandEdit)\r
- {\r
- if(CommandHistoryPos == -1) {\r
- CommandHistoryPos = CommandHistoryNext;\r
- }\r
- CommandHistoryPos--;\r
- if(CommandHistoryPos < 0) {\r
- CommandHistoryPos = COMMAND_HISTORY_MAX-1;\r
- }\r
- SetCommandEditTo(CommandHistory[CommandHistoryPos]);\r
- } else if(msg.message == WM_KEYDOWN && msg.wParam == VK_DOWN &&\r
- msg.hwnd == CommandEdit)\r
- {\r
- CommandHistoryPos++;\r
- if(CommandHistoryPos >= COMMAND_HISTORY_MAX) {\r
- CommandHistoryPos = 0;\r
- }\r
- SetCommandEditTo(CommandHistory[CommandHistoryPos]);\r
- } else if(msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE &&\r
- msg.hwnd == CommandEdit)\r
- {\r
- SendMessage(CommandEdit, WM_SETTEXT, 0, (LPARAM)"");\r
- } else {\r
- if(msg.message == WM_KEYDOWN) {\r
- CommandHistoryPos = -1;\r
- }\r
- TranslateMessage(&msg);\r
- DispatchMessage(&msg);\r
- }\r
- }\r
-\r
- if (!offline)\r
- {\r
- UsbCommand c;\r
- if(ReceiveCommandPoll(&c))\r
- UsbCommandReceived(&c);\r
- }\r
-\r
- Sleep(10);\r
- }\r
-}\r