Overview
Comment: | OFWindowsRegistryKey: Verify string types |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
725eec4cfc2adb2114478bba3f4fff17 |
User & Date: | js on 2020-04-22 22:19:48 |
Other Links: | manifest | tags |
Context
2020-04-24
| ||
00:21 | Add OFIPStreamSocket check-in: 3dfe642dd3 user: js tags: trunk | |
2020-04-22
| ||
22:19 | OFWindowsRegistryKey: Verify string types check-in: 725eec4cfc user: js tags: trunk | |
22:04 | Fix missing cast for AmigaOS check-in: 4edc83ee08 user: js tags: trunk | |
Changes
Modified src/OFWindowsRegistryKey.m from [752886f486] to [bed1fd3ca5].
22 23 24 25 26 27 28 29 30 31 32 33 34 35 ... 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 ... 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 ... 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 ... 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
#include <windows.h> #import "OFCreateWindowsRegistryKeyFailedException.h" #import "OFDeleteWindowsRegistryKeyFailedException.h" #import "OFDeleteWindowsRegistryValueFailedException.h" #import "OFGetWindowsRegistryValueFailedException.h" #import "OFInvalidFormatException.h" #import "OFOpenWindowsRegistryKeyFailedException.h" #import "OFOutOfRangeException.h" #import "OFSetWindowsRegistryValueFailedException.h" @interface OFWindowsRegistryKey () - (instancetype)of_initWithHKey: (HKEY)hKey ................................................................................ } - (OFWindowsRegistryKey *) createSubkeyAtPath: (OFString *)path options: (DWORD)options securityAndAccessRights: (REGSAM)securityAndAccessRights securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes disposition: (LPDWORD)disposition { void *pool = objc_autoreleasePoolPush(); LSTATUS status; HKEY subKey; if ((status = RegCreateKeyExW(_hKey, path.UTF16String, 0, NULL, options, securityAndAccessRights, securityAttributes, ................................................................................ return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } - (OFData *)dataForValue: (OFString *)value type: (LPDWORD)type { void *pool = objc_autoreleasePoolPush(); BYTE stackBuffer[256], *buffer = stackBuffer; DWORD length = sizeof(stackBuffer); OFMutableData *ret = nil; LSTATUS status; ................................................................................ - (OFString *)stringForValue: (OFString *)value { return [self stringForValue: value type: NULL]; } - (OFString *)stringForValue: (OFString *)value type: (LPDWORD)type { void *pool = objc_autoreleasePoolPush(); OFData *data = [self dataForValue: value type: type]; const of_char16_t *UTF16String; size_t length; OFString *ret; if (data == nil) return nil; UTF16String = data.items; length = data.count; if (data.itemSize != 1 || length % 2 == 1) @throw [OFInvalidFormatException exception]; ................................................................................ length = i; break; } } ret = [[OFString alloc] initWithUTF16String: UTF16String length: length]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)setString: (OFString *)string |
> | | | > | > > > > > > |
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ... 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 ... 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 ... 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 ... 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
#include <windows.h> #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" @interface OFWindowsRegistryKey () - (instancetype)of_initWithHKey: (HKEY)hKey ................................................................................ } - (OFWindowsRegistryKey *) createSubkeyAtPath: (OFString *)path options: (DWORD)options securityAndAccessRights: (REGSAM)securityAndAccessRights securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes disposition: (DWORD *)disposition { void *pool = objc_autoreleasePoolPush(); LSTATUS status; HKEY subKey; if ((status = RegCreateKeyExW(_hKey, path.UTF16String, 0, NULL, options, securityAndAccessRights, securityAttributes, ................................................................................ return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey close: true] autorelease]; } - (OFData *)dataForValue: (OFString *)value type: (DWORD *)type { void *pool = objc_autoreleasePoolPush(); BYTE stackBuffer[256], *buffer = stackBuffer; DWORD length = sizeof(stackBuffer); OFMutableData *ret = nil; LSTATUS status; ................................................................................ - (OFString *)stringForValue: (OFString *)value { return [self stringForValue: value type: NULL]; } - (OFString *)stringForValue: (OFString *)value type: (DWORD *)typeOut { void *pool = objc_autoreleasePoolPush(); DWORD type; OFData *data = [self dataForValue: value 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) @throw [OFInvalidFormatException exception]; ................................................................................ length = i; break; } } ret = [[OFString alloc] initWithUTF16String: UTF16String length: length]; if (typeOut != NULL) *typeOut = type; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (void)setString: (OFString *)string |