Hello,
I have a series of related questions and if you think I should post them separately please say so.
So far I've made console programs & window programs where macros have handled user input and output, but just for the sake of learning (not for efficiency, obviously!) I want to learn how to address ports etc. Like in a grass-roots way without includes. Some specific questions I have are:
1. are interrupts the same in x64 and x86
2. do proper programs use interrupts like 21 9, also how would a program like microsoft word take your input and output it to the screen
3. how do you tell the computer to colour in a particular pixel, for example given the information below for a display adaptor does anyone know the role of the different memory and i/o ranges and how you would use them in assembly?
Memory Range 00000000e0000000-00000000efffffff
Memory Range 00000000f0020000-00000000f003ffff
i/o range d000-d0ff
irq 0xfffffffe (-2)
i/o range 03b0-03bb
i/o range 03c0-03df
memory range 00000000000a0000-00000000000bffff
4. how does a program know from computer to computer what port and memory is given to a device or is it generally the same?
Sorry if the questions are asking too much & thank you very much if you can answer even just a small aspect of one of them.
12 replies to this topic
#1
Posted 09 February 2011 - 02:28 PM
|
|
|
#2
Posted 09 February 2011 - 03:44 PM
I don't know whether I am right or wrong, but as far as I know Windows PE programs are structured sort of like this:
section: rdata
exitprocess DWORD ?
section: code
call ExitProcess
section: code
ExitProcess: jmp dword ptr [exitprocess]
So that the PE loader loads the actual address of the ExitProcess() function into the 'exitprocess' dword, so the program can call that function using some sort of that method. I do not know how the assembler or the PE loader knows where to load what address, though.
And interrupts and input/output instructions are generally not allowed for regular programs to use.
Correct me if I'm wrong, but this is as far as I know.
section: rdata
exitprocess DWORD ?
section: code
call ExitProcess
section: code
ExitProcess: jmp dword ptr [exitprocess]
So that the PE loader loads the actual address of the ExitProcess() function into the 'exitprocess' dword, so the program can call that function using some sort of that method. I do not know how the assembler or the PE loader knows where to load what address, though.
And interrupts and input/output instructions are generally not allowed for regular programs to use.
Correct me if I'm wrong, but this is as far as I know.
#3
Posted 09 February 2011 - 04:00 PM
Thanks RhetoricalRuvim for the heads up about portable executables, which I didn't know about
I will do some looking around on how they get system information:thumbup:
I will do some looking around on how they get system information:thumbup:
#4
Posted 10 February 2011 - 05:31 PM
Here are some sites than can help you.
Andy
ASM Community Messageboard - Index
The MASM Forum - Index
The winasm.net programming forum
Andy
ASM Community Messageboard - Index
The MASM Forum - Index
The winasm.net programming forum
#5
Posted 10 February 2011 - 06:37 PM
Comment inline
HTH
SteveC said:
Hello,
I have a series of related questions and if you think I should post them separately please say so.
So far I've made console programs & window programs where macros have handled user input and output, but just for the sake of learning (not for efficiency, obviously!) I want to learn how to address ports etc. Like in a grass-roots way without includes. Some specific questions I have are:
1. are interrupts the same in x64 and x86
Windows program do not use interrupts directly, maybe you can in RING 0?
2. do proper programs use interrupts like 21 9, also how would a program like microsoft word take your input and output it to the screen
As in #1, int is not used in Windows programming, DOS/16bit code, yes. Well, int 3 is used often :) MS Word uses COM and OLE, to make a simple text editor you would use SendMessage and the message WM_GETTEXT for "input" and to use WM_SETTEXT for "output", or DrawText there are many ways...
3. how do you tell the computer to colour in a particular pixel, for example given the information below for a display adaptor does anyone know the role of the different memory and i/o ranges and how you would use them in assembly?
Memory Range 00000000e0000000-00000000efffffff
Memory Range 00000000f0020000-00000000f003ffff
i/o range d000-d0ff
irq 0xfffffffe (-2)
i/o range 03b0-03bb
i/o range 03c0-03df
memory range 00000000000a0000-00000000000bffff
you cannot access irqs, ports, memory (of other programs) you need to use the Windows API, to draw text in a differant color, you would use the RichEdit control, or DrawText, TextOut and other APIs
4. how does a program know from computer to computer what port and memory is given to a device or is it generally the same?
By using the windows API OR writing your own driver
Sorry if the questions are asking too much & thank you very much if you can answer even just a small aspect of one of them.
I have a series of related questions and if you think I should post them separately please say so.
So far I've made console programs & window programs where macros have handled user input and output, but just for the sake of learning (not for efficiency, obviously!) I want to learn how to address ports etc. Like in a grass-roots way without includes. Some specific questions I have are:
1. are interrupts the same in x64 and x86
Windows program do not use interrupts directly, maybe you can in RING 0?
2. do proper programs use interrupts like 21 9, also how would a program like microsoft word take your input and output it to the screen
As in #1, int is not used in Windows programming, DOS/16bit code, yes. Well, int 3 is used often :) MS Word uses COM and OLE, to make a simple text editor you would use SendMessage and the message WM_GETTEXT for "input" and to use WM_SETTEXT for "output", or DrawText there are many ways...
3. how do you tell the computer to colour in a particular pixel, for example given the information below for a display adaptor does anyone know the role of the different memory and i/o ranges and how you would use them in assembly?
Memory Range 00000000e0000000-00000000efffffff
Memory Range 00000000f0020000-00000000f003ffff
i/o range d000-d0ff
irq 0xfffffffe (-2)
i/o range 03b0-03bb
i/o range 03c0-03df
memory range 00000000000a0000-00000000000bffff
you cannot access irqs, ports, memory (of other programs) you need to use the Windows API, to draw text in a differant color, you would use the RichEdit control, or DrawText, TextOut and other APIs
4. how does a program know from computer to computer what port and memory is given to a device or is it generally the same?
By using the windows API OR writing your own driver
Sorry if the questions are asking too much & thank you very much if you can answer even just a small aspect of one of them.
HTH
#6
Posted 10 February 2011 - 08:00 PM
Quote
Comment inline
HTH
Quote
Originally Posted by SteveC
Hello,
I have a series of related questions and if you think I should post them separately please say so.
So far I've made console programs & window programs where macros have handled user input and output, but just for the sake of learning (not for efficiency, obviously!) I want to learn how to address ports etc. Like in a grass-roots way without includes. Some specific questions I have are:
1. are interrupts the same in x64 and x86
Windows program do not use interrupts directly, maybe you can in RING 0?
2. do proper programs use interrupts like 21 9, also how would a program like microsoft word take your input and output it to the screen
As in #1, int is not used in Windows programming, DOS/16bit code, yes. Well, int 3 is used often MS Word uses COM and OLE, to make a simple text editor you would use SendMessage and the message WM_GETTEXT for "input" and to use WM_SETTEXT for "output", or DrawText there are many ways...
3. how do you tell the computer to colour in a particular pixel, for example given the information below for a display adaptor does anyone know the role of the different memory and i/o ranges and how you would use them in assembly?
Memory Range 00000000e0000000-00000000efffffff
Memory Range 00000000f0020000-00000000f003ffff
i/o range d000-d0ff
irq 0xfffffffe (-2)
i/o range 03b0-03bb
i/o range 03c0-03df
memory range 00000000000a0000-00000000000bffff
you cannot access irqs, ports, memory (of other programs) you need to use the Windows API, to draw text in a differant color, you would use the RichEdit control, or DrawText, TextOut and other APIs
4. how does a program know from computer to computer what port and memory is given to a device or is it generally the same?
By using the windows API OR writing your own driver
Sorry if the questions are asking too much & thank you very much if you can answer even just a small aspect of one of them.
Hello,
I have a series of related questions and if you think I should post them separately please say so.
So far I've made console programs & window programs where macros have handled user input and output, but just for the sake of learning (not for efficiency, obviously!) I want to learn how to address ports etc. Like in a grass-roots way without includes. Some specific questions I have are:
1. are interrupts the same in x64 and x86
Windows program do not use interrupts directly, maybe you can in RING 0?
2. do proper programs use interrupts like 21 9, also how would a program like microsoft word take your input and output it to the screen
As in #1, int is not used in Windows programming, DOS/16bit code, yes. Well, int 3 is used often MS Word uses COM and OLE, to make a simple text editor you would use SendMessage and the message WM_GETTEXT for "input" and to use WM_SETTEXT for "output", or DrawText there are many ways...
3. how do you tell the computer to colour in a particular pixel, for example given the information below for a display adaptor does anyone know the role of the different memory and i/o ranges and how you would use them in assembly?
Memory Range 00000000e0000000-00000000efffffff
Memory Range 00000000f0020000-00000000f003ffff
i/o range d000-d0ff
irq 0xfffffffe (-2)
i/o range 03b0-03bb
i/o range 03c0-03df
memory range 00000000000a0000-00000000000bffff
you cannot access irqs, ports, memory (of other programs) you need to use the Windows API, to draw text in a differant color, you would use the RichEdit control, or DrawText, TextOut and other APIs
4. how does a program know from computer to computer what port and memory is given to a device or is it generally the same?
By using the windows API OR writing your own driver
Sorry if the questions are asking too much & thank you very much if you can answer even just a small aspect of one of them.
#7
Posted 11 February 2011 - 03:50 PM
#4 - they're standardized, i.e. ports 80 and 8080 are always used for HTTP, 22 is always used for SSH, and so on.
sudo rm -rf /
#8
Posted 11 February 2011 - 05:36 PM
Wait, what type of ports is he talking about? Hardware I/O ports or networking ports (network port 80 is HTTP, but I'm not sure about the assembly language port 80)?
#9
Posted 11 February 2011 - 09:15 PM
Thanks very much for all your replies.
Slider I will look more closely at those forums when I get a chance
Gunner I understand now about kernel32 & gdi etc and others in the api. I didn't realise how integral they were to windows & I thought that the functions in kernel32.lib which I think calls the dll were just optional like the random high-level function includes that usually come with an installation of an assembler...shows I have a lot to learn:blushing:!
Ruvim & Gunner I did mean how does the operating system know about the hardware below the level of the api, but there might be out there a detailed description of the api libraries which would probably give a clue.
Dargueta I did mean hardware but maybe they too use standard addresses
Thank you:)
Slider I will look more closely at those forums when I get a chance
Gunner I understand now about kernel32 & gdi etc and others in the api. I didn't realise how integral they were to windows & I thought that the functions in kernel32.lib which I think calls the dll were just optional like the random high-level function includes that usually come with an installation of an assembler...shows I have a lot to learn:blushing:!
Ruvim & Gunner I did mean how does the operating system know about the hardware below the level of the api, but there might be out there a detailed description of the api libraries which would probably give a clue.
Dargueta I did mean hardware but maybe they too use standard addresses
Thank you:)
#10
Posted 11 February 2011 - 09:20 PM
sorry .lib and .dll are homologous I think
Edit: No sorry the dll file is got to by the lib file.
Edit: No sorry the dll file is got to by the lib file.
#11
Posted 11 February 2011 - 09:56 PM
#12
Posted 12 February 2011 - 02:13 AM
Oops, my bad. Hardware ports do use standard addresses as well, at least on IBM-compatible computers.* Some examples:
Keyboard: ports 0x60, 0x6D
VGA BIOS: 0x3b4 - 0x3da
Serial IO controller: 0x3f8, 0x2f8, 0x3e8, 0x2e8
* IBM-Compatible: PCs and Macs; other minority systems like Amiga are not.
Keyboard: ports 0x60, 0x6D
VGA BIOS: 0x3b4 - 0x3da
Serial IO controller: 0x3f8, 0x2f8, 0x3e8, 0x2e8
* IBM-Compatible: PCs and Macs; other minority systems like Amiga are not.
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









