![]() |
|
|
#1 |
![]() Join Date: Jul 2008
Posts: 7 (0.00/day)
Thanks: 0
Thanked 4 Times in 4 Posts
|
GPU-Z Shared Memory C# Wrapper
As I got some PNs that the link I've posted in the sticky thread 4 years ago is dead and other users still need the source code, I'll upload it again.
With this source code, C# developers can conveniently access the shared memory (and therefore the data) provided by GPU-Z within their programs.Here's a link to a newly created .zip archive which includes two visual studio 2010 projects, one that's written in C++ and used to create a .dll and the other one to show how you can access the shared memory via the .dll in C#. Usually including the .dll into your project (such as done in the demo project) will be sufficient, but if that doesn't work, you might try to adjust/compile the .dll project by yourself. I've also compiled a x64 version of the .dll, but normally the 32 bit version should work also on all 64 bit OS. Here is a short snippet from the demo project, showing how the shared memory can be accessed: Code: Code:
GpuzWrapper gpuz = new GpuzWrapper(); gpuz.Open(); Console.WriteLine(gpuz.DataKey(0) + ": " + gpuz.DataValue(0)); Console.WriteLine(gpuz.SensorName(0) + ": " + gpuz.SensorValue(0) + " " + gpuz.SensorUnit(0)); gpuz.Close(); Code:
DirectXSupport: 11.0 GPU Core Clock: 732,1149 MHz ![]() Feel free to enjoy the demo and ask if something is unclear. Here are some links to download it: http://www.file-upload.net/download-...ShMem.zip.html http://www.filedropper.com/gpuzshmem https://github.com/JohnnyUT/GpuzShMem/zipball/master And here is the link to the github project, if you want to take a look at the sources without downloading the whole archive: https://github.com/JohnnyUT/GpuzShMem PS: You might have to update the location of the GpuzShMem.dll file in the GpuzDemo project. I think visual studio uses the absolute path. -.- Last edited by JohnnyUT; Apr 12, 2012 at 07:39 PM. |
|
|
|
| The Following User Says Thank You to JohnnyUT For This Useful Post: |
|
|
#2 |
|
Benevolent Dictator
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,870 (4.17/day)
Thanks: 184
Thanked 10,453 Times in 3,219 Posts
|
thanks. suggestion: put it on github
|
|
|
|
|
|
#3 |
![]() Join Date: Jul 2008
Posts: 7 (0.00/day)
Thanks: 0
Thanked 4 Times in 4 Posts
|
Done. I added the link to the original post.
|
|
|
|
|
|
#4 |
|
Hardcore Monkey Moderator
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,254 (5.27/day)
Thanks: 591
Thanked 5,510 Times in 2,948 Posts
|
Thanks Johnny !!
__________________
Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other. Get more tech news on a wide variety of topics at NextPowerUp
|
|
|
|
|
|
#5 |
|
Hardcore Monkey Moderator
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,254 (5.27/day)
Thanks: 591
Thanked 5,510 Times in 2,948 Posts
|
Okay, I thought I'd try my hand at accessing the shared memory from GPU-Z as I haven't done anything with shared memory before.
I'm using that MemoryMappedFiles namespace they added in .Net 4 I sort of works. I get the version, busy and lastUpdate values okay (at least I think so), but I'm seeing garbage in the names and values of the data array of GPUZ_RECORD. Code Inside
Maybe a problem with the c# char type and WCHAR ? Maybe something with mem boundaries of the way structures are stored? Maybe I don't have a clue what I doing ? <---- most likely scenario ![]() Any thoughts appreciated.
__________________
Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other. Get more tech news on a wide variety of topics at NextPowerUp
|
|
|
|
|
|
#6 |
|
Benevolent Dictator
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,870 (4.17/day)
Thanks: 184
Thanked 10,453 Times in 3,219 Posts
|
WCHAR is a 16 bit unicode character
#pragma pack(push, 1) means 1-byte aligned structure members |
|
|
|
| The Following User Says Thank You to W1zzard For This Useful Post: |
|
|
#7 |
|
Hardcore Monkey Moderator
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,254 (5.27/day)
Thanks: 591
Thanked 5,510 Times in 2,948 Posts
|
Got a bit farther. Yay !
I forced the BinaryReader to use unicode decoding for text (which I thought was the default, but apparently not) Code:
BinaryReader reader = new BinaryReader(stream, Encoding.Unicode); ... after much code abuse ... Everything works with no DLLImports of PInvoke calls. WooHooo !! Now to make it useful. lol
__________________
Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other. Get more tech news on a wide variety of topics at NextPowerUp
Last edited by Kreij; Apr 13, 2012 at 06:03 PM. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GPU-Z Shared Memory Layout | W1zzard | GPU-Z | 31 | Jan 6, 2013 04:37 PM |
| exe to read GPU-Z shared memory data? | Irios | GPU-Z | 11 | Apr 13, 2012 01:50 AM |
| C# Shared Memory GPU-Z | symbiote_venom | GPU-Z | 0 | Mar 30, 2011 07:54 AM |
| Increasing shared graphics memory | Ben Clarke | General Hardware | 5 | Mar 24, 2007 02:50 AM |
| Increasing shared graphics memory | Ben Clarke | General Hardware | 3 | Mar 24, 2007 01:18 AM |