Easy Code Masm Macros (All Project Type)
Some useful macros can be used in Easy Code projects (both, visual and classic) by checking the Easy Code macros option in the Project Properties. Their names are colorized as Easy Code reserved words (see Settings menu) and you can use them when you like along the code. These macros, being in the ECMacros.asm file of the Easy Code Macros subfolder, have the following syntax:
Color byRed, byGreen, byBlue
Arguments byRed, byGreen, byBlue must be 8-bit values (Byte). Eax returns an RGB color (a 32-bit value or COLORREF).
Example:
Color 0AH, 0BH, 0CH
Eax returns 000C0B0AH
HiByte
wValue
Argument wValue must be a 16-bit value (Word). Al returns the high byte (8-bit value or Byte) of wValue.
Example:
HiByte 0C0AH
Al returns 0CH
HiWord
dwValue
Argument dwValue must be a 32-bit value (DWord). Ax returns the high word (16-bit value or Word) of dwValue.
Example:
HiWord 000C000AH
Ax returns 000CH
LoByte
wValue
Argument wValue must be a 16-bit value (Word). Al returns the low byte (8-bit value or Byte) of wValue.
Example:
LoByte 0C0AH
Al returns 0AH
LoWord
dwValue
Argument dwValue must be a 32-bit value (DWord). Ax returns the low word (16-bit value or Word) of dwValue.
Example:
LoWord 000C000AH
Ax returns 000AH
MakeWord
byLow,
byHigh
Arguments byLow and byHigh must be 8-bit values (Byte). Ax returns the resultant 16-bit value (Word).
Example:
MakeWord 0CH, 0AH
Ax returns 0A0CH
MakeLong
wLow,
wHigh
Arguments wLow and wHigh must be 16-bit values (Word). Eax returns the resultant 32-bit value (DWord or LONG).
Example:
MakeLong 0A0BH, 0C0DH
Eax returns 0C0D0A0BH
Move
dwValue1,
dwValue2
Arguments dwValue1 and dwValue2 must be a 32-bit (DWord) variable or memory position.
Example:
Move dwMemPos1, dwMemPos2
Moves the value in variable or memory position specified by dwMemPos2 to variable or memory position specified by dwMemPos1.
This macro does not return a value.
Return
dwValue
Argument dwValue must be a 32-bit value (DWord). It loads the Eax register with dwValue and returns from a procedure.
Example:
Return TRUE
Loads the Eax register with TRUE (1) and returns.
Date
lpszBuf
Argument lpszBuf must be the effective address of a buffer.
Example:
Date lpszDate
The lpszDate buffer will be filled with an ANSI text string having the current date.
Now
lpszBuf
Argument lpszBuf must be the effective address of a buffer.
Example:
Now lpszNow
The lpszNow buffer will be filled with an ANSI text string having the current date and time.
Time
lpszBuf
Argument lpszBuf must be the effective address of a buffer.
Example:
Time lpszTime
The lpszTime buffer will be filled with an ANSI text string having the current time.
Text
Name,
"quoted_text"
Argument Name must be any valid name identifying the string specified by the second argument, "quoted_text", which can be any double quoted text.
Example:
Text szBuffer, "Test string"
After that sentence you have a temporary buffer with the specified string (null-terminated). Remeber that the value returned by Text is NOT the effective address of the string, so you should use the Addr operator in order to get it. For example:
Text, szTest, "Test string"
Invoke lstrlen, Addr szTest
Eax returns 11 (the length of the string)
TextW
Name,
"quoted_text"
Argument Name must be any valid name identifying the string specified by the second argument, "quoted_text", which can be any double quoted text.
Example:
TextW szBufferW, "Test string"
After that sentence you have a buffer with the specified string (null-terminated) in Unicode format. Remeber that the value returned by TextW is NOT the effective address of the string, so you should use the Addr operator in order to get it. For example:
TextW, szTestW, "Test string"
Invoke lstrlenW, Addr szTestW
Eax returns 11 (the length of the string)
(Programmed by Héctor A. Medina)
TextAddr
("quoted_text")
Argument "quoted_text" can be any double quoted text.
Example:
TextAddr("Test string")
After that sentence you have the effective address of a temporary null-terminated string. You can use it to pass it as an argument to any routine or API call. Remeber that the value returned by TextAddr is the effective address, so you should NOT use the Addr operator. For example:
Invoke lstrlen, TextAddr("Test string")
Eax returns 11 (the length of the string)
Argument "quoted_text" can be any double quoted text.
Example:
TextAddrW("Test string")
After that sentence you have the effective address of a temporary null-terminated string in Unicode format. You can use it to pass it as an argument to any Unicode routine or API call. Remeber that the value returned by TextAddrW is the effective address, so you should NOT use the Addr operator. For example:
Invoke lstrlenW, TextAddrW("Test string")
Eax returns 11 (the length, in characters, of the string)
(Programmed by Héctor A. Medina)
Argument "quoted_text" can be any double quoted text.
Example:
TextStrA("Test string")
After that sentence you have the effective address of a temporary null-terminated string in ANSI format. Remeber that the value returned by TextStrA is the effective address, so you should NOT use the Addr operator.
Argument "quoted_text" can be any double quoted text.
Example:
TextStrW("Test string")
After that sentence you have the effective address of a temporary null-terminated string in Unicode format. Remeber that the value returned by TextStrW is the effective address, so you should NOT use the Addr operator.
Argument "quoted_text" can be any double quoted text.
Example:
TextStr("Test string")
After that sentence you have the effective address of a temporary null-terminated string in ANSI or Unicode format, depending on the mode the application is working on. If the Build project as Unicode (Windows NT or later) option in the Project Properties is checked, and the application is running on Windows NT or later, the returned text will be Unicode. Otherwise it will be ANSI.
MultiCat
lpszDesPtr,
lpszOrgPtr
Appends two or more text strings. Argument lpszDesPtr must be the effective address of a buffer receiving the appended strings, while lpszOrgPtr must be the effective address of one or more zero-terminated strings separated by commas. At least one string address must be passed as the second argument.
Example:
MultiCat lpszDest, lpszStr1, lpszStr2, ..., lpszStrn
Strings lpszStr1, lpszStr2, ... and lpszStrn are appended to lpszDest.
Swap
dwValue1,
dwValue2
Arguments dwValue1 and dwValue2 must be 32-bit values.
Example:
Swap dwVar1, dwVar2
Exchanges the values of the dwVar1 and dwVar2 variables.
REMARKS:
Note that no final NULL
character is needed, as it is already added internally by Text,
TextW,
TextAddr,
TextAddrW,
TextStr,
TextStrA
and TextStrW
macros. On the other hand, TextW,
TextAddrW
and TextStrW
(returning Unicode text) are limited to 243
characters (including the final zero added by
the macros). So, if more than 242 characters are
passed errors will be fired.
WARNING: The use of TextStr (or TextStrA, or TextStrW) instead of TextAddr (or TextAddrA, or TextAddrW) is recommended for compatibility with future versions.
IMPORTANT:
If you are not going to use any of these macros (included by default),
or their names conflict with any variable, procedure o macro name of
the project, you just can remove them by
unchecking the Easy Code macros option in Project
Properties.