Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/mty-makai/key.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 262 by notanpe, Mon Dec 27 03:23:48 2010 UTC revision 263 by notanpe, Mon Jul 4 09:42:05 2011 UTC
# Line 6  Line 6 
6   *   *
7   */   */
8    
9    #include <stdio.h>
10  #include <assert.h>  #include <assert.h>
11  #include <stdlib.h>  #include <stdlib.h>
12    
13    #ifdef KEYLOG
14     #include <time.h>
15     #include <windows.h>
16    #endif /* KEYLOG */
17    
18  #include "cp932.h"  #include "cp932.h"
19  #include "desconst.h"  #include "desconst.h"
20  #include "key.h"  #include "key.h"
21  #include "translate.h"  #include "translate.h"
22    #include "makai.h"
23    #include "util.h"
24    
25  #if USE_DT  #if USE_DT
26  #include "dt4.h"  #include "dt4.h"
# Line 31  struct DT *kd[8 + 8]; Line 39  struct DT *kd[8 + 8];
39  struct DT *dtidx[0x100 + 1];  struct DT *dtidx[0x100 + 1];
40  #endif  #endif
41    
42    #ifdef KEYLOG
43    #define   KEY_LOG_FILE   "keylog.txt"
44    int     keyLog = MAKAI_FALSE;
45    static HANDLE   mutexKeylog;
46    #endif /* KEYLOG */
47    
48  /* 指定されたクラスと入っているキーから、classify を行う */  /* 指定されたクラスと入っているキーから、classify を行う */
49  void  void
50  key_make_map(struct KS_KEY *key, int n)  key_make_map(struct KS_KEY *key, int n)
# Line 360  key_reset(struct KS_KEY *key, int n) Line 374  key_reset(struct KS_KEY *key, int n)
374    else    else
375          key->key[n] = key_set(key, n, rand());          key->key[n] = key_set(key, n, rand());
376    
377    #ifdef KEYLOG
378      if ( keyLog && (n == 2) ) {
379        FILE        *fp;
380        int i;
381        struct timeb        tb;
382        struct tm   *plt;
383    
384        ftime( &tb );
385        plt = localtime( &tb.time );
386    
387        WaitForSingleObject( mutexKeylog, INFINITE );
388    
389        if ( (fp = fopen( KEY_LOG_FILE, "at" )) == NULL ) {
390         perror( KEY_LOG_FILE );
391         exit( 1 );
392        }
393        fprintf( fp, "%02x%02x%02x", key->key[0], key->key[1], key->key[2] );
394        fprintf( fp, "\t%04d/%02d/%02d %02d:%02d:%02d.%03d\n",
395                 plt->tm_year + 1900, plt->tm_mon + 1, plt->tm_mday,
396                 plt->tm_hour, plt->tm_min, plt->tm_sec, tb.millitm );
397        fclose( fp );
398    
399        ReleaseMutex( mutexKeylog );
400      }
401    #endif /* KEYLOG */
402    
403  #if DEBUG>=3  #if DEBUG>=3
404    printf("key[%d]=%02X ncls=%04X\n", n, key[n], kcls[n].map[key[n]]);    printf("key[%d]=%02X ncls=%04X\n", n, key[n], kcls[n].map[key[n]]);
405  #endif  #endif
# Line 668  set_salt(CODE_T *code, Line 708  set_salt(CODE_T *code,
708            else            else
709                  s = 0;                  s = 0;
710    
711              OLDPRINT( "Salt %d:%02x\n", i, s & 63 );
712    
713  #if DEBUG>=1  #if DEBUG>=1
714            printf("Salt %d:%3o\n", i, s & 63);            printf("Salt %d:%3o\n", i, s & 63);
715  #endif  #endif
# Line 702  set_salt(CODE_T *code, Line 744  set_salt(CODE_T *code,
744          }          }
745  }  }
746    
747    #ifdef KEYLOG
748    void
749    initMutexKeylog()
750    {
751      mutexKeylog = CreateMutex(NULL, FALSE, NULL);
752    }
753    #endif /* KEYLOG */
754    
755  /*  /*
756   *      Local Variables:   *      Local Variables:
757   *              tab-width:      4   *              tab-width:      4

Legend:
Removed from v.262  
changed lines
  Added in v.263

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26