flat assembler
Message board for the users of flat assembler.

Index > Windows > Calling DLL from C

Author
Thread Post new topic Reply to topic
BombStrike



Joined: 03 Jan 2006
Posts: 1
BombStrike
ok i wrote a DLL in fASM
i pass a char* to a function in the DLL from my C apps
i'm searching how to mod the content of this pointer

here is an exemple

Application ( in C ):
Code:
extern int TextFunc(char *pString,int SomethingElse);
...
TextFunc(string,5); // where string is a char *
    


DLL Function ( in ASM ):
Code:
proc TestFunc stdcall pString,SomethingElse
  ; how to modify the value pointed in pString ?
  mov eax,3 ;returning 3
  ret
endp
    


sry if it's hard to understand, i'm not english Smile
Post 04 Jan 2006, 00:48
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
you pass a ptr to a string to your dll function
so
asm dll
Code:
TestFunc:
;;esp+4 = pString ;;esp+8 = SomethingElse 
  mov eax, [esp+4]
;; now the ptr in is eax
;; make the first character of the string '1'
  mov byte[eax],'1'
  xor eax,eax ;;0 return value for success
  ret 8 ;; return 8 because we passed 2 dword(4bytes each) params
    


hope that helps you
I don't like using the proc macro just a preference.
Post 04 Jan 2006, 02:30
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.