Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / DLL loading using LoadLibrary and getting actual data from it.

Author
Message
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 26th Nov 2011 20:03 Edited at: 26th Nov 2011 20:04
Ok, i've tried to load a custom DLL using LoadLibrary and it worked. I even tried to get the proc address of a variable and it worked.......sorta. Rather then return the actual value (42), it returned something else. is there a tutorail or something to do this? could come in handy. I suppose i could always look at Ogre's way of doing it, but let's see if i can learn my self first.



EDIT: it just occurred to me i should of put it in the programming talk section....my bad

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
budokaiman
FPSC Tool Maker
15
Years of Service
User Offline
Joined: 24th Jun 2009
Playing: Hard to get
Posted: 26th Nov 2011 21:09 Edited at: 27th Nov 2011 02:36
What you're doing is getting the address for the function (a pointer) and nothing else. what you need to do is create a pointer to a function, set it to the dll's function address and call it.



Something like that.


reauirentem
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 27th Nov 2011 02:27
well, that didn't work. it just crashed. Hmmm

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 27th Nov 2011 02:31
never mind, i got it. now, how about if i have a class or a function with parameters? or hell a struct?

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
budokaiman
FPSC Tool Maker
15
Years of Service
User Offline
Joined: 24th Jun 2009
Playing: Hard to get
Posted: 27th Nov 2011 02:38
Quote: "never mind, i got it. now, how about if i have a class or a function with parameters? or hell a struct?"

You can't get direct access to variables or classes in .dlls, you'll have to setup functions to return their values (I think, I'm not actually sure of this, if anyone else knows if/how it's done then I'll gladly admit that I was wrong). For functions with parameters, just change the pointer initialisation and calling.

typedef int (__cdecl * pICFUNC)(void);
would become
typedef int (__cdecl * pICFUNC)(int, int, double /* whatever your parameters are*/);

and pass them as
pFunc(0, 1, 2.3);


reauirentem
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 27th Nov 2011 04:46
ah ok thanks

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack

Login to post a reply

Server time is: 2025-05-20 06:57:28
Your offset time is: 2025-05-20 06:57:28