Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit multiasmlib;
- (*
- Delphi SDK for Multiline Ultimate Assembler Library
- Ported by HEX0x29A
- http://rammichael.com/multiline-ultimate-assembler-library
- (!!!) MUAAssemble and MUAAssembleFree have access violation. I'm don't know how to fix this.
- *)
- interface
- uses
- Windows;
- const
- MULTIASMLIBDLL = 'multiasmlib.dll';
- type
- PODBG_DISASM_OPTIONS = ^ODBG_DISASM_OPTIONS;
- ODBG_DISASM_OPTIONS = packed record
- ideal: integer; // Force IDEAL decoding mode
- lowercase: integer; // Force lowercase display
- tabarguments: integer; // Tab between mnemonic and arguments
- extraspace: integer; // Extra space between arguments
- putdefseg: integer; // Display default segments in listing
- showmemsize: integer; // Always show memory size
- shownear: integer; // Show NEAR modifiers
- shortstringcmds: integer; // Use short form of string commands
- sizesens: integer; // How to decode size-sensitive mnemonics
- symbolic: integer; // Show symbolic addresses in disasm
- farcalls: integer; // Accept far calls, returns & addresses
- decodevxd: integer; // Decode VxD calls (Win95/98)
- privileged: integer; // Accept privileged commands
- iocommand: integer; // Accept I/O commands
- badshift: integer; // Accept shift out of range 1..31
- extraprefix: integer; // Accept superfluous prefixes
- lockedbus: integer; // Accept LOCK prefixes
- stackalign: integer; // Accept unaligned stack operations
- iswindowsnt: integer; // When checking for dangers, assume NT
- end;
- PDISASM_OPTIONS = ^DISASM_OPTIONS;
- DISASM_OPTIONS = packed record
- disasm_label: integer; // nonzero to use labels
- disasm_hex: integer; // 0: FFFE, 1: 0FFFE, 2: 0FFFEh ,3: 0xFFFE
- disasm_labelgen: integer; // 0: L[counter], 1: L_[address], 2: L_[pLabelPerfix]_[counter]
- end;
- // FUNCTION
- // MUASetOdbgDisasmOptions
- //
- // DESCRIPTION
- // Sets OllyDbg disassembler flags. By default, all flags are zero.
- //
- // PARAMETERS
- // ODBG_DISASM_OPTIONS *p_odbg_disasm_options
- // OllyDbg disassembler flags, see ODBG_DISASM_OPTIONS struct for details.
- procedure MUASetOdbgDisasmOptions(p_odbg_disasm_options: PODBG_DISASM_OPTIONS); stdcall;
- //void MUASetOdbgDisasmOptions(ODBG_DISASM_OPTIONS *p_odbg_disasm_options);
- // FUNCTION
- // MUADisassemble
- //
- // DESCRIPTION
- // Disassembles binary code to text, compatible with Multiline Ultimate Assembler.
- // Note: it doesn't include the block address (<00401000>).
- //
- // PARAMETERS
- // BYTE *pCode
- // A pointer to the binary code.
- // Note: must be writable, and will be altered!
- // DWORD dwAddress
- // The address (instruction pointer) of the code.
- // DWORD dwSize
- // The size of the code.
- // char *pLabelPerfix
- // Used with the disasm_labelgen=2 option.
- // Note: must be writable! If it contains invalid characters, they will be replaced.
- // DISASM_OPTIONS *p_options:
- // Disassembler options, see DISASM_OPTIONS struct for details.
- // char *lpError
- // In case of an error, recieves the error string. Must be at least 1025 characters long.
- //
- // RETURN
- // char *
- // A pointer to the disassembled text in case of success. Free with MUADisassembleFree.
- // NULL in case of failure.
- function MUADisassemble(pCode: PBYTE; dwAddress: DWORD; dwSize: DWORD;
- pLabelPerfix: PAnsiChar; p_options: PDISASM_OPTIONS; lpError: PAnsiChar): PAnsiChar; stdcall;
- //char *MUADisassemble(BYTE *pCode, DWORD dwAddress, DWORD dwSize, char *pLabelPerfix, DISASM_OPTIONS *p_options, char *lpError);
- // FUNCTION
- // MUADisassembleFree
- //
- // DESCRIPTION
- // Frees the pointer returned by MUADisassemble.
- //
- // PARAMETERS
- // char *lpText
- // The pointer returned by MUADisassemble.
- //
- // RETURN
- // BOOL
- // Nonzero in case of a success.
- // Zero in case of failure.
- function MUADisassembleFree(lpText: PAnsiChar): BOOL; stdcall;
- //BOOL MUADisassembleFree(char *lpText);
- // FUNCTION
- // MUAAssemble
- //
- // DESCRIPTION
- // Assembles text, compatible with Multiline Ultimate Assembler, to binary code.
- // Note: do not include the block address (<00401000>).
- //
- // PARAMETERS
- // char *lpText
- // A pointer to the zero terminated assembly text.
- // Note: must be writable, and will be altered!
- // DWORD dwAddress
- // The address (instruction pointer) of the code.
- // DWORD *pdwSize
- // Recieves the size of the assembled binary code.
- // DWORD dwBaseAddress
- // The base address used for relative RVA addresses ($$1000).
- // See Multiline Ultimate Assembler help for more details.
- // int *pnErrorOffset
- // In case of an error, recieves the offset of the error in the assembly text. Optional.
- // char *lpError
- // In case of an error, recieves the error string. Must be at least 1025 characters long.
- //
- // RETURN
- // BYTE *
- // A pointer to the assembled binary code in case of success. Free with MUAAssembleFree.
- // NULL in case of failure.
- function MUAAssemble(lpText: PAnsiChar; dwAddress: DWORD; pdwSize: PDWORD;
- dwBaseAddress: DWORD; pnErrorOffset: PInteger; lpError: PAnsiChar): PBYTE; stdcall;
- //BYTE *MUAAssemble(char *lpText, DWORD dwAddress, DWORD *pdwSize, DWORD dwBaseAddress, int *pnErrorOffset, char *lpError);
- // FUNCTION
- // MUAAssembleFree
- //
- // DESCRIPTION
- // Frees the pointer returned by MUAAssemble.
- //
- // PARAMETERS
- // BYTE *pAsm
- // The pointer returned by MUAAssemble.
- //
- // RETURN
- // BOOL
- // Nonzero in case of a success.
- // Zero in case of failure.
- function MUAAssembleFree(pAsm: PBYTE): BOOL; stdcall;
- //BOOL MUAAssembleFree(BYTE *pAsm);
- implementation
- procedure MUASetOdbgDisasmOptions; external MULTIASMLIBDLL;
- function MUADisassemble; external MULTIASMLIBDLL;
- function MUADisassembleFree; external MULTIASMLIBDLL;
- function MUAAssemble; external MULTIASMLIBDLL;
- function MUAAssembleFree; external MULTIASMLIBDLL;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement