I'm trying to rewrite a protocol in NodeJS from documentation written for C#.
I'm reading from an index file and here's the description of how the buffer is laid out.
From what I've read, DWORD
is just a 32 bit unsigned integer. However, whenever I read the length bytes with indexFileBuffer.readUInt32BE(offset)
I get a much longer length than expected.
Apparently readUInt32BE()
is not the equivalent of dword
or dword
must be handled differently based on some criteria.
Any insight into how to properly calculate the value would be greatly appreciated.
The proper functions to get a DWORD (unsigned 32 bit integer) from a buffer are either:
buf.readUInt32BE(offset)
or
buf.readUInt32LE(offset)
You do need to know whether your data is little endian or big endian byte ordering in order to select the right option of the two.
If you're using this and it isn't getting you the value you expect, then one of three things must be going on:
FYI, Intel uses little endian byte ordering, ARM uses big endian. More on "endinan-ness" here.