mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Turned the FreeLoader debugger into a GUI app.
Basically just a terminal program that logs the RS232 data to a file. svn path=/trunk/; revision=4567
This commit is contained in:
parent
0abf32e9f6
commit
fb8745e1ef
6 changed files with 803 additions and 32 deletions
|
@ -24,7 +24,7 @@ RM = cmd /C del
|
||||||
|
|
||||||
FLAGS = -Wall
|
FLAGS = -Wall
|
||||||
|
|
||||||
OBJS = rs232.o fdebug.o
|
OBJS = rs232.o fdebug.o fdebug.res
|
||||||
|
|
||||||
.PHONY : clean
|
.PHONY : clean
|
||||||
|
|
||||||
|
@ -32,7 +32,11 @@ all: fdebug.exe
|
||||||
|
|
||||||
fdebug.exe: $(OBJS)
|
fdebug.exe: $(OBJS)
|
||||||
@echo ===================================================== LINKING fdebug
|
@echo ===================================================== LINKING fdebug
|
||||||
$(CC) $(FLAGS) -o fdebug.exe $(OBJS)
|
$(CC) $(FLAGS) -o fdebug.exe $(OBJS) -lgdi32 -lcomdlg32 -Wl,--subsystem,windows
|
||||||
|
|
||||||
|
fdebug.res: fdebug.rc resource.h
|
||||||
|
@echo ===================================================== Compiling $*
|
||||||
|
windres -o fdebug.res fdebug.rc -O coff
|
||||||
|
|
||||||
fdebug.o: fdebug.c rs232.h
|
fdebug.o: fdebug.c rs232.h
|
||||||
@echo ===================================================== Compiling $*
|
@echo ===================================================== Compiling $*
|
||||||
|
@ -44,5 +48,6 @@ rs232.o: rs232.c rs232.h
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@-$(RM) *.o
|
@-$(RM) *.o
|
||||||
|
@-$(RM) *.res
|
||||||
@-$(RM) *.exe
|
@-$(RM) *.exe
|
||||||
@echo Clean ALL done.
|
@echo Clean ALL done.
|
||||||
|
|
|
@ -1,43 +1,554 @@
|
||||||
/*
|
// fdebug.cpp : Defines the entry point for the application.
|
||||||
* FreeLoader - fdebug.c
|
//
|
||||||
*
|
|
||||||
* Copyright (C) 2003 Brian Palmer <brianp@sginet.com>
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <commdlg.h>
|
||||||
|
#include <process.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
#include "resource.h"
|
||||||
#include "rs232.h"
|
#include "rs232.h"
|
||||||
|
|
||||||
void main(void)
|
#define MAX_LOADSTRING 100
|
||||||
|
|
||||||
|
// Global Variables:
|
||||||
|
HINSTANCE hInst; // current instance
|
||||||
|
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||||
|
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
|
||||||
|
HWND hMainWnd; // The main window handle
|
||||||
|
HWND hDisplayWnd; // The window to display the incoming data
|
||||||
|
HWND hEditWnd; // The edit window to get input from the user
|
||||||
|
TCHAR strComPort[MAX_PATH] = TEXT("COM1"); // The COM port to use
|
||||||
|
TCHAR strBaudRate[MAX_PATH] = TEXT("115200"); // The baud rate to use
|
||||||
|
TCHAR strCaptureFileName[MAX_PATH] = TEXT(""); // The file name to capture to
|
||||||
|
BOOL bConnected = FALSE; // Tells us if we are currently connected
|
||||||
|
BOOL bCapturing = FALSE; // Tells us if we are currently capturing data
|
||||||
|
BOOL bLocalEcho = FALSE; // Tells us if local echo is currently enabled
|
||||||
|
HANDLE hCaptureFile; // Handle to the capture file
|
||||||
|
DWORD dwThreadId = 0; // Thread id of RS232 communication thread
|
||||||
|
|
||||||
|
// Foward declarations of functions included in this code module:
|
||||||
|
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||||
|
BOOL InitInstance(HINSTANCE, int);
|
||||||
|
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
LRESULT CALLBACK ConnectionDialogProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
LRESULT CALLBACK CaptureDialogProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
VOID EnableConnectMenuItem(BOOL Enable);
|
||||||
|
VOID EnableDisconnectMenuItem(BOOL Enable);
|
||||||
|
VOID EnableStartCaptureMenuItem(BOOL Enable);
|
||||||
|
VOID EnableStopCaptureMenuItem(BOOL Enable);
|
||||||
|
VOID CheckLocalEchoMenuItem(BOOL Checked);
|
||||||
|
VOID Rs232Thread(VOID* Parameter);
|
||||||
|
|
||||||
|
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||||
|
HINSTANCE hPrevInstance,
|
||||||
|
LPSTR lpCmdLine,
|
||||||
|
int nCmdShow)
|
||||||
{
|
{
|
||||||
BYTE Byte;
|
// TODO: Place code here.
|
||||||
|
MSG msg;
|
||||||
|
HACCEL hAccelTable;
|
||||||
|
|
||||||
Rs232OpenPortWin32(TEXT("COM1"));
|
// Initialize global strings
|
||||||
Rs232ConfigurePortWin32(TEXT("19200,n,8,1"));
|
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||||
|
LoadString(hInstance, IDC_FDEBUG, szWindowClass, MAX_LOADSTRING);
|
||||||
|
MyRegisterClass(hInstance);
|
||||||
|
|
||||||
for (;;)
|
// Perform application initialization:
|
||||||
|
if (!InitInstance (hInstance, nCmdShow))
|
||||||
{
|
{
|
||||||
if (Rs232ReadByteWin32(&Byte))
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_FDEBUG);
|
||||||
|
|
||||||
|
// Main message loop:
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||||
{
|
{
|
||||||
_tprintf(TEXT("%c"), Byte);
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_tprintf(TEXT("\n"));
|
return msg.wParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// FUNCTION: MyRegisterClass()
|
||||||
|
//
|
||||||
|
// PURPOSE: Registers the window class.
|
||||||
|
//
|
||||||
|
// COMMENTS:
|
||||||
|
//
|
||||||
|
// This function and its usage is only necessary if you want this code
|
||||||
|
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
|
||||||
|
// function that was added to Windows 95. It is important to call this function
|
||||||
|
// so that the application will get 'well formed' small icons associated
|
||||||
|
// with it.
|
||||||
|
//
|
||||||
|
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||||
|
{
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
|
||||||
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = (WNDPROC)WndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
|
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_FDEBUG);
|
||||||
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = NULL;//(HBRUSH)(COLOR_WINDOW+1);
|
||||||
|
wcex.lpszMenuName = (LPCSTR)IDC_FDEBUG;
|
||||||
|
wcex.lpszClassName = szWindowClass;
|
||||||
|
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
|
||||||
|
|
||||||
|
return RegisterClassEx(&wcex);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// FUNCTION: InitInstance(HANDLE, int)
|
||||||
|
//
|
||||||
|
// PURPOSE: Saves instance handle and creates main window
|
||||||
|
//
|
||||||
|
// COMMENTS:
|
||||||
|
//
|
||||||
|
// In this function, we save the instance handle in a global variable and
|
||||||
|
// create and display the main program window.
|
||||||
|
//
|
||||||
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||||
|
{
|
||||||
|
HWND hWnd;
|
||||||
|
|
||||||
|
hInst = hInstance; // Store instance handle in our global variable
|
||||||
|
|
||||||
|
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
|
||||||
|
|
||||||
|
if (!hWnd)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hMainWnd = hWnd;
|
||||||
|
|
||||||
|
ShowWindow(hWnd, nCmdShow);
|
||||||
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
int wmId, wmEvent;
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HDC hdc;
|
||||||
|
RECT rc;
|
||||||
|
TCHAR WndText[MAX_PATH];
|
||||||
|
DWORD Index;
|
||||||
|
NONCLIENTMETRICS ncm;
|
||||||
|
HFONT hFont;
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_CREATE:
|
||||||
|
|
||||||
|
hEditWnd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), "", WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_AUTOHSCROLL|ES_LEFT|ES_MULTILINE, 0, 0, 0, 0, hWnd, NULL, hInst, NULL);
|
||||||
|
hDisplayWnd = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), "", WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE, 0, 0, 0, 0, hWnd, NULL, hInst, NULL);
|
||||||
|
|
||||||
|
memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
|
||||||
|
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
||||||
|
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);
|
||||||
|
|
||||||
|
hFont = CreateFontIndirect(&ncm.lfMessageFont);
|
||||||
|
|
||||||
|
SendMessage(hEditWnd, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
|
SendMessage(hDisplayWnd, WM_SETFONT, (WPARAM)hFont, TRUE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case WM_COMMAND:
|
||||||
|
wmId = LOWORD(wParam);
|
||||||
|
wmEvent = HIWORD(wParam);
|
||||||
|
|
||||||
|
if (lParam == (LPARAM)hEditWnd && wmEvent == EN_CHANGE)
|
||||||
|
{
|
||||||
|
GetWindowText(hEditWnd, WndText, MAX_PATH);
|
||||||
|
|
||||||
|
if (_tcslen(WndText) > 0)
|
||||||
|
{
|
||||||
|
SetWindowText(hEditWnd, TEXT(""));
|
||||||
|
|
||||||
|
if (!bConnected)
|
||||||
|
{
|
||||||
|
MessageBox(hWnd, TEXT("You are not currently connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Index=0; Index<_tcslen(WndText); Index++)
|
||||||
|
{
|
||||||
|
if (dwThreadId != 0)
|
||||||
|
{
|
||||||
|
PostThreadMessage(dwThreadId, WM_CHAR, (WPARAM)WndText[Index], (LPARAM)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the menu selections:
|
||||||
|
switch (wmId)
|
||||||
|
{
|
||||||
|
case IDM_ABOUT:
|
||||||
|
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
|
||||||
|
break;
|
||||||
|
case IDM_EXIT:
|
||||||
|
DestroyWindow(hWnd);
|
||||||
|
break;
|
||||||
|
case ID_FILE_CONNECT:
|
||||||
|
if (bConnected)
|
||||||
|
{
|
||||||
|
MessageBox(hWnd, TEXT("You are already connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (DialogBox(hInst, (LPCTSTR)IDD_CONNECTION, hWnd, (DLGPROC)ConnectionDialogProc) == IDOK)
|
||||||
|
{
|
||||||
|
bConnected = TRUE;
|
||||||
|
EnableDisconnectMenuItem(TRUE);
|
||||||
|
EnableConnectMenuItem(FALSE);
|
||||||
|
_beginthread(Rs232Thread, 0, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ID_FILE_DISCONNECT:
|
||||||
|
if (bConnected)
|
||||||
|
{
|
||||||
|
bConnected = FALSE;
|
||||||
|
EnableDisconnectMenuItem(FALSE);
|
||||||
|
EnableConnectMenuItem(TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox(hWnd, TEXT("You are not currently connected!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ID_FILE_STARTCAPTURE:
|
||||||
|
if (DialogBox(hInst, (LPCTSTR)IDD_CAPTURE, hWnd, (DLGPROC)CaptureDialogProc) == IDOK)
|
||||||
|
{
|
||||||
|
bCapturing = TRUE;
|
||||||
|
EnableStopCaptureMenuItem(TRUE);
|
||||||
|
EnableStartCaptureMenuItem(FALSE);
|
||||||
|
hCaptureFile = CreateFile(strCaptureFileName, FILE_APPEND_DATA, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ID_FILE_STOPCAPTURE:
|
||||||
|
if (bCapturing)
|
||||||
|
{
|
||||||
|
bCapturing = FALSE;
|
||||||
|
EnableStopCaptureMenuItem(FALSE);
|
||||||
|
EnableStartCaptureMenuItem(TRUE);
|
||||||
|
CloseHandle(hCaptureFile);
|
||||||
|
hCaptureFile = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ID_FILE_LOCALECHO:
|
||||||
|
if (bLocalEcho)
|
||||||
|
{
|
||||||
|
bLocalEcho = FALSE;
|
||||||
|
CheckLocalEchoMenuItem(bLocalEcho);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bLocalEcho = TRUE;
|
||||||
|
CheckLocalEchoMenuItem(bLocalEcho);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WM_PAINT:
|
||||||
|
hdc = BeginPaint(hWnd, &ps);
|
||||||
|
EndPaint(hWnd, &ps);
|
||||||
|
break;
|
||||||
|
case WM_SIZE:
|
||||||
|
|
||||||
|
GetClientRect(hWnd, &rc);
|
||||||
|
|
||||||
|
MoveWindow(hDisplayWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top - 20, TRUE);
|
||||||
|
MoveWindow(hEditWnd, rc.left, rc.bottom - 20, rc.right - rc.left, 20, TRUE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND hLicenseEditWnd;
|
||||||
|
TCHAR strLicense[0x1000];
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
|
||||||
|
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
|
||||||
|
|
||||||
|
LoadString(hInst, IDS_LICENSE, strLicense, 0x1000);
|
||||||
|
|
||||||
|
SetWindowText(hLicenseEditWnd, strLicense);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK ConnectionDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_COMPORT), strComPort);
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_BAUTRATE), strBaudRate);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (LOWORD(wParam) == IDOK)
|
||||||
|
{
|
||||||
|
GetWindowText(GetDlgItem(hDlg, IDC_COMPORT), strComPort, MAX_PATH);
|
||||||
|
GetWindowText(GetDlgItem(hDlg, IDC_BAUTRATE), strBaudRate, MAX_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK CaptureDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
OPENFILENAME ofn;
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_CAPTUREFILENAME), strCaptureFileName);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
if (LOWORD(wParam) == IDC_BROWSE)
|
||||||
|
{
|
||||||
|
memset(&ofn, 0, sizeof(OPENFILENAME));
|
||||||
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||||
|
ofn.hwndOwner = hDlg;
|
||||||
|
ofn.hInstance = hInst;
|
||||||
|
ofn.lpstrFilter = NULL;
|
||||||
|
ofn.lpstrCustomFilter = NULL;
|
||||||
|
ofn.nMaxCustFilter = 0;
|
||||||
|
ofn.nFilterIndex = 0;
|
||||||
|
ofn.lpstrFile = strCaptureFileName;
|
||||||
|
ofn.nMaxFile = MAX_PATH;
|
||||||
|
ofn.lpstrFileTitle = NULL;
|
||||||
|
ofn.nMaxFileTitle = 0;
|
||||||
|
ofn.lpstrInitialDir = NULL;
|
||||||
|
ofn.lpstrTitle = NULL;
|
||||||
|
ofn.Flags = OFN_HIDEREADONLY|OFN_NOREADONLYRETURN;
|
||||||
|
|
||||||
|
if (GetOpenFileName(&ofn))
|
||||||
|
{
|
||||||
|
SetWindowText(GetDlgItem(hDlg, IDC_CAPTUREFILENAME), strCaptureFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOWORD(wParam) == IDOK)
|
||||||
|
{
|
||||||
|
GetWindowText(GetDlgItem(hDlg, IDC_CAPTUREFILENAME), strCaptureFileName, MAX_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID EnableConnectMenuItem(BOOL Enable)
|
||||||
|
{
|
||||||
|
HMENU hMenuBar;
|
||||||
|
HMENU hFileMenu;
|
||||||
|
|
||||||
|
hMenuBar = GetMenu(hMainWnd);
|
||||||
|
hFileMenu = GetSubMenu(hMenuBar, 0);
|
||||||
|
|
||||||
|
if (Enable)
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_CONNECT, MF_BYCOMMAND|MF_ENABLED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_CONNECT, MF_BYCOMMAND|MF_GRAYED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID EnableDisconnectMenuItem(BOOL Enable)
|
||||||
|
{
|
||||||
|
HMENU hMenuBar;
|
||||||
|
HMENU hFileMenu;
|
||||||
|
|
||||||
|
hMenuBar = GetMenu(hMainWnd);
|
||||||
|
hFileMenu = GetSubMenu(hMenuBar, 0);
|
||||||
|
|
||||||
|
if (Enable)
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_DISCONNECT, MF_BYCOMMAND|MF_ENABLED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_DISCONNECT, MF_BYCOMMAND|MF_GRAYED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID EnableStartCaptureMenuItem(BOOL Enable)
|
||||||
|
{
|
||||||
|
HMENU hMenuBar;
|
||||||
|
HMENU hFileMenu;
|
||||||
|
|
||||||
|
hMenuBar = GetMenu(hMainWnd);
|
||||||
|
hFileMenu = GetSubMenu(hMenuBar, 0);
|
||||||
|
|
||||||
|
if (Enable)
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_STARTCAPTURE, MF_BYCOMMAND|MF_ENABLED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_STARTCAPTURE, MF_BYCOMMAND|MF_GRAYED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID EnableStopCaptureMenuItem(BOOL Enable)
|
||||||
|
{
|
||||||
|
HMENU hMenuBar;
|
||||||
|
HMENU hFileMenu;
|
||||||
|
|
||||||
|
hMenuBar = GetMenu(hMainWnd);
|
||||||
|
hFileMenu = GetSubMenu(hMenuBar, 0);
|
||||||
|
|
||||||
|
if (Enable)
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_STOPCAPTURE, MF_BYCOMMAND|MF_ENABLED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnableMenuItem(hFileMenu, ID_FILE_STOPCAPTURE, MF_BYCOMMAND|MF_GRAYED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CheckLocalEchoMenuItem(BOOL Checked)
|
||||||
|
{
|
||||||
|
HMENU hMenuBar;
|
||||||
|
HMENU hFileMenu;
|
||||||
|
|
||||||
|
hMenuBar = GetMenu(hMainWnd);
|
||||||
|
hFileMenu = GetSubMenu(hMenuBar, 0);
|
||||||
|
|
||||||
|
if (Checked)
|
||||||
|
{
|
||||||
|
CheckMenuItem(hFileMenu, ID_FILE_LOCALECHO, MF_BYCOMMAND|MF_CHECKED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CheckMenuItem(hFileMenu, ID_FILE_LOCALECHO, MF_BYCOMMAND|MF_UNCHECKED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID Rs232Thread(VOID* Parameter)
|
||||||
|
{
|
||||||
|
BYTE Byte;
|
||||||
|
TCHAR String[MAX_PATH];
|
||||||
|
MSG msg;
|
||||||
|
DWORD dwNumberOfBytesWritten;
|
||||||
|
|
||||||
|
dwThreadId = GetCurrentThreadId();
|
||||||
|
|
||||||
|
if (!Rs232OpenPortWin32(strComPort))
|
||||||
|
{
|
||||||
|
MessageBox(hMainWnd, TEXT("Error opening port!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
|
||||||
|
bConnected = FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_stprintf(String, TEXT("%s,n,8,1"), strBaudRate);
|
||||||
|
if (!Rs232ConfigurePortWin32(String))
|
||||||
|
{
|
||||||
|
MessageBox(hMainWnd, TEXT("Error configuring port!"), TEXT("Error"), MB_OK|MB_ICONSTOP);
|
||||||
|
bConnected = FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (bConnected)
|
||||||
|
{
|
||||||
|
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||||
|
{
|
||||||
|
if (msg.message == WM_CHAR)
|
||||||
|
{
|
||||||
|
Rs232WriteByteWin32((BYTE)msg.wParam);
|
||||||
|
|
||||||
|
if (bLocalEcho && msg.wParam != (WPARAM)TEXT('\r'))
|
||||||
|
{
|
||||||
|
PostMessage(hDisplayWnd, WM_CHAR, (WPARAM)msg.wParam, (LPARAM)0);
|
||||||
|
|
||||||
|
if (hCaptureFile)
|
||||||
|
{
|
||||||
|
WriteFile(hCaptureFile, &msg.wParam, sizeof(TCHAR), &dwNumberOfBytesWritten, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Rs232ReadByteWin32(&Byte))
|
||||||
|
{
|
||||||
|
_stprintf(String, TEXT("%c"), Byte);
|
||||||
|
|
||||||
|
PostMessage(hDisplayWnd, WM_CHAR, (WPARAM)String[0], (LPARAM)0);
|
||||||
|
|
||||||
|
if (hCaptureFile)
|
||||||
|
{
|
||||||
|
WriteFile(hCaptureFile, &String[0], sizeof(TCHAR), &dwNumberOfBytesWritten, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dwThreadId = 0;
|
||||||
|
Rs232ClosePortWin32();
|
||||||
}
|
}
|
BIN
freeldr/fdebug/fdebug.ico
Normal file
BIN
freeldr/fdebug/fdebug.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
215
freeldr/fdebug/fdebug.rc
Normal file
215
freeldr/fdebug/fdebug.rc
Normal file
|
@ -0,0 +1,215 @@
|
||||||
|
//Microsoft Developer Studio generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||||
|
#include "windows.h"
|
||||||
|
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
|
// remains consistent on all systems.
|
||||||
|
IDI_FDEBUG ICON DISCARDABLE "fdebug.ICO"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Menu
|
||||||
|
//
|
||||||
|
|
||||||
|
IDC_FDEBUG MENU DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
POPUP "&File"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&Connect", ID_FILE_CONNECT
|
||||||
|
MENUITEM "&Disconnect", ID_FILE_DISCONNECT, GRAYED
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "&Start Capture", ID_FILE_STARTCAPTURE
|
||||||
|
MENUITEM "S&top Capture", ID_FILE_STOPCAPTURE, GRAYED
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "&Local Echo", ID_FILE_LOCALECHO
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "E&xit", IDM_EXIT
|
||||||
|
END
|
||||||
|
POPUP "&Help"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&About ...", IDM_ABOUT
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Accelerator
|
||||||
|
//
|
||||||
|
|
||||||
|
IDC_FDEBUG ACCELERATORS MOVEABLE PURE
|
||||||
|
BEGIN
|
||||||
|
"?", IDM_ABOUT, ASCII, ALT
|
||||||
|
"/", IDM_ABOUT, ASCII, ALT
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
2 TEXTINCLUDE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||||
|
"#include ""windows.h""\r\n"
|
||||||
|
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||||
|
"#include ""resource.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
1 TEXTINCLUDE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DESIGNINFO
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
GUIDELINES DESIGNINFO DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
IDD_ABOUTBOX, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 252
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 203
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_CONNECTION, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 189
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 93
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_CAPTURE, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 244
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 88
|
||||||
|
END
|
||||||
|
END
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Dialog
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 259, 210
|
||||||
|
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "About FreeLoader Debugger"
|
||||||
|
FONT 8, "Tahoma"
|
||||||
|
BEGIN
|
||||||
|
CONTROL "FreeLoader Debugger v1.0\nCopyright (C) 2003\nby Brian Palmer (brianp@reactos.org)",
|
||||||
|
IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,53,28,
|
||||||
|
122,26
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,183,189,44,14,WS_GROUP
|
||||||
|
ICON IDI_FDEBUG,IDC_STATIC,19,30,20,20
|
||||||
|
EDITTEXT IDC_LICENSE_EDIT,53,63,174,107,ES_MULTILINE |
|
||||||
|
ES_READONLY | WS_VSCROLL
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_CONNECTION DIALOG DISCARDABLE 0, 0, 196, 100
|
||||||
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Connection Options"
|
||||||
|
FONT 8, "Tahoma"
|
||||||
|
BEGIN
|
||||||
|
LTEXT "Enter the COM port (e.g. COM1):",IDC_STATIC,7,7,108,8
|
||||||
|
EDITTEXT IDC_COMPORT,7,17,182,14,ES_AUTOHSCROLL
|
||||||
|
LTEXT "Enter the baud rate (e.g. 115200):",IDC_STATIC,7,38,114,
|
||||||
|
8
|
||||||
|
EDITTEXT IDC_BAUTRATE,7,48,182,14,ES_AUTOHSCROLL
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,45,79,50,14
|
||||||
|
PUSHBUTTON "Cancel",IDCANCEL,100,79,50,14
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_CAPTURE DIALOG DISCARDABLE 0, 0, 251, 95
|
||||||
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "Capture File"
|
||||||
|
FONT 8, "Tahoma"
|
||||||
|
BEGIN
|
||||||
|
LTEXT "Capture File Name:",IDC_STATIC,7,17,62,8
|
||||||
|
EDITTEXT IDC_CAPTUREFILENAME,7,26,181,14,ES_AUTOHSCROLL
|
||||||
|
PUSHBUTTON "&Browse",IDC_BROWSE,194,26,50,14
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,139,74,50,14
|
||||||
|
PUSHBUTTON "Cancel",IDCANCEL,194,74,50,14
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// String Table
|
||||||
|
//
|
||||||
|
|
||||||
|
STRINGTABLE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
IDS_APP_TITLE "fdebug"
|
||||||
|
IDS_HELLO "Hello World!"
|
||||||
|
IDC_FDEBUG "FDEBUG"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRINGTABLE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
IDS_LICENSE "This program 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.\r\n\r\nThis program 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // English (U.S.) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
40
freeldr/fdebug/resource.h
Normal file
40
freeldr/fdebug/resource.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Developer Studio generated include file.
|
||||||
|
// Used by fdebug.rc
|
||||||
|
//
|
||||||
|
#define IDC_MYICON 2
|
||||||
|
#define IDD_FDEBUG_DIALOG 102
|
||||||
|
#define IDD_ABOUTBOX 103
|
||||||
|
#define IDS_APP_TITLE 103
|
||||||
|
#define IDM_ABOUT 104
|
||||||
|
#define IDM_EXIT 105
|
||||||
|
#define IDS_HELLO 106
|
||||||
|
#define IDI_FDEBUG 107
|
||||||
|
#define IDI_SMALL 108
|
||||||
|
#define IDC_FDEBUG 109
|
||||||
|
#define IDR_MAINFRAME 128
|
||||||
|
#define IDD_CONNECTION 130
|
||||||
|
#define IDD_CAPTURE 131
|
||||||
|
#define IDC_COMPORT 1000
|
||||||
|
#define IDC_BAUTRATE 1001
|
||||||
|
#define IDC_CAPTUREFILENAME 1002
|
||||||
|
#define IDC_BROWSE 1003
|
||||||
|
#define IDC_LICENSE_EDIT 1029
|
||||||
|
#define ID_FILE_CONNECT 32771
|
||||||
|
#define ID_FILE_DISCONNECT 32772
|
||||||
|
#define ID_FILE_STARTCAPTURE 32773
|
||||||
|
#define ID_FILE_STOPCAPTURE 32774
|
||||||
|
#define ID_FILE_LOCALECHO 32775
|
||||||
|
#define IDS_LICENSE 32815
|
||||||
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 132
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 32776
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1004
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 110
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -148,7 +148,7 @@ BOOL Rs232ConfigurePortWin32(TCHAR* DeviceControlString)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the timeouts
|
// Set the timeouts
|
||||||
if (!Rs232SetCommunicationTimeoutsWin32(MAXDWORD, MAXDWORD, 1000, 0, 0))
|
if (!Rs232SetCommunicationTimeoutsWin32(MAXDWORD, 0, 0, 0, 0))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue