🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: att.lang.c++
Article #229

Question: Problem with variable argument list (...) and va_list

#229
From: Francois Harvey
Date: Sun, 25 Oct 1998 00:00
95 lines
4008 bytes
--------------98879AF9F5793A549D79D446
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi

This code was designed (when it will work) to open a library (NomLib)
execute the function (NomFunc) with the parameters that you add (it's a
variant argument list (...)) (this code was create for implement it in a
code interpretor)

But, i was not able to send the parameter to the MYPROC function,

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
typedef VOID (*MYPROC)(...);
void appellerAPI(char* NomLib, char* NomFunc,...)
{
    void *param;
    va_start(param, NomFunc);
    bool fRunTimeLinkSuccess = false;
    MYPROC PF;
    HWND LibHandle = LoadLibrary(NomLib) ;
    if (LibHandle != NULL)
    {
        PF = (MYPROC) GetProcAddress(LibHandle,NomFunc) ;
        if (fRunTimeLinkSuccess = (PF != NULL))
            (PF)(va_arg(param, void*));
        FreeLibrary(LibHandle);
    }
   return;
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
samples of call of the fonction

appellerAPI("user32","MessageBeep",0 );
 appellerAPI("kernel32","WinExec","explorer.exe",SW_SHOW);

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

if you have a idea, please reply :) i was tired

thanks

Francois Harvey (or nick "Utopiste")
why you predict the future when i can invent it?



--------------98879AF9F5793A549D79D446
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
Hi
<P>This code was designed (when it will work) to open a library (NomLib)
execute the function (NomFunc) with the parameters that you add (it's a
variant argument list (...)) (this code was create for implement it in
a code interpretor)
<P>But, i was not able to send the parameter to the MYPROC function,
<P>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<BR>typedef VOID (*MYPROC)(...);
<BR>void appellerAPI(char* NomLib, char* NomFunc,...)
<BR>{
<BR><FONT COLOR="#FF0000">&nbsp;&nbsp;&nbsp; void *param;</FONT>
<BR><FONT COLOR="#FF0000">&nbsp;&nbsp;&nbsp; va_start(param, NomFunc);</FONT>
<BR>&nbsp;&nbsp;&nbsp; bool fRunTimeLinkSuccess = false;
<BR>&nbsp;&nbsp;&nbsp; MYPROC PF;
<BR>&nbsp;&nbsp;&nbsp; HWND LibHandle = LoadLibrary(NomLib) ;
<BR>&nbsp;&nbsp;&nbsp; if (LibHandle != NULL)
<BR>&nbsp;&nbsp;&nbsp; {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PF = (MYPROC) GetProcAddress(LibHandle,NomFunc)
;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (fRunTimeLinkSuccess
= (PF != NULL))
<BR><FONT COLOR="#FF0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(PF)(va_arg(param, void*));</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FreeLibrary(LibHandle);
<BR>&nbsp;&nbsp;&nbsp; }
<BR>&nbsp;&nbsp; return;
<BR>}
<BR>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<BR>samples of call of the fonction
<P>appellerAPI("user32","MessageBeep",0 );
<BR>&nbsp;appellerAPI("kernel32","WinExec","explorer.exe",SW_SHOW);
<P>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<P>if you have a idea, please reply :) i was tired
<P>thanks
<P>Francois Harvey (or nick "Utopiste")
<BR><I>why you predict the future when i can invent it?</I>
<BR>&nbsp;
<BR>&nbsp;</HTML>

--------------98879AF9F5793A549D79D446--
Technical Details
Message-ID: <3633BE1E.F3C10371@sab.qc.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d4ba,9148a179ec713fcc,start
X-Google-Attributes: gid10d4ba,public
From: Francois Harvey <francois@sab.qc.ca>
Subject: Question: Problem with variable argument list (...) and va_list
Date: 1998/10/25
Message-ID: <3633BE1E.F3C10371@sab.qc.ca>
X-Deja-AN: 405015513
X-Accept-Language: fr-CA,en
X-Priority: 2 (High)
Content-Type: multipart/alternative; boundary="------------98879AF9F5793A549D79D446"
X-Complaints-To: abuse@videotron.net
X-Trace: weber.videotron.net 909360673 207.253.186.37 (Sun, 25 Oct 1998 19:11:13 EDT)
Organization: SAB
MIME-Version: 1.0
NNTP-Posting-Date: Sun, 25 Oct 1998 19:11:13 EDT
Newsgroups: att.lang.c++