The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ecube on October 19, 2006, 03:27:15 PM

Title: confusing code problem
Post by: ecube on October 19, 2006, 03:27:15 PM
mov [zcode + 1], edx

gives an error "immediate operand not allowed"

and zcode is
zcode:
mov edi, 0ABCDEFAAh

anyway my question is considering i'm using all registers for code above how can I make that work? Since it won't let me use zcode, that works in tasm fine.
Title: Re: confusing code problem
Post by: Tedd on October 19, 2006, 04:00:45 PM
It's just an MASM syntax thing - zcode is a code label, and you're trying to put a dword (register) value into it. They don't match - it complains. So just force it to match :bg
mov DWORD PTR [zcode + 1], edx

Of course, you'll have fun modifying the code section as executable pages shouldn't be writable :P (Though windows has a different view, which is a great help to viruses ::))
Title: Re: confusing code problem
Post by: ecube on October 19, 2006, 10:21:26 PM
Quote from: Tedd on October 19, 2006, 04:00:45 PM
It's just an MASM syntax thing - zcode is a code label, and you're trying to put a dword (register) value into it. They don't match - it complains. So just force it to match :bg
mov DWORD PTR [zcode + 1], edx

Of course, you'll have fun modifying the code section as executable pages shouldn't be writable :P (Though windows has a different view, which is a great help to viruses ::))


Thankyou sir, and I can assure you this isn't for a virus, it's for a commerical pe encryptor i'm writing, which i'll give you a free copy once i'm done for your help.
Title: Re: confusing code problem
Post by: hutch-- on October 19, 2006, 11:20:29 PM
Cube,

Keep in mind with a PE encryptor that newer Windows OS versions have data execution prevention available so you will have to get the ".text" and ".data" sections right or it will trigger the DEP protection on start.
Title: Re: confusing code problem
Post by: ecube on October 20, 2006, 01:57:22 AM
Thanks for information Hutch. I added a /SECTION:.text,RWX in the linker options, seems to work fine.