DLLFunction.call Method

Syntax

public anytype call( )

Run On

Called

Parameters

  • Type: [T:]

Remarks

If an attacker can control input to the call method, a security risk exists. Therefore, this method runs under Code Access Security. Calls to this method on the server require permission. Make sure that the user has development privileges by setting the security key to SysDevelopment on the control that calls this method.

Examples

The following example uses the DLL and DLLFunction classes to interoperate with the GetVersion API in Kernel32.dll. It asserts the use of the InteropPermission class to provide code access protection, and then it loads the DLL. If this is successful, the return type is set from the call to the DLLFunction class.

{ 
    Dll               dll; 
    DllFunction       dllFunc; 
    anytype           retVal; 
    InteropPermission perm; 
  
    perm = new InteropPermission(InteropKind::DllInterop); 
  
    // Grants permission to execute the DLL.new method. 
    // DLL.new is protected by code access security. 
    perm.assert(); 
  
    dll = new Dll("Kernel32.dll"); 
    // Closes the code access permission scope. 
    CodeAccessPermission::revertAssert(); 
  
    if (dll != null) 
    { 
        // Grants permission to execute the DLLFunction.new method. 
        // DLLFunction.new is protected by code access security. 
        perm = new InteropPermission(InteropKind::DllInterop); 
        perm.assert(); 
  
        dllFunc = new DllFunction(dll, "GetVersion"); 
        if (dllFunc != null) 
         { 
            dllFunc.returns(ExtTypes::DWord); 
             retVal = dllFunc.call(); 
         } 
       // Closes the code access permission scope. 
       CodeAccessPermission::revertAssert(); 
    } 
}

See Also

Reference

DLLFunction Class