News:

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

New, Unsure about somethings...

Started by NMMX, September 02, 2005, 02:31:39 PM

Previous topic - Next topic

NMMX

Hello,

Yesterday I was bored, so I downloaded MASM started messing around with it.

I looked a some tutorials then set out to make my own small application.


.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
MsgTitle      db "Hello",0
lpBuffer db ?

.code
start:
invoke GetSystemWindowsDirectory, addr lpBuffer, 32767
invoke MessageBox, 0, addr lpBuffer, addr MsgTitle, 0
invoke ExitProcess, NULL
end start


^^ Works lol, but I bet its not the best way to do it.

But I dont understand the use of, mov, and the eax registers etc.
Can anyone help me or point me to websites where it can help me?

Darrel

Welcome NMMX,

Look in the masm32\help folder.   ASMINTRO,OPCODES, etc.

Regards,

Darrel

hutch--

NMMX,

The instructions take a bit of practice and the trick is to start on the simpler ones and just keep adding to the ones you understand. Almost all code is managed by about 20 or 30 instructions so its not a big deal to learn them and while they do have some rules about what you can pass to them and in what format, its pretty straight forward once you get the swing of them. Have a reference handy so you can look up instructions as there is no point in remembering every detail of the near 500 seperate mnemonics. There is over 1000 opcodes that correspond to variation in the instructions (mneminics) but this is what a good reference is for.

Just as an aside, Welcome on board, hope you enjoy the place.  :U
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

evlncrn8

lpBuffer db ?

.code
start:
invoke GetSystemWindowsDirectory, addr lpBuffer, 32767


woah!, bug there... lpbuffer is NOT 32767 bytes in size heh, its 1 byte, so you want to have
lpBuffer db 32767 dup(?)

instead... or...

invoke GetSystemWindowsDirectory, addr lpBuffer, sizeof lpBuffer


the api also doesnt exist for any version of windows below 2000 afaik

PBrennick

NMMX,
Welcome to the board.  It is a fun place to explore.  Be careful with assembly language programming, though; it is VERY addictive!  :toothy

evlncrn8's idea about using sizeof lpBuffer is a technique that you want to always use.  Hardcoding the buffer size leads to very difficult to find errors.  Also sometimes a buffer works more effectively if it is declared as local instead of global so you might want to read up about local variables and buffers.  This may not be something you wish to worry about right now.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

NMMX,

Also, your lpBuffer name is not correct because the named item is a buffer and not a pointer to a buffer. If it were a pointer it would need to be a DWORD. Also, the buffer length is not adequate to hold any path. The recommended length is MAX_PATH (defined in windows.inc).

MSDN: GetSystemWindowsDirectory

MASM documentation is available here:

http://webster.cs.ucr.edu/Page_TechDocs/index.html

eschew obfuscation