Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / The Matrix1Utils plugins collection

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2011 22:28
Any news on whether regular expressions will be added? I think you last said you'd found a suitable library to use?

[b]
Argon Knight
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Gastonia, NC, USA
Posted: 7th Aug 2011 01:39
Ouch, I didn't even see his post above mine. Sorry
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Aug 2011 17:57
What would be quite useful is a version of "unlink array" which returns the old array pointer That way you save two lines of code when passing in arrays to functions which may resize them:



Can be changed to:



[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Aug 2011 21:19
Can't be done I'm afraid. The UNLINK ARRAY command is actually a function call under the hood; it already returns a value which is used to effect the actual unlinking of the array pointer to the array data.

The regex stuff is on my todo list, so it's not forgotten, but right now I've not got the time to do anything big. I might throw something simple together for basic matching, and if so, I'll replace it at a later date with something more comprehensive.

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 7th Aug 2011 21:55 Edited at: 7th Aug 2011 21:56
While wrapping some of your plugins for PureGDK, I noticed a few oddities I thought I'd mention. Of course, none of these really matter since they are 32-bit DLLs anyways. But I just thought I'd mention it:


- ObjectID is passed as DWORD not Integer?

Matrix1Util_18.dll
* MakeObjectPlane_7
* MakeObjectPlane_8


- Pointers passed as DWORD instead of Integer?

Matrix1Util_18.dll:
* MakeObjectFromAddress

Matrix1Util_26.dll
* SetWindowCallback
* SetPostCameraCallback
* SetPostRenderCallback
* SetPostSpriteCallback
* SetPostSyncCallback
* SetPreRenderCallback
* SetPreSpriteCallback
* SetPreSyncCallback
* SetPreCameraCallback

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Aug 2011 22:19
Yeah, it was originally a policy decision I made, that I've since stepped away from:
- Function pointers are addresses, and so cannot be negative.
- ID's are always positive - making them unsigned removes a check for negatives.

The reason I stepped away from that was:
1. It doesn't really matter to DBPro anyway, because as you say, there's no difference between an int and a DWORD in machine terms, except in how it is used.
2. It causes unnecessary conversions in DBPro when passing an integer into a DWORD argument.

So what I gained on the removal of a check for negative, was lost (and more) when the more natural to use integer was passed instead.

As I make changes to the plug-ins, I switch back to integers if I remember.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Aug 2011 20:08 Edited at: 8th Aug 2011 20:11
Quote: "Can't be done I'm afraid. The UNLINK ARRAY command is actually a function call under the hood; it already returns a value which is used to effect the actual unlinking of the array pointer to the array data."


You could make use of the fact that the address of the array pointer is always stored at a fixed offset from the return address of the command. Maybe that's a little too hacky though. It should be fairly safe though since arrays can never be temporary. (ie. if you did the same thing to get the address of an integer variable there's no guarantee that the user wouldn't pass in an expression such as 1+2 which would break it)

[b]
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 9th Aug 2011 12:57 Edited at: 9th Aug 2011 12:58
Ian, I'm getting a corrupted stack and a crash if I load your plugins in this way:







Plugin 18 is crashing because is needs plugin 1. And plugin 26 is crashing because it needs plugin 20. But instead of giving a popup telling you this, it just crashes.

I'm assuming this is DBP.. but it's also possible there might be a bug in how you're handling the dependencies check?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Aug 2011 16:07
The only way that I can introduce any problem is if I remove the plug-in dependencies from the plugin-users directory. Otherwise, everything appears to work OK.

Can you tell me what you are doing to trigger these issues, and maybe upload an executable I can check out?

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 9th Aug 2011 20:53
I'm using DBP 7.7, if maybe that's causing it?

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Aug 2011 01:36
Would it be possible to have commands to insert/delete multiple elements at a time to/from an array/array pointer. At the moment I'm having to delete each element individually, causing all the elements below to be shifted up by one element at a time...

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Aug 2011 20:56
Sure, I'll look at doing it, but you can do it indirectly right now using an insert of multiple items at the bottom of the array, followed by a rotation of all elements from the insert point to the bottom of the array:


@Mistrel,
Nope, I've tried to reproduce the problem under 7.5 and 7.7.

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 11th Aug 2011 05:20 Edited at: 11th Aug 2011 05:21
Project attached. I'm running Windows 7 x64 SP1.

U77 with this code:



Crashes with:

Quote: "
Problem signature:
Problem Event Name: APPCRASH
Application Name: Application.exe
Application Version: 1.0.0.0
Application Timestamp: 4d460aea
Fault Module Name: StackHash_0a9e
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 00000000
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789"


Attachments

Login to view attachments
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 14th Aug 2011 01:58
Ian, would you be willing to remove your calls to IsValidFunctionPtr in your Util 26 plugin? I have some PureGDK users who would like to pass function pointers from their C++ programs and this (I'm guessing) is causing it to fail.

http://forum.thegamecreators.com/?m=forum_view&t=188045&b=38&p=0

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 14th Aug 2011 02:27
Just get them to call "register function ptr" first...

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Aug 2011 02:48
It's a safety feature, that you can override if needed: REGISTER FUNCTION PTR

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 14th Aug 2011 02:54 Edited at: 14th Aug 2011 02:54
Thank you. I didn't know about that.

Isn't it a little redundant to create a white list when you already have "function ptr is valid" to verify the pointer you are passing? It should be the programmer's responsibility to ensure that the pointer is valid, not the function itself?

That's my philosophy, at least.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Aug 2011 12:26
I guess I can see where you're coming from, and if it was C or C++ then I'd agree - obviously though, I don't agree for DBPro, which is why I implemented the check and which for the most part is completely invisible to the user.

DBPro's functions are automatically added to the whitelist, and so are any function pointers that you get from a DLL (GET PTR TO DLL FUNCTION adds, UNLOAD DLL removes), but any function pointers you get from elsewhere have to be registered.

It's not really that much of a hardship for the user, but if you wanted to you could add the registration in your wrapped command 'M1U_PostCameraCallBack' and any other commands that accept function pointers.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Aug 2011 12:06 Edited at: 20th Aug 2011 12:09
Hi Ian, I'm having a problem with image render targets. Attached is the code I'm testing.

What it is doing is making a numbered ball. Image 1 (sphere) + Image 12 (text) = Image 13 (numbered sphere). What should happen when you press a key is:

1. Image 13 is deleted
2. Image 13 is recreated as a render target (MAKE IMAGE)
3. Image 1 (Sphere) is pasted to Image 13. (Draw to Image 13, Paste Image)
4. Image 12 is deleted
5. Image 12 is recreated as a render target
6. Image 12 gets an "X" placed in a random position (Draw to image 12, TEXT)
7. Image 12 is overlaid on image 13 (Draw to Image 1, Paste Image)

What actually happens is obvious when you run it. Image 12 never gets deleted, it just gets added to. I believe the same problem is there for image 13, it's just not as obvious because the whole image gets overlaid.

I posted this originally in Sven B's Image Kit thread, the problem is identical there with his equivalent commands. The code for his in the attached code, commented out.

Attachments

Login to view attachments
gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 20th Aug 2011 18:07
hi I was poking around the forum when I found


this was posted by Daryn Alsup

Posted: 15th Jun 2009 19:16 Edited: 15th Jun 2009 19:31

Lord Einstien and Daryn Alsup's "Evolution": Weather Simulation
http://forum.thegamecreators.com/?m=forum_view&t=149615&b=1

the problem is I have the plugins installed and I got the update
but the command "Object Matrix4 1, 1" dose not seem to be in
plugin # 32 ware the help file says it should be

has the command be removed or changed ?

If a thought is Just a thought ~ so whats the main thought ?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Aug 2011 21:01
I renamed that command to SET MATRIX4 TO OBJECT as it describes the command a lot better.

@BatVink,
That's strange - I always thought that a new rendering surface would be cleared automatically.

No matter - for now, just put a 'CLS 0' after the creation of your surface and it'll be cleared.



Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Aug 2011 16:49 Edited at: 21st Aug 2011 16:49
The reason it happened is that when you recreated the bitmap and it looked for some space in graphics memory to put it, the best place was the place just freed when that same bitmap was deleted. It's just chance that it happened to have the same data in still, it could just have easily been random or blank if the drivers worked a bit differently.

[b]
gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 21st Aug 2011 16:56
I tried
SET MATRIX4 TO 1
then I tried
SET MATRIX4 TO 1,1

but the help brings up the following

SET MATRIX4 Matrix4Result, _11, _12, _13, _14, _21, _22, _23, _24, _31, _32, _33, _34, _41, _42, _43, _44

which leaves me stuck on getting the example working

is there anther command that needs to be
active to make it work or have the rules been
changed that much to have things work ?

If a thought is Just a thought ~ so whats the main thought ?
gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 21st Aug 2011 17:03
ok never mind I got it going

SET MATRIX4 TO object 1,1

a word or two and rile send the road off the tracks ;oP

If a thought is Just a thought ~ so whats the main thought ?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Aug 2011 13:02
Quote: "That's strange - I always thought that a new rendering surface would be cleared automatically.

No matter - for now, just put a 'CLS 0' after the creation of your surface and it'll be cleared."


Thanks Ian, that has resolved my problem. I had tried CLS and forgot you have to add a value for the 2D version of the command.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Aug 2011 17:05
The basic CLS wouldn't have done what you appeared to want - it clears to black with full alpha, while the CLS with a parameter clears to the specific colour you want, in this case black with no alpha.

I've carried out a fix in my MAKE IMAGE command to do the same (black, no alpha) - it'll appear in the next release.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 8th Sep 2011 02:51
IanM,

I have a file, a CSV of sorts, with fields separated by a double pipe |). I tried your split string command but it seems like it only splits with single characters, and so split string s$, "||" splits the string with a single pipe, not double. Is there any way to get your commands to split a string using a multi-character delimiter?

Thanks!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Sep 2011 10:05
As a workaround you could use REPLACE ALL$ as a first step, then use the SPLIT STRING or CSV commands.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th Sep 2011 10:21
I would use something like chr$(1) (Control-A) as no-one ever embeds that into a CSV file.

GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 10th Sep 2011 07:12 Edited at: 10th Sep 2011 07:24
IanM,

Thanks for the great DLL!


Also, nevermind the text that used to occupy this space. /whistle
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Sep 2011 11:50
Really? Because that bug sorting bug is actually fixed in this release.

It's mostly a bug-fix release:

Release 20110910
Matrix1Util_13 - 1.1.0.8
- Rewrite of GRAB FOCUS command.
- General tidying of code.
- Added GET DESKTOP WINDOW function.
- Fixed GET WINDOW CLIENT HEIGHT resource string to point to the correct function.
- Amended GET WINDOW CLIENT WIDTH/HEIGHT to return viewable desktop size when passed the desktop handle.

Matrix1Util_15 - 1.1.0.2
- Fixed help for SUSPEND PROGRAM.

Matrix1Util_17 - 1.1.0.2
- Fixed resource string for BIT INTERSECT MASK function.

Matrix1Util_22 - 1.1.0.14
- Added commands for timestamps of files.
- Added new version of WRITE DATAFILE DATASTRING with a length parameter.

Matrix1Util_29 - 1.1.0.7
- Minor efficiency tweek to LINK ARRAY.
- Fixed sorting of strings when null string pointers are involved.
- Corrected counting of array dimensions (0 dimensions is really 1 dimension).

Matrix1Util_33 - 1.1.0.2
- Ensure that newly constructed images are cleared to black with 0 alpha.

Attachments

Login to view attachments
GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 10th Sep 2011 21:39
Quote: "Really? Because that bug sorting bug is actually fixed in this release."


I read the 3rd post on page 32 and realized I had to set all my strings to "" first. Problem solved. :p
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Sep 2011 22:44
Jeff Miller
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 11th Sep 2011 16:40
I can find the new timestamp commands in the config file, but I can't locate them in the help files.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Sep 2011 18:12
That's because I missed adding them to the help files.

Here's the fixed release.

Attachments

Login to view attachments
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Sep 2011 19:42 Edited at: 15th Sep 2011 19:59
I've started making my DBPro debugger again (much more stable this time, the .dbm file and source code are optional, and it doesn't require cooperation from the program with the shared memory thing!) and I've run into a problem with "get ptr to function".

