Pages: « 1 2 3 4
  Print  
Author Topic: [Solved] Adding a new function  (Read 9559 times)
Offline (Male) Goombert
Reply #45 Posted on: October 03, 2014, 11:30:39 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Oh boy sorlok, I haven't really worked with dll's that much so I don't know how to reproduce and test what he's testing. In fact I don't think I've ever written a dll before, except changes to the compiler which make compileEGMf, but other than that I've never made my own dll's before. Additionally Josh would be the best person to talk about variant, I don't think I would be able to fully understand the implications.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) sorlok_reaves
Reply #46 Posted on: October 03, 2014, 11:39:26 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
My knowledge of DLLs is also limited. I guess we'll need lonewolf to post some sample project & branch.

I'll talk to Josh about this once there's a clear need for pointers in variants. Right now it seems like we'll definitely need to look at this for external library initialization, but maybe there's a better way to chain the calls and avoid variants entirely? After all, normal ENIGMA scripts shouldn't really be playing around with pointers.
Logged
Offline (Unknown gender) lonewolff
Reply #47 Posted on: October 04, 2014, 05:27:03 PM
"Guest"


Email
Still in Sydney at the moment so don't have access to any code right now.

Having said that, the exact same DLL is working 100% in GM:S.

Even if I skip the init to force a null pointer for the device, in the quad crate call, GM:S returns 1 for failed call (as expected) but ENIGMA crashes instantly.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #48 Posted on: October 04, 2014, 05:54:34 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Still in Sydney at the moment so don't have access to any code right now.

Having said that, the exact same DLL is working 100% in GM:S.

Even if I skip the init to force a null pointer for the device, in the quad crate call, GM:S returns 1 for failed call (as expected) but ENIGMA crashes instantly.

Yes, but that's probably because your pointer is initially in a garbage state anyway (because you never set it to anything).

Anyway, it's much better to wait until we get an actual test case; I don't think we'll be able to solve this until Robert and I actually have something concrete to work with.
Logged
Offline (Unknown gender) lonewolff
Reply #49 Posted on: October 04, 2014, 06:01:05 PM
"Guest"


Email
Yep, for sure.

Still confused though. Even if it were a garbage pointer, the error checking would return a D3DERR* message, not simply crash the app.

I am extremely pedantic when error checking, as I never want to release buggy code to the public.

But, for sure, ill send over the DLL and source when I get back to civilisation. :)
Logged
Offline (Unknown gender) sorlok_reaves
Reply #50 Posted on: October 04, 2014, 06:12:15 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Just think of it this way:

Code: [Select]
D3DWhatever* something = 0xFF00FF;
Give this garbage pointer, how can you *possibly* know it's invalid? In C++, it just points to a memory location, and the runtime just assumes that you point to one that represents an object, or NULL.

Now, D3D *could* maintain a list of all known D3DWhatever pointers somewhere global, and check this every single time it's given a pointer. But that's costly, and it only helps very obscure cases like this one.

Valgrind might be able to detect this, if the memory being pointed to is uninitialized or something like that. But even then, it's kind of a gray area.

This is one very good reason why you should always initialized your pointers to NULL; it allows the runtime to detect when a pointer is definitely invalid.
Logged
Offline (Unknown gender) lonewolff
Reply #51 Posted on: October 04, 2014, 06:18:10 PM
"Guest"


Email
Just think of it this way:

Code: [Select]
D3DWhatever* something = 0xFF00FF;
Give this garbage pointer, how can you *possibly* know it's invalid? In C++, it just points to a memory location, and the runtime just assumes that you point to one that represents an object, or NULL.

Now, D3D *could* maintain a list of all known D3DWhatever pointers somewhere global, and check this every single time it's given a pointer. But that's costly, and it only helps very obscure cases like this one.

Valgrind might be able to detect this, if the memory being pointed to is uninitialized or something like that. But even then, it's kind of a gray area.

This is one very good reason why you should always initialized your pointers to NULL; it allows the runtime to detect when a pointer is definitely invalid.

First things first, I always initialise pointers to 0 (as I have done in my DLL)

Secondly even if your pointer is some random value, this is what the D3D calls return code is for. It will return an error upon failure regardless of what caused the error (invalid devices etc..).

If the device handle is some random garbage, the call will simply return an error (not crash) unless the error is disregarded and program flow continues.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #52 Posted on: October 04, 2014, 06:26:28 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
I'm not so familiar with DirectX, so you're probably right. Anyway, if it's crashing on NULL then something is definitely wrong.
Logged
Offline (Male) Goombert
Reply #53 Posted on: October 04, 2014, 07:12:40 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Quote from: lonewolf
the error checking would return a D3DERR* message, not simply crash the app.
No it would not, because the FAILED() macro does not check for garbage pointers, it doesn't check for pointers at all in fact.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms693474%28v=vs.85%29.aspx

Code: (C++) [Select]
#define FAILED(hr) (((HRESULT)(hr)) < 0)
The following would crash.
Code: (C++) [Select]
if(FAILED(d3dDevice->CreateVertexBuffer((nNumVerts)*sizeof(D3DVERTEX),D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,D3DFVF_XYZRHW|D3DFVF_DIFFUSE,D3DPOOL_DEFAULT,&pVertexObjectQuad,NULL)));
Even if you took it out of the macro, before it even enters the function, that's GCC/MinGW/C++ not DirectX failing.
Code: (C++) [Select]
d3dDevice->CreateVertexBuffer((nNumVerts)*sizeof(D3DVERTEX),D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,D3DFVF_XYZRHW|D3DFVF_DIFFUSE,D3DPOOL_DEFAULT,&pVertexObjectQuad,NULL);
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #54 Posted on: October 04, 2014, 08:37:15 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email

I am extremely pedantic when error checking, as I never want to release buggy code to the public.

Yeah you just threw out the window any chance you have at working for ANY software developing company, NOBODY would hire you ! LOL.  ;D   God forbid if software companies had people like that, consumers would have better software but turn around times would be exponentially higher and shite would not be released fast enough (or ever) :D
Though you shouldn't worry about that with ENIGMA, nobody is going to crucify you for finding bugs in your free extension, considering the said product is not exactly bug free to begin with LOL.

Cheers

Quote
But, for sure, ill send over the DLL and source when I get back to civilisation. :)

We're looking forward to your plugin, it would be great, assuming you don't get bitten by scorpions or swallowed by crocodiles, all good ! Later :D
Logged
Offline (Unknown gender) lonewolff
Reply #55 Posted on: October 05, 2014, 04:17:10 AM
"Guest"


Email
Actually had a scorpion in my back yard the other day when I was moving some bricks.

Yet to see a crocodile in my back yard yet.

Although, I do see kangaroos here in a daily basis :)
Logged
Offline (Unknown gender) Darkstar2
Reply #56 Posted on: October 05, 2014, 01:07:57 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
Actually had a scorpion in my back yard the other day when I was moving some bricks.

Was it that Scorpion named Samuel ? LOL!

Quote
Yet to see a crocodile in my back yard yet.

I rather see crocs in my back yard than snakes :D

Anyhow looks like you have quite a challenge here with your plugin ..... I'm wondering if the crash problem doesn't come from something else unrelated, maybe something major that will be discovered from this who knows.........hopefully you can find a way to get this done, that will open the doors to other plugins too...



« Last Edit: October 05, 2014, 01:10:14 PM by Darkstar2 » Logged
Pages: « 1 2 3 4
  Print