I was reading through the wiki while trying to figure out how to communicate with my ISXDK extension from my hosted .NET application and I noticed this example on exposing API: http://www.lavishsoft.com/wiki/index.ph ... ap#Example
As you can see in the first function it reads
Code: Select all
static void * __stdcall GetAPI(const char *Name, unsigned int Version)
{
static map<string,void*> APIMap;
static bool bInitialized=false;
/* initialize map */
if (!bInitialized)
{
APIMap["Echo"]=Echo;
bInitialized=true;
}
/* map has been initialized, retrieve function */
map<string,void*>::iterator i=APIMap.find(Name);
if (i==APIMap.end())
return 0;
return i->second;
}
I also noticed a minor typo in the comment at the top of http://www.lavishsoft.com/wiki/index.ph ... API_layout
Second question is how to actually communicate: My situation is as follows
1. I have the DX application with my ISXDK extension loaded
2. I also want to host a seperate .NET application within the context of the DX app
3. I need to transfer data between the ISXDK and .NET extensions and preferably be able to call functions between them as well
My understanding is that I can either use TLOs or I can expose API; I couldn't find any other ways of communicating except maybe by calling LavishScript commands registered by my ISXDK extension and getting the ToString result (which might not even work, I haven't looked into that heavily because it seems very messy)
Additionally, while researching how to create a custom TLO and transfer data from ISXDK to my .NET app via the TLO, I struggled to find a way to actually get the data I wanted
The data I'm trying to access is a byte[40] located in my ISXDK extension
Running unsafe code is not a problem for me, I don't mind directly accessing memory but I just couldn't figure out how to do it. I tried having the TLO in ISXDK return a pBytePtrType which in Initialize is defined as
Code: Select all
pBytePtrType=pISInterface->FindLSType("byteptr");

The code I use (after verifying the TLO) is as follows:
Code: Select all
LavishVMAPI.Frame.Lock();
byte[] key = new byte[40];
StringBuilder sb = new StringBuilder();
LavishScriptObject ob = LavishScript.Objects.GetObject("MyTLO");
IntPtr keyAddr = ob.GetValue<IntPtr>();
for (int i = 0; i < 39; ++i)
{
key[i] = Marshal.ReadByte(keyAddr + i);
sb.Append(String.Format("{0:x} ", key[i]));
}
InnerSpace.Echo("Key: " + sb.ToString());
LavishVMAPI.Frame.Unlock();
Code: Select all
ob.GetValue<IntPtr>();
Code: Select all
ob.GetValue<String>();
An alternative way I found to do it was to simply have my TLO return a byte based on the value I passed to it and then call that 39 times, but that... seems wrong. It also takes a few seconds to execute on my machine and my machine is hardly slow, which makes me worry about performance on lower spec machines. If returning a pointer to the array and then reading the pointer is not what I should be doing, can you tell me what is? The only "array" I found was limited to 4 bytes and I couldn't seem to be able to extend that.
But is using a TLO even the right thing to do? I'm currently looking into using API to get what I want and I _think_ I can just do something like
Code: Select all
// ISXDK
static byte* __stdcall GetKey()
{
return &keyArray; // byte[40]
}
So seeing as this turned into yet another essay, I suppose my questions would be
1. Is the mistake I pointed out at the top actually a mistake, or am I misunderstanding something fundamental?
2. How should I communicate between my ISXDK extension and my .NET application? the ISXDK ext can run standalone but the .NET application requires the ISXDK ext. I can call custom commands I've registered just fine, but I don't know how to transfer data (e.g. C# requesting the 40 byte array from the ISXDK extension) or how to allow the ISXDK extension to actively message the .NET application (which would be preferred to just, say, looping forever and checking for new messages every 15ms from within the .NET app)
3. Are TLOs the only thing I can access from .NET? From what I understand both from my own research and from what you said to me in my last thread, for most things I should probably be using a data type; I couldn't seem to find how to access those from C#. I'm looking into exposing API as a method of getting data from the ISXDK extension but again, I don't know if that's the right thing to be doing
Finally as I said, if this isn't where I should be asking for help please tell me where I should be; I'm trying my best to keep my questions non-game specific and non-memory (read/write) specific as I understand your primary focus with Inner Space these days seems to be as a multiboxing platform and I'm more interested in the concept of how to do things with IS + extensions than how to do things with specific games. I'm also trying my best to find the answers myself before asking and to test things to see if they work before asking about them so again, feel free to tell me if I should already know the answers to what I'm asking just from source code documentation and/or the wiki
Thank you (:
[/code]