UCHAR stands for unsigned char
which is 1 byte in size. PUCHAR stands for unsigned char*
. To store a pointer you need 8 bytes (in a 64 bit application). That’s why the size of UCHAR is 1 byte and size of PUCHAR is 8 bytes.
Why a pointer is 8 bytes?
That’s because in a 64 bit application, the address of a single byte has 64 bits. To represent this, you need 64 bits. That’s why it takes 8 bits.
Can’t we just use *char instead of *PUCHAR or maybe it’s some hidden meaning for making so much data types?
*PUCHAR
is unsigned char**
, not char*
. But if I understand your question correctly and what you mean is “using unsigned char*
instead of PUCHAR
“, yes you can. But only if you know about the underlying type.
There can be few reasons for why the developers have gone with a custom typedef like that. It could be to fit in multiple platforms, to fit different architectures, personal opinion, etc… Without knowing the real underlying type, we might actually lose information in the process of casting to another type.
3
solved What is the purpose of adding a pointer in: typedef unsigned char UCHAR, *PUCHAR;