Jump to content
The simFlight Network Forums

Windows Service using FSUIPC


Recommended Posts

Hello,

I am trying to write a .NET Windows Service that consumes FSUIPC for messaging FS data.

When I call FSUIPC_Open (included in SDK), I am unable to return the FSUIPC or FS versions.

I turned on logging in FSUIPC and it yielded the following:

345827 IPC ERROR: Cannot OpenFileMapping

346027 IPC ERROR: Cannot OpenFileMapping

346228 IPC ERROR: Cannot OpenFileMapping

346428 IPC ERROR: Cannot OpenFileMapping

346628 IPC ERROR: Cannot OpenFileMapping

I assume this is a security issue with the shared file mapping created by CreateFileMapping().

Any suggestions to fix this issue are much appreciated.

Tom

Link to comment
Share on other sites

I am trying to write a .NET Windows Service that consumes FSUIPC for messaging FS data.

What language is that written in? Are you using any of the sources, libraries or wrappers in the SDK? I'm afraid the only one I know about is the C language one.

345827 IPC ERROR: Cannot OpenFileMapping

Hmmm. I've never seen that error come up before. All it means is that this call to Windows returned zero (which indicates an error):

hMap = OpenFileMapping(FILE_MAP_WRITE, FALSE, chId);

The only reason that I know of that this may fail is that the filename is not one of an existing memory file. The "FILE_MAP_WRITE" access requested requires an existing file, and provides read and write access to it.

The "chId" here is a pointer to a zero-terminated ASCIIZ string which must have been pre-registered in Windows and identified with an Atom ID. It is the Atom ID passed by the SendMessageTimeout in your program which is used in FSUIPC to retrieve the string from Windows. This method of passing the memory-mapped filename is used because it is not possible to supply strings themselves between separate processes, and pointers to them are meaningless because they refer to different virtual memories.

If you are using one of the packages in the SDK exactly as supplied, with no modifications of your own, then possibly there's a bug in the one you are using. But no one has mentioned anything and there have been no changes to any of them for some time now.

The first thing to do is to check you are using the correct package and actually identify the language you are using. Possibly the original author may then be able to help, or someone else using the same language. Failing that you would need to use the Debugger associated with the language you are using in order to track down the problem up to the SendMessageTimeout (or equivalent) call. All the sources are provided, so this should be possible.

Regards,

Pete

Link to comment
Share on other sites

Pete,

Thanks to your pointers, I have determined the problem.

According to this MSDN Article...

http://msdn.microsoft.com/library/defauations.asp

“The Windows Service classes supported by the .NET Framework do not support interaction with interactive stations, that is, the logged-on user. The .NET Framework also does not include classes that represent stations and desktops. If your Windows Service must interact with other stations, you will need to access the unmanaged Windows API.”

Thus, I'll have to figure out how to access the interactive station (same one FSUIPC is accessing).

Tom

Link to comment
Share on other sites

Thanks to your pointers, I have determined the problem.

Well done. I must say I didn't understand a word of the explanation though. I think I'm really still embedded in the world of DOS and only recently got to terms with Win98. Most of the stuff in the current Microsoft spectrum just bewilders me.

Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.