News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Allocate memory in MASM

Started by deeR44, June 07, 2020, 03:19:53 PM

Previous topic - Next topic

Vortex

Hi deeR44,

Windows programming is based on the API functions. There are a lot of them but don't worry : Step by step, one can study them methodically. A lot of Masm32 modules are using APIs, that's true. That's necessary to communicate with the operating system.

deeR44

Quote from: Vortex on June 10, 2020, 05:02:40 AM
Hi deeR44,

Windows programming is based on the API functions. There are a lot of them but don't worry : Step by step, one can study them methodically. A lot of Masm32 modules are using APIs, that's true. That's necessary to communicate with the operating system.
Where does one go to learn how to use them, what they do, and what arguments they need?

TimoVJL

For example, Win32.chm
https://sourceforge.net/projects/win32-help-chm/

Windows API Index
Memory Management Functions
May the source be with you

hutch--

deeR44,

API calls are just functions, there are a very large number of them but you only need to remember a couple of dozen, much the same with messages. This is why I recommended getting the old WIN32.HLP help file, it had all of the old core windows API functions and to make life easier, almost every argument is DWORD in size, you just need to keep an eye on the difference between a DWORD value and a DWORD address (pointer) and the rest of it generally makes sense.

It is a messaging architecture, once you get the swing of the basic executable layout, a main, a message loop and a WndProc the rest of it is just detail.

deeR44

How does one use the old "WIN32.HLP" file, assuming that I can find it? I have nothing that uses ".hlp" files. Thank you for any advice.

TouEnMasm


Help system are numerous but there is one you couldn't avoid it is Internet.
Type "msdn malloc" in a search engine and you will have an answer in a few seconds.
malloc is the favorite function to allocate memory in the CRT,it use heap and there is further functions using it.
Type type "msdn heap" and you will Know all on Heap.
Fa is a musical note to play with CL

hutch--

The reason to have the old WIN32.HLP is that you can have it locally on your own machine. If you are running Win10, you will need to get the file by JimG in the forum to run it. It is between 12 and 24 meg depending on the version you can find and you need to get used to using it but it has all of the messages and functions of the core Windows API.

For later stuff you use MSDN.

iZ!

Quote from: deeR44 on June 07, 2020, 03:19:53 PM
I cannot allocate memory in a project I'm working on.

Try this:

invoke GlobalAlloc,0,dataLength
mov  hMem,eax
invoke GlobalLock,hMem
mov  ptrMem,eax
...


And when you're done, free the memory up by:
     invoke GlobalFree, hMem