flat assembler
Message board for the users of flat assembler.

Index > Windows > callback function resides on dll gives error access denied

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 12873
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 21 Mar 2007, 03:43
hi there Cool
the idea is like this, i was trying to make a enumwindowsproc in a dll, so that i could resuse it next time.

but the problem is, even a simple enumwindowsproc with code
mov eax,TRUE
ret
would give the below error.
Code:
The instruction at "0x004030bb" referenced memory at "0x0051f238". The memory could not be "written".
    

but if i put the exact enumwindowsproc on the .exe itself, it produces no error... i wonder why?

i attached with the dll and the sample test.exe for testing.


Description: 4 files here,
2 asm source, dll & exe
2 assembled files, dll & exe

Download
Filename: test.zip
Filesize: 1.77 KB
Downloaded: 256 Time(s)

Post 21 Mar 2007, 03:43
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 21 Mar 2007, 04:31
Maybe "pop [dllH]" is the actual faulty instruction. Why? Because you forgot to add the fixups to the DLL. Add "section '.reloc' fixups data discardable" to the source.

Cheers

[edit] Well you must still fix what I've told you but looking at the executable that use the DLL I found that you call "invoke EnumWindows,enumTopWindowProc,0" but it must be "invoke EnumWindows,[enumTopWindowProc],0"
Post 21 Mar 2007, 04:31
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12873
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 21 Mar 2007, 08:59
thanks LocoDelAssembly.
the [enumTopWindowProc] seems to solve the error.

but i don't understand why we need to use [enumTopWindowProc] ?
so, if we write mov eax,enumTopWindowProc
what address actually we get in eax? the pointer of enumTopWindowProc?
the pointer of pointer to enumTopWindowProc? the pointer of pointer of pointer to enumTopWindowProc? Confused
Post 21 Mar 2007, 08:59
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 21 Mar 2007, 13:55
You get the pointer of pointer to DLL function. Remember that EXE files are not relocated and uses an import table which consists of pointers to functions that Windows must fill on image load. Note that the same happens when calling, you need to use "call dword [function]" instead of "call function" and the reason again is because there is no relocs (and the last one is uncompilable).

DLL also uses import table but are relocatable, and for that you have to add the fixups because if the base address of DLL is occupied already by something else then your DLL will fail.
Post 21 Mar 2007, 13:55
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12873
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 21 Mar 2007, 16:46
sorry for my stupid question, i think i get it now Smile
thanks LocoDelAssembly
Post 21 Mar 2007, 16:46
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.