News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Structures problem in EasyCode

Started by Danesh, April 12, 2005, 04:28:06 PM

Previous topic - Next topic

Danesh

Hi all,

I have ported my project from another visual tool to EasyCode and I am satisfied but there is a big problem with EasyCode. I have created a struct in EasyCode which is:

DatabasesList Struct
DatabaseName         DB         20, 0
PointerToTablesList      DD         0
PointerToNextLink      DD         0
DatabasesList EndS

I create an instance of it by allocating memory dinamycally. After allocating each field will be filled by approperiate vakues and the address of it will be passed to a DLL. The DLL has been developed into hutch's MASM32 usual enviromnet. I have defined aboce structure there too in DLL and when I try to read the contents of passed address, vaues are different from which I had in EasyCode. I use the following instruction to read/write into structures fields if the instance's address of above strcuture is stored in ebx:

xor     eax, eax
mov   [ebx].DatabasesList.PointerToNextLink, eax

Whats the problem ? I think there something which has been hided in EasyCode's code like alignment instructions or pumping messages loop... Is really structure handling different in EasyCode and MASM32 ? I don't think so...

Regards,

Danesh


P.S: I checked the size of the above structure in both MASM32 and EasyCode and the result was different. In EasyCode the size of above structure was 25 and in MASM32 it was 32 !!! Whay ? Can anybody help ? I am sure the problem begins from here...


Ramon Sala

Hi Danesh,

First of all, have you the Alignment field (in Project->Properties) to 4? If so, it should work. On the other hand, the structure you posted is the following:

DatabasesList Struct
  DatabaseName         DB         20, 0
  PointerToTablesList      DD         0
  PointerToNextLink      DD         0
DatabasesList EndS


I supose it is:

DatabasesList Struct
  DatabaseName         DB         20 Dup(0), 0
  PointerToTablesList      DD         0
  PointerToNextLink      DD         0
DatabasesList EndS


Finally, try this

DatabasesList Struct  4
  DatabaseName         DB         20 Dup(0), 0
  PointerToTablesList      DD         0
  PointerToNextLink      DD         0
DatabasesList EndS


Please, let me know the results.

Regards,

Ramon
Greetings from Catalonia

Danesh

Hi Ramon,

Sotty the actual definition as you said was:

DatabasesList Struct
  DatabaseName         DB         20 Dup(0), 0
  PointerToTablesList      DD         0
  PointerToNextLink      DD         0
DatabasesList EndS

I also changed it to:

DatabasesList Struct 4
  DatabaseName         DB         20 Dup(0), 0
  PointerToTablesList      DD         0
  PointerToNextLink      DD         0
DatabasesList EndS

But it still doesn't work. Align value in EasyCode is 4 too. Why the structure size in EasyCode and my source at MASM32 are different ? I am almost sure it is related to alignment. What do oyu suggest ? For your information, I downloaded the latest version of EasyCode and I am using now the latest version if it would help.

Thanks,

Danesh



Ramon Sala

Hi Danesh,

DatabasesList Struct
  DatabaseName         DB         20 Dup(0), 0
  PointerToTablesList      DD         0
  PointerToNextLink      DD         0
DatabasesList EndS

I copied this structure and pasted in a visual and a classic project. When executing the instruction:

Mov Eax, SizeOf DatabasesList


the returned value is 32, which is correct if the data alignment is 4 (make sure you have the value 4 for the Alignment field in the Project-->Properties). So, I do not know what the problem is. Would you send me the code please? Thank you.

Regards,

Ramon
Greetings from Catalonia

Danesh

Hi Ramon,

Sorry, I think it was my fault. I have a DLL which is called by my project in EasyCode. The DLL is developed in hutch's MASM32 as below:

DatabasesList struct
DatabaseName            db        20 dup(0), 0
PointerToTablesList      dd        0
PointerToNextLink       dd         0
DatabasesList ends

however the structure us aligned by 4 in EasyCode. I changed my definition (as you guided) in the DLL to:

DatabasesList struct  4
DatabaseName            db        20 dup(0), 0
PointerToTablesList      dd        0
PointerToNextLink       dd         0
DatabasesList ends

and now it is aligned by 4 too in my DLL and it works fine. Thanks for your support. By the way, in previous version of EasyCode (I haven't seen this problem in new version yet) when I copied a block of program by Ctrl+Insert from for example Notepad and pasted it to EasyCode by Shift+Insert sometimes EasyCode completely crashed and I had to restart it. Have you fixed this bug ?

Regards,

Danesh





Ramon Sala

Hi Danesh,

I'm glad you solved the problem. About pasting text in Easy Code, yes, I fixed a bug and I think there is no problem now.

Regards,

Ramon
Greetings from Catalonia