obtaining object (pco) locations on a loaded map

Ask questions, discuss ideas, get answers
Post Reply
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

obtaining object (pco) locations on a loaded map

Post by fo0k »

assuming i pause a game.. i want to get the co-ordinates of all the pco's on the map :) heheh how does one extract this from memory? im not good with such witchcraft.

for something like the build mod.. a 1942 - very basic take on Garrys mod. you could spawn several different objects in front of you.. blocks etc.

if you could pull the coordinates of all these pco's from memory then with a clever excel spreadsheet to format things I think you could effectively 'save' your creation and give the objectspawners file to someone else to load up your map.. in game map editing.. I want it for a kinda close quarters pistol/knife map..

people could spawn walls etc to build a map..
User avatar
archer
Posts: 54
Joined: Fri Feb 05, 2010 4:40 pm
Location: Übertów
Contact:

Re: obtaining object (pco) locations on a loaded map

Post by archer »

Hi,
Injecting new objects into your game's memory (assuming you are the client) will not work, since your "bogus" data will be overruled by the server. It's a very basic anti-cheating thing.
Injecting your data into server's memory though *might* work. I once did something similar, and I ended up with a C++ program that would scan the server's memory searching for PCOs with known locations. Then it would track them, calculate their speeds, etc. And it would work only half of the time. I guess it would take someone with better cracking skills than mine :D
The heart of the problem is that, in Battlefield 1942, the position is not a simple thing. For every PCO, the engine seems to remember lots of past positions, the current position, and even some predicted future positions. It is very hard to identify which one of these is your actual position, and even if you get that right, the server seems to scan the position array for anomalies. If you inject a new position that is sufficiently far from the past position, the server will decide that such a move is impossible and immediately pull your PCO back.

All in all, I'd suggest finding a solution that does not involve memory hacking. How about those buildable walls from the Battlefield: Empires mod? They seem to do what you want, though it's not possible to "save" such a map.
dzn.battlefield.pl - my Bf1942 modding website
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: obtaining object (pco) locations on a loaded map

Post by fo0k »

interesting :)

so I realise we cant be injecting things into a live game really unless local.. but thats not really needed. Also the pco's will be static as such so perhaps that will help with locking down their coordinates

What Im talking about is as simple as the mortar in DC for example.. I want to go in game.. place a stationary pco (a mortar) and then 'pause' game or whatever.. and then extract from memory the actual co-ord's of that mortar.


Then in practice one might place/spawn a few hundred objects, but instead of mortars they would be blocks/shapes (think minecraft maybe). then pause... extract all the pco co-ord's... write them to a text file and then be able to create an objectspawms.con for the server map.. then people join and eveyone sees the same blocks.. all spawned in correct position on the map.

does sound like you have got somewhere with extracting this info! :)

what do you think? heheh
User avatar
archer
Posts: 54
Joined: Fri Feb 05, 2010 4:40 pm
Location: Übertów
Contact:

Re: obtaining object (pco) locations on a loaded map

Post by archer »

My case was a bit simpler, because my program already knew positions of my objects. You basically want to extract all PCO positions from the memory.
The problem is that, after hours and hours of research, I was not able to identify the beginning of the PCO array in the memory. Given that, one could identify the PCO structure, determine the offset of the position vector, and the rest would be trivial: start from the beginning, read the position, then read the position+offset, then position+2*offset, and so on, done!
Failing that, I opted for a more crude approach:
1. Scan the whole program memory for anything that looks like 3 successive float values.
2. Filter out anything that doesn't make sense or is outside map
3. Filter out anything that appears in StaticObjects.con
4. After a while, rescan the memory, filter out anything that changed since the last scan (false positives, moving objects.)
I still ended up with lots of coordinates. Some of them were from PCOs, others were from players, spawn points, free cameras, or even completely bogus. You can reduce the noise by repeating step 4 for as many times as you like, but the end result is still not very usable. Oh, and one scan takes quite a while, even on a reasonably fast pc.
It looks like a dead end to me, unless of course you manage to reverse engineer the PCO array. I wouldn't bet on my cracking "skills", so maybe that's doable.
dzn.battlefield.pl - my Bf1942 modding website
Post Reply