Well, I have been doing more test in C, it just take to add a .c file insteand a .cpp file in the DLL project. And for normal API functions it works well in ruby, and I have done some progress with editing Ruby Objects.
First I have remembered that same numbers in ruby have the same pointer, so they are not easy editable. Also after seeing ruby sources, exactly the ruby.h file I have discovered that ruby objects are structs with different values in them. So the __id__ value of a ruby object is a pointer to struct, and not to the objects data.
I have made a test project for editing a simple string object, using a struct defined in ruby.h, but all doesn't work well. Here is the String struct:
typedef unsigned long VALUE;
typedef struct {
unsigned long flags;
VALUE klass;
} RBasic;
typedef struct {
RBasic basic;
long len;
char *ptr;
union {
long capa;
VALUE shared;
} aux;
} RString;
Obtaining the lenght of the string, works perfeclty, but obtaining the data, or modifying it doesn't work well.
I can't obtain the data well, and if I try to modify it, I get weird results, like strange ASCII characters.
Here I have uploaded the dll project in zip and rar:
DLL Test.rar
DLL Test.zip
The project includes also a .rb file for testing the dll in ruby.
I know. It's not very helpful.
That's why I am suggesting that you write it out to a file.
You could write something to a file for each line. Then you can locate the error or the position of the first error.
You could also try attaching the Visual Studio's debugger although that might be difficult since the DLL file is called from rmxp game.
*hugs*
I thought on writing debug things into a file, but I still don't know how to do that in c. Maybe I should google for it.
I'm wondering, is it possible that the Ruby language doesn't handle all values in the same way?
What if, by chance, primitive values, such as numbers, are treated as just numbers, and they're sent in by reference or by value?
Have you tried your method without bit-shifting the incoming value?
I have discovered as I said before, that yes ruby handle the ruby objects by structs, defined in ruby.h in the ruby sources. I will try without bit-shifting, maybe it will work better.
PD: who the hell is vgvgf?