From 24e37795d2db8fdc6f7809e793dadbae80211d26 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 05:02:34 +0200 Subject: add SDKs --- fsuipc/FSUIPC_User.h | 59 ++++++++++++++++++++++++ fsuipc/FSUIPC_User.lib | Bin 0 -> 6890 bytes fsuipc/Lib_source.zip | Bin 0 -> 3525 bytes fsuipc/ReadThis.txt | 120 +++++++++++++++++++++++++++++++++++++++++++++++++ fsuipc/UIPCHello.c | 79 ++++++++++++++++++++++++++++++++ fsuipc/UIPCHello.rc | 109 ++++++++++++++++++++++++++++++++++++++++++++ fsuipc/UIPChello.exe | Bin 0 -> 40960 bytes fsuipc/libc.lib | Bin 0 -> 1379864 bytes fsuipc/resource.h | 15 +++++++ 9 files changed, 382 insertions(+) create mode 100755 fsuipc/FSUIPC_User.h create mode 100755 fsuipc/FSUIPC_User.lib create mode 100755 fsuipc/Lib_source.zip create mode 100755 fsuipc/ReadThis.txt create mode 100755 fsuipc/UIPCHello.c create mode 100755 fsuipc/UIPCHello.rc create mode 100755 fsuipc/UIPChello.exe create mode 100755 fsuipc/libc.lib create mode 100755 fsuipc/resource.h (limited to 'fsuipc') diff --git a/fsuipc/FSUIPC_User.h b/fsuipc/FSUIPC_User.h new file mode 100755 index 0000000..89ab07f --- /dev/null +++ b/fsuipc/FSUIPC_User.h @@ -0,0 +1,59 @@ +#ifndef _FSUIPC_H_ +#define _FSUIPC_H_ + +// Supported Sims +#define SIM_ANY 0 +#define SIM_FS98 1 +#define SIM_FS2K 2 +#define SIM_CFS2 3 +#define SIM_CFS1 4 +#define SIM_FLY 5 +#define SIM_FS2K2 6 +#define SIM_FS2K4 7 +#define SIM_FSX 8 +#define SIM_ESP 9 + +// Error numbers +#define FSUIPC_ERR_OK 0 +#define FSUIPC_ERR_OPEN 1 // Attempt to Open when already Open +#define FSUIPC_ERR_NOFS 2 // Cannot link to FSUIPC or WideClient +#define FSUIPC_ERR_REGMSG 3 // Failed to Register common message with Windows +#define FSUIPC_ERR_ATOM 4 // Failed to create Atom for mapping filename +#define FSUIPC_ERR_MAP 5 // Failed to create a file mapping object +#define FSUIPC_ERR_VIEW 6 // Failed to open a view to the file map +#define FSUIPC_ERR_VERSION 7 // Incorrect version of FSUIPC, or not FSUIPC +#define FSUIPC_ERR_WRONGFS 8 // Sim is not version requested +#define FSUIPC_ERR_NOTOPEN 9 // Call cannot execute, link not Open +#define FSUIPC_ERR_NODATA 10 // Call cannot execute: no requests accumulated +#define FSUIPC_ERR_TIMEOUT 11 // IPC timed out all retries +#define FSUIPC_ERR_SENDMSG 12 // IPC sendmessage failed all retries +#define FSUIPC_ERR_DATA 13 // IPC request contains bad data +#define FSUIPC_ERR_RUNNING 14 // Maybe running on WideClient, but FS not running on Server, or wrong FSUIPC +#define FSUIPC_ERR_SIZE 15 // Read or Write request cannot be added, memory for Process is full + +#ifdef __cplusplus +extern "C" { +#endif + +// Globals accessible from main code +extern DWORD FSUIPC_Version; // HIWORD is 1000 x Version Number, minimum 1998 + // LOWORD is build letter, with a = 1 etc. For 1998 this must be at least 5 (1998e) +extern DWORD FSUIPC_FS_Version; + // FS98=1, FS2k=2, CFS2=3. See above. +extern DWORD FSUIPC_Lib_Version; + // HIWORD is 1000 x version, LOWORD is build letter, a = 1 etc. + +// Library routines +extern BOOL FSUIPC_Open(DWORD dwFSReq, DWORD *pdwResult); // For use externally (IPCuser.lib) +extern BOOL FSUIPC_Open2(DWORD dwFSReq, DWORD *pdwResult, BYTE *pMem, DWORD dwSize); // For use internally (ModuleUser.lib) +extern void FSUIPC_Close(void); +extern BOOL FSUIPC_Read(DWORD dwOffset, DWORD dwSize, void *pDest, DWORD *pdwResult); +extern BOOL FSUIPC_ReadSpecial(DWORD dwOffset, DWORD dwSize, void *pDest, DWORD *pdwResult); +extern BOOL FSUIPC_Write(DWORD dwOffset, DWORD dwSize, void *pSrce, DWORD *pdwResult); +extern BOOL FSUIPC_Process(DWORD *pdwResult); + +#ifdef __cplusplus +}; +#endif + +#endif // _FSUIPC_H_ diff --git a/fsuipc/FSUIPC_User.lib b/fsuipc/FSUIPC_User.lib new file mode 100755 index 0000000..c8d5243 Binary files /dev/null and b/fsuipc/FSUIPC_User.lib differ diff --git a/fsuipc/Lib_source.zip b/fsuipc/Lib_source.zip new file mode 100755 index 0000000..638732c Binary files /dev/null and b/fsuipc/Lib_source.zip differ diff --git a/fsuipc/ReadThis.txt b/fsuipc/ReadThis.txt new file mode 100755 index 0000000..dad3590 --- /dev/null +++ b/fsuipc/ReadThis.txt @@ -0,0 +1,120 @@ +FSUIPC Developer Kit: Library for MSVC/C++ programmers +====================================================== + +To interface to FSUIPC (versions 1.998e or later) in your MSVC/C++ programs: + +* insert the LIB and Header file into your source folder +* include the header in your source module(s) (#include "...") +* add the Lib to the list of Libs in the Link section of the Project Settings +* call the appropriate Library routines in your code. + +More on this last part (and please also refer to the UIPCHello example +provided): + +Opening the link to FSUIPC +========================== + +For this you use the following Library toutine: + + BOOL FSUIPC_Open(DWORD dwFSReq, DWORD *pdwResult); + +where + dwFSReq specified which Flight Simulator you want to connect to: + + SIM_ANY for any supported by FSUIPC or equivalent + SIM_FS98 FS98 + SIM_FS2K FS2000 + SIM_FS2K2 FS2002 + SIM_FS2K4 FS2004 + SIM_FSX FSX + SIM_ESP ESP (first version) + SIM_CFS2 CFS2 + SIM_CFS1 CFS +and + pResult is a pointer to a DWORD to receive an error number if the + operation fails. + +If FSUIPC_Open returns "FALSE" then the value in the result DWORD will +tell you what went wrong. The errors currently possible are defined in +the Header file (see the list of FSUIPC_ERR_ ... definitions). + +If it returns "TRUE" then the link is open and ready for your requests. +Already the Library routine will have obtained some data for you: + + DWORD FSUIPC_Version; // HIWORD is 1000 x Version Number, minimum 1998 + // LOWORD is build letter, with a = 1 etc. + DWORD FSUIPC_FS_Version; + // SIM_FS98, SIM_FS2K etc -- see above + + +Closing the link +================ + +Before terminating your program, or trying to re-open (e.g. to re-connect +after a lost connection, possibly due to FS crashing or closing), you must +Close the link to free up the resources it uses: + + void FSUIPC_Close(void); + +There is no harm done if you Close a link that is already Closed. + + + +Specifying the requests +======================= + +The interface to FSUIPC and hence the simulator is simply one of reads and +writes from and to specific "offsets". These "were originally true offsets +into a specific Global data earea within FS, but nowadays, at least in FS2000 +and CFS they are more likely to be treated a Identifiers to specific +variables, and are translated within FSUIPC. However, you may still address +data with contiguous offsets in blocks, as FSUIPC breaks these down if it +needs to. + +The following Library calls are used to accumulate Read and Write requests: + + BOOL FSUIPC_Read(DWORD dwOffset, DWORD dwSize, + void *pDest, DWORD *pdwResult); + BOOL FSUIPC_Write(DWORD dwOffset, DWORD dwSize, + void *pSrce, DWORD *pdwResult); + +In both cases you supply an offset, identifying the data required or to be +written, and a size (in bytes). The pointers "pDest" for reads and "pSrce" +for writes naturally must point to the area to receive the result or (for +writes) the area containing the data to be written. These pointers are defined +as "void *" here so that you can use whatever component size or structure you +like, as appropriate for the data in question. + +The DWORD for the result is used to identify the reason for error should the +return be FALSE. The only possible errors on these calls are an unopened +link or a full data area. You can only accumulate so much data before you need +to get FSUIPC to "process" it. This is next: + + +Processing the requests +======================= + + BOOL FSUIPC_Process(DWORD *pdwResult); + +This routine sends all the requests accumulated using the Read and Write calls +since the last Process call (if any). It is this call which actually operates +the interface. + +As usual , the error number in the Result DWORD needs to be checked if this +call returns FALSE, indicating an error. + +Note that, if your program is run under WideClient, it is likely that your +first requests for data are met with zeroes for everything. this is because +WideClient sends off the request but meanwhile returns what it already has. If +you depend on seeing correct data from the outset, you will need to wait some +milliseconds (100 or more is good, 500 safer) and read again. + +If you are coninually reading the same data over and over in a loop, as when, +for instance, maintaining a moving map position and so on, the initial values +from Wideclient shouldn't be any bother. But remember, in loops, allow some +time for other processes to run, and also process your own Windows messages. + + +============================================================================== +Pete Dowson, 6th March 2008 + diff --git a/fsuipc/UIPCHello.c b/fsuipc/UIPCHello.c new file mode 100755 index 0000000..c31a54f --- /dev/null +++ b/fsuipc/UIPCHello.c @@ -0,0 +1,79 @@ +/* UIPChello.c Displays UIPC link data in a message box */ + +#include +#include "FSUIPC_User.h" + +char *pszErrors[] = + { "Okay", + "Attempt to Open when already Open", + "Cannot link to FSUIPC or WideClient", + "Failed to Register common message with Windows", + "Failed to create Atom for mapping filename", + "Failed to create a file mapping object", + "Failed to open a view to the file map", + "Incorrect version of FSUIPC, or not FSUIPC", + "Sim is not version requested", + "Call cannot execute, link not Open", + "Call cannot execute: no requests accumulated", + "IPC timed out all retries", + "IPC sendmessage failed all retries", + "IPC request contains bad data", + "Maybe running on WideClient, but FS not running on Server, or wrong FSUIPC", + "Read or Write request cannot be added, memory for Process is full", + }; + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) +{ DWORD dwResult; + + if (FSUIPC_Open(SIM_ANY, &dwResult)) + { char chMsg[128], chTimeMsg[64]; + char chTime[3]; + BOOL fTimeOk = TRUE; + static char *pFS[] = { "FS98", "FS2000", "CFS2", "CFS1", "Fly!", "FS2002", "FS2004" }; // Change made 060603 + + // Okay, we're linked, and already the FSUIPC_Open has had an initial + // exchange with FSUIPC to get its version number and to differentiate + // between FS's. + + // Now to auto-Register with FSUIPC, to save the user of an Unregistered FSUIPC + // having to Register UIPCHello for us: + static char chOurKey[] = "IKB3BI67TCHE"; // As obtained from Pete Dowson + + if (FSUIPC_Write(0x8001, 12, chOurKey, &dwResult)) + FSUIPC_Process(&dwResult); // Process the request(s) + + // I've not checked the reslut of the above -- if it didn't register us, + // and FSUIPC isn't fully user-Registered, the next request will not + // return the FS lock time + + // As an example of retrieving data, well also get the FS clock time too: + if (!FSUIPC_Read(0x238, 3, chTime, &dwResult) || + // If we wanted other reads/writes at the same time, we could put them here + !FSUIPC_Process(&dwResult)) // Process the request(s) + fTimeOk = FALSE; + + // Now display all the knowledge we've accrued: + if (fTimeOk) + wsprintf(chTimeMsg, "Request for time ok: FS clock = %02d:%02d:%02d", chTime[0], chTime[1], chTime[2]); + + else + wsprintf(chTimeMsg, "Request for time failed: %s", pszErrors[dwResult]); + + wsprintf(chMsg, "Sim is %s, FSUIPC Version = %c.%c%c%c%c\r%s", + (FSUIPC_FS_Version && (FSUIPC_FS_Version <= 7)) ? pFS[FSUIPC_FS_Version - 1] : "Unknown FS", // Change made 060603 + '0' + (0x0f & (FSUIPC_Version >> 28)), + '0' + (0x0f & (FSUIPC_Version >> 24)), + '0' + (0x0f & (FSUIPC_Version >> 20)), + '0' + (0x0f & (FSUIPC_Version >> 16)), + (FSUIPC_Version & 0xffff) ? 'a' + (FSUIPC_Version & 0xff) - 1 : ' ', + chTimeMsg); + MessageBox (NULL, chMsg, "UIPChello: Link established to FSUIPC", 0) ; + } + + else + MessageBox (NULL, pszErrors[dwResult], "UIPChello: Failed to open link to FSUIPC", 0) ; + + FSUIPC_Close(); // Closing when it wasn't open is okay, so this is safe here + return 0 ; +} diff --git a/fsuipc/UIPCHello.rc b/fsuipc/UIPCHello.rc new file mode 100755 index 0000000..96fab2c --- /dev/null +++ b/fsuipc/UIPCHello.rc @@ -0,0 +1,109 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.K.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 2,0,0,0 + PRODUCTVERSION 2,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080904b0" + BEGIN + VALUE "Comments", "\0" + VALUE "CompanyName", "Peter L. Dowson\0" + VALUE "FileDescription", "UIPChello\0" + VALUE "FileVersion", "2, 0, 0, 0\0" + VALUE "InternalName", "UIPChello\0" + VALUE "LegalCopyright", "\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "UIPChello.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "UIPC Hello Demo\0" + VALUE "ProductVersion", "2, 0, 0, 0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x809, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.K.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/fsuipc/UIPChello.exe b/fsuipc/UIPChello.exe new file mode 100755 index 0000000..71e5911 Binary files /dev/null and b/fsuipc/UIPChello.exe differ diff --git a/fsuipc/libc.lib b/fsuipc/libc.lib new file mode 100755 index 0000000..4ec9a76 Binary files /dev/null and b/fsuipc/libc.lib differ diff --git a/fsuipc/resource.h b/fsuipc/resource.h new file mode 100755 index 0000000..654c5fb --- /dev/null +++ b/fsuipc/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by UIPCHello2.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3