Index: src/OFWindowsRegistryKey.m ================================================================== --- src/OFWindowsRegistryKey.m +++ src/OFWindowsRegistryKey.m @@ -24,10 +24,11 @@ #import "OFCreateWindowsRegistryKeyFailedException.h" #import "OFDeleteWindowsRegistryKeyFailedException.h" #import "OFDeleteWindowsRegistryValueFailedException.h" #import "OFGetWindowsRegistryValueFailedException.h" +#import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFOpenWindowsRegistryKeyFailedException.h" #import "OFOutOfRangeException.h" #import "OFSetWindowsRegistryValueFailedException.h" @@ -142,11 +143,11 @@ - (OFWindowsRegistryKey *) createSubkeyAtPath: (OFString *)path options: (DWORD)options securityAndAccessRights: (REGSAM)securityAndAccessRights securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes - disposition: (LPDWORD)disposition + disposition: (DWORD *)disposition { void *pool = objc_autoreleasePoolPush(); LSTATUS status; HKEY subKey; @@ -167,11 +168,11 @@ close: true] autorelease]; } - (OFData *)dataForValue: (OFString *)value - type: (LPDWORD)type + type: (DWORD *)type { void *pool = objc_autoreleasePoolPush(); BYTE stackBuffer[256], *buffer = stackBuffer; DWORD length = sizeof(stackBuffer); OFMutableData *ret = nil; @@ -243,21 +244,25 @@ return [self stringForValue: value type: NULL]; } - (OFString *)stringForValue: (OFString *)value - type: (LPDWORD)type + type: (DWORD *)typeOut { void *pool = objc_autoreleasePoolPush(); + DWORD type; OFData *data = [self dataForValue: value - type: type]; + type: &type]; const of_char16_t *UTF16String; size_t length; OFString *ret; if (data == nil) return nil; + + if (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_LINK) + @throw [OFInvalidEncodingException exception]; UTF16String = data.items; length = data.count; if (data.itemSize != 1 || length % 2 == 1) @@ -276,10 +281,13 @@ } } ret = [[OFString alloc] initWithUTF16String: UTF16String length: length]; + + if (typeOut != NULL) + *typeOut = type; objc_autoreleasePoolPop(pool); return [ret autorelease]; }