• R/O
  • SSH
  • HTTPS

naniya: Commit


Commit MetaInfo

Revision263 (tree)
Time2011-07-04 18:42:05
Authornotanpe

Log Message

検索空間の記録機能を追加

Change Summary

Incremental Difference

--- branches/mty-makai/mty.c (revision 262)
+++ branches/mty-makai/mty.c (revision 263)
@@ -33,6 +33,7 @@
3333 #include "scoreboard.h"
3434 #include "synth.h"
3535 #include "util.h"
36+#include "makai.h"
3637
3738 #ifdef WIN32
3839 /* 優先度 */
@@ -788,6 +789,12 @@
788789 if ( fixedSalt[0] != '\0' ) {
789790 printf( "全空間モード (salt:%c%c)\n", fixedSalt[0], fixedSalt[1] );
790791 }
792+#ifdef KEYLOG
793+ if ( keyLog == MAKAI_TRUE ) {
794+ printf( "検索したキー空間のロギング\n" );
795+ initMutexKeylog();
796+ }
797+#endif /* KEYLOG */
791798 #ifdef SPECIAL
792799 dispSpecial();
793800 #else /* SPECIAL */
@@ -838,10 +845,10 @@
838845 /* コードをメモリに貼り付ける */
839846 code = scoreboard_map(sfp);
840847
841- /* キーの初期化 */
848+ /* salt を設定するためにダミーのキーを作成 (ここってロックいるのか ?) */
842849 WaitForSingleObject(mutex_key, INFINITE);
843- srand(usec());
844- key_init(&key);
850+ key.key[1] = 'z' + 1;
851+ key.key[2] = 'z' + 1;
845852 ReleaseMutex(mutex_key);
846853 set_salt(code, crypt64_descs[0], key.key);
847854
--- branches/mty-makai/special.c (revision 262)
+++ branches/mty-makai/special.c (revision 263)
@@ -4,6 +4,8 @@
44
55 #include "special.h"
66 #include "util.h"
7+#include "key.h"
8+#include "makai.h"
79
810 #define TRIP_LEN 10
911
@@ -100,10 +102,10 @@
100102 case 'e': special |= ST_YAKU; break;
101103 case 'Y': special |= ST_CHIN; break;
102104 case 'Z': special |= ST_EROI; break;
103-#if 0
104105 #ifdef KEYLOG
105106 case 'K': keyLog = MAKAI_TRUE; break;
106107 #endif /* KEYLOG */
108+#if 0
107109 case 'S':
108110 seedOffset = atoi( str + 4 );
109111 if ( seedOffset < MIN_SOFF || seedOffset > MAX_SOFF ) {
--- branches/mty-makai/key.c (revision 262)
+++ branches/mty-makai/key.c (revision 263)
@@ -6,13 +6,21 @@
66 *
77 */
88
9+#include <stdio.h>
910 #include <assert.h>
1011 #include <stdlib.h>
1112
13+#ifdef KEYLOG
14+ #include <time.h>
15+ #include <windows.h>
16+#endif /* KEYLOG */
17+
1218 #include "cp932.h"
1319 #include "desconst.h"
1420 #include "key.h"
1521 #include "translate.h"
22+#include "makai.h"
23+#include "util.h"
1624
1725 #if USE_DT
1826 #include "dt4.h"
@@ -31,6 +39,12 @@
3139 struct DT *dtidx[0x100 + 1];
3240 #endif
3341
42+#ifdef KEYLOG
43+#define KEY_LOG_FILE "keylog.txt"
44+int keyLog = MAKAI_FALSE;
45+static HANDLE mutexKeylog;
46+#endif /* KEYLOG */
47+
3448 /* 指定されたクラスと入っているキーから、classify を行う */
3549 void
3650 key_make_map(struct KS_KEY *key, int n)
@@ -360,6 +374,32 @@
360374 else
361375 key->key[n] = key_set(key, n, rand());
362376
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+
363403 #if DEBUG>=3
364404 printf("key[%d]=%02X ncls=%04X\n", n, key[n], kcls[n].map[key[n]]);
365405 #endif
@@ -668,6 +708,8 @@
668708 else
669709 s = 0;
670710
711+ OLDPRINT( "Salt %d:%02x\n", i, s & 63 );
712+
671713 #if DEBUG>=1
672714 printf("Salt %d:%3o\n", i, s & 63);
673715 #endif
@@ -702,6 +744,14 @@
702744 }
703745 }
704746
747+#ifdef KEYLOG
748+void
749+initMutexKeylog()
750+{
751+ mutexKeylog = CreateMutex(NULL, FALSE, NULL);
752+}
753+#endif /* KEYLOG */
754+
705755 /*
706756 * Local Variables:
707757 * tab-width: 4
--- branches/mty-makai/key.h (revision 262)
+++ branches/mty-makai/key.h (revision 263)
@@ -33,6 +33,11 @@
3333 struct CRYPT64_DESC const *desc,
3434 uint8_t const *k);
3535
36+#ifdef KEYLOG
37+extern int keyLog;
38+extern void initMutexKeylog( void );
39+#endif /* KEYLOG */
40+
3641 #endif /* KEY_H__ */
3742
3843 /*
Show on old repository browser