I will provide you disassembly from a computer game that runs in MS-DOS. The game was…
- User
I will provide you disassembly from a computer game that runs in MS-DOS. The game was written in C with a Watcom compiler. Some library function calls are already identified. Explain the functions I give to you and suggest names and C-language function signatures for them, including which parameters map to which registers or stack values. Also suggest names for global values when you have enough context to do so.
FUN_0001296a PUSH EBP MOV EBP,ESP PUSH ESI PUSH EDI SUB ESP,0xc MOV EAX,dword ptr [EBP + Stack[0x8]] PUSH EAX MOV EAX,dword ptr [EBP + Stack[0x4]] PUSH EAX CALL FUN_00011d1b ADD ESP,0x8 TEST AX,AX JZ LAB_00012996 MOV dword ptr [EBP + local_10],0x0 JMP LAB_00012a6c LAB_00012996 MOV EAX,dword ptr [EBP + Stack[0x4]] MOV EDX,dword ptr [EAX + 0x84] MOV EAX,dword ptr [EBP + Stack[0x4]] MOV EAX,dword ptr [EAX + 0x88] ADD EAX,EDX MOV dword ptr [EBP + local_18],EAX MOV EAX,dword ptr [EBP + Stack[0x8]] CALL strlen undefined strlen() ADD EAX,0x6 MOV dword ptr [EBP + local_14],EAX MOV EAX,dword ptr [EBP + Stack[0x4]] MOV EDX,dword ptr [EAX + 0x88] ADD EDX,dword ptr [EBP + local_14] MOV EAX,dword ptr [EBP + Stack[0x4]] CMP EDX,dword ptr [EAX + 0x8c] JBE LAB_000129de MOV dword ptr [EBP + local_10],0x0 JMP LAB_00012a6c LAB_000129de MOV EAX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV byte ptr [EAX],0xd MOV EAX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV byte ptr [EAX],0xa MOV EAX,dword ptr [EBP + local_18] MOV EDX,dword ptr [EBP + Stack[0x4]] MOV dword ptr [EDX + 0x98],EAX MOV EAX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV byte ptr [EAX],0x5b LAB_00012a05 MOV EAX,dword ptr [EBP + Stack[0x8]] CMP byte ptr [EAX],0x0 JZ LAB_00012a1f MOV EAX,dword ptr [EBP + Stack[0x8]] INC dword ptr [EBP + Stack[0x8]] MOV EDX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV AL,byte ptr [EAX] MOV byte ptr [EDX],AL JMP LAB_00012a05 LAB_00012a1f MOV EAX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV byte ptr [EAX],0x5d MOV EAX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV byte ptr [EAX],0xd MOV EAX,dword ptr [EBP + local_18] INC dword ptr [EBP + local_18] MOV byte ptr [EAX],0xa MOV EAX,dword ptr [EBP + local_18] MOV EDX,dword ptr [EBP + Stack[0x4]] MOV dword ptr [EDX + 0xa8],EAX MOV EAX,dword ptr [EBP + local_18] MOV EDX,dword ptr [EBP + Stack[0x4]] MOV dword ptr [EDX + 0x90],EAX MOV EAX,dword ptr [EBP + local_14] MOV EDX,dword ptr [EBP + Stack[0x4]] ADD dword ptr [EDX + 0x88],EAX MOV EAX,dword ptr [EBP + Stack[0x4]] OR byte ptr [EAX + 0x1],0x80 MOV dword ptr [EBP + local_10],0x1 LAB_00012a6c MOV EAX,dword ptr [EBP + local_10] LEA ESP=>local_c,[EBP + -0x8] POP EDI POP ESI POP EBP RET
FUN_000128a2 PUSH EBP MOV EBP,ESP PUSH ESI PUSH EDI SUB ESP,0x10 MOV EAX,dword ptr [EBP + Stack[0x8]] PUSH EAX MOV EAX,dword ptr [EBP + Stack[0x4]] PUSH EAX CALL FUN_00011d1b ADD ESP,0x8 TEST AX,AX JNZ LAB_000128ce MOV dword ptr [EBP + local_10],0x0 JMP LAB_00012960 LAB_000128ce MOV EAX,dword ptr [EBP + Stack[0x4]] MOV EAX,dword ptr [EAX + 0x98] MOV dword ptr [EBP + local_1c],EAX MOV EAX,dword ptr [EBP + Stack[0x4]] MOV EDX,dword ptr [EAX + 0x84] MOV EAX,dword ptr [EBP + Stack[0x4]] MOV EAX,dword ptr [EAX + 0x88] ADD EAX,EDX MOV dword ptr [EBP + local_18],EAX MOV dword ptr [EBP + local_14],0x1 LAB_000128f8 MOV EAX,dword ptr [EBP + local_1c] ADD EAX,dword ptr [EBP + local_14] MOV AL,byte ptr [EAX] AND EAX,0xff CMP EAX,0x5b JZ LAB_00012915 MOV EAX,dword ptr [EBP + local_1c] ADD EAX,dword ptr [EBP + local_14] CMP EAX,dword ptr [EBP + local_18] JC LAB_00012917 LAB_00012915 JMP LAB_0001291f LAB_00012917 MOV EAX,dword ptr [EBP + local_14] INC dword ptr [EBP + local_14] JMP LAB_000128f8 LAB_0001291f PUSH 0x4 PUSH 0x49b MOV ECX,s_profile.c_00170129 = "profile.c" MOV EBX,dword ptr [EBP + local_1c] ADD EBX,dword ptr [EBP + local_14] MOV EAX,dword ptr [EBP + local_18] SUB EAX,EBX MOV EBX,EAX MOV EDX,dword ptr [EBP + local_1c] ADD EDX,dword ptr [EBP + local_14] MOV EAX,dword ptr [EBP + local_1c] CALL FUN_000a0e0d MOV EAX,dword ptr [EBP + local_14] MOV EDX,dword ptr [EBP + Stack[0x4]] SUB dword ptr [EDX + 0x88],EAX MOV EAX,dword ptr [EBP + Stack[0x4]] OR byte ptr [EAX + 0x1],0x80 MOV dword ptr [EBP + local_10],0x1 LAB_00012960 MOV EAX,dword ptr [EBP + local_10] LEA ESP=>local_c,[EBP + -0x8] POP EDI POP ESI POP EBP RET
- Assistant
The given code contains three main functions:
FUN_0001296a,FUN_000128a2, andFUN_00011d1b. I will analyze each of these functions and provide information regarding their possible names, signature in the C language, and their functionalities.- Function:
FUN_0001296aThis function appears to be formatting a text buffer in some specific way to include the string it receives as a parameter, as well as line breaks, brackets, and a specific block size.
Suggested Name:
format_buffer_blocking_textSuggested C signature:int format_buffer_blocking_text(void* pBuffer, const char* pText)Parameter mapping: - Function: