very annoying and strange problem.

This is a discussion on very annoying and strange problem. within the Windows Programming forums, part of the Platform Specific Boards category; details in the top commenting of the code.. Code: /* the problem is that after i call this function it ...

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    very annoying and strange problem.

    details in the top commenting of the code..

    Code:
    /* the problem is that after i call this function it crashes,
    before i used the EmcryptText function it worked fine but 
    ever since i added that the function crashes, i have made
    another program with the encrypt text function and made it
    output the result to a file and it seems to work 100% fine,
    even in this program i placed a messagebox after the function
    and it shows the correct text, i have used GetLastError in this
    function yet it seems to return 0 every time, the messagebox
    before the return 0; shows but if i place a messagebox after calling
    the function, it does not show..here is the code */
     
    int ClientPacket(char SendData[250])
    {
    	/* -------- function the client uses to send data -------*/
     
    	unsigned char buffer[252];
    	unsigned char data[250];
    	int i;
     
    	memset(buffer, 0 , sizeof(buffer));
    	strcpy(data, SendData);
     
    	EncryptText(&data[0]);
    	sprintf(&buffer[1], "%s" , data);
    	buffer[0] = strlen(&buffer[1]);
    	buffer[0] = buffer[0] ^ 3;
    	if((i = send(ClientSock, buffer, strlen(buffer), 0)) == -1)
    	{
    		return -1;
     
    	}
    	MessageBox(0, "test" , "Test", 0);
    	return 0;
    }
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    You have to make sure that whenever you're XORing all your data that you DONT create any \0 characters, because these will totally mess up all your strcpy / %s / strlen type functions which work on proper strings.

  3. #3
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    yes im checking for \0 for example
    Code:
    if((buffer[i] ^ key) == '\0')
    //do nothing
    i have also places a messagebox for the strlen of buffer and its showing the correct length, thanks for the reply
    Good Help Source all round
    Good help for win programmers
    you will probably find something in here
    this thing also helps

    if you have never tried any of the above then maybe you should, they help alot

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    In which line does it crash ? Does it reach the messagebox every time ? Can you step through it with a debugger ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strange ubuntu problem
    By Stonehambey in forum Tech Board
    Replies: 4
    Last Post: 04-21-2009, 11:03 AM
  2. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 06:36 PM
  3. Replies: 5
    Last Post: 08-05-2005, 12:09 PM
  4. Strange file problem.
    By tilex in forum C++ Programming
    Replies: 1
    Last Post: 12-28-2004, 11:32 PM
  5. MSVC behaves strange
    By ripper079 in forum C++ Programming
    Replies: 4
    Last Post: 10-28-2003, 07:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21