recursion的算法分析

 1 UINT __cdecl sub_401150(HWND hDlg)
 2 {
 3   UINT result; // eax@3
 4   unsigned int lenth; // kr04_4@4
 5   signed int v3; // esi@4
 6   unsigned int v4; // edi@5
 7   char v5; // bl@6
 8   unsigned int v6; // edx@8
 9   unsigned int v7; // eax@16
10   signed int j; // eax@21
11 
12   *(_DWORD *)szName = 0;
13   dword_4084E4 = 0;
14   dword_4084E8 = 0;
15   dword_4084EC = 0;
16   memset(&unk_4085FC, 0, 0x1000u);
17   byte_4084F0 = 0;
18   dword_4085F8 = 0;
19   dword_4095FC = 0;
20   if ( GetDlgItemTextA(hDlg, 1001, szName, 16) )
21   {
22     sub_401000();
23     sub_401040();
24   }
25   result = GetDlgItemTextA(hDlg, 1002, &szKey, 256);
26   if ( result )                                 // 如果获取注册码成功
27   {
28     lenth = strlen(&szKey) + 1;
29     v3 = 0;
30     lenTemp = lenth - 1;
31     if ( lenth == 1 )
32     {
33 LABEL_21:
34       j = 1;
35       while ( byte_406030[j] != 1 )
36       {
37         ++j;
38         if ( j > 9 )
39           return 1;
40       }
41     }
42     else
43     {
44       v4 = dword_4085F8;
45       while ( 1 )
46       {
47         v5 = *(&szKey + v3);
48         if ( v5 > 57 )
49           break;
50         if ( v5 < 48 )
51           break;
52         v6 = ((v4 >> v3 % 31) % 0xA + v5 - 48) % 0xA;
53         if ( v6 == 1 )
54         {
55           byte_406031 ^= 1u;
56         }
57         else
58         {
59           if ( v6 == 2 )
60           {
61             byte_406032 ^= 1u;
62           }
63           else
64           {
65             if ( !v6 || byte_40602F[v6] || byte_40602E[v6] != 1 )
66               break;
67             if ( v6 >= 3 )
68             {
69               v7 = 1;
70               if ( v6 - 2 > 1 )
71               {
72                 while ( byte_406030[v7] != 1 )
73                 {
74                   ++v7;
75                   if ( v7 >= v6 - 2 )
76                     goto LABEL_19;
77                 }
78                 break;
79               }
80             }
81 LABEL_19:
82             byte_406030[v6] ^= 1u;
83           }
84         }
85         ++v3;
86         if ( v3 >= (unsigned int)lenTemp )
87           goto LABEL_21;
88       }
89     }
90     result = 0;
91   }
92   return result;
93 }

还有对用户名的处理部分:

 1 void __cdecl sub_401000()
 2 {
 3   int v0; // ebp@1
 4   int i; // ebx@1
 5   int v2; // eax@2
 6 
 7   v0 = (int)szName;
 8   for ( i = 610800471; ; i = ((57807712 * (i + v2) + 324478056) >> 7) | ((57807712 * (i + v2) + 324478056) << 25) )
 9   {
10     v2 = *(_BYTE *)v0;
11     if ( !*(_BYTE *)v0 )
12       break;
13     ++v0;
14   }
15   dword_4085F8 = i;
16 }

下面也是:

 1 unsigned int __cdecl sub_401040()
 2 {
 3   unsigned int result; // eax@1
 4   signed int v1; // ecx@1
 5 
 6   result = dword_4085F8;
 7   v1 = 1;
 8   do
 9   {
10     byte_406030[v1] = (result >> v1) & 1;
11     ++v1;
12   }
13   while ( (unsigned int)v1 < 9 );
14   byte_406039 = 1;
15   return result;
16 }

......

对其中一个函数分析,写为:

 1 int  __cdecl sub_401000(CString szName)
 2 {
 3     int nLen=szName.GetLength();
 4     char *Name=new char [nLen];
 5     Name=szName.GetBuffer(0);
 6 
 7     int m; 
 8     int i; 
 9     int v2; 
10     
11     m = (int)Name;
12     for ( i = 610800471; ; i = ((57807712 * (i + v2) + 324478056) >> 7) | ((57807712 * (i + v2) + 324478056) << 25) )
13     {
14         v2 = *(BYTE *)m;
15         if ( !*(BYTE *)m )
16             break;
17         ++m;
18     }
19     return i;
20  }

....

你可能感兴趣的:(算法)