I need to test if a windows emulator correctly identifies and handles an instruction that is too long (more than 15 bytes long). I compile the code with NASM. The only way I know of specifying an instruction that is too long is by adding prefixes to the instruction. Let's say I do the following:
rep O32 rep O32 rep O32 rep O32 rep O32 mov eax, [fs:0]
In this case, I should get a 16-byte-long instruction, since mov eax, [fs:0]
is a 6-byte-long instruction, plus the 10 O32
and rep
prefixes equal 16 bytes.
At least that's the theory ... but when I compile this with NASM and disassemble the resulting binary, what I find is that the unnecessary prefixes got plucked from there: only 1 rep
prefix stays and obviously the fs
segment prefix. Thus, the total length of the instruction is reduced to just 7 bytes. I guess this is how it is supposed to work, but is there a way to make it so the instruction length actually grows beyond bounds?
You state that mov eax, [fs:0]
is a 6-byte-long instruction. This implies that you're using 16-bit code. (32-bit code would have taken 7 bytes)
Thus mov ax,1
will use 3 bytes. You've prepended 12 operand size prefixes. This totals up to 15 which is still perfectly legal. Therefore you've not yet tested your 'windows emulator'.
If the solution presented is 32-bit code then the total will be 16 bytes.
Just curious : did the emulator complain?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.