Source file: /~heha/hsn/glpntdrv.zip/h#s/glpntdrv.h

#pragma once

#ifdef DRIVER		// Kopfdatei auch für User-Mode-Programme zugänglich machen

extern "C" {
#include <ntddk.h>
#include <parallel.h>
}

#define elemof(x) (sizeof(x)/sizeof(*(x)))
typedef ULONG BOOL;	// Das DDK kennt kein BOOL, BYTE, WORD, DWORD. Leider.

#endif//DRIVER

/******************
 ** glpntdrv.cpp **
 ******************/

#define IOCTL_GALEP CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_NEITHER,FILE_ANY_ACCESS)	// 0x00222003
// Dieser IOCTL ist nicht thread-sicher, ja nicht einmal geräte-sicher.

// Bidirektionaler Kommandopuffer für obiges IOCTL_GALEP
// Enthält Mikrokode zur Ausführung im Kernel-Mode (oder USB-Mikrocontroller) ohne Ringübergänge
// Genau diese Datenstruktur wird beim Aufruf von GLPWOW.DLL:ExecKernelDriver() durchgereicht; nichts weiter.
// Daher kann man (sicherlich) auch durch Ersetzen der GLPWOW.DLL Treiber- und USB-Probleme lösen.
struct CMDBUF{		//sizeof=0x9CA0
 ULONG errorcode;	// Fehlerkode
			// 0 kein Fehler (wird beim DeviceIoControl-Handler zurückgesetzt)
			// 1000 bei SetLptAddress{19} FindAndAllocatePort()
			// 1001 bei Funktionsnummer > 24
			// 1002 bei SetLptAddress{19} HalTranslateBusAddress()
 ULONG retval;		// Returnkode vieler Funktionen (diese können blödsinnigerweise nicht gestapelt werden)
 ULONG BusySpeed;	// Ermittelte BUSY-Geschwindigkeit
 ULONG BAADFOOD[8];	// ungenutzt im Treiber
 struct{		// Liste mit (bis zu) 5000 argn+func-Paaren, gewissermaßen Mikrokode, vergleichbar USB2LPT-API
  ULONG arg;		// Funktionsparameter
  ULONG func;		// Funktionsindex 0..24, die 24 schließt die Liste ab. Siehe kdoio.cpp:Funktionstabelle
 }n[5000];
 ULONG address;		// Zugewiesene Adresse des Parallelports (wie's scheint)
 long loopcount;	// Wiederholungszähler für in-modify-out auf Datenport (unveränderliche Daten! Schwerhörigkeit?)
 long busywaitcount;	// Anzahl verworfener IN bis zum Auswerten von Busy (Spike-Filter)
 long busyloopcount;	// Max. Anzahl von (busywaitcount+1) IN bis zum Akzeptieren von BUSY (svw. TimeOut)
 bool flag_9C7C;	// KrnlInterfaceHdw::ResetL1_Q00() testet und setzt es auf <false>, niemand auf <true>
 UCHAR flag_9C7D;	// Parameter für ResetL1 (unklar)
 UCHAR flag_9C7E;	// Parameter für SetL1 (unklar)
 UCHAR flag_9C7F;	// KrnlInterfaceHdw::SetL1_Q11() testet und setzt es auf 0x10, niemand löscht es
 ULONG DEADBEEF[7];	// ungenutzt im Treiber
 bool interfacemode;	// SetL1 und ResetL1 setzen auf <true>, viele andere Funktionen auf <false>
 UCHAR unused[3];	// zur DWORD-Ausrichtung
};

#ifdef DRIVER		// Der Rest interessiert User-Mode-Programme nicht

/**************************
 ** KrnlInterfaceHdw.cpp **
 **************************/

class BasicIO {
protected:
 CMDBUF *pCmdBuf;
 ULONG lptport;
 UCHAR old[3];		// Backups für die Schreibports
 void WRITE(int offset, UCHAR data);
 UCHAR READ(int offset);
 UCHAR Busy();
 void DataOut(UCHAR b);
};

class KrnlInterfaceHdw:public BasicIO {
protected:
// ULONG DisableCallCount;
// bool IsIrplHigh;
// UCHAR OldIrql;

// void SetIrqlHigh();
// void ResetIrql() const;
 ULONG WaitForNotBusy();
 void SwitchInterfaceMode(bool);
 void SetL1_Q11();
 void ResetL1_Q00();
 void SetReadbackChannel(UCHAR);
 ULONG ReadDatenReg(UCHAR,int);
 static ULONG CalcTimerWert(ULONG val) {return 0x10000-(val>>1);}
 void LoadTimerSerReg(ULONG);
 void StartPgmImpuls();
 bool MeasureBusySpeed();
// void Enable();
};

class GALEP:public KrnlInterfaceHdw {
 PDEVICE_OBJECT pDevObj;
 bool PortExternBusy;
 bool PortAllocFlag;
 PPARALLEL_TRY_ALLOCATE_ROUTINE allocfunc;
 PPARALLEL_FREE_ROUTINE freefunc;
 PVOID context;
 long OldAddr;

 NTSTATUS FindAndAllocParallelPort(ULONG addr);
 long SetLPTAddress(long);
 static long(GALEP::*const vtbl[25])(long);

 long Nop(long);
 long Out(long);
 long Move(long);
 long in(long);
 long Clock(long);
 long Fastout(long);
 long Strobe(long);
 long QuickBusy(long);
 long SetINI(long);
 long Busy(long);
 long DataOut(long);
 long ReadDatenRegByte(long);
 long ReadDatenRegWord(long);
 long ReadDatenRegPin1_20(long);
 long ReadDatenRegPin21_40(long);
 long ExternalDelay(long);
// long Disable(long);
 long MeasureBusySpeed(long);
 long WaitForNotBusy(long);
 long GetKernelVer(long);
public:
 long FreePort(long);	// Freigabe bei IRP_MJ_CLOSE
 void doio(PDEVICE_OBJECT,CMDBUF*);		// Arbeitspferd von DeviceIoControl()
};

#endif//DRIVER
Detected encoding: ANSI (CP1252)4
Wrong umlauts? - Assume file is ANSI (CP1252) encoded