Results 1 to 5 of 5

Thread: Place a uint > 255 in a buffer

  1. #1
    Join Date
    May 2008
    Posts
    859

    Place a uint > 255 in a buffer

    I am currently working on frames by developing a network driver, so I follow hexa placed in buffers. I would add the size of my package to the frame in my buffer, here's how I proceeded:

    Code:
    UINT size = 4512, // I put a fixed value for my test 
    memset (pDest, size, sizeof (size)) // I send this value in my buffer pDest 
    //then after I send the frame ...
    in hex 4512 = 11A0, or when I do my screen I can see that A0:: a0 a0 a0 a0 ff ff ff ff ff ff 45 75 ...

    how do I get for example: 00 00 11 a0 ff ff ff ff ff ff 45 ...

    I am not very clear, I hope you see my problem, thank you.

  2. #2
    Join Date
    May 2008
    Posts
    945

    Re: Place a uint > 255 in a buffer

    The memset () that you give the data value (unsigned char) size with sizeof (size) of characters beginning in pDest table.

    If you want your chars have different values

    Code:
    pDest [3] = size % 256; 
    pDest [2] = (size/256) % 256; 
    pDest [1] = (size/256/256) % 256; 
    pDest [0] = (size/256/256/256) % 256;
    (Assuming pDest is indeed a pointer to unsigned char).

  3. #3
    Join Date
    Feb 2008
    Posts
    194

    Re: Place a uint > 255 in a buffer

    char * pdest = gnigni

    * ((UINT *) pdest) = size;
    pdest + = sizeof UINT;

    by effectively against the endianness depends cpu, so if you want big endian, you fall on the solution Programmer (but with >> and & in principle, or just a >>)

  4. #4
    Join Date
    May 2008
    Posts
    859

    Re: Place a uint > 255 in a buffer

    pDest is PUCHAR type, yes. As against it can not go through having to choose the character of the table? pDest [0], pDest [1 ],... I feel that is what the method of Ashok.M offers but I do not understand how it works?

  5. #5
    Join Date
    May 2008
    Posts
    945

    Re: Place a uint > 255 in a buffer

    When I write C++, I do not write assembler. When I write the assembler, not I do not write C++.

    I think this operation has a decomposition as in base 256, so I expressed it as:

    Code:
    size = ((p[0]* 256 + p[1])*256 + p[2])*256 + p[3];

Similar Threads

  1. Setting depth buffer (z buffer) size (16bit / 24bit)
    By NewComer in forum Monitor & Video Cards
    Replies: 4
    Last Post: 08-04-2010, 05:47 AM
  2. How to Cancel Printer Buffer
    By jennifer in forum Operating Systems
    Replies: 3
    Last Post: 04-09-2009, 03:21 PM
  3. How can i convert c# 'uint' to 'int'
    By Taipai in forum Software Development
    Replies: 3
    Last Post: 02-06-2009, 05:20 AM
  4. Buffer of a disk
    By Xan in forum Hardware Peripherals
    Replies: 3
    Last Post: 16-03-2009, 09:41 AM
  5. I'm having trouble with the buffer
    By monsitj in forum Technology & Internet
    Replies: 4
    Last Post: 22-09-2008, 07:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,892,384.60349 seconds with 17 queries