USHORT cbImageNameLength; cbImageNameLength = ((USHORT) wcslen(wsImageName)) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
USHORT cbImageNameLength; NTSTATUS status; do { status = RtlSizeTToUShort(wcslen(wsImageName), &cbImageNameLength); if (!NT_SUCCESS(status)) { break; } status = RtlUShortMult(cbImageNameLength, sizeof(WCHAR), &cbImageNameLength); if (!NT_SUCCESS(status)) { break; } status = RtlUShortAdd(cbImageNameLength, sizeof(UNICODE_NULL), &cbImageNameLength); if (!NT_SUCCESS(status)) { break; } // cbImageNameLength has now been computed... } while (FALSE);
// // cbImageNameLength = ((USHORT) wcslen(wsImageName)) * sizeof(WCHAR) + sizeof(UNICODE_NULL); // status = RtlSizeTToUShort(wcslen(wsImageName), &cbImageNameLength); [...]