The best way of implementing "step into" functionality seems to be to internally add a conditional breakpoint to the start of every function, that way I can even step into DBPro functions called by external plugins.

The problem is that setting a code breakpoint replaces the code instructions at the start of the function, but your plugin requires that code when it scans for the functions and so crashes when the breakpoints are there. (Also, which commands will trigger the scan?)

Am I right that your code only scans for functions once? I'm thinking that if I call one of the function pointer functions at the start before I add the breakpoints it will scan the code then, and just work after that?

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Sep 2011 20:22
Quote: "Am I right that your code only scans for functions once?"

That's correct - I did try to get it to scan during the call to ReceiveCoreDataPtr, but it appears that the core g_pMachineCodeBlock isn't populated until after that point.

The most harmless and most efficient function that you could call to populate everything would actually be GetFunctionCount. It's signature is 'DWORD GetFunctionCount()'.

I have considered getting the function addresses from the _virtual.dat, which would avoid that problem for you, but that won't help you until I do it, and until everyone else is using that version of the plug-in.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Sep 2011 03:03 Edited at: 17th Sep 2011 03:03
Don't worry, I've got it working fine by calling "GetFunctionCount". It's easier for me to handle since I have full control over what code is executed when I can now step into functions called using "call function ptr" and it doesn't break the stack trace either

