Anyone recognise this routine, or can give a summery of it's function.
I have a routine which is called regularly in one client, but not in another... it's confusing the operation of the one where it is used, and I'm getting lost in it's logic. I believe it's a standard MS VC RT static routine, though I could be wrong... I have no idea what it is supposed to be doing though.
Here is the routine:-
Code:
MOV EDX,DWORD PTR SS:[ARG.3]
MOV ECX,DWORD PTR SS:[ARG.1]
TEST EDX,EDX ; Cascaded IF (cases 0..3, 3 exits)
JE SHORT Jump1
XOR EAX,EAX
MOV AL,BYTE PTR SS:[ARG.2]
PUSH EDI
MOV EDI,ECX
CMP EDX,4
JB SHORT Jump2
NEG ECX ; Default case of cascaded IF
AND ECX,00000003
JE SHORT Jump3
SUB EDX,ECX
Jump4:
MOV BYTE PTR DS:[EDI],AL
ADD EDI,1
SUB ECX,1
JNE SHORT Jump4
Jump3:
MOV ECX,EAX
SHL EAX,8
ADD EAX,ECX
MOV ECX,EAX
SHL EAX,10
ADD EAX,ECX
MOV ECX,EDX
AND EDX,00000003
SHR ECX,2
JE SHORT Jump2
REP STOS DWORD PTR ES:[EDI]
TEST EDX,EDX
JE SHORT Jump5
Jump2:
MOV BYTE PTR DS:[EDI],AL ; Cases 1, 2, 3 of cascaded IF
ADD EDI,1
SUB EDX,1
JNE SHORT Jump2
Jump5:
MOV EAX,DWORD PTR SS:[ARG.1]
POP EDI
RETN
Jump1:
MOV EAX,DWORD PTR SS:[ARG.1] ; Case 0 of cascaded
RETN
I know it's a long shot, and I may be better off asking in a RCE forum, but if someone here has seen this logic in a client and made sense of it, or knows it from MSVC I'd be very greatful if you could untie the knotts in my brain right now.:lol:
Re: Anyone recognise this routine, or can give a summery of it's function.
Okay... I think I'm concluding that this routine resets the state of a block of memory. Seems to set a specified run of bytes to 0x00, but also makes a mess of the registers and I'm not sure why.
A "fastcall function (x byval, y byval, z byval)" one assumes.
---EDIT---
Confirmed:-
void fastcall resetmem (StartAddress as DWord, FillValue as LSB?, RunLength as DWord).