Binutils.FindVirtualFunction()

Discuss API design here.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Binutils.FindVirtualFunction()

Postby Ayuto » Tue Dec 18, 2012 9:33 am

Hi,

I just noticed the latest revision and there might be two problems.

1. Linux offsets are not always one greater than Windows offsets. You can see an example here: http://forums.eventscripts.com/viewtopic.php?f=25&t=46254&start=6
The offset on Windows for CBaseClient::SetName() is 17, but on Linux it's 57 (at least in CS:S).

2. You should stick with one representation of pointers. For FindVirtualFunction() you used int, but for the rest you are using unsigned long (e.g. http://code.google.com/p/source-python/source/browse/src/core/modules/binutils/binutils_scanner.cpp#297 or http://code.google.com/p/source-python/source/browse/src/thirdparty/dyncall/include/dyncall_config.h?spec=svnb2ee4d7d859ef8e4236356117815c4cba729fabc&r=b2ee4d7d859ef8e4236356117815c4cba729fabc#43). You are going to crash if you try to call a function retrieved by FindVirtualFunction()!

Ayuto
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Dec 18, 2012 9:37 am

We are already working on these issues, but thank you for noticing them. I only added the code because it needed added. I am certainly not a C++ programmer, as the first time I wrote anything in C++ was for this project just a couple months ago, so I figured there would be some minor issues.

Satoon
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Tue Dec 18, 2012 9:47 am

I'm new to C++ as well (I started at the end of my summer holidays), but that's what I noticed when using SPE in combination with my C++ - Python library. This is not a reproach!
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Tue Dec 18, 2012 1:25 pm

Since I'm somewhat more advanced C++ programmer (been doing it for ~4 years, not a professional yet tho) and my father is one of the world's finest programmers so I can ask him for help at anything, I would love to help a little with this project. Problem is, I've got barely any knowledge of source engine — How much exactly do I need to know of the source stuff, and where could I learn it if I wanted to help, or is it even possible for someone who doens't know much about source engine to help? :P
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Tue Dec 18, 2012 5:05 pm

Well, we already have 3 very good C++ programmers, but they have just been fairly busy lately. I mostly have been adding stuff to try to help me get into C++ and actually start learning it. And, the things I have added is functionality that I know people have been waiting for to be added to the plugin. That is not to say that if you posted something, we wouldn't look into it and see about adding it.

Satoon
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Fri Dec 21, 2012 4:18 am

Hey Ayuto,

Interesting. First time I hear that virtual offsets are so far away from each other on different platforms. I think that the best way to do is adding a second parameter (defaulted to false) to ignore platform checks.

Thanks for the head up,

L'In20Cible
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Dec 21, 2012 11:09 am

Heh yes, that gave me a headache and took me some time to find that out.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Fri Dec 21, 2012 2:10 pm

Hey,

Just to let you know, FindVirtualFunction now accepts a third parameter (optional, defaulted to False) to disable platform check if set to True.

L'In20Cible
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Dec 21, 2012 4:51 pm

Looks fine now! :)

Return to “API Design”

Who is online

Users browsing this forum: No registered users and 10 guests