News:

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

Beginner Windows API functions

Started by ControlsDude, November 15, 2011, 07:45:54 PM

Previous topic - Next topic

ControlsDude

New guy here with a background in programming programmable logic controllers (PLC's) and human machine interfaces(HMI's) for industrial machines/processes. I have done a little HLL programming mainly using VB but want to learn assembly since it seems similar
to PLC programming.
My question concerns the windows API functions.

Can I see the code behind a function such as a messagebox?

I have seen examples where you include the library that has the messagebox function
Then you would invoke the messagebox function and pass it some parameters to get the messagebox to display what you want.

For the time being I would like to write my code to not use the include library but put the actual messagebox code into my assembly program.


jj2007

First of all: Welcome to the Forum :thumbu

You can see the code of the Hello World example below with OllyDbg. Have a look, and come back soon to discuss the pros and cons of "rolling your own" :wink

include \masm32\include\masm32rt.inc

.code
start: MsgBox 0, "Hello World", "Masm32:", MB_OK
exit

end start

dedndave

welcome to the forum   :U

i programmed a couple allen-bradley's several years ago   :P
didn't care much for "ladder logic" - i would much rather have written in native machine code

yes - MessageBox is a form of a dialog window (or dialog box)
to go deeper one level, you can use one of the dialog functions to make it
dialog boxes, like most everything in windows, are still just windows
you can go another level deeper by using CreateWindowEx to create the dialog box

that having been said, i don't think that is a good place for someone starting out to begin   :bg
recently, i was working on some code to make custom message boxes
it is not as easy as one might think
most of it isn't too bad, but sizing text areas is a nightmare   :red
i put that project on the back burner til i finish a couple others

i suggest you learn your way around the x86 architecture
write a few windows programs
write a few dialog programs
then, if you are still inclined to attack message boxes, you will have the skills required to do so

raymond

Welcome to the forum ControlsDude.

AND, if you write any program to run under the Windows OS (or even under Linux, Apple, or any other modern OS), you still have to refer to the OS library to open at least one window if you need to see any output. MessageBox is just one of the specialized windows available from MS. Might as well use it as is if that's what you need.

In the old days under MS DOS, you could draw anything you wanted directly in the video buffer and write whatever you needed pixel by pixel without ever using any of the DOS interrupts (i.e. functions). Those days are gone.
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

hutch--

You treat Windows API functions as primitives as effectively you have no choice as the operating system has exclusive control of most useful hardware interfaces, disk IO, screen IO etc ... but this is as much a blessing as a curse in that you have a massive range of functionality available that is both reasonably fast and reliable as it is needed for the operating system itself. You can treat Windows API functions as the "hack OS code" that you just need to get to work properly and this leaves you free to work on high performance stuff where speed matters.

Glad to see a member from "Twister Territory". I had a look at a couple of YouTube videos of the more recent ones and thought PHARK, glad I don't have to put up with that.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php