That late loading of "g_pMachineCodeBlock" was a problem for me too. I ended up injecting a DLL at load time which got the globstruct pointer and then putting a data breakpoint on "g_pMachineCodeBlock" so I'd be able to stop as soon as it is filled. Then I can break as soon as execution reaches the start of the code block.

I've also managed to catch standard runtime errors and let the user choose to suppress them I'm working on letting the user calls DBPro commands/user functions in the watch window or command window. (It reads the string tables to work out the commands. No obvious way to get this to work for licensed plugins, the user will have to tell the debugger what the signature is...)

Any ideas for features? You know better than most what it's possible to do!

BTW, as far as I can tell the protection used by licensed plugins appears to simply encrypt the string table used by the plugin. Does this mean that anyone who could somehow generate this string table (say from a command list) could use the licensed plugin simply by replacing the string table? This is especially worrying for decorated function names because the arguments and return type can be inferred from the decorated name...

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Sep 2011 13:31
Quote: "BTW, as far as I can tell the protection used by licensed plugins appears to simply encrypt the string table used by the plugin"

No, the exported symbol table is also removed or hidden too.

Quote: "No obvious way to get this to work for licensed plugins, the user will have to tell the debugger what the signature is"

Or you could asked either TGC or the plug-in writer to provide them. I guess you need the string resource and the entry point in some form - There's not quite enough detail in the decorated function name for just that to work for you.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Sep 2011 15:32 Edited at: 17th Sep 2011 15:33
Quote: "No, the exported symbol table is also removed or hidden too."


