gandalf the white 0 Posted May 9, 2005 if you can find a way to let people who dont even have OFP use a 300 KB program to chat with people who are somewhere deep in the jungles of asia i'll be gratefull to you for ever =) , not only can this be used in sites, but you can easely chat with your classmates aswell as with your clan! Quote[/b] ]1.[global]Hey Ben! how's life? 2.[group]oh feck, just got shot, need a medivac here! 3.[side]Infantry two requesting medivac at Bh33, popping smoke on sight. 1.[global]eh? 3.[side]Cut the chatter please. 1.[global]chatter? what the hell are you guys doing?! 4.[group]enemy inf. 2o ! 4.[group]150 meters! 3.[side]fire them up! 1.[global]quit acting strange! what the hell is happening?! 2.[global]Ben got killed 1.[global]...so... you're not going to show up tomorrow? 3.[side]Respawn is for the weak. 1.[global]...rewhat? Share this post Link to post Share on other sites
DBR_ONIX 0 Posted May 9, 2005 Erm, the host runs a program, that makes a script, if you dont have that script being called, it wont show up ;) And you could toggle it on :P And theres other uses apart from chit-chat Almost done it, it's not a "usefull" program, it's.. ermm.. a tech demo? Will upload tomorrow - Ben Share this post Link to post Share on other sites
vektorboson 8 Posted May 9, 2005 Seems as if OFP doesn't update the file access time stamp of scripts it reads  I think it does (actually this is something done by OS, which can be hardly prevented). However the file may be cached internally, meaning it can be accessed only for the first time you use it. Even if it is cached, the time stamp should have been updated by the first read. Of course it's not your duty to update the last access time stamp, it should be the OS. Quote[/b] ]Quote[/b] ]Well, Microsoft's smart programmers thought that this is actually an access, thus making the right click/properties the last access This shows how hard it can be to prevent OS from modifing access time. In this case it's not the OS, but Explorer (or the file information dialog) And in this case, we just query the meta information, we don't read the file! Quote[/b] ]Quote[/b] ]A better way to do something like this would be to hook the CreateFile function from kernel32.dll in your program. That way you could pass whatever info you want from ofp in the file name to your program, and then return the handle ... This sounds viable to me - interesting idea. It could be quite difficult to implement it for some of us, but for someone who created DXDLL it should be a child's play. Errrm, you could just add a new scripting function to the OFP source code. This would be quite the simpliest solution me thinks  You don't need to find hacks for OFP!  --- Regarding the DLL-hook, one thing I read was, that you need to "inject" your replacement function into the OFP-process, and this means writing in OFP application memory (doesn't this trigger FADE?). And how does DXDLL work? There is a DLL, which says OFP, look, here's DirectX, use me? So, could I just make a kernel32.dll with one overridden fileread-function, or is this much much more work (lots of WinAPI and Assembler?) ? Share this post Link to post Share on other sites
kegetys 2 Posted May 10, 2005 I made a simple test with the method I described and it seems to work, here is a simple "proof of concept" example with C source code. It hooks the file accesses, and when you try to execute a script that begins with ':' the DLL will "take over" and do its own things and then return a handle to a temp file that it created. The code in the example splits the string after the ':' to an array, ie: _arr = call loadFile ":hello world" hint format["%1", _arr] Should print the string "hello world" with each character as individual array elements when the testLauncher.exe is running in the background. It's just an example though and not very useful yet, but it works (for me at least :P) if someone wants to make something useful out of it. TestDLL\chandler.cpp and TestDLL\dllmain.cpp include all the interesting stuff, the launcher and testdll should compile with MS Visual Studio 6.0 at least... The base for it is from the apihijack example from codeguru.com Share this post Link to post Share on other sites
OmniMax 0 Posted May 10, 2005 Very interesting but a very complex method. The best way (I can think of) to get a 'save "mp" feature' along with webupdates: (I'm not sure how OFP stores it's memory within relation to how win32 handles memory) Using common win32api obj's and libs, make arrays with special tokens detailing the information of an object, have a third-party application scan the memory for said tokens and record them, have a simple C program for each purpose, the save game script can be syncronized with the game's timer, this way it doesn't have to scan changing memory constantly (a process which takes up a load of CPU cycles!). For the web news, same thing. You might want to make a custom HTTP server using PERL to parse the data. You could make the third-party memory scanner become intellgent, like once it finds the beginning of an array, have it search there (start at the beginning of the address) next time for news updates. CoC already has a chat "addon", not sure how it works though. Quite personally, I would be very glad if OFP2 featured something that resembled C's malloc() and a way to execute binaries, although this is a major security risk for most people as they don't have their windows enviroment set up in unix style, because it is an absolute pain to set up NT that way (in my experience). Mind you, the news would have to be simple, like who owns what town and such, the data could be inaccurate depending on how much it changes during scanning. Then I could actually complete my WWII Online modification for OFP. Share this post Link to post Share on other sites
LepparD 0 Posted May 10, 2005 Very interesting indeed... Share this post Link to post Share on other sites
DBR_ONIX 0 Posted May 10, 2005 Kegetys, tried that thing, first time I tried it, opening the application, then OFP, didn't work (Couldn't find the scripts/:helloworld thing), shutdown OFP, started it, alt-tabed and started it.. I put the code (in init), and previewed, OFP CTD.. Can't get it to work.. I though of Memory hacking (The find stuff in memory and read it), but never really looked into it past finding a Trainer Maker program and trying to find a OFP varible in it, it was hideously limited, aimed at 2D platformers by the look of it.. Hopefully someone else can get further with it that me, if the DLL Takeover thing isn't viable.. As for the Visual Basic to OFP chat thing, I'll neaten it up, and make it more stable to use, and upload it this evening. Yeh I know it's not what I intended to make, but I'll work on the OFP>Extenral program more soon Kegetys, 1, amazing work, 2, how'd I use it - Ben [Edit : Done as much as I can be bothered with for today, heres what I've done : http://www.dbrweb.co.uk/hosted/VB-OFP.rar EXE_VB-OFP.exe is the complied thing, there is the source files included too, the biggest error just now is I can't work out how to put a " in the file, I have to use ', and OFP doesn't like that (globalchat 'blah'). I'll finish it if anyone can find a use for it Tomorrow I'll continue with the script triggering EXE thing] Share this post Link to post Share on other sites
vektorboson 8 Posted May 10, 2005 @DBR_ONIX It does work, you have to start OFP first, then execute the hook-exe. Then you execute the function with <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> foo = call loadFile ":bleh"; hint format["%1", foo] It should give you then an array like ["b","l","e","h"] Btw. thanks to Kegetys, I looked yesterday at the codeguru site, but with my lack of Win32-programming I didn't try that example. It's also probably the ugliest code I've seen (that's WinAPI of course  ) I got it to work with Dev-C++, if someone's interested (though it was a bitch because of the VisualC stuff). I have optimized the testdll a bit; mine version is called with "\:string"; because of the backslash, lpFileName will be  ":string" only, thus a very easy switch/case on the first character is enough. No memcpy needed. I'll use probably ':', '?' and '*' as a prefix (what other characters are unallowed in the file system?), I've got already some applications in mind. Another OFP-limitation gone (and a lot of new scripting possibilities opened!) Share this post Link to post Share on other sites
crashdome 3 Posted May 10, 2005 ...and you could have saving / loading in multiplayer, right? Well, you already have saving/loading in MP. It's called Sinews of War. Thanks for remembering us! Currently, we've limited saving capability simply because the only file we can access in MP is the object.sav file and it has limitations (saveStatus is the only command that works right now and you share the same object.sav file accross all MP missions) Therefore, we've avoided saving things such as position of all units etc.. simply because of the overhead. If we can create our own file and specifiy which file based on a particular mission, we'd have a rockin MP save system. I'm very interested in this. Can someone sum up the current status of what we know already so I can contribute some knowledge and do some testing myself? EDIT: BTW I am very proficient in .NET programming. I can write something but it requires the .NET framework on any PC running it. Share this post Link to post Share on other sites
kegetys 2 Posted May 10, 2005 I made some extra things to it today, my version now handles multiple commands (only three at the moment, version info, returning a single character from a string and getting files using http or ftp protocol using wget.exe). I used a TCL-like syntax which is quite easy to parse (ie ':file wget http://www.something.com/whatever.php' or ':string index "something" 1' etc.) and it seems to work fine. What would be more important to do though would be to make it work with a dedicated server, especially on linux, before it could be used for anything... There should also be a way to check the presence of it from a script, though I have a method alreay on how this could be done. I think the apihijack example also has some bugs in it, at least for some people it seems to lose all its hooks when another process gets launched in the background after it has already hooked into the ofp process. Share this post Link to post Share on other sites
DBR_ONIX 0 Posted May 10, 2005 I'll use probably ':', '?' and '*' as a prefix (what other characters are unallowed in the file system?) List of unallowed characters - <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> / ? < > \ : * | " Going to try that Hook-EXE out now, wow I hate not knowing C Does it have to be in the OFP folder, or something? Tried again, same result, running it of temp folder on desktop Hmm, the Hook thing can call PHP scripts, you say? Hmmm (Outta the various programming stuff I can do, PHP was what I started on, about.. 5 years ago? ) - Ben PS, kegetys, you check PM? Share this post Link to post Share on other sites
vektorboson 8 Posted May 10, 2005 What would be more important to do though would be to make it work with a dedicated server, especially on linux, before it could be used for anything... Well, if there's no other possibility, you could just compile your personal glibc (unless BIS decided to link it statically). And if this doesn't work, you can intercept all Kernel calls... Nice feature of Linux being Open Source  Share this post Link to post Share on other sites
DBR_ONIX 0 Posted May 10, 2005 With the DLL-Hook thing, you detect when loadFile":blah" is called, so you can run a program off here, you can also get the blah bit.. With this alone, you can do.. lots.. From my real intelligance photos (From cutsceene overview), which was deemed almost-impossible by sevral people, to near-MMOFPS.. mission/mods.. Amazing what one idea can lead too Anyway, in a I've-never-used-C-before way, can someone explain how to use that code (DLL), to : Get loadFile ":thisBit", and put it to a file somewhere, so the file would contain thisBit Sorry about my lack of C knoledge - Ben Share this post Link to post Share on other sites
Yssabem 0 Posted May 10, 2005 I must say this is the most exciting news in recent times. If a save mid-MP game to database could be implimented that recorded player positions and everything else, what's to stop someone hosting a persistant game-world (planetside style) that could "restart" every hour to let new players join, picking up the game EXCATLY where it was left, only with fresh meat spawned at the main bases. To me, that's OFP Heaven. Share this post Link to post Share on other sites
vektorboson 8 Posted May 10, 2005 Anyway, in a I've-never-used-C-before way, can someone explain how to use that code (DLL), to : Get loadFile ":thisBit", and put it to a file somewhere, so the file would contain thisBit Make sure that in chandler.cpp is #include <stdio.h> Then in the function HandleCommand(char *command) write <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> HANDLE HandleCommand(char* command) { Â File *fp; Â fp = fopen( "path_to_your_file", "w"); Â if (fp != NULL) Â { Â Â fprintf(fp, "%s", command); Â Â fclose(fp); Â } ... ... ... } Where the dots stand there should be code for creating a file and returning it to OFP (you can use the code, Kegetys has written). You could change the code to return an empty file. The code I've shown you, uses the standard C library; you could use also the WinAPI functions, though I have little knowledge of them. Share this post Link to post Share on other sites
DBR_ONIX 0 Posted May 10, 2005 Indeed Would be hell on server, a script that goes though foreach thislist on a trigger, say, and this loadfile ":name-position", then the code turns this into a script to create/setpos everything back.. Fun *Waits for explaination on how to write thisBit to a file * - Ben Share this post Link to post Share on other sites
crashdome 3 Posted May 10, 2005 Please keep in mind gentleman, that the object.sav file in MP is writable. You can call saveStatus on any object (such as a gamelogic) and record a few items of info about it. Namely damage and skill. SOW was built around this. If you can intercept when that file was last written to, all you need is to call saveStatus on a gamelogic after setting damage to say.. 0.00008 and it will write that info to that file. Now, if your external program can tell when it was last written.. simply open the object.sav file al'a BinView style with that same program and you can extract that value. No need to call any extra scripts for writing purposes. You can even use the damage values 0.0 or 1.0 as a sort of bitwise interpretation of some data. Since you can saveStatus multiple objects, merely record 8 to 32 objects and you can do a world of neato things. (Do not use "skill" since SuperAI will kill your data.. we learned that the hard way) This object.sav file in MP is located in %OFP Root%\Users\%UserName%\Saved\Tmp It always remains there... and works on a Linux server. PM me if you want dev access to my forums. Rune did a few interesting tests with that file awhile ago and since he is on vacation until July, he may not be around to explain what he did. But, AFAIK, there is some nifty features about that file. Share this post Link to post Share on other sites
crashdome 3 Posted May 10, 2005 ALSO, I've created scripts to keep track of # of kills of players and save it. It wasn't much use because you needed to manually extract the info from the object.sav file. If you can supply a program that can read an object.sav file and extract certain bits of info, I can supply a script (or help someone write one) that "saves" any info you want to collect. With some interesting conditions you can even set it up so only missions with X number of players or more will record the data. again, PM me if you want to know all about the object.sav file in MP Share this post Link to post Share on other sites
vektorboson 8 Posted May 10, 2005 Hopefully someone can confirm this. I created a log-function, I can call with i.e. loadFile "\<Log some stuff" looking in the Log-File I found, that the same string was written twice. In my other logs it seems as if OFP accesses scripts twice. One time for checking whether it exists, and another time to read it. Therefore you should define a static bool to check whether the handleCommand (or whatever function you use) was called for the first time or for the second time. Only calculate and return your stuff, when OFP calls your function the second time. Otherwise you're doing the same work twice. Share this post Link to post Share on other sites
OmniMax 0 Posted May 11, 2005 I though of Memory hacking (The find stuff in memory and read it), but never really looked into it past finding a Trainer Maker program and trying to find a OFP varible in it, it was hideously limited, aimed at 2D platformers by the look of it.. Hopefully someone else can get further with it that me, if the DLL Takeover thing isn't viable.. I haven't tried yet but I recommend on a win32 platform to get a version of ArtMoney. The primary problem is that a video game takes up a lot of memory and that memory is constantly changing, if we know how OFP (roughly) stores its own memory and the convensions, it should be a snap. edit: I could come up with a proof of concept but I'm not as good at programming as I wish I was, especially when it comes to win32api (in XP, the memory is protected and you need to make some calls to access it, which is why some memory editors don't work with XP while they work with all other NT versions!) I haven't tried yet, but perhaps intergers are not stored as such and strings are stored in unicode? This doesn't make much sense, but then again, I've yet to take a look at it. I've given a lot of thought about security of this all and I was thinking if Suma could implement some sort of system where security is tight without losing any functionality. In OFP2, I mean. <warning: sentimental mode> On an off-topic note, This thread clearly shows how faithful the OFP community is, yet while some of us aren't as technically skilled as others, or some aren't technically skilled at all, we all have heart for this little game. The customization of OFP is what keeps this heart pumping and I look forward to having a lot more power in OFP2's overhauled engine. And kudos to every single person in the community. edit: added stuff about protected memory Share this post Link to post Share on other sites
KeyCat 131 Posted May 11, 2005 I'm not a "C guy" myself but this is indeed cool stuff  Quote[/b] ]And kudos to every single person in the community. I Second what you say OmniMax! /Christer (a.k.a KeyCat) Share this post Link to post Share on other sites
vektorboson 8 Posted May 11, 2005 Hooking test under Linux Ok, I've found how API-hooking is done under Linux. But as I don't manage to get an OFP Linux server running on my box, I ask, if someone could try it for me. Take this file: hook.c or from here: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> // hook.c #include <dlfcn.h> typedef void* (*fopenFunc)(const char* fn, const char* mode); typedef int (*openFunc)(const char *fn, int flags, void* arg); static int libraryloaded = 0; static void *handle; static fopenFunc orig_fopen; static openFunc orig_open; void initLibC() {  handle = dlopen("/lib/libc.so.6", RTLD_LAZY);  printf("loading libc\n");  if (handle)  {   orig_fopen = (fopenFunc)dlsym(handle,"fopen");   orig_open = (openFunc)dlsym(handle,"open");   libraryloaded = 1;  } } void* fopen( const char* fn, const char* mode ) {  if(!libraryloaded)   initLibC();  printf("using fopen with: %s\n", fn);  if(orig_fopen)  {   return orig_fopen(fn, mode);  }  else  {   return (void*)0;  } } int open( const char* fn, int flags, void *arg ) {  if(!libraryloaded)   initLibC();  printf("Using open with: %s\n", fn);  if(orig_open)  {   return orig_open(fn, flags, arg);  }  else  {   return 0;  } } (eventually you have to adjust the "/lib/libc.so.6") and compile it with <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> gcc -shared -fPIC hook.c -o libhook.so -ldl copy the libhook.so in your OFP-server directory (or somewhere else) let's assume the OFP-server is in /home/ofp/ and in the same directory there is the libhook.so, then open the console and type export LD_PRELOAD=/home/ofp/libhook.so (or whatever the export-command is in your shell). From the same console (IMPORTANT!) start the ofp-server. You should get some messages when OFP opens files, like "using open with bla.sqs". If not, there are two possibilities: Output goes into a file or /dev/null. Either look into the file (log???) or change the line where /dev/null occurs. The second possibilty is, that the server uses kernel calls instead of LibC-functions. This'd be bad, as we had to hook kernel calls which doesn't seem to be a trivial case... EDIT: open function signature was adjusted to fit fcntl.h Share this post Link to post Share on other sites
crashdome 3 Posted May 11, 2005 .NET rocks http://msdn.microsoft.com/library....pic.asp screw win32api and the horse it rode in on EDIT: With this class, you can actually monitor an entire directory AND it's subdirectories AND has filters.... Share this post Link to post Share on other sites
vektorboson 8 Posted May 11, 2005 .NET rockshttp://msdn.microsoft.com/library....pic.asp screw win32api and the horse it rode in on EDIT: With this class, you can actually monitor an entire directory AND it's subdirectories AND has filters.... ... AND it isn't triggered by OFP's file access, as I already said, that OFP doesn't update the Last Access time stamp... And that .NET-class doesn't anything you could not do with the WinAPI. Kegetys injection hook is by far superior. My DLL can log/write text into files and it can create and overwrite files. It can, like Kegetys has done it, convert strings into arrays of strings, and I am looking into it being expandable through DLLs. Btw.: Has anyone tried that Linux hook? I'd be interested if it works out. Share this post Link to post Share on other sites