flat assembler
Message board for the users of flat assembler.

Index > Windows > Interrupt Question

Author
Thread Post new topic Reply to topic
pal



Joined: 26 Aug 2008
Posts: 227
pal
Hey; I'm new to ASM coding and I'm having problems with int 10h. For some reason this code isn't working and I don't know why (especially as examples I've seen have this code too):

Code:
format PE GUI 4.0
entry start

section '.code' code readable writeable
    start:
        mov     bh,0
        mov     dl,0
        mov     dh,0
        int     10h
        ret
    


I'm trying to set the cursors position (without SetCursorPos). I've tried setting DX and BX by xor'ing them and moving 0 to them but nothing works. The program assembles properly, but it errors upon running it.
Post 26 Aug 2008, 16:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17284
Location: In your JS exploiting you and your system
revolution
In windows you can't use any INT instructions. Those are for DOS.

I think you misunderstand the situation. Have a look at the Windows examples that come with the fasm download.
Post 26 Aug 2008, 17:01
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Because you are using BIOS interrupts on a Win32 executable.

Code:
org $100

        mov     bh,0
        mov     dl,0
        mov     dh,0
        int     10h 

int 20h    


That would work but it wouldn't be a win32 executable anymore but a DOS one (which supports BIOS calls).
Post 26 Aug 2008, 17:03
View user's profile Send private message Reply with quote
pal



Joined: 26 Aug 2008
Posts: 227
pal
Ahh, I was wondering if it wouldn't work on Windows. Cheers for the quick replies. So if I compile it to be a COM application will it work then? Basically I want to be able to do things APIs can do eg. set the cursor position; but without the APIs.

Also a quick question; if I decompile for example kernel32.dll with a program such as OllyDbg; can I view the code for certain API's such as the actual code which is executed when SetCursorPos API is called (even though SetCursorPos API is in user32.dll, but you get what I mean)?
Post 26 Aug 2008, 17:39
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
You'll find a bunch of things that are Windows version specific. If you are writting for the Win32 subsystem then use the APIs of that subsystem (user32.dll, kernel32.dll, gdi32.dll, etc).

BTW, note that SetCursorPos refers to the MOUSE cursor, not the blinking vertical or horizontal bar on the text console.

Follow with OllyDbg the code below but remember that what you'll see is specific to your Windows version, there could be differences even on the same Windows version but with different ServicePack.

Code:
include 'win32a.inc'

format PE GUI 4.0

  push 0
  push 0
  call dword [SetCursorPos]

; Now the mouse pointer should be placed in the upper left corner of the screen

  push 0
  call dword [ExitProcess]

data import
  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL'

  import kernel32,\
                  ExitProcess, 'ExitProcess'
  import user32,\
                  SetCursorPos, 'SetCursorPos'
end data    
Post 26 Aug 2008, 18:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17284
Location: In your JS exploiting you and your system
revolution
You can disassemble any of the system DLLs. But I doubt you will gain much knowledge from them unless you want to spend many many hours in deciphering the code. They are very complex and do many things. Also you need to keep in mind that the DLLs don't always do the work, there is another layer behind there, the heart of the OS, that is not user accessible.
Post 26 Aug 2008, 18:05
View user's profile Send private message Visit poster's website Reply with quote
pal



Joined: 26 Aug 2008
Posts: 227
pal
Yeah I see I see. Alright cool cheers for the help guys.
Post 26 Aug 2008, 20:35
View user's profile Send private message Reply with quote
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
Evil or Very Mad If only we could do those sorts of things without the APIs Evil or Very Mad
Post 27 Aug 2008, 05:12
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.