-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAIN.CPP
90 lines (67 loc) · 2.1 KB
/
MAIN.CPP
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <stdlib.h>
#include<dos.h>
#include<windows.h>
#include<time.h>
int tempo=50; // eh o tempo usado entre um passo e outro
//char a=0x11, b=0x22, c=0x44, d=0x88; //normal dentro antihorario
//char a=0x88, b=0x44, c=0x22, d=0x11; //normal fora horario
char a=0x33, b=0x66, c=0xCC, d=0x99; //alto-torque dentro antihorario
//char a=0x99, b=0xCC, c=0x66, d=0x33; //alto-torque fora horario
using namespace std;
typedef short _stdcall (*inpfuncPtr)(short portaddr);
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);
void espera(int miliseconds)
{
clock_t endwait;
endwait = clock () + (miliseconds * CLK_TCK)/1000 ;
while (clock() < endwait) {}
}
int main(void)
{
HINSTANCE hLib;
inpfuncPtr inp32;
oupfuncPtr oup32;
/* Carrega a biblioteca */
hLib = LoadLibrary("inpout32.dll");
if (hLib == NULL)
{
printf("LoadLibrary Failed.\n");
return -1;
}
/* Pega o endereço da função */
inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
if (inp32 == NULL) //Caso não consiga carregar a função
{
printf("GetProcAddress for Inp32 Failed.\n");
return -1;
}
oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");
if (oup32 == NULL) //Caso não consiga carregar a função
{
printf("GetProcAddress for Oup32 Failed.\n");
return -1;
}
/*************************************************************************/
//(inp32)(i);
int entra;
while(true)
{
(oup32)(0x378, a);
entra = (inp32)(0x378);
espera(tempo);
printf("\n Entra %x", entra);
(oup32)(0x378, b);
entra = (inp32)(0x378);
espera(tempo);
printf("Entra %x", entra);
(oup32)(0x378, c);
entra = (inp32)(0x378);
espera(tempo);
printf("Entra %x", entra);
(oup32)(0x378, d);
entra = (inp32)(0x378);
espera(tempo);
printf("Entra %x", entra);
}//fim while
} //fim main