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. As I provide more information, please revise your explanations and suggestions as necessary.
FUN_0006cc89 PUSH EBP MOV EBP,ESP PUSH ECX PUSH ESI PUSH EDI SUB ESP,0x1c MOV dword ptr [EBP + local_28],EAX MOV dword ptr [EBP + local_24],EDX MOV dword ptr [EBP + local_20],EBX MOV EAX,dword ptr [EBP + local_28] CALL FUN_000a1004 PUSH 0x180 PUSH 0x222 MOV EAX,dword ptr [EBP + local_28] PUSH EAX CALL open ADD ESP,0xc MOV dword ptr [EBP + local_1c],EAX CMP dword ptr [EBP + local_1c],0x1 JGE LAB_0006ccce MOV dword ptr [EBP + local_14],0x0 JMP LAB_0006cd05 LAB_0006ccce MOV EBX,dword ptr [EBP + local_20] MOV EDX,dword ptr [EBP + local_24] MOV EAX,dword ptr [EBP + local_1c] CALL FUN_000a0b42 CMP EAX,dword ptr [EBP + local_20] JNZ LAB_0006ccea MOV dword ptr [EBP + local_2c],0x1 JMP LAB_0006ccf1 LAB_0006ccea MOV dword ptr [EBP + local_2c],0x0 LAB_0006ccf1 MOV EAX,dword ptr [EBP + local_2c] MOV dword ptr [EBP + local_18],EAX MOV EAX,dword ptr [EBP + local_1c] CALL __close MOV EAX,dword ptr [EBP + local_18] MOV dword ptr [EBP + local_14],EAX LAB_0006cd05 MOV EAX,dword ptr [EBP + local_14] LEA ESP=>local_10,[EBP + -0xc] POP EDI POP ESI POP ECX POP EBP RET
FUN_0006cd10 PUSH EBP MOV EBP,ESP PUSH ECX PUSH ESI PUSH EDI SUB ESP,0x10 MOV dword ptr [EBP + local_20],EAX MOV dword ptr [EBP + local_1c],EDX MOV dword ptr [EBP + local_18],EBX MOV EAX,s_disk.c_00175d00 = "disk.c" PUSH EAX PUSH 0x6b CALL FUN_000a0ed9 MOV EAX,dword ptr [EBP + local_20] PUSH EAX MOV EAX,DAT_001917e4 PUSH EAX MOV EAX,s_%s%s_00175d60 = "%s%s" PUSH MOV EAX,DAT_001a41f4 PUSH EAX CALL FUN_000a0f5c ADD ESP,0x10 MOV EBX,dword ptr [EBP + local_18] MOV EDX,dword ptr [EBP + local_1c] MOV EAX,DAT_001a41f4 CALL FUN_0006cc89 MOV dword ptr [EBP + local_14],EAX MOV EAX,dword ptr [EBP + local_14] LEA ESP=>local_10,[EBP + -0xc] POP EDI POP ESI POP ECX POP EBP RET
- Assistant
For FUN_0006cc89:
This function seems to be performing file operations. It opens a file with the given file mode, reads a specified number of bytes from the file, compares the number of bytes read with an expected number of bytes to read, and then closes the file.
Suggested function signature:
cint check_file_read(const char* file_name, int file_mode, int expected_bytes_to_read);Here, the EAX register corresponds to the file_name parameter, EDX to the file_mode parameter, and EBX to the expected_bytes_to_read parameter.
Global values:
- "disk.c": filename string for a file.
For FUN_0006cd10:
This function appears to be creating a filepath by concatenating two strings (in "%s%s" format) and then calling the
check_file_read()function with the created filepath, file mode, and an expected number of bytes to read.