Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 6 7 [8] 9 10 ... 108

Author Topic: DFHack 0.5.15 (legacy)  (Read 385984 times)

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #105 on: July 19, 2010, 09:30:14 am »

peterix i want to add function calling to SHM. Is it better to add it to core or as  a diffrent module? What commands to implement?
I was thinking something like:
Code: [Select]
enum FUNCTION_COMMAND
{
    FUNCTION_INIT = 0, // initialization
    FUNCTION_CALL_PASCAL,
    FUNCTION_CALL_THISCALL,
    FUNCTION_CALL_...etc...
    FUNCTION_GETRESULT,
    NUM_FUNCTION_CMDS
};

although i used something different in my programs (also heavy use of debugger...)
it was like:
Code: [Select]
SetReg(REG_EAX,0);
Push(0);
Push(1);
Call(FUNC_PRINT);
GetRes();
Maybe this is better?

Edit: ugh... digging through code... Correct me if i'm wrong but it seems that SHM starts on any SDL call and really does something only when SDL_NumJoysticks is called? (is it called often?)
Edit2: also very usefull core commands could be: ALLOC_MEM, DEALLOC_MEM (in main DF thread, when function calls are implemented e.g. simple print call needs a pointer to string, so it would be ALLOC_MEM, write string into that mem, FUNCT_CALL,DEALLOC_MEM)
« Last Edit: July 19, 2010, 10:28:15 am by darius »
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #106 on: July 19, 2010, 11:01:22 am »

peterix i want to add function calling to SHM. Is it better to add it to core or as  a diffrent module?
If you want to change the core, only add new commands to the end. Every change should be also reflected in the version number of the module. I'd like to keep the core module intact though.

What commands to implement?
I was thinking something like:
Code: [Select]
enum FUNCTION_COMMAND
{
    FUNCTION_INIT = 0, // initialization
    FUNCTION_CALL_PASCAL,
    FUNCTION_CALL_THISCALL,
    FUNCTION_CALL_...etc...
    FUNCTION_GETRESULT,
    NUM_FUNCTION_CMDS
};
This looks pretty much OK to me, good enough for a low-level access to the process. Also, what about the differences in how compilers work here? I don't think GCC on Linux will produce functions that can be called the same way as MSVC on Windows.
although i used something different in my programs (also heavy use of debugger...)
it was like:
Code: [Select]
SetReg(REG_EAX,0);
Push(0);
Push(1);
Call(FUNC_PRINT);
GetRes();
Maybe this is better?
Maybe too low-level? It could be useful, but note that the more granularity you add, the slower the results. Each such call requires a context switch on a single-core CPU (under ideal conditions. if there's a third CPU-bound process, it can easily degrade the connection). Ideally, there would be pre-made SHM commands for the most used calls, possibly hiding the differences produced by DF's compiler. If the symbols were exported, at least there would be some sure way to call them... this probably isn't easy.
Edit: ugh... digging through code... Correct me if i'm wrong but it seems that SHM starts on any SDL call and really does something only when SDL_NumJoysticks is called? (is it called often?)
SDL_NumJoysticks is called by DF after (or before, same thing) each simulation frame. That means that with a fort that gets 100FPS, SDL_NumJoysticks will be called at the same rate. At that point DF's memory should be in a consistent state for the game thread. A similar outcome could be achieved by placing a breakpoint.
« Last Edit: July 19, 2010, 11:03:06 am by peterix »
Logged

ASnogarD

  • Bay Watcher
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #107 on: July 19, 2010, 04:22:32 pm »

Peterix, I was just curious on how difficult it would be to use DFHack to pull up 'events' for the Soundsense program to utilise as audio cues ?

I am not knowledgeble in the whole programming but as I understand it, your program scans the memory of the machine as DF is running and can monitor changes in the variables in memory and relay a trigger to the program thats is using DFHack.
Could a person use this to look for variable that may indicate a event so as to act as a cue for the audio to play ?

I am just curious so theres no urgency, thanks for taking the time to read my question .
Logged

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #108 on: July 20, 2010, 08:23:17 am »

The source was easy to understand, thank you for writing this.
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #109 on: July 20, 2010, 09:57:29 am »

Ok..

I can add up the different types of items I have.

I can find the workshops available to make those items if I need more.

I can't figure out how to see what a workshop is working on or how to give it something to work on.

If I get that last part done, I should have a pretty good dwarf forman program going on here.
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #110 on: July 20, 2010, 11:07:01 pm »

Memory hacking is so hard for me :( I didn't get as much time today on it as I wanted but here is what I have so far..

Each building has a job list, which is 10 pointers.

The pointer to the front of the list is +0x58 from the building structure, and +0x5c is the current position in the list.

The actual job structure first starts with its ID, the ID is an incrementing value like.. 20,21,22,23... the counter for 31.10 is static at 0x00DE1A20.....
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

Esa94

  • Escaped Lunatic
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #111 on: July 21, 2010, 05:48:30 am »

There still seem to be some problems with Linux memory addresses in 0.31.10. I tried launching Stonesense and it crashed with the following DFHack error:
Code: [Select]
terminate called after throwing an instance of 'DFHack::Error::MissingMemoryDefinition'
  what():  memory definition missing: type address key current_menu_state
Aborted
(Apparently the Windows version works, though.)

Used the latest Memory.xml and libdfhack compiled from the git repository.
Logged

smjjames

  • Bay Watcher
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #112 on: July 23, 2010, 01:48:30 pm »

*bumpage* since .11 is out and waiting for a DFHack update.

Wish updating DFHack was as easy as getting some vectors and whatever like with DFTherapist.
Logged

Ratbert_CP

  • Bay Watcher
    • View Profile
    • The Enraged Primate
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #113 on: July 23, 2010, 01:50:46 pm »

*bumpage* since .11 is out and waiting for a DFHack update.

Wish updating DFHack was as easy as getting some vectors and whatever like with DFTherapist.

But it is!  The issue is that DFHack needs more vectors and offsets than DT.  :)
Logged
Ratbert #CP#Z
"For FUN and HONOR!"

smjjames

  • Bay Watcher
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #114 on: July 23, 2010, 02:02:37 pm »

*bumpage* since .11 is out and waiting for a DFHack update.

Wish updating DFHack was as easy as getting some vectors and whatever like with DFTherapist.

But it is!  The issue is that DFHack needs more vectors and offsets than DT.  :)

