Hallo Leute,
ich bin gerade am verzweifeln, versuche seit Tagen auf meinem Druckerport Hexzahlen zu schreiben, aber Windows kommt permanent mit einem Fehler in meiner Anwendung. „unknown software exception 0x0000096…“
Die „inpout32.dll“ habe ich in das System32 Verzeichnis kopiert.
Hier mein Quelltext:
#include
#include
#include
#include
/* Definitions in the build of inpout32.dll are: */
/* short _stdcall Inp32(short PortAddress); */
/* void _stdcall Out32(short PortAddress, short data); */
/* prototype (function typedef) for DLL function Inp32: */
typedef short _stdcall (*inpfuncPtr)(short portaddr);
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);
#define PPORT_BASE 0x378
/* Prototypes for Test functions */
void test_read8(void);
void test_write(void);
void test_write_datum(short datum);
HINSTANCE hLib;
/* After successful initialization, these 2 variables
will contain function pointers.
*/
inpfuncPtr inp32fp;
oupfuncPtr oup32fp;
/* Wrapper functions for the function pointers
- call these functions to perform I/O.
*/
short Inp32 (short portaddr)
{
return (inp32fp)(portaddr);
}
void Out32 (short portaddr, short datum)
{
(oup32fp)(portaddr,datum);
}
int main(void)
{
// HINSTANCE hLib;
short x;
int i;
/* Load the library */
hLib = LoadLibrary(„inpout32.dll“);
if (hLib == NULL) {
fprintf(stderr,„LoadLibrary Failed.\n“);
return -1;
}
/* get the address of the function */
inp32fp = (inpfuncPtr) GetProcAddress(hLib, „Inp32“);
if (inp32fp == NULL) {
fprintf(stderr,„GetProcAddress for Inp32 Failed.\n“);
return -1;
}
oup32fp = (oupfuncPtr) GetProcAddress(hLib, „Out32“);
if (oup32fp == NULL) {
fprintf(stderr,„GetProcAddress for Oup32 Failed.\n“);
return -1;
}
/*******************************************************/
/** IF WE REACHED HERE, INITIALIZED SUCCESSFUL ******/
/*******************************************************/
/* now test the functions */
/***** Read 8 bytes at I/O base address */
/* test_read8(); */
/***** Write 0x75 to data register and verify */
test_write();
/***** One more time, different value */
/* test_write_datum(0xAA); */
/* finished - unload library and exit */
/* FreeLibrary(hLib); */
return 0;
}
/*
TEST: Read inputs of 8 registers from PORT_BASE address
*/
void test_read8(void) {
short x;
int i;
/* Try to read 0x378…0x37F, LPT1: */
for (i=PPORT_BASE; (i