Mercurial > mplayer.hg
annotate vidix/dhahelperwin/dhasetup.c @ 29138:8aeebf532e48
follow renaming of pbBufPtr() to put_bits_ptr() by stefano
author | rik |
---|---|
date | Mon, 13 Apr 2009 21:43:57 +0000 |
parents | a1c020529cc0 |
children | 0f1b5b68af32 |
rev | line source |
---|---|
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
1 /* |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
2 * dhasetup - dhahelper setup program |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
3 * |
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
4 * Copyright (c) 2004 - 2007 Sascha Sommer (MPlayer) |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
5 * |
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
6 * some parts from dhasetup.c source code |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
7 * http://svn.tilp.info/cgi-bin/viewcvs.cgi/libticables/trunk/src/win32/dha/ |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
8 * |
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
9 * Copyright (C) 2007 Romain Lievin (tilp) |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
10 * |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
11 * This file is part of MPlayer. |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
12 * |
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
13 * MPlayer is free software; you can redistribute it and/or modify |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
14 * it under the terms of the GNU General Public License as published by |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
15 * the Free Software Foundation; either version 2 of the License, or |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
16 * (at your option) any later version. |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
17 * |
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
18 * MPlayer is distributed in the hope that it will be useful, |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
21 * GNU General Public License for more details. |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
22 * |
26726
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
23 * You should have received a copy of the GNU General Public License along |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
24 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
a1c020529cc0
Use standard license header with standard formatting.
diego
parents:
24542
diff
changeset
|
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
26 */ |
12057 | 27 |
28 #include <windows.h> | |
29 #include <stdio.h> | |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
30 #include <winioctl.h> |
12057 | 31 |
24540 | 32 static void print_last_error(char *s){ |
33 LPTSTR lpMsgBuf; | |
34 | |
35 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | | |
36 FORMAT_MESSAGE_FROM_SYSTEM | | |
37 FORMAT_MESSAGE_IGNORE_INSERTS, | |
38 NULL, GetLastError(), | |
39 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | |
40 (LPTSTR) & lpMsgBuf, 0, NULL); | |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
41 if(strlen(lpMsgBuf) >= 2) |
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
42 lpMsgBuf[strlen(lpMsgBuf)-2] = 0; |
24540 | 43 |
44 printf("%s (%i -> %s)\n", s, GetLastError(), lpMsgBuf); | |
45 LocalFree(lpMsgBuf); | |
46 } | |
47 | |
12057 | 48 int main(int argc,char* argv[]){ |
24540 | 49 SC_HANDLE hSCManager = NULL; |
50 SC_HANDLE hService = NULL; | |
12058 | 51 char path[MAX_PATH]; |
12057 | 52 printf("dhasetup (c) 2004 Sascha Sommer\n"); |
12098 | 53 GetWindowsDirectory(path,MAX_PATH); |
54 strcpy(path+strlen(path),"\\system32\\drivers\\dhahelper.sys"); | |
12057 | 55 if(argc==1){ |
12098 | 56 printf("Usage:\n"); |
57 printf("dhasetup install - Copies dhahelper.sys from the current directory to\n%s and configures it to start at boot.\n", path); | |
58 printf("dhasetup remove - Removes the dhahelper utility.\n"); | |
12057 | 59 return 0; |
60 } | |
61 hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); | |
62 if(!strcmp(argv[1],"install")){ | |
24540 | 63 printf("Installing dhahelper..."); |
12453 | 64 if(!CopyFile("dhahelper.sys",path,FALSE)){ |
12098 | 65 printf("Copying dhahelper.sys failed.\nEither dhahelper.sys is not in the current directory or you lack sufficient\nprivileges to write to %s.", path); |
66 return 1; | |
12453 | 67 } |
12057 | 68 // Install the driver |
69 hService = CreateService(hSCManager, | |
70 "DHAHELPER", | |
71 "DHAHELPER", | |
72 SERVICE_ALL_ACCESS, | |
73 SERVICE_KERNEL_DRIVER, | |
74 SERVICE_SYSTEM_START, | |
75 SERVICE_ERROR_NORMAL, | |
12058 | 76 path, |
12057 | 77 NULL, |
78 NULL, | |
79 NULL, | |
80 NULL, | |
81 NULL); | |
12450 | 82 if(!hService){ |
24540 | 83 print_last_error("Unable to register DhaHelper Service"); |
84 return 1; | |
12450 | 85 } |
24542
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
86 |
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
87 if(!StartService(hService, 0, NULL)){ |
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
88 print_last_error("Error while starting service"); |
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
89 return 1; |
a36693ffbb17
it is no longer necessary to reboot the system after the dhahelperwin installation (based on code by Romain Lievin from the tilp project)
faust3
parents:
24540
diff
changeset
|
90 } |
24540 | 91 |
92 printf("Success!\n"); | |
12057 | 93 } |
94 else if(!strcmp(argv[1],"remove")){ | |
95 SERVICE_STATUS ServiceStatus; | |
24540 | 96 |
97 printf("Removing dhahelper... "); | |
12057 | 98 hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS); |
24540 | 99 if(!hService){ |
100 print_last_error("Error opening dhahelper service"); | |
101 return 1; | |
102 } | |
103 if(!ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus)) | |
104 print_last_error("Error while stopping service"); | |
105 if(!DeleteService(hService)) | |
106 print_last_error("Error while deleting service"); | |
12058 | 107 DeleteFile(path); |
24540 | 108 printf("Done!\n"); |
12057 | 109 } |
110 else { | |
111 printf("unknown parameter: %s\n",argv[1]); | |
112 } | |
113 CloseServiceHandle(hService); | |
114 CloseServiceHandle(hSCManager); | |
115 return 0; | |
116 } |