Hi,
I have a dll and one of its exported function is suppossed to return a
pointer to an object.
How can i check whether the exported function is of the same prototype
i want.
Please comment
Thanks & Regards
Srilal 8 1896 sr******@gmail. com wrote: Hi,
I have a dll and one of its exported function is suppossed to return a pointer to an object. How can i check whether the exported function is of the same prototype i want.
Please be noted that the concept of DLL may be implemented differently
across platforms and such a concept is not a concern of the C++ standard
and is generally off-topic in this newsgroup. You may therefore consult
platform specific documentation on DLL's or ask in a more suitable
newsgroup.
That said, I think the C++ name mangling would do the trick, although in
some systems it is mandated exported functions must be extern "C" and
therefore cannot be mangled.
Regards,
Ben
hi,
actually what i meant was, if i am executing the exported function
then how can i test if the returned values is a valid pointer to the
expected object.
Thanks & Regards,
Srilal sr******@gmail. com skrev: hi, actually what i meant was, if i am executing the exported function then how can i test if the returned values is a valid pointer to the expected object.
Thanks & Regards, Srilal
If the function does not guarantee that a returned non-null pointer
is valid, then don't use the function.
--
TB @ SWEDEN
Hi,
here is the code snippent of my application
HINSTANCE hHandle = LoadLibrary ("UserDLL.dll") ;
//If the dll handle returns is null then trow exception.
if (!hHandle)
{ throw Exception; }
//Else get call the exported function pointer for creating the
object
typedef MyClass* (*pMyClass) ();
pMyClass pMyClassCreate= (pMyClass) GetProcAddress( hHandle,
"ExportedFuncti on");
if (!pMyClassCreat e)
{
if (hHandle)
{
FreeLibrary (hHandle);
}
throw Exception
}
MyClass * pMyClassobj;
try
{
pMyClassobj = pMyClassCreate( );
}
catch(...)
{
throw Exception;
}
try
{
pMyClass->MyFunction() ;
}
catch(...)
{
}
now my question is what if the ExportedFunctio n does not return the
pointer to MyClass
then executing pMyClass->MyFunction is giving access violations.
Thanks & Regards,
Srilal sr******@gmail. com skrev: Hi,
here is the code snippent of my application
HINSTANCE hHandle = LoadLibrary ("UserDLL.dll") ;
//If the dll handle returns is null then trow exception. if (!hHandle) { throw Exception; }
//Else get call the exported function pointer for creating the object typedef MyClass* (*pMyClass) ();
pMyClass pMyClassCreate= (pMyClass) GetProcAddress( hHandle, "ExportedFuncti on");
if (!pMyClassCreat e) { if (hHandle) { FreeLibrary (hHandle); }
throw Exception }
MyClass * pMyClassobj; try { pMyClassobj = pMyClassCreate( ); } catch(...) { throw Exception; }
try { pMyClass->MyFunction() ; } catch(...) { }
now my question is what if the ExportedFunctio n does not return the pointer to MyClass then executing pMyClass->MyFunction is giving access violations.
if(pMyClassobj) {
pMyClassobj->MyFunction() ;
}
--
TB @ SWEDEN
hi,
ok.
for me when i execute pMyClassCreate( );
i get an invalid pointer to MyClass object ie. pobjMyClassobj is
invalid.
e.g if the ExportedFunctio n has the prototype int Function(int,in t)
then executing it will give me int instead of MyClass*
so is there a way to check whether the returned pointer is of a valid
object because else executing MyFunction will give access violation.
Thanks & Regards,
Srilal
TB wrote: sr******@gmail. com skrev: Hi,
here is the code snippent of my application
HINSTANCE hHandle = LoadLibrary ("UserDLL.dll") ;
//If the dll handle returns is null then trow exception. if (!hHandle) { throw Exception; }
//Else get call the exported function pointer for creating the object typedef MyClass* (*pMyClass) ();
pMyClass pMyClassCreate= (pMyClass) GetProcAddress( hHandle, "ExportedFuncti on");
if (!pMyClassCreat e) { if (hHandle) { FreeLibrary (hHandle); }
throw Exception }
MyClass * pMyClassobj; try { pMyClassobj = pMyClassCreate( ); } catch(...) { throw Exception; }
try { pMyClass->MyFunction() ; } catch(...) { }
now my question is what if the ExportedFunctio n does not return the pointer to MyClass then executing pMyClass->MyFunction is giving access violations.
if(pMyClassobj) { pMyClassobj->MyFunction() ; }
-- TB @ SWEDEN sr******@gmail. com skrev: hi,
ok. for me when i execute pMyClassCreate( ); i get an invalid pointer to MyClass object ie. pobjMyClassobj is invalid.
pobjMyClassobj? Can't find that name in the source code you posted. e.g if the ExportedFunctio n has the prototype int Function(int,in t) then executing it will give me int instead of MyClass*
Yes, of course it does. so is there a way to check whether the returned pointer is of a valid object because else executing MyFunction will give access violation.
Which pointer, it apparently returns an 'int', not a pointer
to an object of MyClass.
int != MyClass*
Thanks & Regards, Srilal
TB wrote:
sr******@gmail. com skrev: Hi,
here is the code snippent of my application
HINSTANCE hHandle = LoadLibrary ("UserDLL.dll") ;
//If the dll handle returns is null then trow exception. if (!hHandle) { throw Exception; }
//Else get call the exported function pointer for creating the object typedef MyClass* (*pMyClass) ();
pMyClass pMyClassCreate= (pMyClass) GetProcAddress( hHandle, "ExportedFuncti on");
if (!pMyClassCreat e) { if (hHandle) { FreeLibrary (hHandle); }
throw Exception }
MyClass * pMyClassobj; try { pMyClassobj = pMyClassCreate( ); } catch(...) { throw Exception; }
try { pMyClass->MyFunction() ; } catch(...) { }
now my question is what if the ExportedFunctio n does not return the pointer to MyClass then executing pMyClass->MyFunction is giving access violations. if(pMyClassobj) { pMyClassobj->MyFunction() ; }
-- TB @ SWEDEN
--
TB @ SWEDEN sr******@gmail. com wrote: hi,
ok. for me when i execute pMyClassCreate( ); i get an invalid pointer to MyClass object ie. pobjMyClassobj is invalid.
e.g if the ExportedFunctio n has the prototype int Function(int,in t) then executing it will give me int instead of MyClass*
so is there a way to check whether the returned pointer is of a valid object because else executing MyFunction will give access violation.
I would simply do that like you do it with every other library function.
Make a header that belongs to the library and declare the prototype in that
header. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pablo J Royo |
last post by:
Hello:
i have a function that reads a file as an argument and returns a reference
to an object that contains some information obtained from the file: FData
&ReadFile(string FilePath);
But , for example, when the file doesnt exists, i should not return any
reference to a bad constructed object, so i need something as a NULL
reference...
|
by: Kurt Van Campenhout |
last post by:
Hi,
I am trying to get/set Terminal server information in the active directory
on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3,
I need to do it myself.
I'm fairly new to VB.NET, so I need some help.
Here is a code snippit :
|
by: Lloyd Dupont |
last post by:
I have some managed C++ interacting with native DLL,
for good integration I'm setting up some function pointer in the native DLL,
passing some function pointer from the managed world.
=================
typedef void __cdecl NSLogHandler(Oid exception);
static void __cdecl ObjectiveNSLogHandler(Oid ns_str)
{
NSString^ str =...
|
by: Darin |
last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to
handle textbox.validating, and I have the form setup so the Cancel
button is the Cancel button.
WHen the user clicks on the cancel button, the textbox.validating is
being called. I don't want it to be since they are exiting the screen
the validation doesn't have to be...
|
by: Arpan |
last post by:
The .NET Framework 2.0 documentation states that
An Object variable always holds a pointer to the data, never the data
itself.
Now w.r.t. the following ASP.NET code snippet, can someone please
explain me what does the above statement mean?
<script runat="server">
Class Clock
| |
by: TS |
last post by:
I was under the assumption that if you pass an object as a param to a method
and inside that method this object is changed, the object will stay changed
when returned from the method because the object is a reference type?
my code is not proving that. I have a web project i created from a web
service that is my object:
public class...
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first
set of examples, after decoding the HTML FORM contents, merely
verifies the text within a field to make sure it is a valid
representation of an...
|
by: Stodge |
last post by:
Hi folks, new to Boost Python and struggling to build a prototype at
work. I thought I'd start with a conceptual question to help clarify
my understanding. I already have a basic prototype working nicely but
I'm having a few issues, which I may post about later.
A brief functional rundown of what I'm trying to prototype. Hopefully
my...
|
by: Giovanni Gherdovich |
last post by:
Hello,
in the following code I have a pointer (to function), say p,
of type
double (*)(double, double, void*)
and I try to fix the second argument of the function *p
to a given value (using boost::bind), but the compiler
complains, because of a type mismatch in an assignment
which I think should be legal:
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |