flat assembler
Message board for the users of flat assembler.

Index > Windows > Loading menus from dll

Author
Thread Post new topic Reply to topic
ghst



Joined: 09 Feb 2007
Posts: 8
Location: Lusitania
ghst
Hello!

Instead of running resources from .exe I´m trying to load them from a dll resource section separately, but with no luck. I've tried FindResource and then LoadResource, but accordingly to win32.hlp that is only good to get binary data.. LoadMenu doesn't work either..

I've also tried to make a function exported by the dll that would give me a handle for the dll resource.. same thing..

Any help would be very appreciated!
Post 08 Jun 2007, 18:30
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
Garthower
Here is a work example.

file test.asm:

Code:
format PE GUI
entry Start

include 'C:\fasm\INCLUDE\MACRO\STRUCT.INC'
include 'C:\fasm\INCLUDE\MACRO\PROC32.INC'
include 'C:\fasm\INCLUDE\MACRO\IMPORT32.INC'

section '.code' code readable executable
Start:
  invoke  LoadLibraryA,DLLName
        invoke  LoadMenuA,eax,1000      ;return in eax handle to menu
       invoke  ExitProcess,0

section '.data' data readable writeable

DLLName           db 'test_dll.dll',0

section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
  user32,'USER32.DLL'

include 'C:\fasm\INCLUDE\APIA\kernel32.inc'
include 'C:\fasm\INCLUDE\APIA\user32.inc'
    


file test_dll.asm:
Code:
format PE GUI DLL
entry DLLMain

include 'C:\fasm\INCLUDE\MACRO\STRUCT.INC'
include 'C:\fasm\INCLUDE\MACRO\PROC32.INC'
include 'C:\fasm\INCLUDE\MACRO\IMPORT32.INC'

section '.code' code readable executable

proc DLLMain hinstDLL,dwReason,lpvReserved
  mov     eax,1
       ret
endp

section '.rsrc' resource from 'test_dll.res' readable
    


file test_dll.rc:
Code:
1000 MENUEX
BEGIN
  POPUP ""
  BEGIN
    MENUITEM "Item1",1
    MENUITEM "Item2",2
    MENUITEM "",,0x00000800
    MENUITEM "Item3",2
  END
END
    


BAT-file for compile (usage: bat_file your_asm_file):
Code:
@echo off
cls
echo FASM batch-compiler with resources
echo:

if exist %1.rc goto RC1
:COMPILE
c:\fasm\fasm.exe %1.asm
goto EXIT
:RC1
echo:
echo Current RC file founded...
echo:
if not exist %1.res goto LAB1
del %1.res
:LAB1
C:\fasm\GoRC.exe /r /machine x64 %1.rc
goto COMPILE
:EXIT
    
Post 08 Jun 2007, 20:10
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
ghst



Joined: 09 Feb 2007
Posts: 8
Location: Lusitania
ghst
Garthower, thank you very much for your reply.

I've already tried before something similar with your example, but the program kept crashing.. I was passing the dll menu handle to WNDCLASS.lpszMenuName instead using it with CreateWindow Embarassed ...
Post 09 Jun 2007, 13:55
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
Garthower
ghst:
Post here your source code, maybe any mistake can eat there.
Post 09 Jun 2007, 18:41
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number 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.