fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: IntPtr in 64 bit mode

IntPtr in 64 bit mode 5 months 3 weeks ago #1

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Offline
  • Posts: 1426
  • Karma: 6
Hi Chris or Robert,

a stupid question. This code found in the bBrowser sourcecode
sEditStream:dwCookie := dword(_cast, GCHandle.ToIntPtr(ogchSELF))
should be not a bigger problem in a 32 bit application.
But what is in a 64 bit application?
A dword is always 32 bit, but the IntPtr() is 64 bit, so this code would not work, and thanks to the cast the compiler will not complain.
But maybe I'm totally wrong with my assumption....

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

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

Last edit: by wriedmann.

IntPtr in 64 bit mode 5 months 3 weeks ago #2

Wolfgang,
You're absolutely right. This will not work.
In general you should avoid all _CAST operations in your code, unless you really know what you are doing.
If you look at the windows SDK header files then this field in the editStream structure is declared as a DWORD_PTR:
typedef DWORD (CALLBACK *EDITSTREAMCALLBACK)(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);

typedef struct _editstream
{
	DWORD_PTR dwCookie;		// User value passed to callback as first parameter 
	DWORD	  dwError;		// Last error 
	EDITSTREAMCALLBACK pfnCallback;
} EDITSTREAM;

The type DWORD_PTR has a different size depending on the compilation options:

in 32 bits mode:
typedef unsigned long DWORD_PTR, *PDWORD_PTR;

in 64 bits mode:
typedef unsigned __int64 DWORD_PTR, *PDWORD_PTR;


Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

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

IntPtr in 64 bit mode 5 months 3 weeks ago #3

Just to add a bit, I think (without investigating this too much) the whole VOSDK makes so many assumptions about being run in 32bit, making it practically too difficult to run it in AnyCPU/x64, so most likely this is not really an issue in bBrowser either, as it is using the VOSDK, so also has to run in 32bit mode. But, yeah, as a general practice, this is not good.
XSharp Development Team
chris(at)xsharp.eu

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

IntPtr in 64 bit mode 5 months 3 weeks ago #4

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Offline
  • Posts: 1426
  • Karma: 6
Hi Robert, hi Chris,

thank you for the confirmation!

So my conclusion is that no application using the VO GUI classes will be able to run in AnyCPU mode.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

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

IntPtr in 64 bit mode 5 months 3 weeks ago #5

Hi Wolfgang,

I think so at least. Could be worth giving it a try though, to see how many changes are required to make it work in 64 bit. Something for the (not too far) future...

Chris
XSharp Development Team
chris(at)xsharp.eu

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

  • Page:
  • 1