EXCEPINFO structure under Win 64

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

EXCEPINFO structure under Win 64

Post by srod »

Hi,

I am aiming this at anyone who may have the Windows 64-bit sdk and can possibly rummage through the relevant header file(s) to clear this up for me! :)

In getting COMatePLUS to work with PB 64 (which now seems to be working!) I have run up against a structure which the PB compiler does not recognise.

The structure in question (EXCEPINFO) is detailed on MSDN : http://msdn.microsoft.com/en-us/library/ms221133.aspx

Now, with PB x86 I have been using the following without problems :

Code: Select all

Structure EXCEPINFO
  wCode.w
  wReserved.w
  bstrSource.i 
  bstrDescription.i
  bstrHelpFile.i
  dwHelpContext.l
  pvReserved.i
  *pfnDeferredFillIn.i
  scode.l
EndStructure
Under PB 64, however, this caused some very hard to find bugs with COMatePLUS and being unable to find any information on the web as to how this structure should look under win 64, a process of trial and error led me to adjust the 'wReserved' field to be 6 bytes.

At the very least this suggests the addition of an additional field after 'wReserved' or perhaps that the first two fields should be 4 bytes long under win 64.

I am thus using the following version which allows COMatePLUS to run fine (with regards to this structure) with both PB 32 and PB 64 :

Code: Select all

Structure EXCEPINFO
  wCode.i
  bstrSource.i
  bstrDescription.i
  bstrHelpFile.i
  dwHelpContext.l
  pvReserved.i
  *pfnDeferredFillIn.i
  scode.l
EndStructure
I have confirmed that this structure is functioning correctly with both versions of COMatePLUS.

If someone could have a look in the Oleauto.h header file in the 64-bit sdk then I would be grateful. (I assume that this structure will be in this particular header!) My version of Vista 64 is not yet up and running sufficiently well for me to consider downloading the full sdk just yet! :)


@Fred : can we add this structure to Purebasic please? At least once we have the correct definition for both x86 and x64.
I may look like a mule, but I'm not a complete ass.
Fred
Administrator
Administrator
Posts: 18556
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

IMHO, the correct structure should look like this:

Code: Select all

Structure EXCEPINFO
  wCode.w
  wReserved.w
  pad.b[4] ; Only on x64
  bstrSource.i
  bstrDescription.i
  bstrHelpFile.i
  dwHelpContext.l
  pvReserved.i
  *pfnDeferredFillIn.i
  scode.l
  pad2.b[4] ; Only on x64
EndStructure
The rules of structure alignment are a bit tricky, but basically, every 8 byte structure member must be 8 bytes aligned. And the whole structure has to be 8 byte boundary. Could you test this structure ?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes that works fine under PB 64 Fred. I was just seeking one structure which I could use in a single source for use with COMatePLUS x86 and COMatePLUS x64 rather than have to define two separate structures etc.

Still, if this can be added to PB (without the padding of course for PB x86) then COMatePLUS can dispense with its own versions completely! :wink:

Thanks.

**EDIT : what about the dwHelpContext field which is 32-bit ?
Last edited by srod on Thu May 28, 2009 10:56 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Add a compilerdirective to the structure?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

> **EDIT : what about the dwHelpContext field which is 32-bit ?

It needs padding too.
quidquid Latine dictum sit altum videtur
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Can I just make that an integer type?
I may look like a mule, but I'm not a complete ass.
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

> Can I just make that an integer type?

No, because then your program will read the padding bytes as part of the value which can lead to a big mess if the memory wasn't 0-initialized.

Btw, i just verified it with a 64bit C compiler: The structure size must be 64byte, so with the alignment in the 3 places things should be correct.
quidquid Latine dictum sit altum videtur
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

freak wrote:No, because then your program will read the padding bytes as part of the value which can lead to a big mess if the memory wasn't 0-initialized.
Good point!

I shall add additional padding el-pronto!

Thanks Freak / Fred. :)
I may look like a mule, but I'm not a complete ass.
Post Reply