flat assembler
Message board for the users of flat assembler.

Index > Windows > DLL export function problem..

Author
Thread Post new topic Reply to topic
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 02 Mar 2011, 19:05
Hello everyone, I'm having trouble with dll export functions.. I'm trying to make function but when exporting it, doesn't work fine.. Only in debugger works normal..
I'm thinking if there is way to play with stack when programming DLL ? cause I think its main problem for it..
Here's code and tell me what I'm doing wrong.. Thank you.
Code:
format PE GUI 4.0 DLL
INCLUDE 'WIN32AX.INC'
entry DllEntryPoint

section '.data' data readable writeable

handle dd ?

section '.text' code readable executable

proc DllEntryPoint, hInstance, dwReason, lpReserved
     mov eax,1
     ret
endp

proc dec2str, num, sys
     mov eax,[num]
     mov ecx,[sys]
     push edi
     mov edi,esp
     sub esp,30
loop1:
     xor edx,edx
     div ecx
     dec edi
     add dl,0x30
     cmp edx,0x3a
     jae stage2
     jmp decv
stage2:
     cmp edx,0x3f
     jbe conv
decv:
     mov [edi],dl
     test eax,eax
     jnz loop1
     jmp return_value
conv:
     add dl,0x27
     jmp decv
return_value:
     invoke MessageBox,0,edi,edi,MB_OK+MB_ICONINFORMATION
     pop edi
     add esp,30
     ret
endp

section '.idata' import data readable

library user32,'user32.dll',kernel32,'kernel32.dll'
include 'API\USER32.INC'
include 'API\KERNEL32.INC'

section '.edata' export data readable

export '',dec2str,'dec2str'

section '.reloc' fixups data discardable readable    


I'm calling with this command:
Code:
push 16
push 2
call dec2str    

but it fails.. HELP Sad
Post 02 Mar 2011, 19:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 02 Mar 2011, 20:15
Overflowz wrote:
Code:
;...
     push edi
;...
     sub esp,30
;...
     pop edi
     add esp,30
;...    
Looks as though you have the last two instructions reversed.
Post 02 Mar 2011, 20:15
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 03 Mar 2011, 11:51
revolution
I don't understand, what do you mean ?
Post 03 Mar 2011, 11:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 03 Mar 2011, 12:08
Try this:
Code:
;...
     push edi
;...
     sub esp,30
;...
     add esp,30 ;swapped
     pop edi    ;swapped
;...    
Post 03 Mar 2011, 12:08
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 03 Mar 2011, 12:40
revolution
Do you mean like this ? anyway this doesn't work..
Code:
proc dec2str, num, sys
     mov eax,[num]
     mov ecx,[sys]
     push edi
     sub esp,30
loop1:
     xor edx,edx
     div ecx
     dec edi
     add dl,0x30
     cmp edx,0x3a
     jae stage2
     jmp decv
stage2:
     cmp edx,0x3f
     jbe conv
decv:
     mov [edi],dl
     test eax,eax
     jnz loop1
     jmp return_value
conv:
     add dl,0x27
     jmp decv
return_value:
     invoke MessageBox,0,ebp,ebp,MB_OK+MB_ICONINFORMATION
     add esp,30
     pop edi
     ret
endp     
Post 03 Mar 2011, 12:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 03 Mar 2011, 13:29
You still have to set the value of edi upon entry. Only change the order of the two instructions I showed as swapped above so as to properly restore your stack.
Post 03 Mar 2011, 13:29
View user's profile Send private message Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 03 Mar 2011, 14:12
revolution
Mate, I don't understand too much here.. Can you just fix my code instead of suggesting me things and I'll understand what you're saying Smile Thanks.
Post 03 Mar 2011, 14:12
View user's profile Send private message Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 03 Mar 2011, 22:23
Bump.. Nobody else can solve this ?
Post 03 Mar 2011, 22:23
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.