Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
NtQuery authored and NtQuery committed Mar 18, 2014
1 parent 7baf973 commit dea37ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Scylla/DeviceNameResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ bool DeviceNameResolver::resolveDeviceLongNameToShort(const TCHAR * sourcePath,

void DeviceNameResolver::fixVirtualDevices()
{
const USHORT BufferSize = MAX_PATH * 2 * sizeof(WCHAR);
WCHAR longCopy[MAX_PATH] = {0};
OBJECT_ATTRIBUTES oa = {0};
UNICODE_STRING unicodeInput = {0};
Expand All @@ -68,9 +69,9 @@ void DeviceNameResolver::fixVirtualDevices()
ULONG retLen = 0;
HardDisk hardDisk;

unicodeOutput.Length = MAX_PATH * 2 * sizeof(WCHAR);
unicodeOutput.MaximumLength = unicodeOutput.Length;
unicodeOutput.Buffer = (PWSTR)calloc(unicodeOutput.Length, 1);
unicodeOutput.Buffer = (PWSTR)malloc(BufferSize);
if (!unicodeOutput.Buffer)
return;

for (unsigned int i = 0; i < deviceNameList.size(); i++)
{
Expand All @@ -81,8 +82,9 @@ void DeviceNameResolver::fixVirtualDevices()

if(NT_SUCCESS(NativeWinApi::NtOpenSymbolicLinkObject(&hFile, SYMBOLIC_LINK_QUERY, &oa)))
{
unicodeOutput.Length = MAX_PATH * 2 * sizeof(WCHAR);
unicodeOutput.Length = BufferSize;
unicodeOutput.MaximumLength = unicodeOutput.Length;
ZeroMemory(unicodeOutput.Buffer, unicodeOutput.Length);

if (NT_SUCCESS(NativeWinApi::NtQuerySymbolicLinkObject(hFile, &unicodeOutput, &retLen)))
{
Expand Down

0 comments on commit dea37ce

Please sign in to comment.