When compiling the exported assembly from IDA with MASM, I get the following two errors:
test.exe.asm(32767) : fatal error A1019: invalid debug and browser data; file exceeds line limit
test.exe.asm(2697) : error A2068: instruction prefix not allowed
Here is the code that triggers the last error:
mov     eax, ds:dword_40D028
test    eax, eax
jz      short loc_401D40
rep retn                     <----- Line 2697
First of all: How can those errors occure? The original .exe is working fine. Obviously the disassembly cannot produce the exact original assembly but it should at least produce working code, shouldn't it?
Secondly: How do I fix this?
Edit: When trying to compile the assembly with JWASM I no longer get the exceeding line limit error but the following errors:
test.exe.asm(40764) : Error A2150: Missing operator in expression
test.exe.asm(40767) : Error A2150: Missing operator in expression
test.exe.asm(40768) : Error A2150: Missing operator in expression
test.exe.asm(40769) : Error A2150: Missing operator in expression
test.exe.asm(40772) : Error A2150: Missing operator in expression
test.exe.asm(40773) : Error A2150: Missing operator in expression
test.exe.asm(40774) : Error A2150: Missing operator in expression
test.exe.asm(40777) : Error A2150: Missing operator in expression
test.exe.asm(40778) : Error A2150: Missing operator in expression
test.exe.asm(40779) : Error A2150: Missing operator in expression
test.exe.asm(40782) : Error A2150: Missing operator in expression
test.exe.asm(40783) : Error A2150: Missing operator in expression
test.exe.asm(40815) : Error A2150: Missing operator in expression
test.exe.asm(40816) : Error A2150: Missing operator in expression
test.exe.asm(40817) : Error A2150: Missing operator in expression
test.exe.asm(40818) : Error A2150: Missing operator in expression
test.exe.asm(40819) : Error A2150: Missing operator in expression
test.exe.asm(40820) : Error A2150: Missing operator in expression
test.exe.asm(40821) : Error A2150: Missing operator in expression
test.exe.asm(40822) : Error A2150: Missing operator in expression
test.exe.asm(40823) : Error A2150: Missing operator in expression
test.exe.asm(40824) : Error A2150: Missing operator in expression
test.exe.asm(40825) : Error A2150: Missing operator in expression
test.exe.asm(40826) : Error A2150: Missing operator in expression
test.exe.asm(40827) : Error A2150: Missing operator in expression
test.exe.asm(40828) : Error A2150: Missing operator in expression
test.exe.asm(40829) : Error A2150: Missing operator in expression
test.exe.asm(40830) : Error A2150: Missing operator in expression
test.exe.asm(40831) : Error A2150: Missing operator in expression
test.exe.asm(40832) : Error A2150: Missing operator in expression
Here is the code beginning from line 40759 (including comments)
; Segment type: Pure data                        <----- Line 40759
; Segment permissions: Read
imports         segment para public 'DATA' use32
                assume cs:imports
                ;org 40E000h
__IMPORT_DESCRIPTOR_kernel32 dd rva off_40E098 ; Import Name Table
                dd 0                    ; Time stamp
                dd 0                    ; Forwarder Chain
                dd rva aKernel32Dll     ; DLL Name
                dd rva AllocConsole     ; Import Address Table
__IMPORT_DESCRIPTOR_user32 dd rva byte_40E12C+4 ; Import Name Table
                dd 0                    ; Time stamp
                dd 0                    ; Forwarder Chain
                dd rva aUser32Dll       ; DLL Name
                dd rva MessageBoxA      ; Import Address Table
__IMPORT_DESCRIPTOR_msvcrt dd rva byte_40E13C+4 ; Import Name Table
                dd 0                    ; Time stamp
                dd 0                    ; Forwarder Chain
                dd rva aMsvcrtDll       ; DLL Name
                dd rva printf           ; Import Address Table
__IMPORT_DESCRIPTOR_Advapi32 dd rva byte_40E154+4 ; Import Name Table
                dd 0                    ; Time stamp
                dd 0                    ; Forwarder Chain
                dd rva aAdvapi32Dll     ; DLL Name
                dd rva CryptAcquireContextA ; Import Address Table
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
                db    0
aKernel32Dll    db 'kernel32.dll',0     ; DATA XREF: imports:0040E00C\u2191o
                align 2
aUser32Dll      db 'user32.dll',0       ; DATA XREF: imports:0040E020\u2191o
                align 2
aMsvcrtDll      db 'msvcrt.dll',0       ; DATA XREF: imports:0040E034\u2191o
                align 2
aAdvapi32Dll    db 'Advapi32.dll',0     ; DATA XREF: imports:0040E048\u2191o
                align 4
;
; Import names for kernel32.dll
;
off_40E098      dd rva word_40E170      ; DATA XREF: imports:__IMPORT_DESCRIPTOR_kernel32\u2191o
                dd rva unk_40E180
                dd rva word_40E18E
                dd rva word_40E19E
                dd rva word_40E1AE
                dd rva word_40E1C4
                dd rva word_40E1D6
                dd rva word_40E1E6
                dd rva word_40E1F6
                dd rva word_40E20A
                dd rva word_40E21E
                dd rva unk_40E230
                dd rva unk_40E244
                dd rva word_40E256
                dd rva word_40E26C
                dd rva word_40E280
                dd rva word_40E28E
                dd rva word_40E29E
                dd 0
imports         ends
In addition to that another error also occurred:
test.exe.asm(40884) : Error A2209: Syntax error: :
test.exe.asm(40890) : Error A2209: Syntax error: :
test.exe.asm(40897) : Error A2209: Syntax error: :
The code beginning from line 40882:
                extrn LoadLibraryA:dword <------ line 40882
                extrn CreateThread:dword
                extrn byte_40E12C:byte:0Ch
                                        ; DATA XREF: imports:__IMPORT_DESCRIPTOR_user32\u2191o
;
; Imports from user32.dll
;
                extrn MessageBoxA:dword ; DATA XREF: imports:0040E024\u2191o
                extrn byte_40E13C:byte:10h
                                        ; DATA XREF: imports:__IMPORT_DESCRIPTOR_msvcrt\u2191o
;
; Imports from msvcrt.dll
;
                extrn printf:dword      ; DATA XREF: imports:0040E038\u2191o
                extrn memset:dword
                extrn byte_40E154:byte:10h
 
    