summaryrefslogtreecommitdiff
path: root/pyparallel/src
diff options
context:
space:
mode:
Diffstat (limited to 'pyparallel/src')
-rw-r--r--pyparallel/src/win32/README.txt23
-rw-r--r--pyparallel/src/win32/_pyparallel.c69
-rw-r--r--pyparallel/src/win32/giveio/GIVEIO.C168
-rw-r--r--pyparallel/src/win32/giveio/MAKEFILE7
-rw-r--r--pyparallel/src/win32/giveio/README.TXT92
-rw-r--r--pyparallel/src/win32/giveio/SOURCES7
-rw-r--r--pyparallel/src/win32/install_giveio.bat18
-rw-r--r--pyparallel/src/win32/loaddrv_console/loaddrv.c458
-rw-r--r--pyparallel/src/win32/loaddrv_console/loaddrv.h18
-rw-r--r--pyparallel/src/win32/loaddrv_console/makefile5
-rw-r--r--pyparallel/src/win32/remove_giveio.bat13
11 files changed, 0 insertions, 878 deletions
diff --git a/pyparallel/src/win32/README.txt b/pyparallel/src/win32/README.txt
deleted file mode 100644
index b2cb0af..0000000
--- a/pyparallel/src/win32/README.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-This extension is needed on Windows as there is no API to
-manipulate the parallel port. This Python extension exposes
-"inp()" and "outp()" that can be used to manipulate the printer
-IOs directly. It could be basicaly used to access any IO port.
-
-On Windows NT/2k/XP direct access to IOs is not possible for
-user applications (only kernel mode drivers). Because of that
-a kernel driver is needed. The sources to GIVEIO.SYS are in
-the respective directory. The loaddrv sources come from the
-archive that is mentioned in the giveio readme.
-
-If the extension detects that it is running on an NT based system
-(NT, 2k, XP) it activates the giveio driver to gain access to the
-IO ports. To make this work, the giveio driver must be installed.
-this can be done with the loaddrv tool. The batchfiles
-"install_giveio.bat" and "remove_giveio.bat" do whats needed to
-install or uninstall.
-
-Thanks go to
- Dale Roberts for the giveio driver and to
- Paula Tomlinson for the loaddrv sources
-
-chris <cliechti@gmx.net>
diff --git a/pyparallel/src/win32/_pyparallel.c b/pyparallel/src/win32/_pyparallel.c
deleted file mode 100644
index 6316de0..0000000
--- a/pyparallel/src/win32/_pyparallel.c
+++ /dev/null
@@ -1,69 +0,0 @@
-// Parallel port extension for Win32
-// "inp" and "outp" are used to access the parallelport hardware
-// needs giveio.sys driver on NT/2k/XP
-//
-// (C) 2002 Chris Liechti <cliechti@gmx.net>
-// this is distributed under a free software license, see license.txt
-
-#include <Python.h>
-#include <windows.h>
-#include <conio.h>
-
-#define DRIVERNAME "\\\\.\\giveio"
-
-/* module-functions */
-
-static PyObject*
-py_outp(PyObject *self, PyObject *args)
-{
- int port, value;
- if(!PyArg_ParseTuple(args, "ii", &port, &value))
- return 0;
- _outp(port, value);
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject*
-py_inp(PyObject *self, PyObject *args)
-{
- int port, value;
- if(!PyArg_ParseTuple(args, "i", &port))
- return 0;
- value = _inp(port);
- return Py_BuildValue("i", value);
-}
-
-
-
-static PyMethodDef pypar_methods[] = {
- {"outp", py_outp, METH_VARARGS},
- {"inp", py_inp, METH_VARARGS},
- {0, 0}
-};
-
-/* module entry-point (module-initialization) function */
-void init_pyparallel(void) {
- OSVERSIONINFO vi;
-
- /* Create the module and add the functions */
- Py_InitModule("_pyparallel", pypar_methods);
-
- //detect OS, on NT,2k,XP the driver needs to be loaded
- vi.dwOSVersionInfoSize = sizeof(vi);
- GetVersionEx(&vi);
- if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
- HANDLE h;
- //try to open driver
- h = CreateFile(DRIVERNAME, GENERIC_READ, 0, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (h == INVALID_HANDLE_VALUE) {
- //if it fails again, then we have a problem... -> exception
- PyErr_Format(PyExc_ImportError, "Couldn't access giveio device");
- }
- //close again immediately.
- //the process is now tagged to have the rights it needs,
- //the giveio driver remembers that
- if (h != NULL) CloseHandle(h); //close the driver's file
- }
-}
diff --git a/pyparallel/src/win32/giveio/GIVEIO.C b/pyparallel/src/win32/giveio/GIVEIO.C
deleted file mode 100644
index f752a29..0000000
--- a/pyparallel/src/win32/giveio/GIVEIO.C
+++ /dev/null
@@ -1,168 +0,0 @@
-/*********************************************************************
-
-Author: Dale Roberts
-Date: 8/30/95
-Program: GIVEIO.SYS
-Compile: Use DDK BUILD facility
-
-Purpose: Give direct port I/O access to a user mode process.
-
-*********************************************************************/
-#include <ntddk.h>
-
-/*
- * The name of our device driver.
- */
-#define DEVICE_NAME_STRING L"giveio"
-
-/*
- * This is the "structure" of the IOPM. It is just a simple
- * character array of length 0x2000.
- *
- * This holds 8K * 8 bits -> 64K bits of the IOPM, which maps the
- * entire 64K I/O space of the x86 processor. Any 0 bits will give
- * access to the corresponding port for user mode processes. Any 1
- * bits will disallow I/O access to the corresponding port.
- */
-#define IOPM_SIZE 0x2000
-typedef UCHAR IOPM[IOPM_SIZE];
-
-/*
- * This will hold simply an array of 0's which will be copied
- * into our actual IOPM in the TSS by Ke386SetIoAccessMap().
- * The memory is allocated at driver load time.
- */
-IOPM *IOPM_local = 0;
-
-/*
- * These are the two undocumented calls that we will use to give
- * the calling process I/O access.
- *
- * Ke386IoSetAccessMap() copies the passed map to the TSS.
- *
- * Ke386IoSetAccessProcess() adjusts the IOPM offset pointer so that
- * the newly copied map is actually used. Otherwise, the IOPM offset
- * points beyond the end of the TSS segment limit, causing any I/O
- * access by the user mode process to generate an exception.
- */
-void Ke386SetIoAccessMap(int, IOPM *);
-void Ke386QueryIoAccessMap(int, IOPM *);
-void Ke386IoSetAccessProcess(PEPROCESS, int);
-
-/*********************************************************************
- Release any allocated objects.
-*********************************************************************/
-VOID GiveioUnload(IN PDRIVER_OBJECT DriverObject)
-{
- WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING;
- UNICODE_STRING uniDOSString;
-
- if(IOPM_local)
- MmFreeNonCachedMemory(IOPM_local, sizeof(IOPM));
-
- RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);
- IoDeleteSymbolicLink (&uniDOSString);
- IoDeleteDevice(DriverObject->DeviceObject);
-}
-
-/*********************************************************************
- Set the IOPM (I/O permission map) of the calling process so that it
-is given full I/O access. Our IOPM_local[] array is all zeros, so
-the IOPM will be all zeros. If OnFlag is 1, the process is given I/O
-access. If it is 0, access is removed.
-*********************************************************************/
-VOID SetIOPermissionMap(int OnFlag)
-{
- Ke386IoSetAccessProcess(PsGetCurrentProcess(), OnFlag);
- Ke386SetIoAccessMap(1, IOPM_local);
-}
-
-void GiveIO(void)
-{
- SetIOPermissionMap(1);
-}
-
-/*********************************************************************
- Service handler for a CreateFile() user mode call.
-
- This routine is entered in the driver object function call table by
-the DriverEntry() routine. When the user mode application calls
-CreateFile(), this routine gets called while still in the context of
-the user mode application, but with the CPL (the processor's Current
-Privelege Level) set to 0. This allows us to do kernel mode
-operations. GiveIO() is called to give the calling process I/O
-access. All the user mode application needs do to obtain I/O access
-is open this device with CreateFile(). No other operations are
-required.
-*********************************************************************/
-NTSTATUS GiveioCreateDispatch(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp
- )
-{
- GiveIO(); // give the calling process I/O access
-
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
-}
-
-/*********************************************************************
- Driver Entry routine.
-
- This routine is called only once after the driver is initially
-loaded into memory. It allocates everything necessary for the
-driver's operation. In our case, it allocates memory for our IOPM
-array, and creates a device which user mode applications can open.
-It also creates a symbolic link to the device driver. This allows
-a user mode application to access our driver using the \\.\giveio
-notation.
-*********************************************************************/
-NTSTATUS DriverEntry(
- IN PDRIVER_OBJECT DriverObject,
- IN PUNICODE_STRING RegistryPath
- )
-{
- PDEVICE_OBJECT deviceObject;
- NTSTATUS status;
- WCHAR NameBuffer[] = L"\\Device\\" DEVICE_NAME_STRING;
- WCHAR DOSNameBuffer[] = L"\\DosDevices\\" DEVICE_NAME_STRING;
- UNICODE_STRING uniNameString, uniDOSString;
-
- //
- // Allocate a buffer for the local IOPM and zero it.
- //
- IOPM_local = MmAllocateNonCachedMemory(sizeof(IOPM));
- if(IOPM_local == 0)
- return STATUS_INSUFFICIENT_RESOURCES;
- RtlZeroMemory(IOPM_local, sizeof(IOPM));
-
- //
- // Set up device driver name and device object.
- //
- RtlInitUnicodeString(&uniNameString, NameBuffer);
- RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);
-
- status = IoCreateDevice(DriverObject, 0,
- &uniNameString,
- FILE_DEVICE_UNKNOWN,
- 0, FALSE, &deviceObject);
-
- if(!NT_SUCCESS(status))
- return status;
-
- status = IoCreateSymbolicLink (&uniDOSString, &uniNameString);
-
- if (!NT_SUCCESS(status))
- return status;
-
- //
- // Initialize the Driver Object with driver's entry points.
- // All we require are the Create and Unload operations.
- //
- DriverObject->MajorFunction[IRP_MJ_CREATE] = GiveioCreateDispatch;
- DriverObject->DriverUnload = GiveioUnload;
- return STATUS_SUCCESS;
-}
-
diff --git a/pyparallel/src/win32/giveio/MAKEFILE b/pyparallel/src/win32/giveio/MAKEFILE
deleted file mode 100644
index 5818975..0000000
--- a/pyparallel/src/win32/giveio/MAKEFILE
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
-# file to this component. This file merely indirects to the real make file
-# that is shared by all the driver components of the Windows NT DDK
-#
-
-!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/pyparallel/src/win32/giveio/README.TXT b/pyparallel/src/win32/giveio/README.TXT
deleted file mode 100644
index 4a6ec36..0000000
--- a/pyparallel/src/win32/giveio/README.TXT
+++ /dev/null
@@ -1,92 +0,0 @@
-The entire archive was pulled from here:
-Dr. Dobb's Journal, http://www.ddj.com/ftp/1996/1996.05/directio.zip
-It contained some other snippets too, but as they are not useful here
-I don't include them here.
-
-chris
-
-Following is the original readme of the archive:
------------------------------------------------------------------------------
-
-
-Author: Dale Roberts, Direct I/O and Windows NT
-
-
-Here are two helpful hints to get you going with GIVEIO. The first
-section below mentions the INSTDRV utility that is provided with the
-Microsoft DDK. If you do not have access to the DDK, you can use Paula
-Tomlinson's program LOADDRV instead. She describes it in her May 1995
-article in Windows/DOS Developer's Journal (now Windows Developer's
-Journal). You can get the program from their FTP site at:
-
- ftp://ftp.mfi.com/pub/windev/1995/may95.zip.
-
-
-------------------------------------------------------------------
-Device Driver Installation Made Easy
-
-The Microsoft NT Device Driver Kit documentation implies in several
-places that there are several steps involved in installing a device driver
-and making it accessible to a Win32 application. It explains that you
-should edit the registry manually and then reboot the system. But
-device drivers are dynamically loadable and unloadable in NT, and the
-DDK comes with a very handy utility called INSTDRV that
-demonstrates this facility in a very practical manner.
-
-INSTDRV is a console application that will register, load, and start a
-kernel mode device driver. It does not require you to edit the registry
-manually or reboot the computer. On the command line you simply
-give the name of your device driver and the complete path to the .SYS
-file (which does not need to be in the system's DRIVERS directory).
-After this command is executed, you will find that the driver has been
-registered with the system and appears in the Devices applet in the
-control panel. If you give the word remove instead of the path, the
-driver is removed from the system and taken out of the driver database.
-
-Once the driver is loaded and started, you can use the control panel's
-Devices applet to start and stop it, or you can use the net start and net
-stop commands (these are much faster) from a console window. When
-a kernel mode device is stopped, it is in also unloaded from memory.
-The next time you start the device, a fresh copy of the driver is read
-from the hard drive, if it has been modified. This makes it very
-convenient to develop device drivers, since you can go through the
-modify, stop, start cycle repeatedly without ever needing to reboot. If
-you need your driver to load at boot time, you can go into the Devices
-applet and change its startup mode to boot.
-
-The other component that is needed to make the driver visible to user
-mode applications, so they can use CreateFile() calls to access the
-driver, is registering the name in the DOS Devices name space. This
-can be done, as documented in the DDK, by editing the registry
-manually and rebooting. Or, much more simply, the kernel mode
-driver can call the IoCreateSymbolicLink() function to register the
-name itself. The GIVEIO driver shown in Listing Four uses the later
-technique. Once the name is registered, user mode applications can get
-a file handle to the device driver by calling CreateFile() with the driver
-name as the file parameter, but preceding the driver name with the
-special cookie \\.\. The TESTIO application in Listing Five uses this
-technique.
-
-------------------------------------------------------------------
-Quick Trick: Using DEBUG With Port I/O
-
-Sometimes you just need to do a quick I/O operation to a port. In DOS,
-you could use the DEBUG program to accomplish this. In NT, once
-you have the GIVEIO device driver up and running, you can once
-again use DEBUG for port I/O. If you look at the source code for the
-test application, you'll see that all it does is open and close the GIVEIO
-device driver. It uses the special cookie \\.\ before the driver name in
-order to access it. Without modifying DEBUG, you can have it open
-this device driver by simply typing debug \\.\giveio in an NT console
-window. You will get an error message complaining that the file
-\\.\giveio is not found, but it will give DEBUG I/O access anyway.
-Subsequent DOS applications that are run from this console window
-will also have I/O access.
-
-WIN32 applications executed from this console window will still cause
-exceptions. This is because DEBUG (and any other DOS application)
-runs in the context of the VDM (Virtual DOS Machine) process of the
-console box, whereas each WIN32 application gets its own process.
-The VDM process stays active as long as the console window is open,
-but each WIN32 application creates a brand new process with the
-IOPM offset initialized to point beyond the end of the TSS.
diff --git a/pyparallel/src/win32/giveio/SOURCES b/pyparallel/src/win32/giveio/SOURCES
deleted file mode 100644
index 1f8abef..0000000
--- a/pyparallel/src/win32/giveio/SOURCES
+++ /dev/null
@@ -1,7 +0,0 @@
-TARGETNAME=giveio
-TARGETPATH=.
-TARGETTYPE=DRIVER
-
-INCLUDES=c:\ddk\inc
-
-SOURCES=giveio.c
diff --git a/pyparallel/src/win32/install_giveio.bat b/pyparallel/src/win32/install_giveio.bat
deleted file mode 100644
index 79f1383..0000000
--- a/pyparallel/src/win32/install_giveio.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@set DIRVERNAME=giveio
-
-@echo Installing Windows NT/2k/XP driver: %DIRVERNAME%
-
-@loaddrv install %DIRVERNAME%
-@if errorlevel 3 goto error
-
-@loaddrv start %DIRVERNAME%
-@if errorlevel 1 goto error
-
-@loaddrv starttype %DIRVERNAME% auto
-@if errorlevel 1 goto error
-
-@goto exit
-:error
-@echo ERROR: Installation of %DIRVERNAME% failed
-:exit
-@pause
diff --git a/pyparallel/src/win32/loaddrv_console/loaddrv.c b/pyparallel/src/win32/loaddrv_console/loaddrv.c
deleted file mode 100644
index 99755fb..0000000
--- a/pyparallel/src/win32/loaddrv_console/loaddrv.c
+++ /dev/null
@@ -1,458 +0,0 @@
-// loaddrv.c - Dynamic driver install/start/stop/remove
-// based on Paula Tomlinson's LOADDRV program.
-// She describes it in her May 1995 article in Windows/DOS Developer's
-// Journal (now Windows Developer's Journal).
-// i removed the old/ugly dialog, it now accepts command line options and
-// prints error messages with textual description from the OS.
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "loaddrv.h"
-
-// globals
-SC_HANDLE hSCMan = NULL;
-
-//get ext messages for windows error codes:
-void DisplayErrorText(DWORD dwLastError) {
- LPSTR MessageBuffer;
- DWORD dwBufferLength;
-
- DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_IGNORE_INSERTS |
- FORMAT_MESSAGE_FROM_SYSTEM;
-
- dwBufferLength = FormatMessageA(
- dwFormatFlags,
- NULL, // module to get message from (NULL == system)
- dwLastError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
- (LPSTR) &MessageBuffer,
- 0,
- NULL
- );
- if (dwBufferLength) {
- // Output message
- puts(MessageBuffer);
- // Free the buffer allocated by the system.
- LocalFree(MessageBuffer);
- }
-}
-
-int exists(char *filename) {
- FILE * pFile;
- pFile = fopen(filename, "r");
- return pFile != NULL;
-}
-
-void usage(void) {
- printf("USGAE: loaddrv command drivername [args...]\n\n"
- "NT/2k/XP Driver and Service modification tool.\n"
- "(C)2002 Chris Liechti <cliechti@gmx.net>\n\n"
- "Suported commands:\n\n"
- " install [fullpathforinstall]\n"
- " Install new service. Loaded from given path. If path is not present,\n"
- " the local directory is searched for a .sys file. If the service\n"
- " already exists, it must be removed first.\n"
- " start\n"
- " Start service. It must be installed in advance.\n"
- " stop\n"
- " Stop service.\n"
- " remove\n"
- " Remove service. It must be stopped in advance.\n"
- " status\n"
- " Show status information about service.\n"
- " starttype auto|manual|system|disable\n"
- " Change startup type to the given type.\n"
- );
-}
-
-int main(int argc, char *argv[]) {
- DWORD status = 0;
- int level = 0;
- if (argc < 3) {
- usage();
- exit(1);
- }
- LoadDriverInit();
- if (strcmp(argv[1], "start") == 0) {
- printf("starting %s... ", argv[2]);
- status = DriverStart(argv[2]);
- if ( status != OKAY) {
- printf("start failed (status %ld):\n", status);
- level = 1;
- } else {
- printf("ok.\n");
- }
- } else if (strcmp(argv[1], "stop") == 0) {
- printf("stoping %s... ", argv[2]);
- status = DriverStop(argv[2]);
- if ( status != OKAY) {
- printf("stop failed (status %ld):\n", status);
- level = 1;
- } else {
- printf("ok.\n");
- }
- } else if (strcmp(argv[1], "install") == 0) {
- char path[MAX_PATH*2];
- if (argc<4) {
- char cwd[MAX_PATH];
- getcwd(cwd, sizeof cwd);
- sprintf(path, "%s\\%s.sys", cwd, argv[2]);
- } else {
- strncpy(path, argv[3], MAX_PATH);
- }
- if (exists(path)) {
- printf("installing %s from %s... ", argv[2], path);
- status = DriverInstall(path, argv[2]);
- if ( status != OKAY) {
- printf("install failed (status %ld):\n", status);
- level = 2;
- } else {
- printf("ok.\n");
- }
- } else {
- printf("install failed, file not found: %s\n", path);
- level = 1;
- }
- } else if (strcmp(argv[1], "remove") == 0) {
- printf("removing %s... ", argv[2]);
- status = DriverRemove(argv[2]);
- if ( status != OKAY) {
- printf("remove failed (status %ld):\n", status);
- level = 1;
- } else {
- printf("ok.\n");
- }
- } else if (strcmp(argv[1], "status") == 0) {
- printf("status of %s:\n", argv[2]);
- status = DriverStatus(argv[2]);
- if ( status != OKAY) {
- printf("stat failed (status %ld):\n", status);
- level = 1;
- } else {
- printf("ok.\n");
- }
- } else if (strcmp(argv[1], "starttype") == 0) {
- if (argc < 4) {
- printf("Error: need start type (string) as argument.\n");
- level = 2;
- } else {
- DWORD type = 0;
- printf("set start type of %s to %s... ", argv[2], argv[3]);
- if (strcmp(argv[1], "boot") == 0) {
- type = SERVICE_BOOT_START;
- } else if (strcmp(argv[3], "system") == 0) {
- type = SERVICE_SYSTEM_START;
- } else if (strcmp(argv[3], "auto") == 0) {
- type = SERVICE_AUTO_START;
- } else if (strcmp(argv[3], "manual") == 0) {
- type = SERVICE_DEMAND_START;
- } else if (strcmp(argv[3], "disabled") == 0) {
- type = SERVICE_DISABLED;
- } else {
- printf("unknown type\n");
- level = 1;
- }
- if (level == 0) {
- status = DriverStartType(argv[2], type);
- if ( status != OKAY) {
- printf("set start type failed (status %ld):\n", status);
- level = 1;
- } else {
- printf("ok.\n");
- }
- }
- }
- } else {
- usage();
- level = 1;
- }
- if (status) DisplayErrorText(status);
- LoadDriverCleanup();
- exit(level);
- return 0;
-}
-
-
-DWORD LoadDriverInit(void) {
- // connect to local service control manager
- if ((hSCMan = OpenSCManager(NULL, NULL,
- SC_MANAGER_ALL_ACCESS)) == NULL) {
- return -1;
- }
- return OKAY;
-}
-
-void LoadDriverCleanup(void) {
- if (hSCMan != NULL) CloseServiceHandle(hSCMan);
-}
-
-/**-----------------------------------------------------**/
-DWORD DriverInstall(LPSTR lpPath, LPSTR lpDriver) {
- BOOL dwStatus = OKAY;
- SC_HANDLE hService = NULL;
-
- // add to service control manager's database
- if ((hService = CreateService(hSCMan, lpDriver,
- lpDriver, SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,
- SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, lpPath,
- NULL, NULL, NULL, NULL, NULL)) == NULL)
- dwStatus = GetLastError();
- else CloseServiceHandle(hService);
-
- return dwStatus;
-} // DriverInstall
-
-/**-----------------------------------------------------**/
-DWORD DriverStart(LPSTR lpDriver) {
- BOOL dwStatus = OKAY;
- SC_HANDLE hService = NULL;
-
- // get a handle to the service
- if ((hService = OpenService(hSCMan, lpDriver,
- SERVICE_ALL_ACCESS)) != NULL)
- {
- // start the driver
- if (!StartService(hService, 0, NULL))
- dwStatus = GetLastError();
- } else dwStatus = GetLastError();
-
- if (hService != NULL) CloseServiceHandle(hService);
- return dwStatus;
-} // DriverStart
-
-/**-----------------------------------------------------**/
-DWORD DriverStop(LPSTR lpDriver)
-{
- BOOL dwStatus = OKAY;
- SC_HANDLE hService = NULL;
- SERVICE_STATUS serviceStatus;
-
- // get a handle to the service
- if ((hService = OpenService(hSCMan, lpDriver,
- SERVICE_ALL_ACCESS)) != NULL)
- {
- // stop the driver
- if (!ControlService(hService, SERVICE_CONTROL_STOP,
- &serviceStatus))
- dwStatus = GetLastError();
- } else dwStatus = GetLastError();
-
- if (hService != NULL) CloseServiceHandle(hService);
- return dwStatus;
-} // DriverStop
-
-/**-----------------------------------------------------**/
-DWORD DriverRemove(LPSTR lpDriver)
-{
- BOOL dwStatus = OKAY;
- SC_HANDLE hService = NULL;
-
- // get a handle to the service
- if ((hService = OpenService(hSCMan, lpDriver,
- SERVICE_ALL_ACCESS)) != NULL)
- { // remove the driver
- if (!DeleteService(hService))
- dwStatus = GetLastError();
- } else dwStatus = GetLastError();
-
- if (hService != NULL) CloseServiceHandle(hService);
- return dwStatus;
-} // DriverRemove
-
-/**-----------------------------------------------------**/
-////extensions by Lch
-/**-----------------------------------------------------**/
-DWORD DriverStatus(LPSTR lpDriver) {
- BOOL dwStatus = OKAY;
- SC_HANDLE hService = NULL;
- DWORD dwBytesNeeded;
-
- // get a handle to the service
- if ((hService = OpenService(hSCMan, lpDriver,
- SERVICE_ALL_ACCESS)) != NULL)
- {
- LPQUERY_SERVICE_CONFIG lpqscBuf;
- //~ LPSERVICE_DESCRIPTION lpqscBuf2;
- // Allocate a buffer for the configuration information.
- if ((lpqscBuf = (LPQUERY_SERVICE_CONFIG) LocalAlloc(
- LPTR, 4096)) != NULL)
- {
- //~ if ((lpqscBuf2 = (LPSERVICE_DESCRIPTION) LocalAlloc(
- //~ LPTR, 4096)) != NULL)
- {
- // Get the configuration information.
- if (QueryServiceConfig(
- hService,
- lpqscBuf,
- 4096,
- &dwBytesNeeded) //&&
- //~ QueryServiceConfig2(
- //~ hService,
- //~ SERVICE_CONFIG_DESCRIPTION,
- //~ lpqscBuf2,
- //~ 4096,
- //~ &dwBytesNeeded
- )
- {
- // Print the configuration information.
- printf("Type: [0x%02lx] ", lpqscBuf->dwServiceType);
- switch (lpqscBuf->dwServiceType) {
- case SERVICE_WIN32_OWN_PROCESS:
- printf("The service runs in its own process.");
- break;
- case SERVICE_WIN32_SHARE_PROCESS:
- printf("The service shares a process with other services.");
- break;
- case SERVICE_KERNEL_DRIVER:
- printf("Kernel driver.");
- break;
- case SERVICE_FILE_SYSTEM_DRIVER:
- printf("File system driver.");
- break;
- case SERVICE_INTERACTIVE_PROCESS:
- printf("The service can interact with the desktop.");
- break;
- default:
- printf("Unknown type.");
- }
- printf("\nStart Type: [0x%02lx] ", lpqscBuf->dwStartType);
- switch (lpqscBuf->dwStartType) {
- case SERVICE_BOOT_START:
- printf("Boot");
- break;
- case SERVICE_SYSTEM_START:
- printf("System");
- break;
- case SERVICE_AUTO_START:
- printf("Automatic");
- break;
- case SERVICE_DEMAND_START:
- printf("Manual");
- break;
- case SERVICE_DISABLED:
- printf("Disabled");
- break;
- default:
- printf("Unknown.");
- }
- printf("\nError Control: [0x%02lx] ", lpqscBuf->dwErrorControl);
- switch (lpqscBuf->dwErrorControl) {
- case SERVICE_ERROR_IGNORE:
- printf("IGNORE: Ignore.");
- break;
- case SERVICE_ERROR_NORMAL:
- printf("NORMAL: Display a message box.");
- break;
- case SERVICE_ERROR_SEVERE:
- printf("SEVERE: Restart with last-known-good config.");
- break;
- case SERVICE_ERROR_CRITICAL:
- printf("CRITICAL: Restart w/ last-known-good config.");
- break;
- default:
- printf("Unknown.");
- }
- printf("\nBinary path: %s\n", lpqscBuf->lpBinaryPathName);
-
- if (lpqscBuf->lpLoadOrderGroup != NULL)
- printf("Load order grp: %s\n", lpqscBuf->lpLoadOrderGroup);
- if (lpqscBuf->dwTagId != 0)
- printf("Tag ID: %ld\n", lpqscBuf->dwTagId);
- if (lpqscBuf->lpDependencies != NULL)
- printf("Dependencies: %s\n", lpqscBuf->lpDependencies);
- if (lpqscBuf->lpServiceStartName != NULL)
- printf("Start Name: %s\n", lpqscBuf->lpServiceStartName);
- //~ if (lpqscBuf2->lpDescription != NULL)
- //~ printf("Description: %s\n", lpqscBuf2->lpDescription);
- }
- //~ LocalFree(lpqscBuf2);
- }
- LocalFree(lpqscBuf);
- } else {
- dwStatus = GetLastError();
- }
- } else {
- dwStatus = GetLastError();
- }
-
- if (hService != NULL) CloseServiceHandle(hService);
- return dwStatus;
-} // DriverStatus
-
-/**-----------------------------------------------------**/
-DWORD DriverStartType(LPSTR lpDriver, DWORD dwStartType) {
- BOOL dwStatus = OKAY;
- SC_HANDLE hService = NULL;
-
- SC_LOCK sclLock;
- LPQUERY_SERVICE_LOCK_STATUS lpqslsBuf;
- DWORD dwBytesNeeded;
-
- // Need to acquire database lock before reconfiguring.
- sclLock = LockServiceDatabase(hSCMan);
-
- // If the database cannot be locked, report the details.
- if (sclLock == NULL) {
- // Exit if the database is not locked by another process.
- if (GetLastError() == ERROR_SERVICE_DATABASE_LOCKED) {
-
- // Allocate a buffer to get details about the lock.
- lpqslsBuf = (LPQUERY_SERVICE_LOCK_STATUS) LocalAlloc(
- LPTR, sizeof(QUERY_SERVICE_LOCK_STATUS)+256);
- if (lpqslsBuf != NULL) {
- // Get and print the lock status information.
- if (QueryServiceLockStatus(
- hSCMan,
- lpqslsBuf,
- sizeof(QUERY_SERVICE_LOCK_STATUS)+256,
- &dwBytesNeeded) )
- {
- if (lpqslsBuf->fIsLocked) {
- printf("Locked by: %s, duration: %ld seconds\n",
- lpqslsBuf->lpLockOwner,
- lpqslsBuf->dwLockDuration
- );
- } else {
- printf("No longer locked\n");
- }
- }
- LocalFree(lpqslsBuf);
- }
- }
- dwStatus = GetLastError();
- } else {
- // The database is locked, so it is safe to make changes.
- // Open a handle to the service.
- hService = OpenService(
- hSCMan, // SCManager database
- lpDriver, // name of service
- SERVICE_CHANGE_CONFIG
- ); // need CHANGE access
- if (hService != NULL) {
- // Make the changes.
- if (!ChangeServiceConfig(
- hService, // handle of service
- SERVICE_NO_CHANGE, // service type: no change
- dwStartType, // change service start type
- SERVICE_NO_CHANGE, // error control: no change
- NULL, // binary path: no change
- NULL, // load order group: no change
- NULL, // tag ID: no change
- NULL, // dependencies: no change
- NULL, // account name: no change
- NULL, // password: no change
- NULL) ) // display name: no change
- {
- dwStatus = GetLastError();
- }
- }
- // Release the database lock.
- UnlockServiceDatabase(sclLock);
- }
-
- if (hService != NULL) CloseServiceHandle(hService);
- return dwStatus;
-} // DriverStartType
diff --git a/pyparallel/src/win32/loaddrv_console/loaddrv.h b/pyparallel/src/win32/loaddrv_console/loaddrv.h
deleted file mode 100644
index e09b276..0000000
--- a/pyparallel/src/win32/loaddrv_console/loaddrv.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef LOADDRV_H
-#define LOADDRV_H
-
-#include <windows.h>
-
-#define OKAY 0
-#define UNEXPECTED_ERROR 9999
-
-//prototypes
-DWORD LoadDriverInit(void);
-void LoadDriverCleanup(void);
-DWORD DriverInstall(LPSTR, LPSTR);
-DWORD DriverStart(LPSTR);
-DWORD DriverStop(LPSTR);
-DWORD DriverRemove(LPSTR);
-DWORD DriverStatus(LPSTR);
-DWORD DriverStartType(LPSTR, DWORD);
-#endif //LOADDRV_H \ No newline at end of file
diff --git a/pyparallel/src/win32/loaddrv_console/makefile b/pyparallel/src/win32/loaddrv_console/makefile
deleted file mode 100644
index d09ec29..0000000
--- a/pyparallel/src/win32/loaddrv_console/makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-COPT = -O2 -Wall -g -mno-cygwin
-
-loaddrv.exe: loaddrv.c loaddrv.h
- gcc ${COPT} $< -o $@
- strip $@
diff --git a/pyparallel/src/win32/remove_giveio.bat b/pyparallel/src/win32/remove_giveio.bat
deleted file mode 100644
index c75caea..0000000
--- a/pyparallel/src/win32/remove_giveio.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-@set DIRVERNAME=giveio
-
-@loaddrv stop %DIRVERNAME%
-@if errorlevel 2 goto error
-
-@loaddrv remove %DIRVERNAME%
-@if errorlevel 1 goto error
-@goto exit
-
-:error
-@echo ERROR: Deinstallation of %DIRVERNAME% failed
-:exit
-@pause