1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Display messages via SimConnect?

Discussion in 'SimConnect' started by ziporama, 12/11/06.

  1. ziporama

    ziporama

    Joined:
    28/9/06
    Messages:
    203
    Country:
    unitedstates
    Has anyone figured out the trick to send message strings to FSX via SimConnect or the C++ gauges?

    This used to be the old adventure message string, but it's not documented anywhere I've been able to find.

    One way is to draw a window on the screen with a transparent background but I was hoping to use the "normal" way...

    Cheers,

    Etienne
  2. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    You can do it with FSUIPC. But I don't know how Pete implemented this, via simconnect or by visiting the good ol' FS internals ;)
  3. ziporama

    ziporama

    Joined:
    28/9/06
    Messages:
    203
    Country:
    unitedstates
    I've done it in FSUIPC, but was hoping that SimConnect would support it. Perhaps the next SDK version...

    Cheers,

    Etienne
  4. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    You can do it from inside FSX and relay to the functions via simconnect client data areas and client events

    Attached file is an example of how to do this. See Send Event A,B,C of SDK Samples. Maybe not the best way since I've not used simconnect client data so much. Very dirty too ;)

    View attachment advbarserver.cpp.txt
  5. Javier

    Javier

    Joined:
    15/10/06
    Messages:
    31
    Country:
    spain
    Ok, dirty, but.... it works :D

    Thank you,
    Javier
  6. ziporama

    ziporama

    Joined:
    28/9/06
    Messages:
    203
    Country:
    unitedstates
    Very, very sneaky, dirty and smart... Thanks so much for the tip, un tres grand merci :)

    Etienne
    Last edited: 17/11/06
  7. RobertFly

    RobertFly

    Joined:
    17/11/06
    Messages:
    4
    Is it possible to do the same for other dialogs like the ones on the missions or the flying tips?

    By the way, how do you found that (char *) 24?????? :confused: :confused:

    Best Regards
  8. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    I looked at the import/export tables of FSX dll modules. But it was purely luck I found the right function at the second try ;)
    I have absolutely no knowledge of FS internals or assembly. I doubt accessing other UI related functions will be so easy.
  9. ziporama

    ziporama

    Joined:
    28/9/06
    Messages:
    203
    Country:
    unitedstates
  10. RobertFly

    RobertFly

    Joined:
    17/11/06
    Messages:
    4
    Aha, very interesting tool. But it seems I'm handicaped understanding at low level. I haven't been able to find anything around this. Even the famous (char*)24 is missing to me :(

    I quit. I'll wait for the experts to have some light in this issue :cool:

    Robert
  11. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    FSX DLL don't export function names, you have to give the ordinal instead. The cast is just here to prove we can do elegant polymorphism in C :D
  12. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    But, lc0277, how did you figured out the arguments or parameters that it was needed to pass to the procedure exported in the WINDOW.DLL?...because the dependency walker..just displays the ordinal, and entry point of the procedures, but...how did you know how many and what types of arguments (char msg[256], int style, int delay, int cleanup) <--- how did you figured out them??...

    Best Regards,

    Manuel Ambulo
  13. virtuali

    virtuali

    Joined:
    8/8/05
    Messages:
    209
    Country:
    italy
    Luckyly enough, they are exactly the same as FS9, just the function ordinal has changed.

    Now, you might say "how did you figured out in FS9"... :)
  14. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    :confused:
    Lol, yeah...."how did you figured out in FS9".....because, in FS9 for access WINDOW.DLL....there is the linkage system, and i think that for access to the exported functions list, i need to specify the MODULE ID of the WINDOW.DLL module, then a pointer which will be filled with the pointer that points to the list of functions exported by the WINDOW.DLL, the problem (for me)..is to know HOW MANY and WHAT TYPES of arguments need each one......i think (or i believe..that you may need some assembler knowledge to get that information...lol...:confused:)....i know that they are not exported with the names of the functions, so then i may guess you ran all pointers (which in some cases if you try to run the functions from your module (without passing any arguments to it...)..FS will crash...thats why i guessing how you did it....??? :confused:...)....lol :eek:

    Best Regards,

    Manuel Ambulo
  15. jcboliveira

    jcboliveira

    Joined:
    8/6/04
    Messages:
    150
    Country:
    portugal
  16. virtuali

    virtuali

    Joined:
    8/8/05
    Messages:
    209
    Country:
    italy
    Using the linkage system it's not the only way of calling an FS function. Once you find the correct prototype, you simply declare a "pointer to function " variable, assign its address with GetProcAddress(), and you call the routine normally.

    assuming you found in the module "XXX.DLL", the function with ordinal 10 takes two doubles in input and returns an int, with the "standard" calling conventio, the prototype will be, in your .H

    Code:
    typedef int (__stdcall *MyNewfoundFunctionFunc) ( const double, const double );
    in your .CPP file, you declare and init a variable of this new type:

    Code:
    MyNewfoundFunctionFunc MyNewfoundFunction = 0;
    at start of your program, you do something like this:

    Code:
    
    HMODULE hMod = GetModuleHandleA( "XXX.DLL" );
    if( hMod )
    {
      MyNewfoundFunction = (MyNewfoundFunctionFunc)GetProcAddress(hMod, MAKEINTRESOURCEA( 10 ) );  // assuming the ordinal it's 10, for example
    }
    
    from now on, in your program, you can call the function as if it were a regular function according to its prototype, like this:

    Code:
    int result = MyNewfoundFunction( 3.0, 4.3 );
    
    Of course, to figure out the parameters types, a disassember AND some asm knowledge it's helpful, and of course the use of a debugger with breakpoints. Also, using the wrong calling convention, as well the wrong parameter types, will usually make FS crash, so yes, some care is needed.

    Usually, it's much easier to figure out parameters if the function name is "decorated", you'll recognize the names with those funny "@!""3213£@##!" characters appended. In that case, the parameters are encoded in the name itself, so a good disassembler should be able to decode them and give you some basic prototype (of course, no disassembler will be able to tell you what the parameters DO, even if they are correct and not crashing FS, their actual meaning can't be figure out without following the actual assembler code to see what they are really doing ).

    Yes, it's a long a tedious work, not really my idea of having fun. I think we should lobby Microsoft into convincing them to extend Simconnect to officially support these kind of things as well...
  17. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    If the function is simple (or expected to be) using a debugger is generaly enough. Just put a breakpoint and watch the values on the top of the stack at each call.
    With some habits and knowledge about your adress space, differents data types can be easily distinguished :
    code pointers (meaning function pointers or return address, thus the begin or end of arguments),
    heap pointers (allocated data, mainly big control structures),
    stack pointers (temp data, format strings, ...).
    integers or floating point numbers (formatting random bits to a float has very little chance to give a number between -100. and +100.).

    VC++ Express has a good debugger which can format data on the fly to quickly find strings or numbers.
    After that you had to guess or experiment.

    But if the function is more complex, eg if it takes structures or pointers to structures which are not documented (ie we don't have the corresponding header file), this process is nearly impossible. :confused:
    C++ function calls are even worst, since you have to provide a pointer to this in registers, not on the stack.

    I agree with virtuali, this process is not funny and is clearly not what add-on developers are expected to do. Simconnect has changed the way we can communicate with FS, and we should really try to convince MS to make it more feature-rich.
  18. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Thanks, jcboliveira, i didnt knew that it was possible to intercept calls made to a DLL. When you posted it, i went searching in internet and found some interesting documents that explains how to intercept API calls made to DLLs like (user32.dll).:eek:


    Yep, it is much easier, because Dependency Walker has an option that can "undecorate" the "decorated" functions (as far as i remmember, is the version 2, of Dependency Walker..).



    Yesterday, during my search in internet, i also found a tool called OlllyDbg v1.1, which can open DLLs, and see it in assembler, the good thing is that the program has an analyzer that tells me how many calls are made, and where are there come from. Analyzing the FSX's DLLs is a bit much easier, because i can see the exported functions (just the module name and ordinal, example: "util.#28", which means that a function exported in util.dll, with ordinal 28) of other FSX modules, there in the code, but openning the FS9 modules, its a bit more different (and complex for me) because of the linkage system (i think), i cannt see the exported functions directly....and yeah, as virtuali said, is really a pain trying to figured out arguments...:banghead: :(

    Best Regards....:coffee:,

    Manuel Ambulo
  19. RobertFly

    RobertFly

    Joined:
    17/11/06
    Messages:
    4
    José, this is incredible. It is openning a lot of possibilities. But is it possible to use it from a C# program? How?

    Sorry but I'm not familiar at all with C++

    Regards
  20. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    A BIG THANKS!!....JCBOLIVEIRA, LC0277 AND VIRTUALI..... because,....i learnned a LOT!, since you guys posted those posts above, i investigated in internet about how is the ASSEMBLY language and the method to intercept API calls, i found some interesting documents, and since that day i had been playing around with my old FS9's modules and i had discovered how to figure out how many parameters that some functions needs to run (exported functions bettween FS9's modules), however..i still dont know the type or size of each parameter and as LC0277 said it is really hard if they are pointers to structures (or pointers to pointers)....and also, during my playing time with FS9 modules, i found where it is located the AdvBar function that LC0277 found in the WINDOW.DLL of FSX,......yes...it is the same function but it has different ordinal (located inside of the LINKAGE of the WINDOW.DLL of FS9)..REALLY COOL ...so thanks JCBOLIVEIRA, LC0277 AND VIRTUALI..... i do really found many cool stuff....in FS9's MODULES (and in FSX MODULES), the problem, of course, is to figure out what each function do...(which is REALLY HARD)...:)...


    Yep, it is really incredible :D


    Best Regards,

    Manuel Ambulo
    Last edited: 9/12/06

Share This Page