Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API Questions
#18
(08-20-2023, 05:47 PM)TerryRitchie Wrote:
(08-20-2023, 12:01 AM)a740g Wrote: Here. This should work on 64-bit compilers.

Yes it does, thank you! This example should be added to the Windows Library examples in the Wiki.

Could you explain the changes you made and why they needed to be done so I can get a better understanding of your code and why 64-bit needs to be approached differently please?

The issue lies in data alignment and type packing.  In 32 bit OSes, data is packed on a 4 byte alignment.  In 64-bit OSes, it's packed on 8-byte alignments.

For example:  
TYPE Foo
    x AS INTEGER
    y AS LONG
    z AS STRING *3
END TYPE

The above type (as a windows type) would align on 4-byte break points.  It'd actually use 12-bytes per record in memory as:

TRANSLATED TYPE Foo32
   x AS INTEGER
   buffer AS STRING *2 'complete that 4 byte block
   y AS LONG 'already 4 bytes; no buffer is needed
   z AS STRING * 3
   buffer2 AS STRING * 1 'complete the other 4 byte block
END TYPE

On a 64-bit type, the breakpoints are 8-bytes, for 16-bytes per record in memory.

TRANSLATED TYPE Foo64
   x AS INTEGER
   y AS LONG
   buffer AS STRING * 2 'complete the 8-byte block
   z AS STRING * 3
   buffer2 AS STRING * 5 'complete the second 8-byte block
END TYPE

For 32-bit windows API types, data is aligned in 4-byte segments.  For 64-bit window API types, it's in 8-byte segments.
Reply


Messages In This Thread
API Questions - by TerryRitchie - 08-18-2023, 07:35 PM
RE: API Questions - by SpriggsySpriggs - 08-18-2023, 07:51 PM
RE: API Questions - by TerryRitchie - 08-18-2023, 07:55 PM
RE: API Questions - by SMcNeill - 08-18-2023, 10:36 PM
RE: API Questions - by SMcNeill - 08-18-2023, 10:45 PM
RE: API Questions - by SpriggsySpriggs - 08-18-2023, 10:48 PM
RE: API Questions - by TerryRitchie - 08-19-2023, 02:06 AM
RE: API Questions - by SpriggsySpriggs - 08-19-2023, 04:32 AM
RE: API Questions - by TerryRitchie - 08-19-2023, 03:32 PM
RE: API Questions - by Dav - 08-19-2023, 03:48 PM
RE: API Questions - by TerryRitchie - 08-19-2023, 03:53 PM
RE: API Questions - by SpriggsySpriggs - 08-19-2023, 09:10 PM
RE: API Questions - by TerryRitchie - 08-19-2023, 09:45 PM
RE: API Questions - by Jack - 08-19-2023, 10:45 PM
RE: API Questions - by TerryRitchie - 08-19-2023, 11:06 PM
RE: API Questions - by a740g - 08-20-2023, 12:01 AM
RE: API Questions - by TerryRitchie - 08-20-2023, 05:47 PM
RE: API Questions - by SMcNeill - 08-20-2023, 06:04 PM
RE: API Questions - by a740g - 08-20-2023, 06:32 PM
RE: API Questions - by SMcNeill - 08-20-2023, 06:08 PM
RE: API Questions - by Jack - 08-20-2023, 06:15 PM
RE: API Questions - by a740g - 08-20-2023, 06:20 PM
RE: API Questions - by SMcNeill - 08-20-2023, 06:22 PM
RE: API Questions - by a740g - 08-20-2023, 06:23 PM
RE: API Questions - by SpriggsySpriggs - 08-20-2023, 11:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Hardware images questions Dav 5 462 12-04-2025, 04:18 PM
Last Post: Pete
  A couple of loadimage questions. Pete 7 1,225 04-13-2025, 03:33 PM
Last Post: Kernelpanic
  $RESIZE questions TerryRitchie 8 2,028 06-07-2024, 03:38 PM
Last Post: TerryRitchie
Question reading multiple mice absolute position, keyboard with raw input api ? madscijr 1 736 05-29-2024, 05:38 PM
Last Post: madscijr
Question why are these API declarations causing compilation to fail? madscijr 2 858 05-24-2024, 10:52 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)