News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

About stack

Started by braymailloux, October 24, 2010, 04:36:16 AM

Previous topic - Next topic

braymailloux

On an unrelated note:

How does Windows setup the stack for a new process, say a process I've created by compiling and executing Ice's MsgBox hello world tutorial?

My ASM class is teaching us to program using GNU tools. Linux has simple boiler plate that save the callee's stack pointer on the stack then sets up the programs stack for use. At the end of the day, would someone give me an idea what the stack looks like for a newly created program?

On another note, I wanna talk to the metal. I hear ASM is very open to this. However, I hear NT is not. But I hear that http://www.beyondlogic.org/porttalk/porttalk.htm porttalk here gives me the ability to talk to some low level stuff. Does some of that low level stuff include the real-time clock? Maybe the programmable interrupt controller? What may I do with such power?

BogdanOntanu

Quote from: braymailloux on October 24, 2010, 04:36:16 AM
On an unrelated note:

Please DO NOT parasite other people's threads with unrelated issues. If you have an unrelated question then take the time an create a new topic with a relevant title.

Quote
How does Windows setup the stack for a new process, say a process I've created by compiling and executing Ice's MsgBox hello world tutorial?

Why do you need to know this? For making normal windows applications you do not have a need to use the stack "above" your initial ESP and you do not really need to know how Windows setups a stack for a new process.

What might be of interest when you advance a little  is the fact that the are two fields named something like "Stack Reserve size" and "Stack commit size"  in the PE Optional header and the windows PE loader will use them to reserve a stack for your application (plus / minus some alignment).


Quote
My ASM class is teaching us to program using GNU tools.

A big mistake. GNU tools do not play nice in Windows environment. Hence you will have 2 sets of problems: 1) learn ASM 2) handle problems resulting from using GNU on windows.

This is bad especially when you have MASM32 free and available for this kind of learning tasks.

Quote
Linux has simple boiler plate that save the callee's stack pointer on the stack then sets up the programs stack for use. At the end of the day, would someone give me an idea what the stack looks like for a newly created program?

No. I do not see any reason for a beginner to know this... Nothing other than some form of exploit and or a bad programming practice as in using some undocumented stack positions.


Quote
On another note, I wanna talk to the metal. I hear ASM is very open to this.

Conceptually yes but practically no. In windows the user mode applications are executed in a "protected" mode and because of this it does not matter if you are in ASM or C++ or Delphi... Anyway you do not have access to the "bare metal" hardware. The only thing you could eventually use in ASM are the CPUID and the RDTSC instructions but the last one has it's own problems also.

Quote
However, I hear NT is not. But I hear that http://www.beyondlogic.org/porttalk/porttalk.htm porttalk here gives me the ability to talk to some low level stuff. Does some of that low level stuff include the real-time clock? Maybe the programmable interrupt controller? What may I do with such power?

Only if you write your own unprotected OS you might talk directly to hardware from an normal application (or by using old DOS OS).
You can not do this in Windows and Linux.

An alternative would be to write a kernel mode driver but that is relatively advanced and lately it does require a signature from Microsoft in order to run on other people's machines.... hence it is very unlikely.

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

braymailloux

Awight, I'll just stick to the icezelion tutorials for now. Thanks for the input and guidance.