Click to See Complete Forum and Search --> : Invalid Number Help


lurner
January 28th, 2005, 03:04 AM
Hello, I am trying to run a simple ASM sample that opens notepad.exe. When I try to load WinExec and ExitProcess addresses into bx the TASM assembler says:


Assembling file: test.ASM
**Error** test.ASM(29) Illegal number
**Error** test.ASM(34) Illegal number
Error messages: 2
Warning messages: None
Passes: 1
Remaining memory: 418k


Here is my code... btw: I am writing for 8086, Windows XP


.model small
.stack
.data

.code

main proc ;start main procEDURE


start:

jmp short GetCommand

CommandReturn:
pop bx ;bx now holds the handle to the string
xor ax,ax
push ax
xor ax,ax
mov [bx + 22],al ;insert the NULL character
push bx
mov bx, 0x77e6fd35
call bx ;call WinExec(path,showcode)

xor ax,ax ;zero the register again, clears winexec retval
push ax
mov bx, 0x77e798fd
call bx ;call ExitProcess(0);


GetCommand:
call CommandReturn
db "cmd.exe /c notepad.exe$"
mov ax,4c00h ;end clean
int 21h ;intERRUPT - (DOS Service)
main endp ;end main procEDURE
end main ;exit application


I must be trying to load the addresses wrong or I am not doing something with them in order to make them valid. I tried using quotes "" and square brackets [] and neither worked. Can someone please help me fix this code so it will work. This will be a great snippet to learn from if I can just get it to movE the kernel addresses into bx. Unless there is a better way, in which I would be interested in seeing.

Thanks in advance

japheth
January 28th, 2005, 08:02 AM
the error comes from line

> mov bx, 0x77e6fd35

it is in C syntax, not ASM, and bx is a 16 bit register, it cannot hold 32bit values.

Furthermore, you are trying to call 32bit protected mode code from 16 bit real-mode (or v86mode) code. That cannot work.

NoHero
January 28th, 2005, 11:59 AM
the error comes from line

> mov bx, 0x77e6fd35

it is in C syntax, not ASM, and bx is a 16 bit register, it cannot hold 32bit values.

Furthermore, you are trying to call 32bit protected mode code from 16 bit real-mode (or v86mode) code. That cannot work.

That's absolutly correct. Try this instead:


mov ebx, 077e798fdh


The WinAPI calls are far calls so you will need a 32bit register and a valid 32bit windows compiler such as the Microsoft Macro Assembler (MASM) or the Netwide Assembler for Win32. And as far as I know they are named like __imp__ExitProcess() or something like that. :ehh:.

/ 11 posts to go

Lican
January 28th, 2005, 01:09 PM
When I was using tasm while writing code I used a macro:

calle MACRO x
extrn x:PROC
call x
ENDM calle

then I just wrote:

calle somefunction

and that was enough. I also recommend to read some optimization trick, because they can be quite useful when writing in asm. I learned then by heart and now with c++ I'm still trying to use them, although the compiler's optimizer will "do that for me" it's just a habit :P

lurner
January 28th, 2005, 02:37 PM
oh.. ok so use nasm or masm and try it that way.. I am learning ASM in reverse I first learnt VB then C++ and now ASM. I am so use to API to not use it makes me feel limited while coding, I am definently graduating early to 32bit as soon as possible.

thanks a lot for your help guys, much appreciated. :)