slacky Posted March 17, 2013 Share Posted March 17, 2013 (edited) Well, as the topic states, I'm tryin' to write a plugin for scar but I constantly bump in to some sort of problem. Now the only thing I actually need is to be able to "transfer" (from/and to) arrays more spesific: T2DIntArray (Array of array of Integer)... Yet something that simple is giving me a hard time. So I know the plugin "works", as the plugin is able to send/recieve Integers, strings was partial working (seemed to have encoding truble) - tried AnsiString... Anyways, all I need is to be able to, is to send an array (T2DIntArray) from Scar, and get the result-array (T2IntArray) back. I havn't actually tried with T2DIntArray, but I tried a basic Array of Integer.. The result was: "Access voilation at address 058BFE09...". library TestPlugin;{$mode objfpc}{$H+}uses SysUtils, Classes;Type TIntArray = Array of Integer;//Test function: '' NOT working last time I checked ''function TIAFuncTest: TIntArray; Stdcall;var Arr: TIntArray;begin SetLength(Arr, 2); Arr[0] := 645; Arr[1] := 321; Result := Arr;end;//Test procedure: '' working last time I checked ''procedure IntProcTest(var T: Integer); Stdcall;begin T := T * 10;end;{=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=] Export our functions, name, information etc... All that is needed for scar to see this as a DLL.[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}//Count of functions that will be exported...function GetFunctionCount(): Integer; stdcall; export;begin Result := 2; end;//Information about our functions... And seems to be linking am as well. I've tried PAnsiCharfunction GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall;begin case x of 0: begin ProcAddr := @TIAFuncTest; StrPCopy(ProcDef, 'function TIAFuncTest: TIntArray;'); end; 1: begin ProcAddr := @IntProcTest; StrPCopy(ProcDef, 'procedure IntProcTest(var T: Integer);'); end; else x := -1; end; Result := x;end;exports GetFunctionCount;exports GetFunctionInfo;beginend.[/Code][i]Edit:[/i] I managed to get parts of the TIntArray, more exactly the first index (Arr[0] := 645;)... It was simply enough to change the function to a procedure... But the first index does not really cut it... Haha >> I've looked at the SPS-source for SCAR, and see some parts that I miss (not that I can see it matters..). I also noted that it was a .dpr file (delphi), so I have a feeling i'll be needing to use Delphi?? <-- Is it so? I also took a look at the source for In both thoes examples I see: "Uses FastShareMem" <--- Is that what i'm missing to get it working? FastShareMem.pas is ofcourse written Delphi so am I forced to use delphi?.. If only someone could give me some pointers, and/or some good tips. Or even better: A code example of how to do this, I would be SO HAPPY! [b]EDIT (Of topic):[/b] After 5 years of service my monitor "finally" decided to [u]die[/u].. :'( So now I had to put my 37 inch TV to use.. And my TV is not made for this, pixels get's blurry, and it's only HD.. FUCK! This is giving me a headache... And ofc, it's Sunday.. I can't even go to the store to look for a cheap new monitor.. "Wizzyplugin", my include does not seem wrong... Edited September 27, 2013 by slacky Arrrg! Quote Link to comment Share on other sites More sharing options...
Wanted Posted March 17, 2013 Share Posted March 17, 2013 EDIT (Of topic): After 5 years of service my monitor "finally" decided to die.. :'( So now I had to put my 37 inch TV to use.. And my TV is not made for this, pixels get's blurry, and it's only HD.. FUCK! This is giving me a headache... And ofc, it's Sunday.. I can't even go to the store to look for a cheap new monitor.. Sorry I don't know the solution to your problems (try Delphi maybe?) But you could try craigslist or a pawn shop for a monitor lol. I'm sure Freddy can help. Catch him on IRC/here. Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 17, 2013 Share Posted March 17, 2013 Can't do much now, but you're using the outdated library architecture, that should work, but it's not recommended. I'll have a look when I get home. Quote Link to comment Share on other sites More sharing options...
slacky Posted March 17, 2013 Author Share Posted March 17, 2013 I'm aware that i'm using the outdated library-architecture, but honestly there's a lack on documentation (and preferably some examples) on that part, so I found my self using the old api. But if you would be able to give me some pointers when you get back, it would be much appreciated! : ) As for my monitor problem, I actually managed to get a fine 19" screen that'll do for now! It feels a little small, but i'll get used to it! Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 17, 2013 Share Posted March 17, 2013 I have a Delphi example working but I don't know how much good that would do you if you're working with fpc. Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 17, 2013 Share Posted March 17, 2013 Oh, you're using fpc, well, can't help you there... It's often not all that compatible with Delphi. Quote Link to comment Share on other sites More sharing options...
Wanted Posted March 17, 2013 Share Posted March 17, 2013 I'm aware that i'm using the outdated library-architecture, but honestly there's a lack on documentation (and preferably some examples) on that part, so I found my self using the old api. But if you would be able to give me some pointers when you get back, it would be much appreciated! : ) As for my monitor problem, I actually managed to get a fine 19" screen that'll do for now! It feels a little small, but i'll get used to it! What were you on before lol? I'm on a 14" (900p max) laptop dualsetup with a 23" (1080p max) LCD monitor via compRGB Quote Link to comment Share on other sites More sharing options...
slacky Posted March 18, 2013 Author Share Posted March 18, 2013 (edited) First I downloaded borlands delphi 8, which I later noted was 100 years old. So I went to my friend google and asked some questions. He told me about embarcadero, but they did not help me, instead they offered to take my money. And I said "hell NO!" and walked away. So I asked google again, he told me that I could look at Wikipedia. So I did that, Wiki told me that embarcadero is the current holder of delphi, so i tought to my self that I would have to pay money to get a delphi-compiler... Umm, so.. Where can I get a delphi-compiler? Should I use borlands old delphi 8? This requres me to get some REALLY old SDK's... Wanted, not that much bigger Edited March 18, 2013 by slacky Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 18, 2013 Share Posted March 18, 2013 They used to offer a free scaled down version of Delphi (similiar to how Visual Studio offers a free scaled down version). The current owners decided this was a bad thing (Delphi has always been owned by people who know shit about marketing/getting people to use the product) They now offer a "light" version you have to buy for some silly amount (couple hundred dollars). So the answer is your old version of Delphi and take your chances or Fpc and take your chances. Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 18, 2013 Share Posted March 18, 2013 Delphi 8 is the only version of Delphi you should absolutely avoid. It will not work at all. It's also recommended you have a version 2009 or up. Quote Link to comment Share on other sites More sharing options...
slacky Posted March 18, 2013 Author Share Posted March 18, 2013 Well, the tought of downloading something as closed as Delphi does not get me in a good mood. So, that wont happen. I'll give FPC some tries.. Freddy, is SCAR Titan in line of sight? You posted a pre alpha(was it?) a few years back, but I never heard of it after that. - - - Updated - - - Bixby Sayz, would you be so kind to upload the file!? I might just be able to grab something from it. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 18, 2013 Share Posted March 18, 2013 Not sure I have it here at home. If not I'll grab it from work tomorrow. Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 19, 2013 Share Posted March 19, 2013 (edited) Well, the tought of downloading something as closed as Delphi does not get me in a good mood. So, that wont happen. I'll give FPC some tries.. Freddy, is SCAR Titan in line of sight? You posted a pre alpha(was it?) a few years back, but I never heard of it after that. - - - Updated - - - Bixby Sayz, would you be so kind to upload the file!? I might just be able to grab something from it. Titan, not so ,much, but I am working on something big As for your code: Make sure GetFunctionInfo has ProcDef as PAnsiChar, I think this is the default for fpc, but it doesn't hurt to make sure, SCAR will not work with a PWideChar, which is the default for PChar in Delphi 2009 and up. You don't need the begin at the bottom. I'd recommend "$mode delphi" over "$mode objfpc". EDIT: Also, the reason why it might not be working is that you're missing the FastShareMem unit. Edited March 19, 2013 by Freddy Quote Link to comment Share on other sites More sharing options...
slacky Posted March 19, 2013 Author Share Posted March 19, 2013 Yes, true indeed. I figured out about "$Mode DELPHI", I also know that chars are defult Ansi. As a side not I tested it anyways... What I did not yet know was that I needed FastShareMem... This is indeed a bigger chalange, i'll see what I can do. Thanks for your feedback! Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 19, 2013 Share Posted March 19, 2013 I also found I had to use exact version of FastShareMem Freddy supplies with his plugin samples. http://svn.scar-divi.com/samples/ ...which appears to not exist any more? Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 19, 2013 Share Posted March 19, 2013 I also found I had to use exact version of FastShareMem Freddy supplies with his plugin samples. http://svn.scar-divi.com/samples/ ...which appears to not exist any more? SVN has not been restored yet. Quote Link to comment Share on other sites More sharing options...
slacky Posted March 19, 2013 Author Share Posted March 19, 2013 If it's the version I downloaded a day or two ago, ye... Some problems there. It wont work with FPC-delphimode, multiple errors: EG: - Identifier not found TMemoryManagerEx.. - Identifier not found GetMemoryManagerState Etc... The list is long. Quote Link to comment Share on other sites More sharing options...
FHannes Posted March 19, 2013 Share Posted March 19, 2013 If it's the version I downloaded a day or two ago, ye... Some problems there. It wont work with FPC-delphimode, multiple errors: EG: - Identifier not found TMemoryManagerEx.. - Identifier not found GetMemoryManagerState Etc... The list is long. Well, those are part of Delphi, not FPC, it's not surprising... Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted March 19, 2013 Share Posted March 19, 2013 Bixby Sayz, would you be so kind to upload the file!? I might just be able to grab something from it. Nvm. Just tried it using passing simple integers to a function and it generates a run time error same as you were getting. So no further along using Delphi plugin than you got. Quote Link to comment Share on other sites More sharing options...