- Timestamp:
- Dec 19, 1999, 11:05:40 PM (26 years ago)
- Location:
- trunk/src/advapi32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/advapi32/registry.cpp
r1915 r2150 1 /* $Id: registry.cpp,v 1. 7 1999-12-01 10:48:16sandervl Exp $ */1 /* $Id: registry.cpp,v 1.8 1999-12-19 22:05:39 sandervl Exp $ */ 2 2 3 3 /* … … 129 129 LONG rc; 130 130 131 dprintf(("RegCreateKeyW %x %s", hKey, astring)); 131 132 rc = _O32_RegCreateKey(ConvertKey(hKey), 132 133 astring, -
trunk/src/advapi32/service.cpp
r2143 r2150 1 /* $Id: service.cpp,v 1. 1 1999-12-19 19:53:37sandervl Exp $ */1 /* $Id: service.cpp,v 1.2 1999-12-19 22:05:40 sandervl Exp $ */ 2 2 3 3 /* … … 9 9 * Copyright 1998 Patrick Haller 10 10 * 11 * 12 * NOTE: Uses registry key for service as handle 11 13 * 12 14 * Project Odin Software License can be found in LICENSE.TXT … … 23 25 #include "unicode.h" 24 26 #include "winreg.h" 27 #include <heapstring.h> 25 28 26 29 ODINDEBUGCHANNEL(ADVAPI32-SERVICE) … … 29 32 #define SC_LOCK DWORD 30 33 34 //***************************************************************************** 35 //TODO: Faster way to checking this 36 //***************************************************************************** 37 BOOL CheckServiceHandle(SC_HANDLE hService) 38 { 39 HKEY keyThisService; 40 41 if(RegOpenKeyA((HKEY)hService, NULL, &keyThisService) != 0) { 42 return FALSE; 43 } 44 RegCloseKey(keyThisService); 45 return TRUE; 46 } 31 47 /***************************************************************************** 32 48 * Name : OpenSCManagerA … … 42 58 * Status : UNTESTED STUB 43 59 * 44 * Author : Patrick Haller [Tue, 1998/06/16 23:00]60 * Author : SvL 45 61 *****************************************************************************/ 46 62 47 63 SC_HANDLE WIN32API OpenSCManagerA(LPCSTR lpszMachineName, 48 64 LPCSTR lpszDatabaseName, 49 DWORD 50 { 51 dprintf(("ADVAPI32: OpenSCManagerA(%s,%s,%x) not implemented.\n",65 DWORD fdwDesiredAccess) 66 { 67 dprintf(("ADVAPI32: OpenSCManagerA(%s,%s,%x) not correctly implemented.\n", 52 68 lpszMachineName, 53 69 lpszDatabaseName, 54 70 fdwDesiredAccess)); 55 71 56 return (NULL); /* signal failure */ 72 if(!lpszMachineName && !lpszDatabaseName) { 73 HKEY keyServices; 74 if(RegCreateKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services", &keyServices) != 0) { 75 SetLastError(ERROR_INTERNAL_ERROR); 76 return 0; 77 } 78 return keyServices; 79 } 80 return 0; 57 81 } 58 82 … … 71 95 * Status : UNTESTED STUB 72 96 * 73 * Author : Patrick Haller [Tue, 1998/06/16 23:00]97 * Author : SvL 74 98 *****************************************************************************/ 75 99 76 100 SC_HANDLE WIN32API OpenSCManagerW(LPCWSTR lpszMachineName, 77 LPCWSTR lpszDatabaseName, 78 DWORD fdwDesiredAccess) 79 { 80 dprintf(("ADVAPI32: OpenSCManagerW(%x,%x,%x) not implemented.\n", 101 LPCWSTR lpszDatabaseName, 102 DWORD fdwDesiredAccess) 103 { 104 LPSTR lpszDataBaseNameA = NULL, lpszMachineNameA = NULL; 105 SC_HANDLE hService; 106 107 dprintf(("ADVAPI32: OpenSCManagerW(%x,%x,%x) not correctly implemented.\n", 81 108 lpszMachineName, 82 109 lpszDatabaseName, 83 110 fdwDesiredAccess)); 84 111 85 return (NULL); /* signal failure */ 112 if(lpszMachineName) 113 lpszMachineNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpszMachineName); 114 if(lpszDatabaseName) 115 lpszDataBaseNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpszDatabaseName); 116 117 hService = OpenSCManagerA(lpszMachineNameA, lpszDataBaseNameA, fdwDesiredAccess); 118 119 if(lpszMachineNameA) 120 HeapFree(GetProcessHeap(), 0, lpszMachineNameA); 121 if(lpszDataBaseNameA) 122 HeapFree(GetProcessHeap(), 0, lpszDataBaseNameA); 123 124 return hService; 86 125 } 87 126 … … 98 137 * Status : UNTESTED STUB 99 138 * 100 * Author : Patrick Haller [Tue, 1998/06/16 23:00]139 * Author : SvL 101 140 *****************************************************************************/ 102 141 103 142 SC_HANDLE WIN32API OpenServiceA(SC_HANDLE schSCManager, 104 105 106 { 107 dprintf(("ADVAPI32: OpenServiceA(%08xh,%s,%08xh) not implemented.\n",143 LPCSTR lpszServiceName, 144 DWORD fdwDesiredAccess) 145 { 146 dprintf(("ADVAPI32: OpenServiceA(%08xh,%s,%08xh) not correctly implemented.\n", 108 147 schSCManager, 109 148 lpszServiceName, 110 149 fdwDesiredAccess)); 111 150 112 return (NULL); /* signal failure */ 151 if(CheckServiceHandle(schSCManager) == FALSE) { 152 SetLastError(ERROR_INVALID_PARAMETER); 153 return FALSE; 154 } 155 156 if(lpszServiceName == NULL) { 157 SetLastError(ERROR_INVALID_PARAMETER); 158 return 0; 159 } 160 HKEY keyThisService; 161 if(RegOpenKeyA((HKEY)schSCManager, lpszServiceName, &keyThisService) != 0) { 162 SetLastError(ERROR_SERVICE_DOES_NOT_EXIST); 163 return 0; 164 } 165 return keyThisService; 113 166 } 114 167 … … 125 178 * Status : UNTESTED STUB 126 179 * 127 * Author : Patrick Haller [Tue, 1998/06/16 23:00]180 * Author : SvL 128 181 *****************************************************************************/ 129 182 130 183 SC_HANDLE WIN32API OpenServiceW(SC_HANDLE schSCManager, 131 LPCWSTR lpszServiceName, 132 DWORD fdwDesiredAccess) 133 { 134 dprintf(("ADVAPI32: OpenServiceW(%08xh,%s,%08xh) not implemented.\n", 184 LPCWSTR lpszServiceName, 185 DWORD fdwDesiredAccess) 186 { 187 LPSTR lpszServiceNameA = NULL; 188 SC_HANDLE hService; 189 190 dprintf(("ADVAPI32: OpenServiceW(%08xh,%s,%08xh) not correctly implemented.\n", 135 191 schSCManager, 136 192 lpszServiceName, 137 193 fdwDesiredAccess)); 138 194 139 return (NULL); /* signal failure */ 195 if(lpszServiceName == NULL) { 196 SetLastError(ERROR_INVALID_PARAMETER); 197 return 0; 198 } 199 lpszServiceNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpszServiceName); 200 hService = OpenServiceA(schSCManager, lpszServiceNameA, fdwDesiredAccess); 201 HeapFree(GetProcessHeap(), 0, lpszServiceNameA); 202 return hService; 140 203 } 141 204 … … 153 216 * Status : UNTESTED STUB 154 217 * 155 * Author : Patrick Haller [Tue, 1998/06/16 23:00]218 * Author : SvL 156 219 *****************************************************************************/ 157 220 … … 314 377 315 378 BOOL WIN32API QueryServiceStatus(SC_HANDLE schService, 316 317 { 318 dprintf(("ADVAPI32: QueryServiceStatus(%08xh,%08xh) not implemented.\n",379 LPSERVICE_STATUS lpssServiceStatus) 380 { 381 dprintf(("ADVAPI32: QueryServiceStatus(%08xh,%08xh) not correctly implemented.\n", 319 382 schService, 320 383 lpssServiceStatus)); 321 384 322 return (FALSE); /* signal failure */ 385 if(CheckServiceHandle(schService) == FALSE) { 386 SetLastError(ERROR_INVALID_PARAMETER); 387 return FALSE; 388 } 389 390 memset(lpssServiceStatus, 0, sizeof(SERVICE_STATUS)); 391 return TRUE; 323 392 } 324 393 … … 471 540 BOOL WIN32API CloseServiceHandle(SC_HANDLE hSCObject) 472 541 { 473 dprintf(("ADVAPI32: CloseServiceHandle(%08xh) not implemented.\n",542 dprintf(("ADVAPI32: CloseServiceHandle(%08xh)", 474 543 hSCObject)); 475 544 476 return (FALSE); /* signal failure */ 545 if(CheckServiceHandle(hSCObject) == FALSE) { 546 SetLastError(ERROR_INVALID_PARAMETER); 547 return FALSE; 548 } 549 550 RegCloseKey((HKEY)hSCObject); 551 return TRUE; 477 552 } 478 553 … … 492 567 493 568 BOOL WIN32API ControlService(SC_HANDLE hService, 494 495 496 { 497 dprintf(("ADVAPI32: ControlService(%08xh,%08xh,%08xh) not implemented.\n",569 DWORD dwControl, 570 LPSERVICE_STATUS lpServiceStatus) 571 { 572 dprintf(("ADVAPI32: ControlService(%08xh,%08xh,%08xh) not correctly implemented.\n", 498 573 hService, 499 574 dwControl, 500 575 lpServiceStatus)); 501 502 return (FALSE); /* signal failure */ 576 HKEY keyThisService; 577 578 if(CheckServiceHandle(hService) == FALSE) { 579 SetLastError(ERROR_INVALID_PARAMETER); 580 return FALSE; 581 } 582 return TRUE; 503 583 } 504 584 … … 530 610 531 611 SC_HANDLE WIN32API CreateServiceA(SC_HANDLE hSCManager, 532 LPCSTR lpServiceName, 533 LPCSTR lpDisplayName, 534 DWORD dwDesiredAccess, 535 DWORD dwServiceType, 536 DWORD dwStartType, 537 DWORD dwErrorControl, 538 LPCSTR lpBinaryPathName, 539 LPCSTR lpLoadOrderGroup, 540 LPDWORD lpdwTagId, 541 LPCSTR lpDependencies, 542 LPCSTR lpServiceStartName, 543 LPCSTR lpPassword) 544 { 545 dprintf(("ADVAPI32: CreateServiceA(%08xh,%s,%s,%08xh,%08xh,%08xh,%08xh,%s,%s,%08xh,%s,%s,%s) not implemented.\n", 612 LPCSTR lpServiceName, 613 LPCSTR lpDisplayName, 614 DWORD dwDesiredAccess, 615 DWORD dwServiceType, 616 DWORD dwStartType, 617 DWORD dwErrorControl, 618 LPCSTR lpBinaryPathName, 619 LPCSTR lpLoadOrderGroup, 620 LPDWORD lpdwTagId, 621 LPCSTR lpDependencies, 622 LPCSTR lpServiceStartName, 623 LPCSTR lpPassword) 624 { 625 HKEY keyServices, keyThisService; 626 627 dprintf(("ADVAPI32: CreateServiceA(%08xh,%s,%s,%08xh,%08xh,%08xh,%08xh,%s,%s,%08xh,%s,%s,%s) not correctly implemented.\n", 546 628 hSCManager, 547 629 lpServiceName, … … 558 640 lpPassword)); 559 641 560 return (NULL); /* signal failure */ 642 //displayname too? 643 if(lpServiceName == NULL || lpBinaryPathName == NULL) { 644 SetLastError(ERROR_INVALID_PARAMETER); 645 return 0; 646 } 647 648 if(RegCreateKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services", &keyServices) != 0) { 649 SetLastError(ERROR_INTERNAL_ERROR); 650 return 0; 651 } 652 if(RegCreateKeyA(keyServices, lpServiceName, &keyThisService) != 0) { 653 SetLastError(ERROR_INTERNAL_ERROR); 654 return 0; 655 } 656 RegSetValueExA(keyThisService, "Start", 0, REG_DWORD, (LPBYTE)&dwServiceType, sizeof(DWORD)); 657 RegSetValueExA(keyThisService, "Type", 0, REG_DWORD, (LPBYTE)&dwStartType, sizeof(DWORD)); 658 RegSetValueExA(keyThisService, "ErrorControl", 0, REG_DWORD, (LPBYTE)&dwErrorControl, sizeof(DWORD)); 659 if(lpDisplayName) 660 RegSetValueExA(keyThisService, "DisplayName", 0, REG_SZ, (LPBYTE)lpDisplayName, strlen(lpDisplayName)+1); 661 if(lpLoadOrderGroup) 662 RegSetValueExA(keyThisService, "lpLoadOrderGroup", 0, REG_SZ, (LPBYTE)lpDisplayName, strlen(lpLoadOrderGroup)+1); 663 if(lpLoadOrderGroup) 664 RegSetValueExA(keyThisService, "lpLoadOrderGroup", 0, REG_SZ, (LPBYTE)lpDisplayName, strlen(lpLoadOrderGroup)+1); 665 //TODO: %SystemRoot% 666 RegSetValueExA(keyThisService, "ImagePath", 0, REG_SZ, (LPBYTE)lpBinaryPathName, strlen(lpBinaryPathName)+1); 667 668 //TODO: What else? 669 670 RegCloseKey(keyServices); 671 return keyThisService; 561 672 } 562 673 … … 601 712 LPCWSTR lpPassword) 602 713 { 603 dprintf(("ADVAPI32: CreateServiceW(%08xh,%s,%s,%08xh,%08xh,%08xh,%08xh,%s,%s,%08xh,%s,%s,%s) not implemented.\n", 714 LPSTR lpServiceNameA = NULL, lpDisplayNameA = NULL, lpBinaryPathNameA = NULL; 715 LPSTR lpDependenciesA = NULL, lpServiceStartNameA = NULL, lpPasswordA = NULL; 716 LPSTR lpLoadOrderGroupA = NULL; 717 SC_HANDLE hService; 718 719 dprintf(("ADVAPI32: CreateServiceW(%08xh,%s,%s,%08xh,%08xh,%08xh,%08xh,%s,%s,%08xh,%s,%s,%s) not correctly implemented.\n", 604 720 hSCManager, 605 721 lpServiceName, … … 616 732 lpPassword)); 617 733 618 return (NULL); /* signal failure */ 734 if(lpServiceName) 735 lpServiceNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpServiceName); 736 if(lpDisplayName) 737 lpDisplayNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDisplayName); 738 if(lpBinaryPathName) 739 lpBinaryPathNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpBinaryPathName); 740 if(lpDependencies) 741 lpDependenciesA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDependencies); 742 if(lpServiceStartName) 743 lpServiceStartNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpServiceStartName); 744 if(lpPassword) 745 lpPasswordA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpPassword); 746 if(lpDisplayName) 747 lpDisplayNameA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDisplayName); 748 if(lpLoadOrderGroup) 749 lpLoadOrderGroupA = HEAP_strdupWtoA(GetProcessHeap(), 0, lpLoadOrderGroup); 750 751 hService = CreateServiceA(hSCManager,lpServiceNameA, lpDisplayNameA, 752 dwDesiredAccess, dwServiceType, dwStartType, 753 dwErrorControl, lpBinaryPathNameA, lpLoadOrderGroupA, 754 lpdwTagId, lpDependenciesA, lpServiceStartNameA, 755 lpPasswordA); 756 757 if(lpServiceNameA) HeapFree(GetProcessHeap(), 0, lpServiceNameA); 758 if(lpDisplayNameA) HeapFree(GetProcessHeap(), 0, lpDisplayNameA); 759 if(lpBinaryPathNameA) HeapFree(GetProcessHeap(), 0, lpBinaryPathNameA); 760 if(lpDependenciesA) HeapFree(GetProcessHeap(), 0, lpDependenciesA); 761 if(lpServiceStartNameA) HeapFree(GetProcessHeap(), 0, lpServiceStartNameA); 762 if(lpPasswordA) HeapFree(GetProcessHeap(), 0, lpPasswordA); 763 if(lpLoadOrderGroupA) HeapFree(GetProcessHeap(), 0, lpLoadOrderGroupA); 764 765 return hService; 619 766 } 620 767 … … 637 784 hService)); 638 785 639 return (FALSE); /* signal failure */786 return FALSE; 640 787 } 641 788 … … 822 969 823 970 BOOL WIN32API GetServiceDisplayNameA(SC_HANDLE hSCManager, 824 LPCSTRlpServiceName,825 826 971 LPCSTR lpServiceName, 972 LPTSTR lpDisplayName, 973 LPDWORD lpcchBuffer) 827 974 { 828 975 dprintf(("ADVAPI32: GetServiceDisplayNameA(%08xh,%08xh,%08xh,%08xh) not implemented.\n", … … 854 1001 855 1002 BOOL WIN32API GetServiceDisplayNameW(SC_HANDLE hSCManager, 856 857 858 1003 LPCWSTR lpServiceName, 1004 LPWSTR lpDisplayName, 1005 LPDWORD lpcchBuffer) 859 1006 { 860 1007 dprintf(("ADVAPI32: GetServiceDisplayNameW(%08xh,%08xh,%08xh,%08xh) not implemented.\n", … … 885 1032 886 1033 BOOL WIN32API GetServiceKeyNameA(SC_HANDLE hSCManager, 887 LPCSTRlpDisplayName,888 889 1034 LPCSTR lpDisplayName, 1035 LPTSTR lpServiceName, 1036 LPDWORD lpcchBuffer) 890 1037 { 891 1038 dprintf(("ADVAPI32: GetServiceKeyNameA(%08xh,%08xh,%08xh,%08xh) not implemented.\n", … … 987 1134 988 1135 BOOL WIN32API StartServiceA(SC_HANDLE schService, 989 990 1136 DWORD dwNumServiceArgs, 1137 LPCSTR *lpszServiceArgs) 991 1138 { 992 1139 dprintf(("ADVAPI32: StartServiceA(%08xh,%08xh,%s) not implemented.\n", … … 1013 1160 1014 1161 BOOL WIN32API StartServiceW(SC_HANDLE schService, 1015 1016 1162 DWORD dwNumServiceArgs, 1163 LPCWSTR *lpszServiceArgs) 1017 1164 { 1018 1165 dprintf(("ADVAPI32: StartServiceW(%08xh,%08xh,%s) not implemented.\n",
Note:
See TracChangeset
for help on using the changeset viewer.