Easy Code 2 Macros (All Project Type)


Easy Code includes some useful macros for the various supported assemblers that 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 correspondig file depending on the used configuration, are located in the \EasyCode\Macros folder and 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


HiDWord dqValue (64-bit projects only)

Argument dqValue must be a 64-bit value (QWord). Eax returns the high double word (32-bit value or DWord) of dqValue.

Example:

HiDWord 00FFFFFF000C000AH

Eax returns 00FFFFFFH


LoDWord dqValue (64-bit projects only)

Argument dqValue must be a 64-bit value (QWord). Eax returns the low double word (32-bit value or DWord) of dqValue.

Example:

LoDWord 00FFFFFF000C000AH

Eax returns 000C000AH


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).

Example:

MakeLong 0A0BH, 0C0DH

Eax returns 0C0D0A0BH


MakeQWord dwLow, dwHigh (64-bit projects only)

Arguments dwLow and dwHigh must be 32-bit values (DWord). Rax returns the resultant 64-bit value (QWord).

Example:

MakeQWord 000C000AH, 00FFFFFFH

Rax returns 00FFFFFF000C000AH


Move dwValue1, dwValue2 (for 32-bit projects)

Arguments dwValue1 and dwValue2 must be a 32-bit (DWord) variable or register.

Example:

Move dwMemPos1, dwMemPos2

Moves the value in variable or register specified by dwMemPos2 to variable or register specified by dwMemPos1.

This macro does not return a value.


Move dqValue1, dqValue2 (for 64-bit projects)

Arguments dqValue1 and dqValue2 must be a 64-bit (QWord) variable or register.

Example:

Move dqMemPos1, dqMemPos2

Moves the value in variable or register specified by dqMemPos2 to variable or register specified by dqMemPos1.

This macro does not return a value.


Return dwValue (for 32-bit projects)

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.


Return dqValue (for 64-bit projects)

Argument dqValue must be a 64-bit value (QWord). It loads the Rax register with dqValue and returns from a procedure.

Example:

Return TRUE

Loads the Rax 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.


TextA 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:

TextA szBuffer, "Test string"

After that sentence you have a temporary buffer with the specified string (null-terminated). Remeber that the value returned by TextA is NOT the effective address of the string, so you should use the Addr operator in order to get it. For example:

TextA, szTestA, "Test string"

Invoke lstrlen, Addr szTestA

Eax/Rax 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/Rax returns 11 (the length of the string)

(Programmed by Héctor A. Medina)


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 szTest, ("Test string")

After that sentence you will have a buffer with the specified null-terminated string in ANSI or Unicode format, depending on the mode the application is running on. If the This project will run in 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. 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 (Addr szTest).


TextAddrA ("quoted_text")

Argument "quoted_text" can be any double quoted text.

Example:

TextAddrA("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 TextAddrA is the effective address, so you should NOT use the Addr operator. For example:

Invoke lstrlen, TextAddrA("Test string")

Eax/Rax returns 11 (the length of the string)


TextAddrW ("quoted_text")

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/Rax returns 11 (the length, in characters, 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 in ANSI or Unicode format, depending on the mode the application is working on. If the This project will run in 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.


TextStrA ("quoted_text")

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.


TextStrW ("quoted_text")

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.


TextStr ("quoted_text")

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 This project will run in 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 (for 32-bit projects)

Arguments dwValue1 and dwValue2 must be a 32-bit variable or register.

Example:

Swap dwVar1, dwVar2

Exchanges the values of the dwVar1 and dwVar2 variables.


Swap dqValue1, dqValue2 (for 64-bit projects)

Arguments dqValue1 and dqValue2 must be 64-bit variable or register.

Example:

Swap dqVar1, dqVar2

Exchanges the values of the dqVar1 and dqVar2 variables.



REMARKS
: Remember that you do not need to add any NULL character at the end of the string for the Text, TextA, TextW, TextAddr, TextAddrA, TextAddrW, TextStr, TextStrA and TextStrW macros, as it is always internally added. 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.

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.