CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Posts
    8

    Invalid Number Help

    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

    Code:
    .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

  2. #2
    Join Date
    Dec 2002
    Location
    Germany
    Posts
    7

    Re: Invalid Number Help

    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.

  3. #3
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Invalid Number Help

    Quote Originally Posted by japheth
    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:

    Code:
    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. .

    / 11 posts to go
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  4. #4
    Join Date
    Jan 2005
    Location
    Gdansk, Poland
    Posts
    15

    Re: Invalid Number Help

    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

  5. #5
    Join Date
    Jan 2005
    Posts
    8

    Re: Invalid Number Help

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured