1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| #include <stdio.h>
#include <conio.h>
#include <windows.h>
/* 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);
int main(void)
{
HINSTANCE hLib;
inpfuncPtr inp32;
oupfuncPtr oup32;
short x;
int i;
// Chargement de la librairie
hLib = LoadLibrary("inpout32.dll");
if (hLib == NULL)
{
printf("LoadLibrary Failed.\n");
return -1;
}
// Récupération de l'adresse de la fonction avec "GetProcAddress"
inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
// Vérification que la fonction existe
if (inp32 == NULL) {
printf("GetProcAddress for Inp32 Failed.\n");
return -1;
}
//Récupération de l'adresse de la fonction avec "GetProcAddress"
oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");
// Vérification que la fonction existe
if (oup32 == NULL) {
printf("GetProcAddress for Oup32 Failed.\n");
return -1;
}
//initialisation du port,
(oup32)(0x378 + 2, 0x00);
//allumer ma LED
(oup32)(0x378, 1<< 3);
//etteindre ma led
(oup32)(0x378, 0 << 3);
FreeLibrary(hLib);
return 0;
} |
Partager