PDA

View Full Version : Anyone successfully imported the SDK-DLL in C/C++?


Kabukiman
12-06-2004, 18:34
Hi there!

I'm planning to code some tools for TS for my Clan, and I'm struggling hard with the Delphi/Pascal Stuff...

Can anyone send or post all the defines/typedefs needed to call the Functions in the DLL from C/C++?

Kabukiman
12-06-2004, 23:22
Ah, I solved it with the help of [DUCK]Butcher and his OSD-Linux-Tool.

http://www.teamspeak.org/forums/showthread.php?t=12960

Thanks mate, I checked your SourceCode and finally I got the whole stuff working under Windows...

You really saved my day!

[DUCK]Butcher
13-06-2004, 21:57
Well - Nice, that my application is helping other people.

BUT:

There are not ALL functions imported. There are WAY MORE functions available.
I have _EXTREMELY HARD PROBLEMS_ with calls that return data in structs! The data returned is partly corrupted and therefore partly _USELESS_. A friend of mine said, that it could be due to interoperation of a kylix-lib with a C-prog.
Anyone has an idea? This is the data returned by the function call tsrGetSvInfo (extracted via GDB):
(gdb) print tvSvInfo
$1 = {ServerName = "[DUCK] Teamspeak", '\0' <repeats 13 times>,
WelcomeMessage = "Welcome to motherfucking [TEAMSPEAK]",
'\0' <repeats 218 times>, ServerVMajor = 0, ServerVMinor = 1245184,
ServerVRelease = 2621440, ServerVBuild = 1766588416,
ServerPlatform = "nux", '\0' <repeats 25 times>, "62",
ServerIp = ".109.92.10:42131", '\0' <repeats 12 times>, "ts",
ServerHost = ".cbct.de:42131", '\0' <repeats 84 times>, "\005",
ServerType = 33554432, ServerMaxUsers = 536805376,
SupportedCodecs = 1179648, ChannelCount = 1966080,
PlayerCount = 0}
As you can see, some char[] are cut off and some Integers contain just JUNK. I fiddled around with char[]-sizes, but it changes absolutely NOTHING. :mad:

Maybe you can tell me, if you experience the same problem with your windows-applications and perhaps send me your code? Would be fine! Any other comments on this are _very_ welcome. :)

Kabukiman
14-06-2004, 13:11
That's strange...

I have the same problems with the function "GetServerInfo".

Very strange int are coming back, instead of "Win32", I get "n32" as Platform etc.

In fact every char-array has the first 2 chars missing...
I'll dig deeper into it, as I had these problems when I used "my" version of importing the functions, not yours!

I already import the other functions (was easy once I understood how you are doing it), but don't use them yet (except GetChannelInfoByID, which works okay so far).

I'll post if I have the same problems like you!

Kabukiman
14-06-2004, 20:32
Okay, I checked it with the tsrSvInfo-function.

Make sure you have the exact sizes of the members in the structs!

I'm using:

#pragma pack(push,1) //Byte alignment
struct TtsrServerInfo
{
char ServerName[30];
char WelcomeMessage[256];
int ServerVMajor;
int ServerVMinor;
int ServerVRelease;
int ServerVBuild;
char ServerPlatform[30];
char ServerIp[30];
char ServerHost[100];
int ServerType;
int ServerMaxUsers;
int SupportedCodecs;
int ChannelCount;
int PlayerCount;
};
#pragma pack(pop)


Using this everything works okay at my side!
My mistake was to set the ServerIp-Member too large... this somehow screwed it all up... Now all the ints (Playercount, Majorversion etc) show the true values after calling the tsrSvInfo-function.

I hope I could help...

[DUCK]Butcher
14-06-2004, 22:02
i checked the struct once again, but it doesn't change anything! here is my code:
struct TtsrServerInfo
{
char ServerName[30];
char WelcomeMessage[256];
int ServerVMajor;
int ServerVMinor;
int ServerVRelease;
int ServerVBuild;
char ServerPlatform[30];
char ServerIp[30];
char ServerHost[100];
int ServerType;
int ServerMaxUsers;
int SupportedCodecs;
int ChannelCount;
int PlayerCount;
};

Kabukiman
15-06-2004, 09:28
What about the Byte-Alignment?

#pragma pack(push,1) tells my compiler (Visual Studio .NET 2003) to align all struct-members at 1 Byte-boundaries

MSDN: #pragma directive "pack" (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/pragm_22.asp)

Maybe your compiler supports manual boundary-setting, too?

[DUCK]Butcher
20-06-2004, 19:37
YEAH!
You saved my life! :D

Looks like that was the failure.
I think i would never have thought of such a mistake :p

Thank you very much!

(Looks like I'm still a C-Noob :( )

Kabukiman
21-06-2004, 07:34
I am glad that I was able to help you!

BTW, I checked your new sourcecode (0.31), and there's no need to call up the #pragma pack/pop before and after every struct.

This will do, too:

#pragma pack(push,1)
struct TtsrPlayerInfo
{...};
struct TtsrServerInfo
{...};
struct TtsrChannelInfo
{...};
struct TtsrUserInfo
{ ... };
#pragma pack(pop)