diff options
author | midipix <writeonce@midipix.org> | 2016-06-29 16:18:43 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-06-29 19:16:37 -0400 |
commit | fc8f1d0e51b7135ab336318557181df394455843 (patch) | |
tree | bc882c9077c6bd359a9e4af7748d8228087706ff /src/fs/ntapi_tt_mount.c | |
parent | f7b99942f85f4c8c35058f1a8b1194cd4468bc6d (diff) | |
download | ntapi-fc8f1d0e51b7135ab336318557181df394455843.tar.bz2 ntapi-fc8f1d0e51b7135ab336318557181df394455843.tar.xz |
__ntapi_tt_dev_mount_points_to_statfs: refactor, explicit string comparison.
Diffstat (limited to 'src/fs/ntapi_tt_mount.c')
-rw-r--r-- | src/fs/ntapi_tt_mount.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/src/fs/ntapi_tt_mount.c b/src/fs/ntapi_tt_mount.c index 6b6dce2..344f5c1 100644 --- a/src/fs/ntapi_tt_mount.c +++ b/src/fs/ntapi_tt_mount.c @@ -280,39 +280,53 @@ int32_t __stdcall __ntapi_tt_dev_mount_points_to_statfs( __in nt_mount_points * mount_points, __in_out nt_statfs * statfs) { - int32_t status; - uint32_t hash; - uint32_t i; + int32_t status; + uint32_t i; nt_mount_mgr_mount_point * mount_point; - char * symlink; + wchar16_t * symlink; mount_point = mount_points->mount_points; statfs->nt_drive_letter = 0; for (i = 0; i < mount_points->number; i++, mount_point++) { - symlink = (char *)mount_points + mount_point->symlink_name_offset; - - /* both prefixes of interest happen to be of the same length */ - hash = __ntapi->tt_buffer_crc32( - 0, symlink, __DOS_DEVICES_PREFIX_LEN); - - if (hash == __DOS_DEVICES_PREFIX_HASH) + symlink = (wchar16_t *)mount_points; + symlink += mount_point->symlink_name_offset / sizeof(wchar16_t); + + if (symlink[0] != '\\') + return NT_STATUS_UNEXPECTED_IO_ERROR; + + if ((symlink[1] == 'D') + && (symlink[2] == 'o') + && (symlink[3] == 's') + && (symlink[4] == 'D') + && (symlink[5] == 'e') + && (symlink[6] == 'v') + && (symlink[7] == 'i') + && (symlink[8] == 'c') + && (symlink[9] == 'e') + && (symlink[10] == 's')) statfs->nt_drive_letter = ((nt_dos_devices_name *)(symlink))->letter; - else if (hash == __VOLUME_PATH_PREFIX_HASH) { - status = __ntapi_tt_utf16_string_to_guid( - (nt_guid_str_utf16 *)(symlink \ - + __VOLUME_PATH_PREFIX_LEN \ - - sizeof(wchar16_t)), - &statfs->nt_volume_guid); - - if (status != NT_STATUS_SUCCESS) + + else if ((symlink[1] == '?') + && (symlink[2] == '?') + && (symlink[3] == '\\') + && (symlink[4] == 'V') + && (symlink[5] == 'o') + && (symlink[6] == 'l') + && (symlink[7] == 'u') + && (symlink[8] == 'm') + && (symlink[9] == 'e') + && (symlink[10] == '{')) { + if ((status = __ntapi_tt_utf16_string_to_guid( + (nt_guid_str_utf16 *)&symlink[10], + &statfs->nt_volume_guid))) return status; } } - return 0; + return NT_STATUS_SUCCESS; } |