sfrazor 3 Posted April 21, 2023 When building a DLL, I have a series of arrays that I want compiled together in the binary. Perhaps like a packed record. I'm not sure I'm asking this question correctly.... For example item1: array [0..64] of ansichar item2: array [0..64] of ansichar item3: array [0..64] of ansichar I want the compiler/linker to keep them together in the binary so I can open the DLL and do a replace on 192 contiguous bytes. The compiler seems to move these around and not contiguous. Is there a way, or a better way to achieve this without using a packed record? I've searched the compiler and linker flags but I don't see anything that looks obvious. The Align flag doesn't seem to be what I'm looking for. Share this post Link to post
FPiette 383 Posted April 21, 2023 Yes, a packed record is the way to go to control memory layout as much as possible. Share this post Link to post
sfrazor 3 Posted April 21, 2023 Thank you. I was afraid that was the answer. I have some refactoring to do of some rather ugly code. Share this post Link to post
Remy Lebeau 1395 Posted April 22, 2023 (edited) If you want the arrays contiguous, then why not just use a single array? const itemSize = 65; numItems = 3; var items: array[0..(itemSize*numItems)-1] of AnsiChar; function item1: PAnsiChar; begin Result := @items[0]; end; function item2: PAnsiChar; begin Result := @items[itemSize*1]; end; function item3: PAnsiChar; begin Result := @items[itemSize*2]; end; Or: const itemSize = 65; numItems = 3; type itemType = array[0..itemSize-1] of AnsiChar; var items: array[0..numItems-1] of itemType; function item1: PAnsiChar; begin Result := @items[0][0]; end; function item2: PAnsiChar; begin Result := @items[1][0]; end; function item3: PAnsiChar; begin Result := @items[2][0]; end; Edited April 22, 2023 by Remy Lebeau 1 Share this post Link to post
sfrazor 3 Posted April 26, 2023 (edited) Sorry for the late reply. That was a wow moment! I honestly didn't even think of that. That's a MUCH easier refactor than I was getting ready to do. Thanks Remy. I'll give it a try. I'll have to figure out how to add a search marker so I can scan the binary for the beginning of the array. Edited April 26, 2023 by sfrazor Share this post Link to post