Code: Show/Hide void SwapEndian(void *pData, int iBytes)
{ if (iBytes % 2) //even check return; char *pSwapped = (char*)malloc(iBytes); char *source = (char*)pData + iBytes; char *dest = pSwapped; while (iBytes--) *dest++ = *source--; memcpy(pData, pSwapped, iBytes); free(pSwapped); } |
Code: Show/Hide void SwapEndian (void *pData, int iBytes)
{ char *p = (char *)pData; char *q = p + iBytes - 1; // don't even check for odd while (iBytes--) *p++ = *q--; } |
Code: Show/Hide #define SWAP2(x) ((x >> 8) | ((x & 0xff) << 8))
etc |
Code: Show/Hide inline void SwapEndian64(char *pData)
{ char cTemp; cTemp = pData[0]; pData[0] = pData[7]; pData[7] = cTemp; cTemp = pData[1]; pData[1] = pData[6]; pData[6] = cTemp; cTemp = pData[2]; pData[2] = pData[5]; pData[5] = cTemp; cTemp = pData[3]; pData[3] = pData[4]; pData[4] = cTemp; } |
Code: Show/Hide void SwapEndian (void *pData, int iBytes)
{ char *p = (char *)pData; char *q = p + iBytes - 1; // don't even check for odd while (iBytes--) *p++ = *q--; } int main(int argv, char **argc) { char test[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; SwapEndian(test, 8); return 0; } |
Code: Show/Hide void SwapEndian(void *pData, int iBytes)
{ char swapped[10]; //should not be used above 80 bits if (iBytes % 2) //even check return; char *source = (char*)pData + iBytes; char *dest = swapped; while (iBytes--) *dest++ = *source--; memcpy(pData, swapped, iBytes); } |
Code: Show/Hide void SwapEndian (void *pData, int iBytes)
{ char *p = (char *)pData; char *q = p + iBytes - 1; char ch; // don't even check for odd iBytes >>= 1; while (iBytes--) { ch = *p; *p++ = *q; *q-- = ch; } } |
Code: Show/Hide void switchtomac, it's cool
{ la la la smurfs are fun } |
Code: Show/Hide void switchtomac, it's cool
{ la la la smurfs are fun. } |
SuSE wrote: |
LIES!! I HAVE CODED A PROGRAM IN ASM THAT WILL EXTRACT YOUR BRAIN!! |
Mr Ekted wrote: |
The one with the 536,189 bit key? It's hopeless... |