Exemple #1
0
void CEvBlk::Skip(DWORD DeltaID)
  {
  DeltaID--;
  if (DeltaID<=0x1F)
    {
    pData[pTS->iLen++] = (TS_SKIP_0 | (byte)DeltaID); 
    }
  else if (DeltaID<=0x1FFF)
    {
    pData[pTS->iLen++] = (TS_SKIP_1 | ((byte)DeltaID & 0x1F)); 
    pData[pTS->iLen++] = (byte)_lrotr(DeltaID, 5);
    }
  else if (DeltaID<=0x1FFFFF)
    {
    pData[pTS->iLen++] = (TS_SKIP_2 | ((byte)DeltaID & 0x1F)); 
    *((WORD*)&pData[pTS->iLen]) = (WORD)_lrotr(DeltaID, 5);
    pTS->iLen += 2;
    }
  else if (DeltaID<=0x1FFFFFFF)
    {
    *((DWORD*)&pData[pTS->iLen]) = (DWORD)_lrotr(DeltaID, 5);
    pData[pTS->iLen++] = (TS_SKIP_3 | ((byte)DeltaID & 0x1F)); 
    pTS->iLen += 3;
    }
  else
    {
    dbgpln("DeltaID in historian %d is to large !!!!!", DeltaID);
    VERIFY(FALSE);
    }
  }
Exemple #2
0
unsigned long thirtytwobits(unsigned long seed)
{
/*  In use, we call sixteenbits(seed) once
 with some nonzero seed, and from then on call it
 with seed value zero to get the next random value.  It also works fine
 if you don't seed it it all, but for short runs you may want to start
 from different seeds. Using the same seed twice produces the same
 sequence of numbers.*/

	register unsigned long l,c,r;

	if (seed)
	{
		shiftregister = seed;
		count = 0;
		return seed;
	}
	l = r = c = shiftregister;
#ifndef MYMACROS  //Borland compiler
	l = _lrotr(l, 1);/* bit i of l equals bit just left of bit i in c */
	r = _lrotl(r, 1);/* bit i of r euqals bit just right of bit i in c */
#else  //other compiler
	l = MYLROTR(l);/* bit i of l equals bit just left of bit i in c */
	r = MYLROTL(r);/* bit i of r euqals bit just right of bit i in c */
#endif //MYMACROS
	c |= r;
	c ^= l;		/* c = l xor (c or r), aka rule 30, named by wolfram */
	c ^= count;	/* rucker's trick to  make reaction self-sustaining */
	count++;
	shiftregister = c;
	return c;
}
Exemple #3
0
int HashFunction5 ( char* Word )
{
    if ( *Word == '\0' )
        return 0;
    if ( *( Word + 1 ) == '\0' )
        return ( int )( ( unsigned char )( *( Word ) ) );
    return ( ( _lrotr ( HashFunction5 ( Word + 1 ), 1 ) ) ^ ( int )( ( unsigned char )( *Word ) ) );
}
Exemple #4
0
// set data to network byte order
void CCapsLoader::Swap(PUDWORD buf, int cnt)
{
#ifdef INTEL
	for (cnt>>=2; cnt > 0; cnt--, buf++) {
		UDWORD src=*buf;
		UDWORD dst=_lrotl(src, 8)&0x00ff00ff | _lrotr(src, 8)&0xff00ff00;
		*buf=dst;
	}
#endif
}
typedef struct {
	s8 magic[13];		// "MalieScenario"
} mls_header_t;
#pragma pack ()

static int is_libu, is_encryption;

static unsigned int keyTable[CAMELLIA_TABLE_WORD_LEN];

static void rotate16bytes(u32 offset, DWORD *cipher)
{
	BYTE shifts = ((offset >> 4) & 0x0f) + 16;

	cipher[0] = _lrotl(cipher[0], shifts);
	cipher[1] = _lrotr(cipher[1], shifts);
	cipher[2] = _lrotl(cipher[2], shifts);
	cipher[3] = _lrotr(cipher[3], shifts);
}

static void *memstr(void *_dst, int len, char *src)
{
	BYTE *dst = (BYTE *)_dst;
	for (int i = 0; i < len; ++i) {
		for (int k = 0; src[k]; ++k) {
			if (dst[i + k] != src[k])
				break;
		}
		if (!src[k])
			break;
	}
Exemple #6
0
void main()
  {
    mask = _lrotr( mask, 4 );
    printf( "%08lX\n", mask );
  }
static __inline u32 __wsbh(u32 rt) { return  _lrotr(__wsbw(rt), 16); }
static __inline u32 __rotr(u32 rt, u32 sa) { return _lrotr(rt, sa); }