Forum

Page 4 of 5 FirstFirst ... 2345 LastLast
Results 46 to 60 of 72
  1. #46
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    Code:
    char* resChPtr;
    int resGetChVar = ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resChPtr);
    String^ a = String::Copy(gcnew String(resChPtr));
    So like that? The problem is this still crashes, same error...
    I commented out the Add part, now it does not crash anymore, it hangs itself instead...

    The only loop I have now is the While loop that loops over the Clientlist / Channellist.
    And if the arrays there are really NULL-Terminated that one should not be infinite.

    Code:
    if (resChL == ERROR_ok) {
    	int i = 0;
    	while (channelListPtr[i++] != NULL) {
    		char* resChPtr; // Creating resChPtr here
                    /* Setting pointer here */
    		int resGetChVar = ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resChPtr);
    		/* Copying resChPtr to new string here */
                    String^ a = String::Copy(gcnew String(resChPtr));
                    /* Checking if I could get the channelnames */
    		if (resGetChVar == ERROR_ok) {
                            /* Works, add string a to channellist */
    			channel->Add(a);
    		}
                    /* Now that I am done using resChPtr I can safely delete it, since I don't need it anymore. */
    		ts3Functions.freeMemory(resChPtr);
    	}
            /* Here, delete channelListPtr when done using it, since I left my loop over it and its not needed anymore */
    	ts3Functions.freeMemory(channelListPtr);
    }
    Last edited by Jhhhj_original; March 13th, 2017 at 01:27 PM.

  2. #47
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Quote Originally Posted by Jhhhj_original View Post
    Code:
    char* resChPtr;
    int resGetChVar = ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resChPtr);
    String^ a = String::Copy(gcnew String(resChPtr));
    So like that? The problem is this still crashes, same error...
    No. Depending on the implementation of the String class, this might not make a difference. I meant using one function of the strcpy family to copy the string, then use this copy to initialize your String^.

    But again, never used .Net, I might be wrong.

    Btw. your loop won't work as expected. On first iteration, your while-condition will set i to 1. So in the while-body the call to getChannelVariableAsString won't get the first channel's name, but the second.
    Code:
    int list[] = {1, 2, 3, 4, 0};
    i = 0;
    while (list[i++] != 0) {
      printf("i = %d\n", list[i]);
    }
    This will print:
    Code:
    i = 2
    i = 3
    i = 4
    i = 0
    I always use for-loops for that:
    Code:
    for (int i = 0; channelListPtr[i]; ++i) {
      //now i is valid
    }

  3. #48
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    I have no idea...

    I copied the char* to another local char* using strcpy(), I even initialized the pointers to make sure there was no pointer to a random location... Still crashes! Still same error, same crash.
    Absolutely to idea...

    Imma upload to GitHub I guess, so it is easier to review...

  4. #49
    Join Date
    May 2016
    Location
    Idar-Oberstein
    Posts
    163
    Couple of potential problems (fixed)
    Code:
    for (int i = 0; channelListPtr[i]; ++i) {
      char* resChPtr; // Creating resChPtr here
      /* Setting pointer here */
      const auto resGetChVar = ts3Functions.getChannelVariableAsString(schid, channelListPtr[i], CHANNEL_NAME, &resChPtr);
      /* Checking if I could get the channelnames */
      if (resGetChVar == ERROR_ok) {
        /* Copy things only if the source actually is ok */
        String^ a = String::Copy(gcnew String(resChPtr));
        /* Only delete ressources that you got with ERROR_ok */
        ts3Functions.freeMemory(resChPtr);
        /* add string a to channellist */
        channel->Add(a);
      }
      else
      {
        so_sad(resGetChVar);
      }
    }

  5. #50
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    Still...
    Same logging, same problem, same error message.
    I seriously don't know whats wrong.

    https://github.com/WhOoKie/TS3WKVC/b...ter/plugin.cpp
    My Sourcecode file.

    https://www.dropbox.com/s/6s5xrg4dkt...be2fe.dmp?dl=1
    The Crashdump

    https://www.dropbox.com/s/3136ja02jy...03853.log?dl=1
    The Logfile

    Is there any other way to do this than the way I am trying?
    So I don't have to go through all that crap?

  6. #51
    Join Date
    February 2017
    Posts
    45
    how do you get those log and dmp files?? I have a crash problem, too and that would be much easier to find the problem

  7. #52
    Join Date
    May 2016
    Location
    Idar-Oberstein
    Posts
    163
    I know little about C#, however one might try something like
    Code:
    String^ a = String::Copy(Marshal::PtrToStringAnsi((IntPtr) (char *) resChPtr));
    as in I don't see a C# string constructor that takes a const char*.

    @GT-Anakin
    Logs & crashdumps are, depending on selection during install, in %APPDATA%/TS3Client or INSTALLDIR/config.

  8. #53
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    It is not C# it is C++ CLI.
    But your Marshalling way might be a good idea, I'll see

  9. #54
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    Quote Originally Posted by GT-Anakin View Post
    how do you get those log and dmp files?? I have a crash problem, too and that would be much easier to find the problem
    They are where you install your plugin, for me in TS3Client\Crashdumps.

  10. #55
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    For everyone:
    So far, marshalling has been proven to fix my crashing problem, as suggested by throwe.

    NOPE, nevermind.

    So actually, for sure, the problem lies in the channel->Add(a)
    My new function does return a string, and also the correct string.
    So, as soon as I want to append it to my List, is crashes.
    Again, same error, same log.

  11. #56
    Join Date
    October 2015
    Location
    Austin
    Posts
    17
    I suggest attaching to the process to make debugging much easier.
    Last edited by Birdboat; March 14th, 2017 at 08:19 PM.

  12. #57
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    Yes, I am using Visual Studio.
    The Problem is, I have to debug it inside TS3.
    Like, I know exactly where it crashes and what is wrong, but I don't get it fixed...

    Code:
    The thread has tried to read or write from a virtual address that it does not have permission for.
    System.NullReferenceException: The Objectreference was not set to the Objectinstance, occured in tsapi.assembleGrammar()
    Those are the error messages I got.
    And I have no idea how to interpret them and put them together to make my code work...

    EDIT:
    The (same but edited) part it crashes:
    Code:
    if (resChL == ERROR_ok) {
    	for (int i = 0; clientListPtr[i]; ++i) {
    		String^ a = getClientName(schid, clientListPtr[i]);
    		clients[i] = a;
    	}
    }
    else {
    	ts3Functions.logMessage("Could not assemble client grammar!", LogLevel_ERROR, "PLUGIN_VOICECONTROL", schid);
    }
    ts3Functions.logMessage("Assembled Client grammar", LogLevel_INFO, "PLUGIN_VOICECONTROL", schid);

  13. #58
    Join Date
    October 2015
    Location
    Austin
    Posts
    17
    Does it not say the exact line of where it crashes?

  14. #59
    Join Date
    October 2015
    Location
    Germany, Bavaria
    Posts
    142
    Yes, it does.
    If you check my file:
    https://github.com/WhOoKie/TS3WKVC/b...ter/plugin.cpp

    It crashes on line 275 and 286

  15. #60
    Join Date
    October 2015
    Location
    Austin
    Posts
    17
    Ok, so getChannelName and getClientName are probably the issue, mainly this line:
    Code:
    String^ a = String::Copy(Marshal::PtrToStringAnsi((IntPtr)(char*)tmp));
    There's nothing wrong with the pointer, because if there was, it would return "ERROR_GETTING_CLIENT/CHANNELNAME".
    First off, why are you casting tmp to char*? It doesn't need that conversion. I'm also almost positive that String::Copy isn't necessary. So I would write:
    Code:
    return Marshal::PtrToStringAnsi(new IntPtr(tmp))

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ts3Functions.requestChannelGroupClientList
    By Bluscream in forum Suggestions and Feedback
    Replies: 1
    Last Post: October 26th, 2016, 05:44 AM
  2. Problem with ts3Functions.getClientID()
    By Dione in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: August 30th, 2014, 10:40 AM
  3. Replies: 1
    Last Post: March 14th, 2013, 09:06 AM
  4. ts3Functions.createIdentity - where the heck is it?
    By sea212 in forum Client Plugins / Lua Scripts
    Replies: 7
    Last Post: March 1st, 2010, 06:14 PM
  5. [Solved] ts3Functions.requestClientMove
    By tomix in forum Client Plugins / Lua Scripts
    Replies: 2
    Last Post: February 22nd, 2010, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •