News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Creating a simple DLL in ASM?

Started by wossname, November 12, 2005, 01:08:41 PM

Previous topic - Next topic

wossname

I would like to learn how to pass an array of 32 bit integers (unsigned) from C# to an ASM module, have the ASM manipulate the array (something simple like adding 1 to each int) and then being able to use the modified values in the C# program.

I am already very experienced in C# but I'm still new to ASM (I've been playing with graphics so far, so i can get by, but writing DLLs in ASM is new to me).

I'm using MASM and I need a really simple example so I can learn how to optimise my C# windows forms apps for speed and efficiency.

Cheers :)


hutch--

wossname,

The MASM32 Project has a script set up in the editor for a DLL skeleton and tere is a tutorial on how they work as well. You will have to know the low level details of how C# passes data and how to prototype an assembler DLL for its use but the DLL is simple enough once you have te C# data.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

AeroASM

\masm32\tutorial\dlltute contains an example.

Here is a skeleton:

csdll.asm:

--INCLUDE FILES---
.code
LibMain proc hInstDLL:dword,reason:dword,unused:dword
mov eax,1
ret
LibMain endp

--PUT YOUR CODE HERE---

end LibMain


csdll.def (a text file)

LIBRARY csdll
EXPORTS {a function name}
EXPORTS {another function name}
etc ...


Building is the same as a normal exe except that you pass the linker two extra arguments: /dll and /def:csdll.def.

wossname

Quote from: AeroASM on November 12, 2005, 02:33:20 PM
\masm32\tutorial\dlltute contains an example.

Here is a skeleton:

csdll.asm:

--INCLUDE FILES---
.code
LibMain proc hInstDLL:dword,reason:dword,unused:dword
mov eax,1
ret
LibMain endp

--PUT YOUR CODE HERE---

end LibMain


csdll.def (a text file)

LIBRARY csdll
EXPORTS {a function name}
EXPORTS {another function name}
etc ...


Building is the same as a normal exe except that you pass the linker two extra arguments: /dll and /def:csdll.def.



OK Thanks aero, thats a good place to start, cheers  :thumbu

Vortex

Hi wossname,

Here is an example for you. The function sum from the sample dll arraysum.dll takes two parameters two calculate
the sum of an array of 32-bit integers : The first one the address of the array and the second the number of members.

[attachment deleted by admin]