Index: src/OFDNSResolverSettings.m ================================================================== --- src/OFDNSResolverSettings.m +++ src/OFDNSResolverSettings.m @@ -621,11 +621,12 @@ #if defined(OF_WINDOWS) # ifdef OF_HAVE_FILES OFWindowsRegistryKey *key = [[OFWindowsRegistryKey localMachineKey] openSubkeyAtPath: @"SYSTEM\\CurrentControlSet\\Services\\" @"Tcpip\\Parameters" - securityAndAccessRights: KEY_QUERY_VALUE]; + accessRights: KEY_QUERY_VALUE + options: 0]; path = [[[key stringForValueNamed: @"DataBasePath"] stringByAppendingPathComponent: @"hosts"] stringByExpandingWindowsEnvironmentStrings]; if (path != nil) Index: src/OFWindowsRegistryKey.h ================================================================== --- src/OFWindowsRegistryKey.h +++ src/OFWindowsRegistryKey.h @@ -72,66 +72,43 @@ /** * @brief Opens the subkey at the specified path. * * @param path The path of the subkey to open - * @param securityAndAccessRights Please refer to the `RegOpenKeyEx()` - * documentation for `samDesired` - * @return The subkey with the specified path - */ -- (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path - securityAndAccessRights: (REGSAM)securityAndAccessRights; - -/** - * @brief Opens the subkey at the specified path. - * - * @param path The path of the subkey to open - * @param options Please refer to the `RegOpenKeyEx()` documentation for - * `ulOptions`. Usually 0. - * @param securityAndAccessRights Please refer to the `RegOpenKeyEx()` - * documentation for `samDesired` - * @return The subkey with the specified path - */ -- (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights; - -/** - * @brief Creates a subkey at the specified path or opens it if it already - * exists. - * - * @param path The path of the subkey to create - * @param securityAndAccessRights Please refer to the `RegCreateKeyEx()` - * documentation for `samDesired` - * @return The subkey with the specified path - */ -- (OFWindowsRegistryKey *)createSubkeyAtPath: (OFString *)path - securityAndAccessRights: (REGSAM)securityAndAccessRights; - -/** - * @brief Creates a subkey at the specified path or opens it if it already - * exists. - * - * @param path The path of the subkey to create - * @param options Please refer to the `RegCreateKeyEx()` documentation. - * Usually 0. - * @param securityAndAccessRights Please refer to the `RegCreateKeyEx()` - * documentation for `samDesired` - * @param securityAttributes Please refer to the `RegCreateKeyEx()` - * documentation for `lpSecurityAttributes`. Usually - * NULL. - * @param disposition Whether the key was created or already existed. Please - * refer to the `RegCreateKeyEx()` documentation for - * `lpdwDisposition`. - * @return The subkey with the specified path - */ -- (OFWindowsRegistryKey *) - createSubkeyAtPath: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - securityAttributes: (nullable SECURITY_ATTRIBUTES *)securityAttributes - disposition: (nullable DWORD *)disposition; + * @param accessRights Please refer to the `RegOpenKeyEx()` documentation for + * `samDesired` + * @param options Please refer to the `RegOpenKeyEx()` documentation for + * `ulOptions`. Usually 0. + * @return The subkey with the specified path + */ +- (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path + accessRights: (REGSAM)accessRights + options: (DWORD)options; +/** + * @brief Creates a subkey at the specified path or opens it if it already + * exists. + * + * @param path The path of the subkey to create + * @param accessRights Please refer to the `RegCreateKeyEx()` documentation for + * `samDesired` + * @param securityAttributes Please refer to the `RegCreateKeyEx()` + * documentation for `lpSecurityAttributes`. Usually + * NULL. + * @param options Please refer to the `RegCreateKeyEx()` documentation for + * `dwOptions`. Usually 0. + * @param disposition A pointer to a variable that will be set to whether the + * key was created or already existed, or `NULL`. Please + * refer to the `RegCreateKeyEx()` documentation for + * `lpdwDisposition`. + * @return The subkey with the specified path + */ +- (OFWindowsRegistryKey *) + createSubkeyAtPath: (OFString *)path + accessRights: (REGSAM)accessRights + securityAttributes: (nullable SECURITY_ATTRIBUTES *)securityAttributes + options: (DWORD)options + disposition: (nullable DWORD *)disposition; /** * @brief Returns the data for the specified value at the specified path. * * @param name The name of the value to return Index: src/OFWindowsRegistryKey.m ================================================================== --- src/OFWindowsRegistryKey.m +++ src/OFWindowsRegistryKey.m @@ -91,86 +91,67 @@ [super dealloc]; } - (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path - securityAndAccessRights: (REGSAM)securityAndAccessRights -{ - return [self openSubkeyAtPath: path - options: 0 - securityAndAccessRights: securityAndAccessRights]; -} - -- (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path + accessRights: (REGSAM)accessRights options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights { void *pool = objc_autoreleasePoolPush(); LSTATUS status; HKEY subKey; if ([OFSystemInfo isWindowsNT]) status = RegOpenKeyExW(_hKey, path.UTF16String, options, - securityAndAccessRights, &subKey); + accessRights, &subKey); else status = RegOpenKeyExA(_hKey, [path cStringWithEncoding: [OFLocale encoding]], options, - securityAndAccessRights, &subKey); + accessRights, &subKey); if (status != ERROR_SUCCESS) @throw [OFOpenWindowsRegistryKeyFailedException exceptionWithRegistryKey: self path: path + accessRights: accessRights options: options - securityAndAccessRights: securityAndAccessRights status: status]; objc_autoreleasePoolPop(pool); return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } -- (OFWindowsRegistryKey *)createSubkeyAtPath: (OFString *)path - securityAndAccessRights: (REGSAM)securityAndAccessRights -{ - return [self createSubkeyAtPath: path - options: 0 - securityAndAccessRights: securityAndAccessRights - securityAttributes: NULL - disposition: NULL]; -} - - (OFWindowsRegistryKey *) - createSubkeyAtPath: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes - disposition: (DWORD *)disposition + createSubkeyAtPath: (OFString *)path + accessRights: (REGSAM)accessRights + securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes + options: (DWORD)options + disposition: (DWORD *)disposition { void *pool = objc_autoreleasePoolPush(); LSTATUS status; HKEY subKey; if ([OFSystemInfo isWindowsNT]) status = RegCreateKeyExW(_hKey, path.UTF16String, 0, - NULL, options, securityAndAccessRights, securityAttributes, - &subKey, NULL); + NULL, options, accessRights, securityAttributes, &subKey, + NULL); else status = RegCreateKeyExA(_hKey, [path cStringWithEncoding: [OFLocale encoding]], 0, NULL, - options, securityAndAccessRights, securityAttributes, - &subKey, NULL); + options, accessRights, securityAttributes, &subKey, NULL); if (status != ERROR_SUCCESS) @throw [OFCreateWindowsRegistryKeyFailedException exceptionWithRegistryKey: self path: path - options: options - securityAndAccessRights: securityAndAccessRights + accessRights: accessRights securityAttributes: securityAttributes + options: options status: status]; objc_autoreleasePoolPop(pool); return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey Index: src/exceptions/OFCreateWindowsRegistryKeyFailedException.h ================================================================== --- src/exceptions/OFCreateWindowsRegistryKeyFailedException.h +++ src/exceptions/OFCreateWindowsRegistryKeyFailedException.h @@ -30,11 +30,11 @@ @interface OFCreateWindowsRegistryKeyFailedException: OFException { OFWindowsRegistryKey *_registryKey; OFString *_path; DWORD _options; - REGSAM _securityAndAccessRights; + REGSAM _accessRights; LPSECURITY_ATTRIBUTES _Nullable _securityAttributes; LSTATUS _status; } /** @@ -46,26 +46,25 @@ * @brief The path for the subkey that could not be created. */ @property (readonly, nonatomic) OFString *path; /** - * @brief The options for the subkey that could not be created. - */ -@property (readonly, nonatomic) DWORD options; - -/** - * @brief The security and access rights for the subkey that could not be - * created. - */ -@property (readonly, nonatomic) REGSAM securityAndAccessRights; + * @brief The access rights for the subkey that could not be created. + */ +@property (readonly, nonatomic) REGSAM accessRights; /** * @brief The security options for the subkey that could not be created. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) LPSECURITY_ATTRIBUTES securityAttributes; +/** + * @brief The options for the subkey that could not be created. + */ +@property (readonly, nonatomic) DWORD options; + /** * @brief The status returned by RegCreateKeyEx(). */ @property (readonly, nonatomic) LSTATUS status; @@ -73,24 +72,24 @@ * @brief Creates a new, autoreleased create Windows registry key failed * exception. * * @param registryKey The registry key on which creating the subkey failed * @param path The path for the subkey that could not be created - * @param options The options for the subkey that could not be created - * @param securityAndAccessRights The security and access rights for the sub - * key that could not be created + * @param accessRights The access rights for the sub key that could not be + * created * @param securityAttributes The security options for the subkey that could * not be created + * @param options The options for the subkey that could not be created * @param status The status returned by RegCreateKeyEx() * @return A new, autoreleased creates Windows registry key failed exception */ + (instancetype) exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights + accessRights: (REGSAM)accessRights securityAttributes: (nullable LPSECURITY_ATTRIBUTES)securityAttributes + options: (DWORD)options status: (LSTATUS)status; - (instancetype)init OF_UNAVAILABLE; /** @@ -97,23 +96,23 @@ * @brief Initializes an already allocated create Windows registry key failed * exception. * * @param registryKey The registry key on which creating the subkey failed * @param path The path for the subkey that could not be created - * @param options The options for the subkey that could not be created - * @param securityAndAccessRights The security and access rights for the sub - * key that could not be created + * @param accessRights The access rights for the sub key that could not be + * created * @param securityAttributes The security options for the subkey that could * not be created + * @param options The options for the subkey that could not be created * @param status The status returned by RegCreateKeyEx() * @return An initialized create Windows registry key failed exception */ - (instancetype) initWithRegistryKey: (OFWindowsRegistryKey *)registryKey path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights + accessRights: (REGSAM)accessRights securityAttributes: (nullable LPSECURITY_ATTRIBUTES)securityAttributes + options: (DWORD)options status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFCreateWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFCreateWindowsRegistryKeyFailedException.m +++ src/exceptions/OFCreateWindowsRegistryKeyFailedException.m @@ -16,51 +16,51 @@ #include "config.h" #import "OFCreateWindowsRegistryKeyFailedException.h" @implementation OFCreateWindowsRegistryKeyFailedException -@synthesize registryKey = _registryKey, path = _path, options = _options; -@synthesize securityAndAccessRights = _securityAndAccessRights; -@synthesize securityAttributes = _securityAttributes, status = _status; +@synthesize registryKey = _registryKey, path = _path; +@synthesize accessRights = _accessRights; +@synthesize securityAttributes = _securityAttributes, options = _options; +@synthesize status = _status; + (instancetype) exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights + accessRights: (REGSAM)accessRights securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes + options: (DWORD)options status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey path: path - options: options - securityAndAccessRights: securityAndAccessRights + accessRights: accessRights securityAttributes: securityAttributes + options: options status: status] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype) - initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes - status: (LSTATUS)status +- (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey + path: (OFString *)path + accessRights: (REGSAM)accessRights + securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes + options: (DWORD)options + status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; _path = [path copy]; - _options = options; - _securityAndAccessRights = securityAndAccessRights; + _accessRights = accessRights; _securityAttributes = securityAttributes; + _options = options; _status = status; } @catch (id e) { [self release]; @throw e; } Index: src/exceptions/OFGetWindowsRegistryValueFailedException.h ================================================================== --- src/exceptions/OFGetWindowsRegistryValueFailedException.h +++ src/exceptions/OFGetWindowsRegistryValueFailedException.h @@ -29,11 +29,10 @@ */ @interface OFGetWindowsRegistryValueFailedException: OFException { OFWindowsRegistryKey *_registryKey; OFString *_Nullable _valueName; - DWORD _flags; LSTATUS _status; } /** * @brief The registry key on which getting the value at the key path failed. Index: src/exceptions/OFOpenWindowsRegistryKeyFailedException.h ================================================================== --- src/exceptions/OFOpenWindowsRegistryKeyFailedException.h +++ src/exceptions/OFOpenWindowsRegistryKeyFailedException.h @@ -29,13 +29,13 @@ */ @interface OFOpenWindowsRegistryKeyFailedException: OFException { OFWindowsRegistryKey *_registryKey; OFString *_path; - DWORD _options; - REGSAM _securityAndAccessRights; + REGSAM _accessRights; LPSECURITY_ATTRIBUTES _Nullable _securityAttributes; + DWORD _options; LSTATUS _status; } /** * @brief The registry key on which opening the subkey failed. @@ -45,21 +45,20 @@ /** * @brief The path for the subkey that could not be opened. */ @property (readonly, nonatomic) OFString *path; +/** + * @brief The access rights for the subkey that could not be opened. + */ +@property (readonly, nonatomic) REGSAM accessRights; + /** * @brief The options for the subkey that could not be opened. */ @property (readonly, nonatomic) DWORD options; -/** - * @brief The security and access rights for the subkey that could not be - * opened. - */ -@property (readonly, nonatomic) REGSAM securityAndAccessRights; - /** * @brief The status returned by RegOpenKeyEx(). */ @property (readonly, nonatomic) LSTATUS status; @@ -67,43 +66,41 @@ * @brief Creates a new, autoreleased open Windows registry key failed * exception. * * @param registryKey The registry key on which opening the subkey failed * @param path The path for the subkey that could not be opened + * @param accessRights The access rights for the sub key that could not be + * opened * @param options The options for the subkey that could not be opened - * @param securityAndAccessRights The security and access rights for the sub - * key that could not be opened * @param status The status returned by RegOpenKeyEx() * @return A new, autoreleased open Windows registry key failed exception */ -+ (instancetype) - exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - status: (LSTATUS)status; ++ (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey + path: (OFString *)path + accessRights: (REGSAM)accessRights + options: (DWORD)options + status: (LSTATUS)status; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Initializes an already allocated open Windows registry key failed * exception. * * @param registryKey The registry key on which opening the subkey failed * @param path The path for the subkey that could not be opened + * @param accessRights The access rights for the sub key that could not be + * opened * @param options The options for the subkey that could not be opened - * @param securityAndAccessRights The security and access rights for the sub - * key that could not be opened * @param status The status returned by RegOpenKeyEx() * @return An initialized open Windows registry key failed exception */ -- (instancetype) - initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; +- (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey + path: (OFString *)path + accessRights: (REGSAM)accessRights + options: (DWORD)options + status: (LSTATUS)status OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFOpenWindowsRegistryKeyFailedException.m ================================================================== --- src/exceptions/OFOpenWindowsRegistryKeyFailedException.m +++ src/exceptions/OFOpenWindowsRegistryKeyFailedException.m @@ -16,47 +16,44 @@ #include "config.h" #import "OFOpenWindowsRegistryKeyFailedException.h" @implementation OFOpenWindowsRegistryKeyFailedException -@synthesize registryKey = _registryKey, path = _path, options = _options; -@synthesize securityAndAccessRights = _securityAndAccessRights; -@synthesize status = _status; - -+ (instancetype) - exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey - path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - status: (LSTATUS)status +@synthesize registryKey = _registryKey, path = _path; +@synthesize accessRights = _accessRights, options = _options, status = _status; + ++ (instancetype)exceptionWithRegistryKey: (OFWindowsRegistryKey *)registryKey + path: (OFString *)path + accessRights: (REGSAM)accessRights + options: (DWORD)options + status: (LSTATUS)status { return [[[self alloc] initWithRegistryKey: registryKey path: path + accessRights: accessRights options: options - securityAndAccessRights: securityAndAccessRights status: status] autorelease]; } + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } -- (instancetype) - initWithRegistryKey: (OFWindowsRegistryKey *)registryKey - path: (OFString *)path - options: (DWORD)options - securityAndAccessRights: (REGSAM)securityAndAccessRights - status: (LSTATUS)status +- (instancetype)initWithRegistryKey: (OFWindowsRegistryKey *)registryKey + path: (OFString *)path + accessRights: (REGSAM)accessRights + options: (DWORD)options + status: (LSTATUS)status { self = [super init]; @try { _registryKey = [registryKey retain]; _path = [path copy]; + _accessRights = accessRights; _options = options; - _securityAndAccessRights = securityAndAccessRights; _status = status; } @catch (id e) { [self release]; @throw e; } Index: tests/OFWindowsRegistryKeyTests.m ================================================================== --- tests/OFWindowsRegistryKeyTests.m +++ tests/OFWindowsRegistryKeyTests.m @@ -40,24 +40,30 @@ [OFWindowsRegistryKey localMachineKey]) TEST(@"+[OFWindowsRegistryKey usersKey]", [OFWindowsRegistryKey usersKey]) - TEST(@"-[openSubkeyAtPath:securityAndAccessRights:] #1", + TEST(@"-[openSubkeyAtPath:accessRights:options:] #1", (softwareKey = [[OFWindowsRegistryKey currentUserKey] - openSubkeyAtPath: @"Software" - securityAndAccessRights: KEY_ALL_ACCESS])) + openSubkeyAtPath: @"Software" + accessRights: KEY_ALL_ACCESS + options: 0])) - EXPECT_EXCEPTION(@"-[openSubkeyAtPath:securityAndAccessRights:] #2", + EXPECT_EXCEPTION(@"-[openSubkeyAtPath:accessRights:options:] #2", OFOpenWindowsRegistryKeyFailedException, [[OFWindowsRegistryKey currentUserKey] - openSubkeyAtPath: @"nonexistent" - securityAndAccessRights: KEY_ALL_ACCESS]) + openSubkeyAtPath: @"nonexistent" + accessRights: KEY_ALL_ACCESS + options: 0]) - TEST(@"-[createSubkeyAtPath:securityAndAccessRights:]", + TEST(@"-[createSubkeyAtPath:accessRights:securityAttributes:options:" + @"disposition:]", (objFWKey = [softwareKey createSubkeyAtPath: @"ObjFW" - securityAndAccessRights: KEY_ALL_ACCESS])) + accessRights: KEY_ALL_ACCESS + securityAttributes: NULL + options: 0 + disposition: NULL])) TEST(@"-[setData:forValueNamed:type:]", R([objFWKey setData: data forValueNamed: @"data" type: REG_BINARY])) TEST(@"-[dataForValueNamed:subkeyPath:flags:type:]",