Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

ProcessWorkingSetSize

Hello,
I was experimenting with the Win32API a bit and found the GetProcessWorkingSetSize method.
But when I call it, the RGSS Player crashes ("has stopped working").

Code:
api = Win32API.new('kernel32.dll', 'GetProcessWorkingSetSize', 'iii', 'i')

min, max = 0, 0

api.call(-1, min ,max) # crash here
 

Zeriab

Sponsor

When win32api calls give exceptions the RGSS Player crashes.

The crash may be caused by you giving -1 as the process handle.
It may also be due to min and max not being pointers.
You'll have to set min and max to strings and indicate that they should be passed as pointers.
I suggest that you for security's sake null-terminate the strings. (Ends with a \000)

*hugs*
 
The reason is definitely because you set the first argument to -1, at least initially. Specifically, that requires a handle to the process you want to access. (In this case, I'm assuming the RGSS player, since you won't have access rights to anything else)

Try looking up some information on handles. In RGSS, the most commonly used handle I've seen is to access a window, in the case of RMXP resolution changing scripts. However, this will be a very different kind of handle, and I can't really give you any tips aside from doing a bit of digging for methods to access a process handle, and and then doing a bit of experimentation to figure out how to access the RGSS player process handle.

One thing you want to keep in mind is that dummy data is rarely acceptable to Win32API calls, since .dll files are usually looking for something very specific. Give them something they aren't expecting, and it usually crashes. Note that, in most cases, Win32API is NOT made to give a safe crash with basic error checking. Instead, it will often simply reject the call or quit partway through, instead of returning with an easily accessible error code. In fact, in the rare instances where there is an accessible error code, you have to go through other portions of the Win32API to get to it.
 
That's an incredibly useful tip, since I wasn't able to find that in the documentation. Also, if you ever have trouble with Win32API and passing structures, send me a PM and I'll help out. (It's actually easier than most people think it is, once you figure out exactly how many bits of data each piece of the structure takes up in C++)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top