Welcome, Guest
Username: Password: Remember me
CodeTyphon MS Windows (Win7, Win8.x, Win10 and Win11) OS Development, discussions and problems
  • Page:
  • 1

TOPIC:

PROCESSENTRY32W padding issue on 64bit lazarus fo 10 years 7 months ago #5393

  • marunguy
  • marunguy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
Hello!

I use jwawindows unit on 64bit lazarus for windows.
The size of all record types in jwawindows unit is wrong in 64bit lazarus because of wrong align compiler directive.
The size of all record types in jwawindows unit is right in 32bit lazarus.

I already reported this issue in lazarus forum.
forum.lazarus.freepascal.org/index.php/topic,24081.0.html
CodeTyphon 4.8.0 has same issue.

I make efforts to fix this issue.
But, it is difficult for me to fix as I am beginner for Lazarus and Free Pascal.

Would you help me to fix this issue?
Or, Would you can fix this issue?

Please Log in or Create an account to join the conversation.

PROCESSENTRY32W padding issue on 64bit lazarus fo 10 years 7 months ago #5394

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Sir post here
any suggestion or example and we will put this ASAP to
CT 4.90 LAB version info
for public test
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

PROCESSENTRY32W padding issue on 64bit lazarus fo 10 years 7 months ago #5399

  • marunguy
  • marunguy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
Same issue occurred in latest CT 4.90 Lab version(Revision: 004814).

"align" compiler directives are in below source files for jwawindows unit.
Search "{$Align" (7 hits in 5 files)
  C:\codetyphon\fpcsrc\packages\winunits-jedi\src\jwawindows.pas (2 hits)
	Line 215:     {$ALIGN 4}
	Line 218: {$ALIGN 4}
  C:\codetyphon\fpcsrc\packages\winunits-jedi\src\jwawinldap.pas (1 hit)
	Line 510: {$ALIGN ON}
  C:\codetyphon\fpcsrc\packages\winunits-jedi\src\jwawinsock2.pas (1 hit)
	Line 68: {$ALIGN 4}
  C:\codetyphon\fpcsrc\packages\winunits-jedi\src\jwaws2atm.pas (1 hit)
	Line 67: {$ALIGN ON}
  C:\codetyphon\fpcsrc\packages\winunits-jedi\src\jwaws2spi.pas (2 hits)
	Line 70: {$ALIGN OFF}
	Line 72: {$ALIGN ON}

jwawindows.pas include other .pas files.
JwaTlHelp32.pas is included by last order.
(PROCESSENTRY32W is declared in JwaTlHelp32.pas)
...
 {$I JwaWinSock2.pas} // 324 line
 {$I JwaWS2atm.pas} // 326 line
 {$I JwaWS2spi.pas} // 330 line
 {$I JwaWinLDAP.pas} // 399 line
 {$I JwaTlHelp32.pas} // 521 line
....
 {$I JwaWinSock2.pas} // 649 line
 {$I JwaWS2atm.pas} // 651 line
 {$I JwaWS2spi.pas} // 655 line
 {$I JwaWinLDAP.pas} // 724 line
 {$I JwaTlHelp32.pas} // 849 line

"align" compiler directive in JwaWinLDAP.pas, I think, affect to align of JwaTlHelp32.pas.

jwawindows.pas 211 line
{$IFNDEF COMPILER6_UP}
  {$ifndef FPC}
    type PCardinal = ^Cardinal;
  {$ELSE}
    {$ALIGN 4}
  {$ENDIF}
{$ELSE}
{$ALIGN 4}
{$ENDIF}
to
{$IFNDEF COMPILER6_UP}
  {$ifndef FPC}
    type PCardinal = ^Cardinal;
  {$ELSE}
    {$IFDEF CPU64}
      {$ALIGN 8}
    {$ELSE}
      {$ALIGN 4}
    {$ENDIF}
  {$ENDIF}
{$ELSE}
{$ALIGN 4}
{$ENDIF}

jwawinldap.pas 211 line
{$ALIGN ON}
to
{$IFDEF CPU64}
  {$ALIGN 8}
{$ELSE}
  {$ALIGN ON}
{$ENDIF}

After change source code as above, rebuild package by CodeTyphon Center->FreePascal->FPC 64bit Build Compiler
PROCESSENTRY32W have correct size(568bytes) and my code works for me fine on windows 64bit.

Is it correct?
It seems to be dangerous as I am not sure that all record types must be aligned by 8bytes on 64bit windows.

Please Log in or Create an account to join the conversation.

Last edit: by marunguy.

PROCESSENTRY32W padding issue on 64bit lazarus fo 10 years 7 months ago #5400

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Thanks Sir
we will test and report here
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Page:
  • 1