Main > Software Forum
Need advice from programmers that deal with memory sniping.
(1/5) > >>
Howard_Casto:
Here's the deal, I had a sort of revelation in my medicated stupor this week. 

For some time I have pressed to get an output system in place in mame (for afterburner and it's force feedback, gorf and it's multiple lights, the q-bert knocker, ect).  Although Aaron is psuedo-receptive to the idea I don't see it happening anytime soon.  It's just a lot to undertake to make all those different types of outputs generic and mappable. 

Ok here's the idea..... In the mame drivers, the memory addresses to control thes devices are in place and assigned a region in memory.  They don't do anything, but they are there and do change the proper data.  I am VERY weak in the skills department when it comes to intercepting memory, but shouldn't it be possible to have an external application that monitors the memory and then do something with the data?

The only issue I see is figuring out where the data resides.  As I said, I'm sorta dumb about this aspect of low-level programming so I would appreciate some help/advice/clarification.  I know this is done with console "enhancers" all the time but in those cases you are working with a known size of memory. 
youki:
It will be very difficult to do that, even impossible.

Ok, you can manage to access MAME memory from an external process (it was  what i was doing a a prototype for my credit management from the FE , i wanted redirect a MAME function to my own function , that worked but no so reliable and terribly tricky).

The main problem, in your case, if that you want juste read data in a given location. It could seem simple, but the questions is how you find the location of the data you want read in the "live" memory!   For a function you can manage by finding a kind of signature and looking for it in the memory , but for a simple "memory zone" or a variable....:(

One solution would to make some test, by putting easly identifiable values in that memory zone (by modifying  temporary mame) ex:  0xCAFECAFE   , then you search the memory to find where is that zone.  There is strong change that the next time you run mame , it will be allocated at the same location in the process memory map.

But anyway , it will work only for one version of mame , compiled with the same compiler.  Because for the next mame version or for a version from another compiler the position will change.
In that case, i think it is lot of much easier to simply to our own mame version.

Why don't you make your own build adding this features?








 
Buddabing:
What youki said.

You would have to do this within MAME.

The memory monitoring function is how gl.tter's Light Signal Engine worked. gl.tter is gone, but the memory monitoring code is still in BuddaMAME.

Basically, you can monitor an address and have an arbitrary event happen when the address hits a certain value. Gl.tter used this to trigger an animation when Mr. Do's ball was released. You could easily do the same for the Gorf lights, etc.
Howard_Casto:
That's what I assumed but I was hoping some smarty pants would know some method I don't.  ;)

Ah well, it was worth a shot. 

A custom mame build isn't an option, at least not for me anyway.  I think my custom build lasted like 4 versions before I lost interest.  ;)



headkaze:
FYI the API functions to read/write memory from an external process are VirtualAllocEx, WriteProcessMemory, ReadProcessMemory and VirtualFreeEx. I don't see why you couldn't have a play with a RAM editor like Hackman Hex Editor, but it would probably require knowledge of assembler to make any real ground with it. With knowledge of x86 assembler (and how it compiles into binary) would make searching for data in RAM easier, rather than some arbitrary memory offset that will change with each new Mame compile.

I guess there are also other questions about the Force Feedback data itself, does Mame even interpret the data from the ROM and place it in memory? Is it ignored, and what else? How is it stored in the ROM etc. Although it's a long shot, but it would be a good learning process to figure it out, and I don't doubt you have the skills to pull it off.

Like youki, I did some interesting things with Mame by attaching a dll to the Mame process to intercept the DirectInput using a wrapper for CoinDrop. It is quite a complex thing to do, but not impossible. Something like that has to be written in C++ though, I think there would be too many problems writing something like that in VB. But I can give you the source for CoinDrop if you PM me (and noone else so don't bother asking), only because I trust that you won't abuse it.

Just a final note on the dll attaching the Mame process, after doing it this difficult way, Tom told me an easier way to intercept DirectInput is to use DirectInput in background mode to poll it. Not sure if that would be of any help to you.
Navigation
Message Index
Next page

Go to full version