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 if you have enough context to do so.
FUN_0006cb53 PUSH EBP MOV EBP,ESP PUSH EBX PUSH ECX PUSH ESI PUSH EDI SUB ESP,0x1c MOV dword ptr [EBP + local_30],EAX MOV dword ptr [EBP + local_2c],EDX MOV EAX,dword ptr [EBP + local_2c] MOV dword ptr [EBP + local_28],EAX MOV EAX,dword ptr [EBP + local_30] CALL FUN_0006cd6e MOV dword ptr [EBP + local_24],EAX CMP dword ptr [EBP + local_24],0x0 JGE LAB_0006cbac MOV EAX,s_disk.c_00175d00 = "disk.c" PUSH EAX PUSH 0x2d CALL FUN_000a0ed9 MOV EAX,dword ptr [EBP + local_30] PUSH EAX MOV EAX,s_Error_opening_the_file_%s.00175d07 = "Error opening the file %s." PUSH EAX MOV EAX,DAT_001a41f4 PUSH EAX CALL FUN_000a0f5c ADD ESP,0xc MOV EAX,DAT_001a41f4 CALL FUN_00050069 LAB_0006cbac MOV EAX,dword ptr [EBP + local_24] CALL filelength MOV [DAT_000c0ba8],EAX MOV EAX,[DAT_000c0ba8] MOV dword ptr [EBP + local_20],EAX CMP dword ptr [EBP + local_28],0x0 JNZ LAB_0006cbdc MOV EBX,0x34 MOV EDX,s_disk.c_00175d00 = "disk.c" MOV EAX,dword ptr [EBP + local_20] CALL FUN_000a00af MOV dword ptr [EBP + local_28],EAX LAB_0006cbdc CMP dword ptr [EBP + local_28],0x0 JNZ LAB_0006cc11 MOV EAX,s_disk.c_00175d00 = "disk.c" PUSH EAX PUSH 0x38 CALL FUN_000a0ed9 MOV EAX,dword ptr [EBP + local_30] PUSH EAX MOV EAX,s_Insufficent_memory_to_read_in%s_00175d22 = "Insufficent memory to read in %s." PUSH EAX MOV EAX,DAT_001a41f4 PUSH EAX=>DAT_001a41f4 CALL FUN_000a0f5c ADD ESP,0xc MOV EAX,DAT_001a41f4 CALL FUN_00050069 LAB_0006cc11 PUSH 0x4 PUSH 0x3c MOV ECX,s_disk.c_00175d00 = "disk.c" MOV EBX,dword ptr [EBP + local_20] XOR EDX,EDX MOV EAX,dword ptr [EBP + local_28] CALL FUN_000a0040 MOV EBX,dword ptr [EBP + local_20] MOV EDX,dword ptr [EBP + local_28] MOV EAX,dword ptr [EBP + local_24] CALL read MOV dword ptr [EBP + local_1c],EAX MOV EAX,dword ptr [EBP + local_1c] CMP EAX,dword ptr [EBP + local_20] JZ LAB_0006cc6f MOV EAX,s_disk.c_00175d00 = "disk.c" PUSH EAX PUSH 0x41 CALL FUN_000a0ed9 MOV EAX,dword ptr [EBP + local_30] PUSH EAX MOV EAX,s_Error_reading_%s_from_disk._00175d44 = "Error reading %s from disk." PUSH EAX MOV EAX,DAT_001a41f4 PUSH EAX CALL FUN_000a0f5c ADD ESP,0xc MOV EAX,DAT_001a41f4 CALL FUN_00050069 LAB_0006cc6f MOV EAX,dword ptr [EBP + local_24] CALL __close MOV EAX,dword ptr [EBP + local_28] MOV dword ptr [EBP + local_18],EAX MOV EAX,dword ptr [EBP + local_18] LEA ESP=>local_14,[EBP + -0x10] POP EDI POP ESI POP ECX POP EBX POP EBP RET
FUN_0006cd6e PUSH EBP MOV EBP,ESP PUSH EBX PUSH ECX PUSH EDX PUSH ESI PUSH EDI SUB ESP,0x8 MOV dword ptr [EBP + local_20],EAX MOV EAX,dword ptr [EBP + local_20] CALL FUN_0006d13e MOV dword ptr [EBP + local_20],EAX PUSH 0x200 MOV EAX,dword ptr [EBP + local_20] PUSH EAX CALL open ADD ESP,0x8 MOV dword ptr [EBP + local_1c],EAX MOV EAX,dword ptr [EBP + local_1c] LEA ESP=>local_18,[EBP + -0x14] POP EDI POP ESI POP EDX POP ECX POP EBX POP EBP RET
- Assistant
- Disassembled function FUN_0006cb53:
This function appears to load a file from disk into memory. It takes two arguments in EAX and EDX which are file name and buffer pointer respectively. It returns the buffer pointer if the file is read successfully.
Suggested name: load_file_into_memory
Suggested function signature:
void* load_file_into_memory(const char* file_name, void* buffer_ptr);- Disassembled function FUN_0006cd6e:
This function appears to open a file with read-only access. It takes a single argument in EAX which is the file name. It returns the file descriptor if the file is opened successfully.
Suggested name: open_file_read_only
Suggested function signature:
int open_file_read_only(const char* file_name);- Disassembled function FUN_0006d13e:
This function appears to create a modified version of the file path. It takes a single argument in EAX which is the input file path. It returns the modified file path.