jp-slackspace / x-tension-c-sharp

An updated C# port of X-Ways X-Tensions API.
GNU General Public License v3.0
12 stars 1 forks source link

GetHashValue #1

Closed xtaylord closed 6 years ago

xtaylord commented 6 years ago

Hi JP,

I'm having an issue with the GetHashValue function which does not appear to be providing me with the item hash. Is this because the Buffer should be filled with an initial value?

X-ways API: "The buffer should be prepared and its start filled with a single DWORD value of 0x00000001. In v18.0 SR-12, v18.1 SR-7, v18.2 SR-5, v18.3 SR-4 and later versions you may fill the buffer with a DWORD 0x00000002 to request the secondary hash value of a file instead of the primary hash value"

I'm running v19.3.

Thanks Dan

public static string GetHashValue(int itemId) { // Fail if item Id less than 0 provided. if (itemId < 0) throw new ArgumentException("Invalid item Id provided.");

        string Hash;
        IntPtr Buffer = Marshal.AllocHGlobal(_volumeNameBufferLength);
        ImportedMethods.XWF_GetHashValue(itemId, Buffer);
        Hash = Marshal.PtrToStringUni(Buffer);
        Marshal.FreeHGlobal(Buffer);
        return Hash;

}

jp-slackspace commented 6 years ago

You’re absolutely right. Looks like this function has been updated since I last worked on it. Will try to make updates this weekend though testing is hard since my dongle is expired. =/

xtaylord commented 6 years ago

Thanks JP, That would be great, I'm happy to test any amendments. Cheers Dan


From: JP Copeland notifications@github.com Sent: 02 February 2018 11:34 To: jp-slackspace/x-tension-c-sharp Cc: xtaylord; Author Subject: Re: [jp-slackspace/x-tension-c-sharp] GetHashValue (#1)

You’re absolutely right. Looks like this function has been updated since I last worked on it. Will try to make updates this weekend though testing is hard since my dongle is expired. =/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jp-slackspace/x-tension-c-sharp/issues/1#issuecomment-362563069, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFu2G8ed_f1QmRtlsZNdEGgHxHIzyzz2ks5tQvLRgaJpZM4R2-6S.

xtaylord commented 6 years ago

Morning JP,

I'm progressing with using your c# API and have a question which you may be able to assist with as my c# knowledge is a bit limited in places. I wanted to confirm if my logic is correct for using your OpenItem function.

I'm trying to create an Xtension which copies out picture files, but the files created on the disk contain invalid data (the majority of file data is 00, though content does vary between the files). Any comments you may be able to offer would be much appreciated, even if its just to confirm that I'm using the correct approach for copying out files.

Thanks

Dan

IntPtr LogicalItemPtr = HelperMethods.OpenItem(volume, ItemID, ItemOpenModes.LogicalContentsAndSlack);

Int64 itemsize = HelperMethods.GetItemSize(itemID)

byte[] byteArray = new byte[itemsize];

Marshal.Copy(LogicalItemPtr, byteArray, 0, Convert.Int32(itemsize));

File.WriteAllBytes(@"C:\temp\" + filename, byteArray);


From: dan t boardwize@hotmail.com Sent: 02 February 2018 14:26 To: jp-slackspace/x-tension-c-sharp Subject: Re: [jp-slackspace/x-tension-c-sharp] GetHashValue (#1)

Thanks JP, That would be great, I'm happy to test any amendments. Cheers Dan


From: JP Copeland notifications@github.com Sent: 02 February 2018 11:34 To: jp-slackspace/x-tension-c-sharp Cc: xtaylord; Author Subject: Re: [jp-slackspace/x-tension-c-sharp] GetHashValue (#1)

You’re absolutely right. Looks like this function has been updated since I last worked on it. Will try to make updates this weekend though testing is hard since my dongle is expired. =/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jp-slackspace/x-tension-c-sharp/issues/1#issuecomment-362563069, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFu2G8ed_f1QmRtlsZNdEGgHxHIzyzz2ks5tQvLRgaJpZM4R2-6S.

jp-slackspace commented 6 years ago

Hey @xtaylord, thanks again for the report. No current dongle yet, but didn't want to make you keep waiting. Would appreciate if you can test out the GetHashValue() function again when you have a chance.

jp-slackspace commented 6 years ago

Tested, appears to still be having issues. Looking into it again.

jp-slackspace commented 6 years ago

Fixed.