Advertisement
HEX0x29A

SDK for Multiline Ultimate Assembler Library

May 13th, 2014
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 5.96 KB | None | 0 0
  1. unit multiasmlib;
  2. (*
  3. Delphi SDK for Multiline Ultimate Assembler Library
  4. Ported by HEX0x29A
  5. http://rammichael.com/multiline-ultimate-assembler-library
  6. (!!!) MUAAssemble and MUAAssembleFree have access violation. I'm don't know how to fix this.
  7. *)
  8. interface
  9.  
  10. uses
  11.   Windows;
  12.  
  13. const
  14.   MULTIASMLIBDLL = 'multiasmlib.dll';
  15.  
  16. type
  17.   PODBG_DISASM_OPTIONS = ^ODBG_DISASM_OPTIONS;
  18.   ODBG_DISASM_OPTIONS = packed record
  19.     ideal: integer;                // Force IDEAL decoding mode
  20.     lowercase: integer;            // Force lowercase display
  21.     tabarguments: integer;         // Tab between mnemonic and arguments
  22.     extraspace: integer;           // Extra space between arguments
  23.     putdefseg: integer;            // Display default segments in listing
  24.     showmemsize: integer;          // Always show memory size
  25.     shownear: integer;             // Show NEAR modifiers
  26.     shortstringcmds: integer;      // Use short form of string commands
  27.     sizesens: integer;             // How to decode size-sensitive mnemonics
  28.     symbolic: integer;             // Show symbolic addresses in disasm
  29.     farcalls: integer;             // Accept far calls, returns & addresses
  30.     decodevxd: integer;            // Decode VxD calls (Win95/98)
  31.     privileged: integer;           // Accept privileged commands
  32.     iocommand: integer;            // Accept I/O commands
  33.     badshift: integer;             // Accept shift out of range 1..31
  34.     extraprefix: integer;          // Accept superfluous prefixes
  35.     lockedbus: integer;            // Accept LOCK prefixes
  36.     stackalign: integer;           // Accept unaligned stack operations
  37.     iswindowsnt: integer;          // When checking for dangers, assume NT
  38.   end;
  39.   PDISASM_OPTIONS = ^DISASM_OPTIONS;
  40.   DISASM_OPTIONS = packed record
  41.     disasm_label: integer;         // nonzero to use labels
  42.     disasm_hex: integer;           // 0: FFFE, 1: 0FFFE, 2: 0FFFEh ,3: 0xFFFE
  43.     disasm_labelgen: integer;      // 0: L[counter], 1: L_[address], 2: L_[pLabelPerfix]_[counter]
  44.   end;
  45.  
  46. // FUNCTION
  47. // MUASetOdbgDisasmOptions
  48. //
  49. // DESCRIPTION
  50. // Sets OllyDbg disassembler flags. By default, all flags are zero.
  51. //
  52. // PARAMETERS
  53. // ODBG_DISASM_OPTIONS *p_odbg_disasm_options
  54. //   OllyDbg disassembler flags, see ODBG_DISASM_OPTIONS struct for details.
  55.  
  56. procedure MUASetOdbgDisasmOptions(p_odbg_disasm_options: PODBG_DISASM_OPTIONS); stdcall;
  57. //void MUASetOdbgDisasmOptions(ODBG_DISASM_OPTIONS *p_odbg_disasm_options);
  58.  
  59. // FUNCTION
  60. // MUADisassemble
  61. //
  62. // DESCRIPTION
  63. // Disassembles binary code to text, compatible with Multiline Ultimate Assembler.
  64. // Note: it doesn't include the block address (<00401000>).
  65. //
  66. // PARAMETERS
  67. // BYTE *pCode
  68. //   A pointer to the binary code.
  69. //   Note: must be writable, and will be altered!
  70. // DWORD dwAddress
  71. //   The address (instruction pointer) of the code.
  72. // DWORD dwSize
  73. //   The size of the code.
  74. // char *pLabelPerfix
  75. //   Used with the disasm_labelgen=2 option.
  76. //   Note: must be writable! If it contains invalid characters, they will be replaced.
  77. // DISASM_OPTIONS *p_options:
  78. //   Disassembler options, see DISASM_OPTIONS struct for details.
  79. // char *lpError
  80. //   In case of an error, recieves the error string. Must be at least 1025 characters long.
  81. //
  82. // RETURN
  83. // char *
  84. //   A pointer to the disassembled text in case of success. Free with MUADisassembleFree.
  85. //   NULL in case of failure.
  86.  
  87. function MUADisassemble(pCode: PBYTE; dwAddress: DWORD; dwSize: DWORD;
  88.  pLabelPerfix: PAnsiChar; p_options: PDISASM_OPTIONS; lpError: PAnsiChar): PAnsiChar; stdcall;
  89.  
  90. //char *MUADisassemble(BYTE *pCode, DWORD dwAddress, DWORD dwSize, char *pLabelPerfix, DISASM_OPTIONS *p_options, char *lpError);
  91.  
  92. // FUNCTION
  93. // MUADisassembleFree
  94. //
  95. // DESCRIPTION
  96. // Frees the pointer returned by MUADisassemble.
  97. //
  98. // PARAMETERS
  99. // char *lpText
  100. //   The pointer returned by MUADisassemble.
  101. //
  102. // RETURN
  103. // BOOL
  104. //   Nonzero in case of a success.
  105. //   Zero in case of failure.
  106.  
  107. function MUADisassembleFree(lpText: PAnsiChar): BOOL; stdcall;
  108. //BOOL MUADisassembleFree(char *lpText);
  109.  
  110. // FUNCTION
  111. // MUAAssemble
  112. //
  113. // DESCRIPTION
  114. // Assembles text, compatible with Multiline Ultimate Assembler, to binary code.
  115. // Note: do not include the block address (<00401000>).
  116. //
  117. // PARAMETERS
  118. // char *lpText
  119. //   A pointer to the zero terminated assembly text.
  120. //   Note: must be writable, and will be altered!
  121. // DWORD dwAddress
  122. //   The address (instruction pointer) of the code.
  123. // DWORD *pdwSize
  124. //   Recieves the size of the assembled binary code.
  125. // DWORD dwBaseAddress
  126. //   The base address used for relative RVA addresses ($$1000).
  127. //   See Multiline Ultimate Assembler help for more details.
  128. // int *pnErrorOffset
  129. //   In case of an error, recieves the offset of the error in the assembly text. Optional.
  130. // char *lpError
  131. //   In case of an error, recieves the error string. Must be at least 1025 characters long.
  132. //
  133. // RETURN
  134. // BYTE *
  135. //   A pointer to the assembled binary code in case of success. Free with MUAAssembleFree.
  136. //   NULL in case of failure.
  137.  
  138. function MUAAssemble(lpText: PAnsiChar; dwAddress: DWORD; pdwSize: PDWORD;
  139.  dwBaseAddress: DWORD; pnErrorOffset: PInteger; lpError: PAnsiChar): PBYTE; stdcall;
  140. //BYTE *MUAAssemble(char *lpText, DWORD dwAddress, DWORD *pdwSize, DWORD dwBaseAddress, int *pnErrorOffset, char *lpError);
  141.  
  142. // FUNCTION
  143. // MUAAssembleFree
  144. //
  145. // DESCRIPTION
  146. // Frees the pointer returned by MUAAssemble.
  147. //
  148. // PARAMETERS
  149. // BYTE *pAsm
  150. //   The pointer returned by MUAAssemble.
  151. //
  152. // RETURN
  153. // BOOL
  154. //   Nonzero in case of a success.
  155. //   Zero in case of failure.
  156.  
  157. function MUAAssembleFree(pAsm: PBYTE): BOOL; stdcall;
  158. //BOOL MUAAssembleFree(BYTE *pAsm);
  159.  
  160. implementation
  161.  
  162. procedure MUASetOdbgDisasmOptions; external MULTIASMLIBDLL;
  163. function MUADisassemble; external MULTIASMLIBDLL;
  164. function MUADisassembleFree; external MULTIASMLIBDLL;
  165. function MUAAssemble; external MULTIASMLIBDLL;
  166. function MUAAssembleFree; external MULTIASMLIBDLL;
  167.  
  168. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement