locked
What win64 calls require alignment? RRS feed

  • Question

  • I was trying to figure out a port bug from win32 to win64 where a LB_GETSELITEMS message was returning a -1 in the 64 bit port, but not in the original 32 bit environment.

    My head about exploded when I finally realized that the LB_GETSELITEMS requires that the lParam cannot be 2 byte aligned, but must be 8 byte (maybe 4 byte?) aligned.  Edit: Through testing, it has been shown that 32-bit can be byte aligned while 64-bit requires 4 byte alignment.

    Sample Image

    This application is written in MFC, and direct calls to SendMessage() were not done.

    I've not seen this documented anywhere. Does anyone know of any documentation related to this? Are there any other places where this is a problem?


    Adrian



    • Edited by A D R I A N Friday, October 4, 2013 6:30 PM
    Thursday, October 3, 2013 9:40 PM

Answers

  • You aren't using an Itanium, are you?  Alignment should not be an issue for AMD64.

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.

    Sunday, October 6, 2013 7:12 AM
  • Hi A D R I A N,

    Welcome to MSDN forum!

    I have found many articles but no one help.

    So I think we need to resolve this issue by the way shown below:

    I think we could add "if" in this message proc section. You could check if the message is required as int64 or int32.

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 11, 2013 7:58 AM

All replies

  • Man, seems that I only ask questions that nobody has answers for. :/

    Adrian

    Friday, October 4, 2013 6:18 PM
  • You aren't using an Itanium, are you?  Alignment should not be an issue for AMD64.

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.

    Sunday, October 6, 2013 7:12 AM
  • I'm running on an i7-3770.

    Adrian

    Monday, October 7, 2013 7:57 PM
  • Hi A D R I A N,

    Welcome to MSDN forum!

    I have found many articles but no one help.

    So I think we need to resolve this issue by the way shown below:

    I think we could add "if" in this message proc section. You could check if the message is required as int64 or int32.

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 11, 2013 7:58 AM
  • Hey Xiaoliang,

    Could you please give an example?  I don't know what you mean by I think we could add "if" in this message proc section. You could check if the message is required as int64 or int32.

    Thanks,

    A


    Adrian

    Tuesday, October 15, 2013 2:40 PM
  • Adrian I'm not quite following this, but want to mention that the compiler automatically aligns variables correctly based on their type - be they simple variables or struct/class members.

    So ordinarily you'd never have a 64-bit variable that was inappropriately aligned...

    Cap'n

    Wednesday, October 16, 2013 7:01 AM
  • And that would be true if the compiler settings were not set to 2 byte alignment.  Dun-dun-dun!  :/

    We are currently in the midst of moving it over to 8 byte alignment.  This should fix the problem HOWEVER, I would still like to know why this isn't working under MFC.  I asked this on stackoverflow and one user said in a PURE WinAPI programme, this didn't have a problem, which if correct, implies that the MFC wrapper is what is causing the problem.

    Hrmmmm


    Adrian

    Thursday, October 17, 2013 7:42 PM