Please examine the following decompiled function. This function is for an MS-DOS program…
- User
Please examine the following decompiled function. This function is for an MS-DOS program written in C using the Watcom compiler.
Unknown_Function PUSH EBP MOV EBP,ESP MOV EBX,dword ptr [EBP + Stack[0x4]] MOV EAX,EBX CALL strlen MOVZX EAX,AL LEA EDX,[EAX + EBX*0x1] LAB_000a8e34
TEST EAX,EAX JZ LAB_000a8e40 DEC EDX DEC EAX CMP byte ptr [EDX],0x5c JNZ LAB_000a8e34 INC EAX LAB_000a8e40 ADD EAX,EBX POP EBP RET 0x4 - Assistant
This function appears to take a string as input and return the length of the string appended with a backslash character if it does not already end with a backslash.
The function begins by saving the current EBP register value onto the stack and setting EBP to ESP (which is the current stack pointer).
The next instruction loads the first parameter passed to the function (which is at offset 0x4 from EBP) into EBX using the dword ptr keyword, signifying that we are loading a four-byte value.
The next instruction saves the value of EBX into EAX. This is likely done so that the original value of EBX can be used later without losing its value.