logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
ObjectToString for development?

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Mon Jun 15, 2009 16:03    Post subject: ObjectToString for development? Reply with quote

Guys, when making a nwnx plugin, do you use the ObjectToString function to get a hex string of an object, and then use a Memory Disassembler to locate that object in the memory of the server process?

Im just wondering if this is how you would get started making a nwnx plugin for player related functions.

Eg - Get the Player/character hex value, search for it in memory, and then in theory, feats, skills etc would be a pre-set amount of bytes on into the memory - eg Offset.


Basically, im asking, are you able to use ObjectToString as a pointer/Starting Point at all?



Still not tried to develop my own nwnx plugin, since I am stuck on a xp64bit machine. Might have to try installing a new partition on my desktop to get windows xp working - to give it a go.



Of course...
If anyone wants to port NWNeXalt to windows, that would solve all my problems. Lol

Primarily, would love to get Feat/Ability/Skill edits working minus Letoscript.
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Mon Jun 15, 2009 19:45    Post subject: Reply with quote

ObjectToString does not return a pointer or anything close, so no. The game does have a function for going from object ID to, say, creature object, but it's more common to hook functions and then use the arguments passed to those functions, which necessarily include most objects that will be used, or a simple way to get at them.

A good example (though there are many others) is plugins/weapons/hooks/h_GetEpicWeaponDevastatingCritical.c. Note how the hook is simply a function with the same prototype as the function being hooked, and uses the arguments passed to the original function.

Doing this on Windows is slightly different, because the 'this' pointer is passed in a register rather than on the stack, so needs to be handled specially. The concept of "how you access the data" is the same, though.
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Thu Jun 25, 2009 2:28    Post subject: Reply with quote

A fellow could ask almost anything in the world in the field of computer science and find people leaping to answer, but something about debugging always returns crickets and silence.

Well, since I have written an NWNX plugin (that actually works) I'll share with you how I did it.

First and foremost, I want to say you need to use a way that works best for what you were trying to solve. I made a plugin to beat the TMI limit, so naturally I wanted to start off close to the script engine.

I fired up IDA, the debugger that virusman recommended to me, and found the hook written originaly by Papillion inside the instruction image and setup a breakpoint. I called SetLocalString() in my mod to trip the breakpoint (since this is the function he originally hooked). I then did analysis in the surrounding area, stepped the functions, and so on, until I saw where the instruction counter was incremented and I knew what to do.

I also started writing a plugin similar to nwnx_functions (for Windows) - I've never released this yet since I've only got like 3 functions and have lost the will to bother with it (perhaps I feel the project is not valueable enough to pursue). I went about that one much differently. I made an NWNX function that used ReadProcessMemory() near the GameObject array and would make memory dumps and write them to file. Then, between two successive runs, I'd compare them in Ultra-Edit in hex mode. Obviously differences were often what some thread or another might have been doing at that precise moment in time, but some are glaringly obvious.

There are really a lot of different ways how you can go to start on your problem.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group