64 bit conversions

hello,

the following code gives me an error in 64 bit:

unsigned char *pRSTBuffer;

PHYSICAL_ADDRESS pAddr;

:

:

//some code

:

:

pRSTBuffer = (unsigned char*) pAddr.LowPart;

error C4312: ‘type cast’ : conversion from ‘ULONG’ to ‘unsigned char *’ of
greater size

How do I fix this code?

Thanks

AP

Please see below

Cheers
Deepak

On Fri, Dec 19, 2008 at 1:28 PM, A P wrote:

> hello,
>
> the following code gives me an error in 64 bit:
>
>
> unsigned char pRSTBuffer;
>
> PHYSICAL_ADDRESS pAddr;
>
> :
>
> :
>
> //some code
>
> :
>
> :
>
> pRSTBuffer = (unsigned char
) pAddr.LowPart;
>
>
>
Why are you not using pAddr.QuaPart

> error C4312: ‘type cast’ : conversion from ‘ULONG’ to ‘unsigned char *’ of
> greater size
>
>
>
> How do I fix this code?
>
>
>
> Thanks
>
>
>
> AP
>
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

>

the following code gives me an error in 64 bit:

unsigned char *pRSTBuffer;

PHYSICAL_ADDRESS pAddr;

pRSTBuffer = (unsigned char*) pAddr.LowPart;

error C4312: ‘type cast’ : conversion from ‘ULONG’ to ‘unsigned char
*’ of
greater size

How do I fix this code?

Correct use of UlongToPtr ‘pRSTBuffer = UlongToPtr(pAddr.LowPart)’ will
get rid of the compile error, but if pAddr actually represents a
physical address, your code will still be broken :slight_smile:

If it actually is a physical address, you need to map it to a virtual
address before you can do something useful with it. If it’s not actually
a physical address, .LowPart is only a ULONG and is not sufficient to
hold a pointer in 64 bit mode, hence the error.

If you can elaborate on what you are trying to do, you are more likely
to find help…

James