🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Francois Harvey Sun, 25 Oct 1998 00:00
Question: Problem with variable argument list (...) and va_list
#229
Author: 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--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads