Author Topic: Pointers  (Read 2585 times)

Offline Spikerocks101

  • Hero Member
  • *****
  • Posts: 711
Pointers
« on: June 23, 2009, 10:39:10 AM »
I was wondering, can you use pointers to read varibles from other programs and edit them? I was wanting to make a simple program to read all of your resources in op2, and then just show you them for dual monitar (1 monitor is the game, the other is all your information). I.E. shows you how many people you have, structures, and other info. I know the game shows it already, but i mainly want to make a program to manage research better. I would like to know if theres a way i can view/edit varibles and stuff from op2 while playing. not for cheating, just to kinda add something. just wondering.
I AM YOUR PET ROCK!!!!!!

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
Pointers
« Reply #1 on: June 23, 2009, 11:13:40 AM »
It is possible to have an external program that reads the data and displays it.

How that is done is not my field.
"Nothing from nowhere, I'm no one at all"

Offline Brazilian Fan

  • Sr. Member
  • ****
  • Posts: 302
Pointers
« Reply #2 on: June 23, 2009, 11:14:44 AM »
Yes, if you know what's their address and types. Having the target program load a custom DLL would be the best way, since it's loaded in the same segment. Then you'd only have to get the base address of the target and the offset of the desired variable, plus some kind of hook to have your code run. You can also use in-memory patching, although I don't remember the exact WinAPI functions exactly, it has something to do with ReadMemoryAddress() or something like that (search MSDN).
I'm not entirely sure though. Hooman or BlackBox should be able to give you a better answer.

Offline Spikerocks101

  • Hero Member
  • *****
  • Posts: 711
Pointers
« Reply #3 on: June 23, 2009, 11:23:24 AM »
hmm, ok. I'm pretty noob at this, and my understadning of pointers and dlls is very little. I think (thou don't know at all) that they would store things like current thing being constucted in varibles, and i think when something gets finished constuction, the game gets notifed (i.e. they use a timer, or an actual verible saying constuction complete) so i would do some code so that, at vechile factories, when constuction is complete, build previous item if you have enough money and so on. again, these are all guess', and even if i get the code, i really don't know how to aproch it, so if you could explain it, that would be aweseom.
I AM YOUR PET ROCK!!!!!!

Offline Brazilian Fan

  • Sr. Member
  • ****
  • Posts: 302
Pointers
« Reply #4 on: June 23, 2009, 11:31:42 AM »
Go here before doing anything. When you have a proper "understadning" of pointers and dynamic linking, ask again.

Have a nice day :D.

Offline Spikerocks101

  • Hero Member
  • *****
  • Posts: 711
Pointers
« Reply #5 on: June 23, 2009, 11:42:09 AM »
Atleast you didn't say "See you on tuesday" >_>
I AM YOUR PET ROCK!!!!!!

Offline Brazilian Fan

  • Sr. Member
  • ****
  • Posts: 302
Pointers
« Reply #6 on: June 23, 2009, 11:51:25 AM »
Quote
Atleast you didn't say "See you on tuesday" >_>
Although I do think you have a bit of troll's mentality, I don't go 'Sirbombing' on every one until the situation is hopeless.

See you on tuesday B).

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Pointers
« Reply #7 on: June 23, 2009, 02:15:29 PM »
Slightly off topic:
How can a program not change the memory adress?

Doesn't that just mean you're f***ed when another program allready stored stuff there?

Offline Brazilian Fan

  • Sr. Member
  • ****
  • Posts: 302
Pointers
« Reply #8 on: June 23, 2009, 02:22:28 PM »
Quote
Slightly off topic:
How can a program not change the memory adress?

Doesn't that just mean you're f***ed when another program allready stored stuff there?
You mean absolute or segmented? If you mean absolute, it almost certanly changes the base address. But if it's segmented, it doesn't (all addresses are relative to 0). But still, you need to know the offset of the target variables.
I'm not completely sure about this, as PE files have a relocation segment and a preferred memory address :blink:.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Pointers
« Reply #9 on: June 23, 2009, 03:25:28 PM »
Quote
Although I do think you have a bit of troll's mentality, I don't go 'Sirbombing' on every one until the situation is hopeless.
You got some kinda problem with me punk?
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Pointers
« Reply #10 on: June 24, 2009, 12:17:46 AM »
A pointer has an implied address space, and is only valid in that one address space. Each executable is run in it's own address space. Hence pointers in use by one executable will never interfere with the memory of a separate executable. A DLL is loaded into the address space of the executable referencing it. Pointers can be shared between executables, and the DLLs that it loads, and they can freely overwrite each other's memory. Note that a DLL can be loaded into the address space of two executables at the same time, but this implies that those two running copies of the DLL are separate from each other and can't write to each other's memory. The same thing happens if you start two copies of the same executable. They each run in a separate address space and can't overwrite each other's memory.

There are of course exceptions to this. There are some debugging functions that let you read and write memory in another process. They probably require admin access to use them though. When using them, you have to specify both an address space, and a pointer into it's memory. The address space is specified using a handle to the running process.

There are also shared memory segments. However, this requires co-operation from both address spaces, as they both need to setup handles to the shared space, and generally need to follow some sort of memory access pattern to keep the two processes from corrupting the shared area.


Now, first of all, I'd like to state I think you're getting in way over your head. What you want to do is not particularly easy, and will require both a lot of knowledge of programming, and a lot of knowledge on how Outpost 2 works internally.


I suppose I could go on at great length on this subject, but I somehow doubt it would really end up helping anybody. In short, what you want to do it not possible using simple pointers.
 

Offline Spikerocks101

  • Hero Member
  • *****
  • Posts: 711
Pointers
« Reply #11 on: June 24, 2009, 05:30:07 AM »
oh, ok. thanks any way all :D
I AM YOUR PET ROCK!!!!!!

Offline Brazilian Fan

  • Sr. Member
  • ****
  • Posts: 302
Pointers
« Reply #12 on: June 24, 2009, 10:47:38 AM »
Quote
Quote
Although I do think you have a bit of troll's mentality, I don't go 'Sirbombing' on every one until the situation is hopeless.
You got some kinda problem with me punk?
Not at all. I was just making fun of you and Spikerocks101 :lol:.