SHARE
TWEET

Untitled

a guest Feb 4th, 2017 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int write_bootdata(unsigned char* buf, int len,unsigned int boot_volume)
  2. {
  3.     (void) boot_volume;
  4.     struct boot_data_t *boot_data = NULL;
  5.     int ret = 0;
  6.     unsigned int i;
  7.     unsigned int magic[2] = {BOOT_DATA_MAGIC0, BOOT_DATA_MAGIC1};
  8.     if (len < BOOT_DATA_SEARCH_SIZE)
  9.         ret = EKEY_NOT_FOUND;
  10.  
  11.     if (ret == 0)
  12.     {
  13.         /* search for boot data header prior to this offset */
  14.         for(i = 0;i <= (BOOT_DATA_SEARCH_SIZE - sizeof(struct boot_data_t));i++)
  15.         {
  16.             if ( memcmp ( &buf[i], &magic[0], sizeof(magic) ) == 0)
  17.             {
  18.                 boot_data = (struct boot_data_t*) &buf[i];
  19.                 boot_data->boot_volume = 0x52622300 | boot_volume;
  20.                 boot_data->crc = magic[0] ^ magic[1] ^ boot_data->boot_volume ^ len;
  21.                 break;
  22.             }
  23.         }
  24.         if (boot_data == NULL)
  25.             ret = EKEY_NOT_FOUND;
  26.  
  27.     }
  28.  
  29.     return ret;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top