how a volume serial number is used for a serial

Posted by Jarrydred under BizTalk Server on 2/26/2011 | Points: 10 | Views : 2133 | Status : [Member] | Replies : 2

I have a question to ask. How or is it possible to take a volume serial number convert it into decimal from hex and then some how modify it to generate a portion of a serial number.I have and example as follows:

Example 1:
2350214222 -HDD Serial Number converted from Hex

000A0C3B2EE30087 -Activation Code
A B 3 7 -Expiry Date
3 e 8 -Emp amount
000 0C 2E 00 -Corresponds to HDD Volume(2350214222) ?

Example 2:
142598462 -HDD Serial Number converted from Hex 87FE13E

000A0E0BA6C30087 -Activation Code
A B 3 7 -Expiry Date
0 C 8 -Emp amount
000 0E A6 00 -Corresponds to HDD Volume(142598462) ?
Any comments appreciated.

One of the guys at another forum posted this but not to sound stupid or anything but i am a complete noob at this but i do want to find out how to implement the code, do i use.NET sdk to run the code or visual studio
he said this:

You problem is thinking as hex and decimal as of data types, hence "convert". You cannot "convert" because there is nothing to convert. There is only one integer type your working with. Hex and decimal are only string presentations of it.

It looks like you need to work with separate bytes or semi-bytes in your integer.
For bytes, this is easy. Instead of your 64-bit integer, use 64-bit structure structure:

using System.Runtime.InteropServices;


struct VolumeSerialNumberDecoded {
[FieldOffset(0)] byte ExpirationDay;
[FieldOffset(1)] byte Amount; //1-byte shift
//you can define intercepting memory areas: this is like union
Address separate bytes in this structure.
You you need semi-bytes, its a bit more:

//this will work correctly only for lo or hi in 0..F:
static byte ByteFromSemibytes(byte lo, byte hi) {
return (byte)(hi << 4 + lo);

static byte GetLoSemibyte(byte value) {
return (byte)(value & 0x0F);

static byte GetHiSemibyte(byte value) {
return (byte)((value & 0xF0) >> 4);
You still work with bytes and manipulate with semi-bytes withing the byte.

Sorry for the complete noob question but how will i run these commands- will i run them in visual studio?

Your question is almost like "How can I develop software using VS?" :-)
I modified my code; renamed a structure. You're using something like ulong (64-bit) for your serial number, but actually need access to separate bytes/bits if this 64-bit word. Instead of ulong you should use my structure (modify it according to you documentation); my structure provides convenient access to separate bytes using FieldOffset (see help on this attribute).

Please could any one point my on the right track or road


Posted by: Jarrydred on: 2/26/2011 [Member] Starter | Points: 25

Sorry about this but i accidentally place in the wrong category any way to change that?

Jarrydred, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/26/2011 [Member] [MVP] Bronze | Points: 25

Alert the moderator.. He can do that for you.

Thanks and Regards

Jarrydred, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response