flat assembler
Message board for the users of flat assembler.

Index > Windows > Resources

Author
Thread Post new topic Reply to topic
DustWolf



Joined: 26 Jan 2006
Posts: 373
Location: Ljubljana, Slovenia
DustWolf 09 Sep 2006, 19:57
I need to program something that reads raw data out of it's own EXE in a reliable manner.

In the documentation I have read thus far, everything suggests I should use the FindResource API. However I find myself a little lost about it's use and how to supply it these "Resources", since all the documentation is for VC++ and VC++ hides these aspects from the programmer.

I'm sure it's simple. Can somebody give me a quick example?

Here is my code to load the resource called "MyData" from self:
Code:
invoke FindResource,0,'MyData',RT_RCDATA
mov [ResourceHandle],eax    


How do I provide this code the "Resource" it needs?

Thanks in advance. Smile
Post 09 Sep 2006, 19:57
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 09 Sep 2006, 20:57
You can get the resource section from the PE headers.

_________________
redghost.ca


Last edited by RedGhost on 10 Sep 2006, 06:13; edited 2 times in total
Post 09 Sep 2006, 20:57
View user's profile Send private message AIM Address MSN Messenger Reply with quote
DustWolf



Joined: 26 Jan 2006
Posts: 373
Location: Ljubljana, Slovenia
DustWolf 09 Sep 2006, 21:37
RedGhost wrote:
You can get the resource section from the PE headers.


And what do I have to call "MyData" there for it to find the right thing?
Post 09 Sep 2006, 21:37
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 10 Sep 2006, 06:12
Hi, if you read the remarks on the MSDN for FindResource you see 'MyData' is the identifier for the resource, whether it is a string or an integer identifier, so pass the ID that defines that resource, in C/C++ you would use the MAKEINTRESOURCE macro which just casts int to char * but in asm just pass the value of the ID or the address of a string.

If you don't know the ID you can find the address of the resource section (from the PE headers) and go from there.

There is also EnumResourceNames.

Here is an example of how to use FindResource and how to enumerate all the resources of a module.

http://tinyurl.com/93xxt

_________________
redghost.ca
Post 10 Sep 2006, 06:12
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 10 Sep 2006, 11:20
You call FindResource and pass the returned value to LoadResource
Code:
invoke  FindResource, 0, 'MyData', RT_RCDATA
mov     [ResourceHandle], eax
invoke  LoadResource, 0, eax
mov     [ResourceData], eax ; <-- this is what you want    
Post 10 Sep 2006, 11:20
View user's profile Send private message Visit poster's website 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.