|
From: Marcel T. <te...@us...> - 2002-07-17 14:59:04
|
Update of /cvsroot/openwince/tools/ioperm/admin
In directory usw-pr-cvs1:/tmp/cvs-serv13439/admin
Added Files:
.cvsignore Makefile.am install.c ioperm.c uninstall.c
Log Message:
Added admin tools (ioperm.exe) for install/uninstall ioperm.sys.
--- NEW FILE: .cvsignore ---
Makefile
Makefile.in
--- NEW FILE: Makefile.am ---
#
# $Id: Makefile.am,v 1.1 2002/07/17 14:59:01 telka Exp $
#
# ioperm driver implementation
# Copyright (C) 2002 ETC s.r.o.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# Written by Marcel Telka <ma...@te...>, 2002.
#
bin_PROGRAMS = ioperm
ioperm_SOURCES = \
ioperm.c \
install.c \
uninstall.c
--- NEW FILE: install.c ---
/*
* $Id: install.c,v 1.1 2002/07/17 14:59:01 telka Exp $
*
* Copyright (C) 2002 ETC s.r.o.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by Marcel Telka <ma...@te...>, 2002.
*
*/
#include <windows.h>
#include <stdio.h>
#include <sys/cygwin.h>
int
install( void )
{
SC_HANDLE scm;
SC_HANDLE svc;
char drv_path[MAX_PATH];
printf( "Installing ioperm.sys...\n" );
printf( "%-20s", "OpenSCManager" );
scm = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (scm == NULL) {
printf( "failed\n" );
return 0;
}
printf( "ok\n" );
cygwin_conv_to_full_win32_path( "/bin/ioperm.sys", drv_path );
printf( "%-20s", "CreateService" );
svc = CreateService( scm, TEXT("ioperm"), TEXT("ioperm"), SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, drv_path, NULL, NULL, NULL, NULL, NULL );
if (svc == NULL) {
printf( "failed\n" );
CloseServiceHandle( scm );
return 0;
}
printf( "ok\n" );
printf( "%-20s", "StartService" );
if (!StartService( svc, 0, NULL ))
printf( "failed\n" );
else
printf( "ok\n" );
CloseServiceHandle( svc );
CloseServiceHandle( scm );
return 1;
}
--- NEW FILE: ioperm.c ---
/*
* $Id: ioperm.c,v 1.1 2002/07/17 14:59:01 telka Exp $
*
* Copyright (C) 2002 ETC s.r.o.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by Marcel Telka <ma...@te...>, 2002.
*
*/
#include <stdio.h>
int install( void );
int uninstall( void );
int
main( int argc, char **argv )
{
int i, u;
if (argc != 2) {
printf( "Missing argument. Use '-i' or '-u'.\n" );
return -1;
}
i = !strcmp( argv[1], "-i" );
u = !strcmp( argv[1], "-u" );
if (!i && !u) {
printf( "Invalid argument. Use '-i' or '-u'.\n" );
return -1;
}
if (i) {
if (!install())
printf( "\nInstallation failed.\n" );
else
printf( "\nInstallation ok.\n" );
}
if (u) {
if (!uninstall())
printf( "\nUninstallation failed.\n" );
else
printf( "\nUninstallation ok.\n" );
}
return 0;
}
--- NEW FILE: uninstall.c ---
/*
* $Id: uninstall.c,v 1.1 2002/07/17 14:59:01 telka Exp $
*
* Copyright (C) 2002 ETC s.r.o.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by Marcel Telka <ma...@te...>, 2002.
*
*/
#include <windows.h>
#include <stdio.h>
int
uninstall( void )
{
SC_HANDLE scm;
SC_HANDLE svc;
SERVICE_STATUS stat;
printf( "Uninstalling ioperm.sys...\n" );
printf( "%-20s", "OpenSCManager" );
scm = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (scm == NULL) {
printf( "failed\n" );
return 0;
}
printf( "ok\n" );
printf( "%-20s", "OpenService" );
svc = OpenService( scm, TEXT("ioperm"), SERVICE_ALL_ACCESS );
if (svc == NULL) {
printf( "failed\n" );
CloseServiceHandle( scm );
return 0;
}
printf( "ok\n" );
printf( "%-20s", "DeleteService" );
if (!DeleteService( svc )) {
printf( "failed\n" );
CloseServiceHandle( svc );
CloseServiceHandle( scm );
return 0;
}
printf( "ok\n" );
printf( "%-20s", "ControlService()" );
if (!ControlService( svc, SERVICE_CONTROL_STOP, &stat ))
printf( "failed\n" );
else
printf( "ok\n" );
CloseServiceHandle( svc );
CloseServiceHandle( scm );
return 1;
}
|