DLL export viewer can still see the exported function names, or did you mean something else?

And sorry for hijacking your thread, I'll stop now

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Sep 2011 16:00
No, I did mean that, except I forgot to add the '/exports' when I used the dumpbin utility on the plug-ins

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Sep 2011 17:38 Edited at: 20th Sep 2011 19:04
Do you know how to turn an error code into an error message? I know I could use the Errors.txt file but I'd prefer to get the information from the .exe. Any way of doing it that would work in a plugin would also work for me.

edit:
NVM, just found it was the 5th element of the error handler info in the globstruct, and there seems to be extra info appended to the pEXEUnpackDirectory string after the first null character.

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Sep 2011 19:14
The item before it is the size of the error array. The fact that you have extra data after pEXEUnpackDirectory's last byte is coincidental, so don't rely on that.

You could also get the error messages directly from the _virtual.dat.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Sep 2011 19:22 Edited at: 20th Sep 2011 19:24
I don't think it's coincidental... (Look at the overloaded form of RunTimeError)

The size will come in useful though, thanks!

[b]
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Sep 2011 01:09
Ah, I see what you mean - I thought you meant that the error messages array was placed in memory at the end of that string, though TBH, I had forgotten about that extra 'hidden' error message area.

sladeiw
15
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Sep 2011 13:07
I think I have discovered a bug with the datafile positioning when reading datafiles. If you try the code below it does not work unless you specifically set the datafile position after reading the first dword, although it does report that it is correct.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Sep 2011 23:32
Ok, I've found the problem.

It appears the a flush issued to a file not only forces cached writes to be written to disk, but also clears the cache of any read data - the read cache clearance was something I wasn't aware of.

When you request the file size, I flush the file to ensure that written data is included in the result, but didn't make that flush specific to writes only.

The fix is trivial. I'm not ready for a full release yet as I have other stuff currently in progress, so I've attached that one file to this post.

Attachments

Login to view attachments
sladeiw
15
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 22nd Sep 2011 00:18 Edited at: 22nd Sep 2011 00:18
Quote: "I've attached that one file to this post."


Great, thanks!
enderleit
17
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 23rd Sep 2011 00:20 Edited at: 23rd Sep 2011 00:23
Not sure if this has been noted yet, but it appears there is a bug with array sorting. (unless I missed something)

Running this code:


Gives output similar to this:
54 12 87 45 32
0 12 32 45 54

It seems that for some reason the last element is messed up somehow...

USING: Win7 Professional, DBPro Update U77-RC7

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Sep 2011 01:01
No, the sort is working. It's your code that's incorrect.

This code defines an array of 6 items, not 5.


When you fill the array, List(5) is left as zero. When you sort, that value naturally migrates to List(0), and the highest value migrates to List(5), which you don't display.

Try this:


Login to post a reply

Server time is: 2024-11-23 08:26:41
Your offset time is: 2024-11-23 08:26:41