CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Assembly
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Assembly Questions and Answers for Assembly here!

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old January 28th, 2005, 04:04 AM
    lurner lurner is offline
    Junior Member
     
    Join Date: Jan 2005
    Posts: 8
    lurner is an unknown quantity at this point (<10)
    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:

    Quote:
    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
    Reply With Quote
      #2    
    Old January 28th, 2005, 09:02 AM
    japheth japheth is offline
    Junior Member
     
    Join Date: Dec 2002
    Location: Germany
    Posts: 7
    japheth is an unknown quantity at this point (<10)
    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.
    Reply With Quote
      #3    
    Old January 28th, 2005, 12:59 PM
    NoHero's Avatar
    NoHero NoHero is offline
    Moderator
     
    Join Date: Mar 2004
    Location: (Upper-) Austria
    Posts: 2,899
    NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)NoHero has much to be proud of (1500+)
    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!
    Reply With Quote
      #4    
    Old January 28th, 2005, 02:09 PM
    Lican Lican is offline
    Junior Member
     
    Join Date: Jan 2005
    Location: Gdansk, Poland
    Posts: 15
    Lican is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #5    
    Old January 28th, 2005, 03:37 PM
    lurner lurner is offline
    Junior Member
     
    Join Date: Jan 2005
    Posts: 8
    lurner is an unknown quantity at this point (<10)
    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.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Assembly


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:35 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009