Unnamed Fossil Project

Check-in [cf0c3331be]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:updated
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cf0c3331be5525ffe4bd746153d714ab606679f2
User & Date: alexey@sudachen.name 2011-08-07 17:41:38
Context
2011-08-20
17:55
updated check-in: 3b588728b9 user: alexey@sudachen.name tags: trunk
2011-08-07
17:41
updated check-in: cf0c3331be user: alexey@sudachen.name tags: trunk
2011-08-05
14:13
updated check-in: f79a51d5e8 user: alexey@sudachen.name tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to core.hc.

1570
1571
1572
1573
1574
1575
1576

1577
1578
1579
1580
1581
1582
1583
    Yo_Unwind_Scope(0,-1);
    exit(code);
  }
#endif
  ;

#define __Pool(Ptr)                     Yo_Pool_Ptr(Ptr,0)

#define __Release(Pooled)               Yo_Release(Pooled)
#define __Retain(Pooled)                Yo_Retain(Pooled)
#define __Purge(TholdPtr)               Yo_Pool_Purge(TholdPtr,YOYO_DEFAULT_PURGE_CAP)
#define __Refe(Ptr)                     Yo_Refe(Ptr)
#define __Unrefe(Ptr)                   Yo_Unrefe(Ptr)
#define __Raise(Err,Msg)                Yo_Raise(Err,Msg,__Yo_FILE__,__LINE__)
#define __Raise_Format(Err,Fmt)         Yo_Raise(Err,(Yo_Format Fmt),__Yo_FILE__,__LINE__)







>







1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
    Yo_Unwind_Scope(0,-1);
    exit(code);
  }
#endif
  ;

#define __Pool(Ptr)                     Yo_Pool_Ptr(Ptr,0)
#define __Pool_Ptr(Ptr,Free)            Yo_Pool_Ptr(Ptr,Free)
#define __Release(Pooled)               Yo_Release(Pooled)
#define __Retain(Pooled)                Yo_Retain(Pooled)
#define __Purge(TholdPtr)               Yo_Pool_Purge(TholdPtr,YOYO_DEFAULT_PURGE_CAP)
#define __Refe(Ptr)                     Yo_Refe(Ptr)
#define __Unrefe(Ptr)                   Yo_Unrefe(Ptr)
#define __Raise(Err,Msg)                Yo_Raise(Err,Msg,__Yo_FILE__,__LINE__)
#define __Raise_Format(Err,Fmt)         Yo_Raise(Err,(Yo_Format Fmt),__Yo_FILE__,__LINE__)

Changes to crc.hc.

37
38
39
40
41
42
43



44
45
46
47
48
49
50
byte_t    Crc_8(byte_t crc, void *, int len);
byte_t    Crc_8_Of_Cstr(char *S);
uint_t    Adler_32(uint_t adler, void *, int len);

#define Digest_Crc_32(Data,Len) Crc_32(0,Data,Len)
#define Digest_Crc_16(Data,Len) Crc_16(0,Data,Len)
#define Digest_Crc_8(Data,Len)  Crc_8(0,Data,Len)




byte_t Crc_8_32(byte_t start, uint_t val) 
#ifdef _YOYO_CRC_BUILTIN
  { 
    byte_t q[] = { (byte_t)(val>>24), (byte_t)(val>>16), (byte_t)(val>>8), (byte_t)(val) }; 
    return Crc_8(start,q,4); 
  }







>
>
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
byte_t    Crc_8(byte_t crc, void *, int len);
byte_t    Crc_8_Of_Cstr(char *S);
uint_t    Adler_32(uint_t adler, void *, int len);

#define Digest_Crc_32(Data,Len) Crc_32(0,Data,Len)
#define Digest_Crc_16(Data,Len) Crc_16(0,Data,Len)
#define Digest_Crc_8(Data,Len)  Crc_8(0,Data,Len)
#define Crc32_Digest(Data,Len,Buf)  Unsigned_To_Four(Crc_32(0,Data,Len),(Buf))
#define Crc16_Digest(Data,Len,Buf)  Unsigned_To_Two(Crc_16(0,Data,Len),(Buf))
#define Crc8_Digest(Data,Len,Buf)   (*(byte_t*)(Buf) = Crc_8(0,Data,Len))

byte_t Crc_8_32(byte_t start, uint_t val) 
#ifdef _YOYO_CRC_BUILTIN
  { 
    byte_t q[] = { (byte_t)(val>>24), (byte_t)(val>>16), (byte_t)(val>>8), (byte_t)(val) }; 
    return Crc_8(start,q,4); 
  }

Changes to md5.hc.

408
409
410
411
412
413
414











415
416
417
418
419

void Hmac_Md5_Reset(YOYO_HMAC_MD5 *hmac)
#ifdef _YOYO_MD5_BUILTIN
  {
    Md5_Start(&hmac->md5);
    Md5_Update(&hmac->md5,hmac->ipad,64);
  }











#endif
  ;

#endif /* C_once_C5021104_5DB9_4FCC_BAFC_AFB22BD458D3 */








>
>
>
>
>
>
>
>
>
>
>





408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

void Hmac_Md5_Reset(YOYO_HMAC_MD5 *hmac)
#ifdef _YOYO_MD5_BUILTIN
  {
    Md5_Start(&hmac->md5);
    Md5_Update(&hmac->md5,hmac->ipad,64);
  }
#endif
  ;

void *Hmac_Md5_Digest(void *data, int len, void *key, int key_len, void *digest)
#ifdef _YOYO_MD5_BUILTIN
  {
    YOYO_HMAC_MD5 hmac5;
    Hmac_Md5_Start(&hmac5,key,key_len);
    Md5_Update(&hmac5.md5,data,len);
    return Hmac_Md5_Finish(&hmac5,digest);
  }
#endif
  ;

#endif /* C_once_C5021104_5DB9_4FCC_BAFC_AFB22BD458D3 */

Changes to pefile.hc.

341
342
343
344
345
346
347









































348
349
350
351
352
353
354
...
604
605
606
607
608
609
610
611
612
613















































614
615
    uint_t   NumberOfFunctions;
    uint_t   NumberOfNames;
    uint_t   AddressOfFunctions;
    uint_t   AddressOfNames;
    uint_t   AddressOfNameOrdinals;
  } PE_EXPORT_DIRECTORY;










































#define Pe_GET_NTH_32(Pe) \
  ((PE_HEADERS_32*)((char*)(Pe) + ((PE_DOS_HEADER*)(Pe))->e_lfanew))
#define Pe_GET_SEC_32(Pe) \
  ((PE_SECTION_HEADER*)((char*)(Pe) + ((PE_DOS_HEADER*)(Pe))->e_lfanew + 4 + sizeof(PE_FILE_HEADER) + Pe_GET_NTH_32(Pe)->FileHeader.SizeOfOptionalHeader ))
#define Pe_GET_NTH_64(Pe) \
  ((PE_HEADERS_64*)((char*)(Pe) + ((PE_DOS_HEADER*)(Pe))->e_lfanew))
#define Pe_GET_SEC_64(Pe) \
................................................................................
        else
          return ((uint_t*)Pe_RVA_To_Ptr(pe,edir->AddressOfFunctions))
                  [(longptr_t)procname - edir->Base];
      }
    
    return 0;
  }
#endif
  ;
















































#endif /* C_once_EA617668_2E48_4AC6_9079_699B387A0662 */








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
    uint_t   NumberOfFunctions;
    uint_t   NumberOfNames;
    uint_t   AddressOfFunctions;
    uint_t   AddressOfNames;
    uint_t   AddressOfNameOrdinals;
  } PE_EXPORT_DIRECTORY;

typedef struct _PE_RESOURCE_DIRECTORY 
  {
    uint_t   Characteristics;
    uint_t   TimeDateStamp;
    ushort_t MajorVersion;
    ushort_t MinorVersion;
    ushort_t NumberOfNamedEntries;
    ushort_t NumberOfIdEntries;
//  IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
  } PE_RESOURCE_DIRECTORY;

typedef struct _PE_RESOURCE_DIRECTORY_ENTRY 
  {
    union {
        struct {
            uint_t NameOffset:31;
            uint_t NameIsString:1;
        };
        uint_t   Name;
        ushort_t Id;
    };
    union {
        uint_t OffsetToData;
        struct {
            uint_t OffsetToDirectory:31;
            uint_t DataIsDirectory:1;
        };
    };
  } PE_RESOURCE_DIRECTORY_ENTRY;

typedef struct _PE_RESOURCE_DATA_ENTRY 
  {
    uint_t OffsetToData;
    uint_t Size;
    uint_t CodePage;
    uint_t Reserved;
  } PE_RESOURCE_DATA_ENTRY;

