Results 1 to 3 of 3

Thread: Getting Functions/Types From A Plugin

  1. #1
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Getting Functions/Types From A Plugin

    I am currently working on a script that will get all of the functions
    and types exported from a plugin.

    The following script is what I have so far...
    Code:
    program DLLFunctionViewer;
    
    type
      Pointer = procedure;
    
      {$Define GetFunctions}
      {$Define GetTypes}
    
      {$IfDef GetFunctions}
        function GetFunctionCount: Integer; external 'GetFunctionCount@WizzyPlugin.dll stdcall';
        function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; external 'GetFunctionInfo@WizzyPlugin.dll stdcall';
      {$EndIf}
      {$IfDef GetTypes}
        function GetTypeCount: Integer; external 'GetTypeCount@WizzyPlugin.dll stdcall';
        function GetTypeInfo(x: Integer; var sType, sTypeDef: string): Integer; external 'GetTypeInfo@WizzyPlugin.dll stdcall';
      {$EndIf}
    
    var
      Count, Counter: Integer;
      ProcAddr: Pointer;
      ProcDef: PChar;
      sType, sTypeDef: String;
    
    begin
      {$IfDef GetFunctions}
        Count := GetFunctionCount;
        WriteLn('Functions (Count: ' + IntToStr(Count) + ')');
        for Counter := 0 to Count - 1 do
        begin
          GetFunctionInfo(Counter, ProcAddr, ProcDef); // Problem: Variables never contain any values...
          WriteLn('-> ' + ProcDef);
        end;
      {$EndIf}
      {$IfDef GetTypes}
        Count := GetTypeCount;
        WriteLn('Types (Count: ' + IntToStr(Count) + ')');
        for Counter := 0 to Count - 1 do
        begin
          GetTypeInfo(Counter, sType, sTypeDef);
          WriteLn('-> ' + sType + ': ' + sTypeDef);
        end;
      {$EndIf}
    end.
    Currently it is able to get all of the types, but it is unable to produce a
    list of the functions.

    GetFunctionInfo is not assigning any values to the variables passed within
    its parameters.

    I have been playing around with the script for the last few hours, and
    figured that someone on SRL might have a solution.

    API Calls must be allowed for the script to work

    Thanks,
    The_Scripts

  2. #2
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    SCAR Code:
    program DLLFunctionViewer;

      {$Define GetFunctions}
      {$Define GetTypes}

      {$IfDef GetFunctions}
        function GetFunctionCount: Integer; external 'GetFunctionCount@WizzyPlugin.dll stdcall';
        function GetFunctionInfo(x: Integer; var ProcAddr: LongInt; var ProcDef: string): Integer; external 'GetFunctionInfo@WizzyPlugin.dll stdcall';
      {$EndIf}
      {$IfDef GetTypes}
        function GetTypeCount: Integer; external 'GetTypeCount@WizzyPlugin.dll stdcall';
        function GetTypeInfo(x: Integer; var sType, sTypeDef: string): Integer; external 'GetTypeInfo@WizzyPlugin.dll stdcall';
      {$EndIf}

    var
      Count, Counter, i: Integer;
      ProcAddr: LongInt;
      ProcDef, Temp: string;
      sType, sTypeDef: String;

    begin
      {$IfDef GetFunctions}
        Count := GetFunctionCount;
        SetLength(Temp, 255);
        WriteLn('Functions (Count: ' + IntToStr(Count) + ')');
        for Counter := 0 to Count - 1 do
        begin
          for i := 1 to 255 do
            Temp[i] := #0;
          GetFunctionInfo(Counter, ProcAddr, Temp); // Problem: Variables never contain any values...
          ProcDef := '';
          for i := 1 to 255 do
            if (Temp[i] = #0) then
            begin
              ProcDef := Copy(Temp, 1, i - 1);
              Break;
            end;
          WriteLn('-> ' + ProcDef);
        end;
      {$EndIf}
      {$IfDef GetTypes}
        Count := GetTypeCount;
        WriteLn('Types (Count: ' + IntToStr(Count) + ')');
        for Counter := 0 to Count - 1 do
        begin
          GetTypeInfo(Counter, sType, sTypeDef);
          WriteLn('-> ' + sType + ': ' + sTypeDef);
        end;
      {$EndIf}
    end.

    I replaced Pointer with LongInt and PChar with a string (with preset length).

  3. #3
    Join Date
    Aug 2008
    Location
    Canada
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @nielsie95: I should of figured you would be the one with the solution
    Thanks again!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •