From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- fddnotify/fdd.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 fddnotify/fdd.c (limited to 'fddnotify/fdd.c') diff --git a/fddnotify/fdd.c b/fddnotify/fdd.c new file mode 100644 index 0000000..3d91b38 --- /dev/null +++ b/fddnotify/fdd.c @@ -0,0 +1,81 @@ +/* + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include "porttalk_IOCTL.h" + + +// Globals +extern BOOL bWindowsNT; +HANDLE hFddDev=INVALID_HANDLE_VALUE; + + +void outportb(UINT portid, BYTE value) +{ + __asm mov edx,portid + __asm mov al,value + __asm out dx,al +} + +BOOL OpenFddDevice(void) +{ + if (!bWindowsNT) + return TRUE; + + if((hFddDev = CreateFile("\\\\.\\PortTalk", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) + return FALSE; + + return TRUE; +} + +BOOL ToggleFddLight(BYTE drive, BYTE status) +{ + DWORD BytesReturned; + unsigned char Buffer[3]; + unsigned short *pBuffer; + BYTE value = status<<(drive|4)|drive|12; + + if (!bWindowsNT) { + outportb(0x3F2, value); + return TRUE; + } + + if (hFddDev == INVALID_HANDLE_VALUE) + return FALSE; + + pBuffer = (unsigned short *)&Buffer[0]; + *pBuffer = 0x3F2; + Buffer[2] = (unsigned char)value; + + if (!DeviceIoControl(hFddDev, IOCTL_WRITE_PORT_UCHAR, &Buffer, 3, NULL, 0, &BytesReturned, NULL)) + return FALSE; + + return TRUE; +} + +void CloseFddDevice(void) +{ + if (!bWindowsNT) + return; + + if (hFddDev != INVALID_HANDLE_VALUE) + CloseHandle(hFddDev); +} -- cgit v1.2.3