Results 1 to 3 of 3

Thread: Causes Crashes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    England
    Posts
    94

    Causes Crashes

    Hey Guys

    Code:
    void CMiscFunctions::CopyValueToBuffer(BYTE *pDataToCopy, BYTE *pBuffer, DWORD *dwLengthOfBuffer, DWORD dwSizeOfData)
    {
    
    	DWORD i = *dwLengthOfBuffer;
    
    	for(DWORD y = 0; y < dwSizeOfData; y++, i++)
    	{
    		pBuffer[i] = pDataToCopy[y];
    	}
    
    	*dwLengthOfBuffer = i;
    
    }
    This little piece of code works fine copying one buffer to the other up to 59kb if the buffer is bigger then this the program crashes any ideas. I originally had int y not DWORD y and was convinced it was the problem but it still causes a crash.

    Any Ideas

    Peter
    Last edited by pskyboy; Sep 29th, 2001 at 06:08 AM.
    "Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
    -- Judas Priest

    My email is [email protected]

  2. #2
    jim mcnamara
    Guest
    First place I would look -

    You need to use an unsigned counter & pointer datatype. Your datatype is 'rolling over'. maybe including DWORD SizeOfData.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I don't understand your usage of i. You first set it to the size of buffer, then increment it and use it as index. Or do you always supply 0 for dwLengthOfBuffer. If so, you should write i = 0; instead of i = *dwLengthOfBuffer.
    I can't help you with the 59k problem. Maybe you show us the declaration of the buffers and the function call.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width