I want to change the integer's value in this function and bring this value out.

how to declare the proto of this function and how to use it?

can anyone give me a simple code snippet, thanks!
Posted on 2003-09-15 09:21:31 by lovelypp
NameOFProc PROTO :DWORD,:DOWRD

depending on now meany vars there are

invoke NameOFProc,var1,var2
Posted on 2003-09-15 13:44:35 by devilsclaw
I encapsulate that function in a dll module. Now I want to call that function and take the handled value back
Posted on 2003-09-15 21:36:53 by lovelypp
This is a ASM community not a C++
Posted on 2003-09-15 21:55:42 by devilsclaw
?
Posted on 2003-09-15 23:29:38 by lovelypp
lovelypp
;

; asmdll.asm
;
; build
;
; \masm32\bin\ml /c /coff asmdll.asm
; \masm32\bin\link /subsystem:windows /dll /def:asmdll.def asmdll.obj
;

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\kernel32.lib

.code

DllEntry proc hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
mov eax,1
ret
DllEntry Endp

AsmFunc proc dwInputNumber:DWORD
mov eax,dwInputNumber
add eax,10
ret
AsmFunc endp

End DllEntry
asmdll.def
LIBRARY asmdll

EXPORTS AsmFunc
test.c (for VC+6.0) with static link
#include <windows.h>

#include <stdio.h>

#pragma comment(lib, "asmdll.lib")

int __stdcall AsmFunc(int);

int main(void)
{
int i = 10;

printf("i = %d, AsmFunc(i) return %d\n", i, AsmFunc(i));
return 0;
}
test.c (for VC+6.0) with dynamic link
#include <windows.h>

#include <stdio.h>

int main(void)
{
int (__stdcall *pfAsmFunc)(int);

int i = 10;
HMODULE hDll = LoadLibrary("asmdll.dll");
if (NULL != hDll)
{
pfAsmFunc = (int (__stdcall *)(int))GetProcAddress(hDll,"AsmFunc");
if (NULL != pfAsmFunc)
printf("i = %d, AsmFunc(i) return %d\n", i, pfAsmFunc(i));
else
printf("GetProcAddress failed %d\n", GetLastError());

FreeLibrary(hDll);
}
else
printf("LoadLibrary failed %d\n", GetLastError());

return 0;
}
Posted on 2003-09-17 00:24:49 by P2M
thanks!
Posted on 2003-09-17 00:31:45 by lovelypp