#define IMAGE_RESOURCE_NAME_IS_STRING        0x80000000
#define IMAGE_RESOURCE_DATA_IS_DIRECTORY     0x80000000

#define Pe_GET_NTH_32(Pe) \
  ((PE_HEADERS_32*)((char*)(Pe) + ((PE_DOS_HEADER*)(Pe))->e_lfanew))
#define Pe_GET_SEC_32(Pe) \
  ((PE_SECTION_HEADER*)((char*)(Pe) + ((PE_DOS_HEADER*)(Pe))->e_lfanew + 4 + sizeof(PE_FILE_HEADER) + Pe_GET_NTH_32(Pe)->FileHeader.SizeOfOptionalHeader ))
#define Pe_GET_NTH_64(Pe) \
  ((PE_HEADERS_64*)((char*)(Pe) + ((PE_DOS_HEADER*)(Pe))->e_lfanew))
#define Pe_GET_SEC_64(Pe) \
................................................................................
        else
          return ((uint_t*)Pe_RVA_To_Ptr(pe,edir->AddressOfFunctions))
                  [(longptr_t)procname - edir->Base];
      }
    
    return 0;
  }
#endif
  ;

void Pe_Fixup_Rsrc_Req(byte_t *rsrc, longptr_t rva, PE_RESOURCE_DIRECTORY *dir)
#ifdef _YOYO_PEFILE_BUILTIN
  {
    PE_RESOURCE_DIRECTORY_ENTRY *r = (PE_RESOURCE_DIRECTORY_ENTRY *)((byte_t*)dir + sizeof(*dir));
    PE_RESOURCE_DIRECTORY_ENTRY *rE = r+dir->NumberOfIdEntries+dir->NumberOfNamedEntries;
    for ( ; r != rE; ++r )
      if ( r->DataIsDirectory )
        Pe_Fixup_Rsrc_Req(rsrc,rva,(PE_RESOURCE_DIRECTORY *)(rsrc+r->OffsetToDirectory));
      else
        {
          PE_RESOURCE_DATA_ENTRY *e = (PE_RESOURCE_DATA_ENTRY *)(rsrc+r->OffsetToData);
          e->OffsetToData += rva;
        }
  }
#endif
  ;

void Pe_Fixup_Rsrc(void *rsrc, longptr_t rva)
#ifdef _YOYO_PEFILE_BUILTIN
  {
    Pe_Fixup_Rsrc_Req(rsrc,rva,(PE_RESOURCE_DIRECTORY *)rsrc);
  }
#endif
  ;
  
YOYO_BUFFER *Pe_Copy_Rsrc(void *pe)
#ifdef _YOYO_PEFILE_BUILTIN
  {
    PE_SECTION_HEADER *S = Pe_RVA_To_Section(pe,Pe_Get_Dir(pe,PE_DIRECTORY_ENTRY_RESOURCE)->VirtualAddress);
    YOYO_BUFFER *bf = 0;
    
    if ( S )
      {
        int q = S->SizeOfRawData;
        if ( q > S->Misc.VirtualSize && S->Misc.VirtualSize && q-S->Misc.VirtualSize < 0x1000)
         {
           q = S->Misc.VirtualSize;
         }
        bf = Buffer_Copy((byte_t*)pe+S->PointerToRawData,q);
        Pe_Fixup_Rsrc(bf->at,-S->VirtualAddress);
      }
    
    return bf;
  }
#endif
  ;

#endif /* C_once_EA617668_2E48_4AC6_9079_699B387A0662 */

Changes to random.hc.

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
69
70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

*/

#ifndef C_once_FF657866_8205_4CAE_9D01_65B8583E9D19
#define C_once_FF657866_8205_4CAE_9D01_65B8583E9D19

#include "core.hc"
#include "sha2.hc"
#include "md5.hc"

#ifdef __windoze
# include <wincrypt.h>
# ifdef _MSC_VER
#  pragma comment(lib,"advapi32.lib")
# endif
#else
................................................................................
#define _YOYO_RANDOM_EXTERN extern
#endif

void Soft_Random(byte_t *bits, int count)
#ifdef _YOYO_RANDOM_BUILTIN
  {
    static uquad_t rnd_ct[4] = {0};
    static byte_t rnd_bits[32] = {0}; 
    static int rnd_bcont = 0;
    static int initialized = 0;
    __Xchg_Interlock
      {
        if ( !initialized )
          {
            rnd_ct[0] = ((quad_t)getpid() << 48 ) | (quad_t)time(0);
................................................................................
          }
          
        while ( count )
          {
            if ( !rnd_bcont )
              {
                rnd_ct[1] = clock();

              #ifdef _SOFTRND_ADDENTRPY  
                rnd_ct[2] = (*(quad_t*)((byte_t*)&count - 256) ^  *(quad_t*)((byte_t*)&count + 256)) + 1;
              #else
                rnd_ct[2] = (quad_t)count ^ (longptr_t)bits;
              #endif
                Md5_Digest(rnd_ct,64,rnd_bits);
                ++rnd_ct[3];
                Md5_Digest(rnd_ct,64,rnd_bits+16);
                ++rnd_ct[3];
                rnd_bcont = 32;
              }
            *bits++ = rnd_bits[--rnd_bcont];
            --count;
          }
      }
  }
#endif







|
<







 







|







 







>

|
<
<

|

<
<
|







27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
..
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
68
69
70
71
72
73
74
75
76
77


78
79
80


81
82
83
84
85
86
87
88

*/

#ifndef C_once_FF657866_8205_4CAE_9D01_65B8583E9D19
#define C_once_FF657866_8205_4CAE_9D01_65B8583E9D19

#include "core.hc"
#include "sha1.hc"


#ifdef __windoze
# include <wincrypt.h>
# ifdef _MSC_VER
#  pragma comment(lib,"advapi32.lib")
# endif
#else
................................................................................
#define _YOYO_RANDOM_EXTERN extern
#endif

void Soft_Random(byte_t *bits, int count)
#ifdef _YOYO_RANDOM_BUILTIN
  {
    static uquad_t rnd_ct[4] = {0};
    static byte_t  rnd_bits[20] = {0}; 
    static int rnd_bcont = 0;
    static int initialized = 0;
    __Xchg_Interlock
      {
        if ( !initialized )
          {
            rnd_ct[0] = ((quad_t)getpid() << 48 ) | (quad_t)time(0);
................................................................................
          }
          
        while ( count )
          {
            if ( !rnd_bcont )
              {
                rnd_ct[1] = clock();
                rnd_ct[2] = (rnd_ct[2] + ((quad_t)count ^ (longptr_t)bits)) >> 1;
              #ifdef _SOFTRND_ADDENTRPY  
                rnd_ct[2] ^= (*(quad_t*)((byte_t*)&count - 256) ^  *(quad_t*)((byte_t*)&count + 256)) + 1;


              #endif
                Sha1_Digest(rnd_ct,sizeof(rnd_ct),rnd_bits);
                ++rnd_ct[3];


                rnd_bcont = 20;
              }
            *bits++ = rnd_bits[--rnd_bcont];
            --count;
          }
      }
  }
#endif

Changes to sha2.hc.

395
396
397
398
399
400
401











402
403
404
405
406

void Hmac_Sha2_Reset(YOYO_HMAC_SHA2 *hmac)
#ifdef _YOYO_SHA2_BUILTIN
  {
    Sha2_Start(&hmac->sha2);
    Sha2_Update(&hmac->sha2,hmac->ipad,64);
  }











#endif
  ;

#endif /* C_once_18F7EAA7_0DBC_4720_BA4A_7E0B1A9A5B1E */








>
>
>
>
>
>
>
>
>
>
>





395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

void Hmac_Sha2_Reset(YOYO_HMAC_SHA2 *hmac)
#ifdef _YOYO_SHA2_BUILTIN
  {
    Sha2_Start(&hmac->sha2);
    Sha2_Update(&hmac->sha2,hmac->ipad,64);
  }
#endif
  ;

void *Hmac_Sha2_Digest(void *data, int len, void *key, int key_len, void *digest)
#ifdef _YOYO_SHA2_BUILTIN
  {
    YOYO_HMAC_SHA2 hmac2;
    Hmac_Sha2_Start(&hmac2,key,key_len);
    Sha2_Update(&hmac2.sha2,data,len);
    return Hmac_Sha2_Finish(&hmac2,digest);
  }
#endif
  ;

#endif /* C_once_18F7EAA7_0DBC_4720_BA4A_7E0B1A9A5B1E */