Well okay, but how do you get them and apply them? DT has it easier on that front.
Logged

Ratbert_CP

  • Bay Watcher
    • View Profile
    • The Enraged Primate
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #115 on: July 23, 2010, 02:26:57 pm »

*bumpage* since .11 is out and waiting for a DFHack update.

Wish updating DFHack was as easy as getting some vectors and whatever like with DFTherapist.

But it is!  The issue is that DFHack needs more vectors and offsets than DT.  :)

Well okay, but how do you get them and apply them? DT has it easier on that front.

Aye.  There's the rub.  DT needs much fewer memory locations than DFHack.  That's because it's only dealing with the Dwarves themselves, not all the other stuff (tiles, materials, etc.).  Sadly, the tools aren't available to speed up the search for the more esoteric vectors/offsets, so we need to wait for peterix or another memhacking guru to find them.  DT provides tools to find the few offsets it needs.  Before anyone gets too bent out of shape, I think the values DT needs have pretty well-defined and static landmark string nearby, whereas DFHack requires values that may be based on other values that need to be found first, etc.  i.e., Not quite so simple.

Of course I could be wrong, but it helps me sleep at night... ;)
Logged
Ratbert #CP#Z
"For FUN and HONOR!"

sizeak

  • Bay Watcher
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #116 on: July 23, 2010, 02:42:40 pm »

You can *borrow* the DT offsets, you just have to adjust them. Vectors from DT need 0x8 subtracting from them to get them to work with DFHack. Sadly they haven't found material addresses, which is what RS is currently failing on :(
Logged
Runesmith - http://www.bay12forums.com/smf/index.php?topic=59056.0 - A Dwarf Companion like tool

SeveQ

  • Bay Watcher
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #117 on: July 23, 2010, 03:07:41 pm »

DF itself should be able to determine the needed offsets. I wonder if Toady was willing to add a feature that would log some offsets somewhere. Just my two cents...
Logged

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #118 on: July 23, 2010, 07:30:03 pm »

http://www.bay12forums.com/smf/index.php?topic=43260.msg1425561#msg1425561

Copy that file into your dfhack directory and it should work(if you're using windows-sdl lol).

On a side note, I finally figured out how to create jobs from dfhack lol.
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

smjjames

  • Bay Watcher
    • View Profile
Re: DFHack 0.4.0.2 - tools and memory access library
« Reply #119 on: July 23, 2010, 10:29:11 pm »

http://www.bay12forums.com/smf/index.php?topic=43260.msg1425561#msg1425561

Copy that file into your dfhack directory and it should work(if you're using windows-sdl lol).

On a side note, I finally figured out how to create jobs from dfhack lol.

It works now, thank you! :)
Logged
Pages: 1 ... 6 7 [8] 9 10 ... 108