15 static void remove_driver(
void )
18 SERVICE_STATUS status;
20 manager = OpenSCManager(
NULL,
NULL, GENERIC_ALL );
22 service = OpenService( manager,
"fbportio", SERVICE_ALL_ACCESS );
24 ControlService( service, SERVICE_CONTROL_STOP, &status );
25 DeleteService( service );
26 CloseServiceHandle( service );
28 CloseServiceHandle( manager );
32 static SC_HANDLE install_driver( SC_HANDLE manager )
34 SC_HANDLE service =
NULL;
39 if( GetSystemDirectory( driver_filename,
MAX_PATH ) ) {
40 strncat( driver_filename,
"\\Drivers\\fbportio.sys",
MAX_PATH - strlen( driver_filename ) - 1 );
43 FILE *
f = fopen( driver_filename,
"wb" );
47 service = CreateService( manager,
"fbportio",
"fbportio",
48 SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
54 static void start_driver(
void )
58 manager = OpenSCManager(
NULL,
NULL, GENERIC_ALL );
60 manager = OpenSCManager(
NULL,
NULL, GENERIC_READ );
62 service = OpenService( manager,
"fbportio", SERVICE_ALL_ACCESS );
63 if( (!service ) || (!StartService( service, 0,
NULL ) ) ) {
65 CloseServiceHandle( service );
66 service = install_driver( manager );
67 StartService( service, 0,
NULL );
69 CloseServiceHandle( service );
70 CloseServiceHandle( manager );
74 static int init_ports(
void )
76 OSVERSIONINFO ver_info;
78 DWORD pid, bytes_written;
80 int status, started =
FALSE;
82 memset( &ver_info, 0,
sizeof(OSVERSIONINFO) );
83 ver_info.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
84 if ( !GetVersionEx( (OSVERSIONINFO *)&ver_info ) )
86 switch (ver_info.dwPlatformId) {
88 case VER_PLATFORM_WIN32_WINDOWS:
91 case VER_PLATFORM_WIN32_NT:
93 driver = CreateFile(
"\\\\.\\fbportio", GENERIC_READ | GENERIC_WRITE, 0,
NULL,
94 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL );
95 if( driver == INVALID_HANDLE_VALUE ) {
107 CloseHandle( driver );
111 driver = INVALID_HANDLE_VALUE;
116 }
while( driver == INVALID_HANDLE_VALUE );
119 pid = GetCurrentProcessId( );
121 CloseHandle( driver );
134 int fb_hIn(
unsigned short port )
143 __asm__
volatile (
"inb %1, %0" :
"=a" (value) :
"d" (port));
148 int fb_hOut(
unsigned short port,
unsigned char value )
155 __asm__
volatile (
"outb %0, %1" : :
"a" (value),
"d" (port));
167 int fb_hOut(
unsigned short port,
unsigned char value )