A little 'you know what' with reversing some code.

So this code was optimazed and compiled by VC++ and my target is to turn it back what it was avoiding the optimization. This mean making some do while loops into for loops and etc. So here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
DWORD v2 = 0;
	bool v65 = false;
	BYTE v4 = m_36 & 0xDF | 0x10;
	DWORD v5 = m_40+1;
	BYTE v6 = m_72 & 0xDF | 0x10;
	m_36 = v4;
	m_40 = v5;
	m_72 = v6;
	m_96 = 0.0f;
	m_100 = 0.0f;
	m_104 = 0.0f;
	m_108 = 0.0f;
	m_112 = 0.0f;
	m_116 = 0.0f;
	m_120 = 0.0f;
	m_124 = 0.0f;
	m_128 = 0.0f;
	m_132 = 0.0f;
	m_136 = 0.0f;
	m_140 = 0.0f;
	m_144 = 0.0f;
	m_148 = 0.0f;
	m_152 = 0.0f;
	m_156 = 0.0f;
	m_228 = 0.0f;
	m_232 = 0.0f;
	m_136 = 0.0f;
	bool v60 = false;
	bool v63 = false;
	bool v64 = false;
	bool v62 = false;
	bool v61 = false;
	SYS_DI_DEVICE* v1 = m_272;
	const char * v75 = GetGameProfileName();
	DWORD v79[2] = { 0, 0 };
	for(; v1; v1=v1->m_16)
	{
		SYS_DI_PROFILE* v7 = v1->m_12;
		v1->SetActiveProfile(v75);
		SYS_DI_PROFILE* v73 = v1->m_12;
		v61 |= v73 != v7;
		if(v73)
		{
			SYS_DI_DEVICE_DATA* v8 = v1->m_44;
			if(v8)
			{
				if(!v8->ReadData(v1))
				{
					BYTE v9 = v1->m_4->m_0.guidInstance.Data4[4];
					if(v8->m_36)
					{
						char* v10 = v8->m_32;
						DWORD nData = v8->m_28;
						DWORD v76 = v1->m_20;
						DWORD v77 = v1->m_24;
						char* v70 = v8->m_32;
						DWORD v78 = v1->m_28;
						if(v9==19)
						{
							SYS_DI_DEVICE_DATA* v11 = v1->m_44;
							DIOBJECTDATAFORMAT* v12 = v11->m_24;
							DWORD v71;
							//??????????
							if(v11->DIDataFormat.dwNumObjs)
							{
								v71=v11->DIDataFormat.dwNumObjs;
								do
								{
									if ( v12->dwType == 4 || v12->dwType == 12 )
									{
										if((v10[v12->dwOfs] & 0x80) == 0x80)
										{
											v2 |= 0x80000000u;
											switch ( v12->dwType )
											{
												case 0xC8:
													v2 |= 0x100000u;
												break;
												case 0xD0:
													v2 |= 0x200000u;
												break;
												case 0xCB:
													v2 |= 0x400000u;
												break;
												case 0xCD:
													v2 |= 0x800000u;
												break;
												case 0x1C:
													v2 |= 0x40000u;
												break;
												case 1:
													v2 |= 0x80000u;
												break;
												case 0xF:
													v2 |= 0x20000u;
												break;
												case 0x3F:
													v2 |= 0x2000000u;
												break;
												case 0x43:
													v2 |= 0x1000000u;
												break;
												case 0x30:
													if ( m_9 )
														v2 |= 0x404Cu;
												break;
											}
										}
									}
								}
								while ( v71-- != 1 );
								v79[0] = v2;
							}
							//??????????
						}
						SYS_DI_PROFILE_ITEM* v72 = v73->m_4;


The commented place with many "????" is the place that need to be reversed. Please help I tried different things but it wasn't that:

Eg.:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
for(; v11->DIDataFormat.dwNumObjs; ++v12, --v71)
							{	
								v71=v11->DIDataFormat.dwNumObjs;
								if ( v12->dwType == 4 || v12->dwType == 12 )
								{
									if((v10[v12->dwOfs] & 0x80) == 0x80)
									{
										v2 |= 0x80000000u;
										switch ( v12->dwType )
										{
											case 0xC8:
												v2 |= 0x100000u;
											break;
											case 0xD0:
												v2 |= 0x200000u;
											break;
											case 0xCB:
												v2 |= 0x400000u;
											break;
											case 0xCD:
												v2 |= 0x800000u;
											break;
											case 0x1C:
												v2 |= 0x40000u;
											break;
											case 1:
												v2 |= 0x80000u;
											break;
											case 0xF:
												v2 |= 0x20000u;
											break;
											case 0x3F:
												v2 |= 0x2000000u;
											break;
											case 0x43:
												v2 |= 0x1000000u;
											break;
											case 0x30:
												if ( m_9 )
													v2 |= 0x404Cu;
											break;
										}
									}
								}
								if(v71==1)
								{
									v79[0] = v2;
									break;
								}
							}
Last edited on
Topic archived. No new replies allowed.