Cannot figure this out!

Hello everyone, this is my first time posting here and I hope someone can help me.
I am having issues with getting my code to work. It works fine with VS2010 c++ compiler, but now that I'm using VS2013 community, it does not seem to be working. When I test this, it doesn't filter anything like the vector is empty or it's not iterating through it properly. I suspect that the main issue has to be with the fact that itemFilterList cannot be assigned to esi like that anymore. If anyone can help, I would appreciate it alot! Thanks.
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
int mesoFilterAmt  = 10; //Mesos at or below this amount will be filtered
int itemFilterType = 0;  
char ItemMem[6];
std::vector<DWORD> itemFilterList;
DWORD ItemAddy = 0x005059CC, ItemRet = ItemAddy+6;

__declspec(naked) void __stdcall ItemFilter()
{
	__asm
	{
			PUSH esi
			MOV esi, mesoFilterAmt
			CMP eax, esi
			JLE FilterMeso
			CMP itemFilterType, 0x00
			JE RejectFilter
			JMP AcceptFilter

			AcceptFilter :
			MOV ESI, itemFilterList
			IfAccept :
			CMP EAX, [esi]
			JE EndFilter
			CMP[esi], 0x00 //Check to see if we're at the end of the item list
			JE NoMatch
			ADD esi, 0x04 //Go to the next element in the array
			JMP IfAccept

			RejectFilter :
			MOV esi, itemFilterList //We use the same filter for good and bad items.

			IfReject :
			CMP eax, [esi]
			JE NoMatch
			CMP[esi], 0x00
			JE EndFilter
			ADD esi, 0x04
			JMP IfReject

			NoMatch :
			MOV eax, 0x00

			EndFilter :
			POP esi
			MOV[edi + 0x34], eax
			MOV edi, [ebp - 0x14]
			JMP DWORD PTR[ItemRet]

			FilterMeso :
			MOV[edi + 0x30], 0x00
			JMP EndFilter
	}
}
void AddItem(DWORD ItemID)
{
	itemFilterList.push_back(ItemID);
}
void ClearItem()
{
	itemFilterList.erase(itemFilterList.begin(), itemFilterList.end());
	itemFilterList.resize(0);
}
So you just storing memory at itemFilterList to the esi? Without regard to vector internal structure, the fact that it is not just a pointer, that internal vector structure can change between compiler versions, updates to current version and even different compiling options?
It is miracle that it worked at all before.

For example there could be small size optimization for vectors where first 4 (8 for 64 bit) bytes are pointer to logical end of vector and second and third are either pointers to beginning and physical end, or elements themselves dependingon value of first pointer.

Or compiler might reorder fields a little, because it would be more optimal and standard library is built to allow this?

EDIT: do DWORD* data = itemFilterList.data(); before assembly. data will point to actual array containing your data.
Last edited on
Thanks for the reply MiiNiPaa.
I agree that it was a miracle it worked before haha. I don't really know how to go about fixing this problem. I would like to revise my code, but I don't know how to access the vector's internal structure. If you could give me some tips, that would be awesome!
I made an edit to the original post with method to access unedlying array.
Thanks for the help MiiNi! I will get back to you if I can figure it out haha. I tried this, and it didn't work, so I'm going to guess that the structure is completely different?
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

int mesoFilterAmt  = 10; //Mesos at or below this amount will be filtered
int itemFilterType = 0;  
char ItemMem[6];
std::vector<DWORD> itemFilterList;
DWORD ItemAddy = 0x005059CC, ItemRet = ItemAddy+6;
__declspec() void __stdcall ItemFilter()
{
	DWORD* data = itemFilterList.data();
	__asm
	{
			PUSH esi
			MOV esi, mesoFilterAmt
			CMP eax, esi
			JLE FilterMeso
			CMP itemFilterType, 0x00
			JE RejectFilter
			JMP AcceptFilter

			AcceptFilter :
			MOV ESI, data
			IfAccept :
			CMP EAX, [esi]
			JE EndFilter
			CMP[esi], 0x00 //Check to see if we're at the end of the item list
			JE NoMatch
			ADD esi, 0x04 //Go to the next element in the array
			JMP IfAccept

			RejectFilter :
			MOV esi, data //We use the same filter for good and bad items.

			IfReject :
			CMP eax, [esi]
			JE NoMatch
			CMP[esi], 0x00
			JE EndFilter
			ADD esi, 0x04
			JMP IfReject

			NoMatch :
			MOV eax, 0x00

			EndFilter :
			POP esi
			MOV[edi + 0x34], eax
			MOV edi, [ebp - 0x14]
			JMP DWORD PTR[ItemRet]

			FilterMeso :
			MOV[edi + 0x30], 0x00
			JMP EndFilter
	}
}
void AddItem(DWORD ItemID)
{
	itemFilterList.push_back(ItemID);
}
void ClearItem()
{
	itemFilterList.erase(itemFilterList.begin(), itemFilterList.end());
	itemFilterList.resize(0);
}
No, data is a simple array pointer (pointer to the first element of array). No strings attached. It is creates specially for compatibility with c-arrays.

So your error is probably lies somewhere else (and you are building in 32bit mode, right?)

Also: ClearItem is doing the same thing twice. And it is enough to just do itemFilterList.clear()
I've been trying for hours and finally just gave up haha. I can't figure out how to do it, but once I moved the code over to a visual studio 2010 compiler it worked.
Topic archived. No new replies allowed.