ulong Assemble(wchar_t *src,ulong ip,uchar *buf,ulong nbuf,int mode,wchar_t *errtxt);
Generates the shortest possible form of the specified precise command src. Understands commands in MASM, IDEAL and HLA formats dependless on the currently selected disassembling mode. Syntax is relatively fuzzy and accepts commands that would be rejected by some compilers.On success, saves binary code to buf and returns its length in bytes. On error, copies optional error description to errtxt and returns 0.
Bit AM_ALLOWBAD in mode enables suspicious and undocumented forms. However, if undocumented form is allowed but documented form of the same size exists, documented form is preferred.
There is a special case where produced command is 1 byte longer than minimally possible. Assemble() assumes 32-bit addressing, so commands like MOV EDX,[FS:2C] will use the full 32-bit displacement and compile to 64:8B15 2C000000. If we specify 16-bit addressing (prefix 67), displacement will be only 16-bit and we will spare one byte: MOV EDX,[SMALL FS:2C] compiles to 67:64:8B16 2C00.
Parameters:
src
(in)
Pointer to the UNICODE string containing 80x86 command in the text
form
ip
(in)
Address where command must be placed, necessary to calculate offsets
for relative jumps and calls
buf
(out)
Pointer to the buffer of length at least nbuf bytes that will receive the compiled command in binary form
nbuf
(in)
Maximal allowed length of the command. Valid 80x86 commands are at most MAXCMDSIZE bytes long (more precisely, maximal command length is 15 bytes but MAXCMDSIZE is rounded up for better alignment)
mode
(in)
Assembling mode, a combination of zero or more of the following flags:
AM_ALLOWBAD - allows bad or undocumented commands
errtxt
AM_ALLOWBAD - allows bad or undocumented commands
(out)
Pointer to the UNICODE buffer at least TEXTLEN wide
characters long that receives error message, or NULL if error message
is not needed
Return values:
On success, returns length of the generated binary code in bytes. On error, sets errtxt and returns 0
See also: