The problem is, that your CPU lays out the bytes of integers in memory in the opposite direction (little endian) as you are used to (big endian).
So when you type the bytes in the order 00, 8D, A4, EE, you mean the hexadecimal number 8DA4EE, but your processor "thinks" you mean EEA48D00.

You can't generalize this effect though. On other CPUs, it may be just the other way around. Don't write your integers that way or use a conversion function (ntohl for example) afterwards. But then you'll have to be careful about data alignment, because some CPUs can't read integers from memory addresses that are not a multiple of four (and your new BYTE[] will likely align the new memory to 1 byte).

Also, you should not use new and if you use it, don't use it without a smart pointer like unique_ptr or shared_ptr.

Ah, and don't use C-Style casts "(DWORD*)buffer". If you really want to do something like this, use a reinterpret_cast<DWORD*>. This does not change how error-prone the cast is, but it shows that you know it is dangerous. Also you can see the cast more easily in your editor.

And I have one more advice for your coding practices, even if this one is more of a question of good taste. Don't use DWORD or BYTE unless you really need to. Use cstdint's uint32_t or uint8_t instead.

Also, you should not use new and if you use it, don't use it without a smart pointer like unique_ptr or shared_ptr.

And I have one more advice for your coding practices, even if this one is more of a question of good taste. Don't use DWORD or BYTE unless you really need to. Use cstdint's uint32_t or uint8_t instead.

Using a new without a smart pointer type is fine as long as you know what you are doing and you know who has ownership of the pointer, and DON'T forget to use delete on it, otherwise you might be better of using a smart pointer type. But just flat out saying don't use without a new is just wrong. In this case you don't even need to use "new" as "Byte buffer[4];" will achieve the same thing without dynamic memory

I'm sorry, but this is wrong. What happens if an exception is thrown between your new and the matching delete? Or you refactor your code months later and you insert a return statement somewhere in the middle. Your pointer will go out of scope, the delete will never be executed. Result: Memory leak. If you use new without a smart pointer, you most like do not know, what you are doing, thus must not use it. There may be a few exceptions to this, but you will have to think really hard before doing it.

Yes, you can just allocate it on the stack which is a much better idea, if it fits the rest of your program (like you can't return the memory from a function then).

DWORD is a particularly awful name for a 32-bit integer. The machine word hasn't been 16 bits since the 80386, which came out in 1985. I understand keeping the label around in VC++ for compatibility, but I wouldn't use it.

In masm a word is still a 16 bit entity and that is where the names come from for MSVC++. But as I showed in an earlier post to be portable throughout your code you should redefine the primitive types to names of your own choosing as that will make your code compiler independent.

Please don't. I can tell you from my experience, that this will give you a bad time. At a company I worked for, they had done this. They used an awful mess of conditional compilation to select the right typedefs for a given compiler and target processor. I tried to port code from 32 to 64 bits. I had to redo all the old type definitions (there were some for several 8 bit processors, a few 32 processors and so on). It was a pain in the ass.

There isn't a single sensible reason to define your own MY_INT32 or something similar. We have stdint.h and cstdint. They define everything you need. Types with guaranteed sizes and signedness. Redefining those types will also require you to include your type definition headers in each and every source file, thus slowing down the development process and compilation.

In order to improve readability of your code, you could define types for your function arguments. Like a typedef double Angle; or something like this. It won't keep you from passing the wrong type to your function, but it allows you to make the code easier to understand for a reader.