 
View Full Version : loading a library
vmagic
January 11th, 2005, 08:24
hello,
i am wondering how you would load a library into an exe. example, if i wanted to add some code to popup a message box into a simple hello world application, and i need to import the user32.dll, how would i do that.
Ricardo Narvaja
January 11th, 2005, 11:02
with the api LoadLibraryA load the dll and with GetProcAddress you have the adress of any api of this library in your machine.
look WINAPIS32 is the help of the apis.
Ricardo Narvaja
vmagic
January 12th, 2005, 06:00
when i use GetProcAddress, where does the address get stored so that i can use it?
thanks

blabberer
January 12th, 2005, 09:32
please grab a copy of win32.hlp 
or downlaod platform sdk from microsoft 
and go through them it will clearly state what will be returned 
now where it returns is dependent on how you see it i believe
for example a line of hll program may look like this
if (ret = GetProcAddress( *dll ,*proc) !=0)
{
call ret (args);
do blah;
return success;
}
else {
get lost;
}
return iamlost;
now the same would be looking like this is asm 
invoke GetProcAddres, ADDR name_of_dll, ADDR name_of_proc
mov return,eax
push args 
call [return]
now if you are looking and coding under debugger 
you can do like below
push addr 
push addr
call GetprocAddress
push args
call eax
please look into winhlp 
code some simple programs
run them under debugger get your self familiarized with 
what return where and how 
and btw i am not discouraging you but in this forum you cant expect 
answers to questions like your because this forum is meant for questions
regarding ollydbg its usage its problems its plugins etc
try to visit win32asmboard if you are interested in coding in assembly 
or may be read through forgers winprog tuts if you prefer 
high level syntax
ps edit 
i re read your original question 
by a simple hello world program you mean you are coding with c or c++
and building it as console version ?? (a console version means it displays 
the string in the black box called dos)
then you will have some more compatibility problems like 
putting together gui code along side of cui 
gui == graphical user interface
cui == console user interface
vmagic
January 12th, 2005, 13:42
ok thanks.
why would it matter if its being in dos or not, because if im loading that library and calling code from there then would it really matter?
i know all about windows api and stuff, i was wondering where does the value returned from GetProcAddress go in asm? cause its not like one can use variables at the debugging level..
Powered by vBulletin® Version 4.2.2 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.