I'm a old C++ guy, so forgive my ignorance in ASM.. I'm having issues with getting CPU utilization through perfmon, because of a small memory leak in the pdh.dll after being called every 60 seconds for weeks on end. I then tried using MS typeperf.exe, but I found that EXE will return nothing at times and get into a state where it just will not return anything until the machine is restarted. So, I've decided to drop to a lower level and see if this can be done in ASM without these kinds of issues.

Anyone have a snippet they can part with to pull CPU Utilization per CPU within ASM?

I know there's at least two on Codeproject that show up right away on Google.

Realy? I can't seem to find any and google is where I found this place. I also had already done searches on codeproject, but with no luck. Mind posting a link?

Microsoft has good C code with excellent descriptions at its Win32 API reference library:

http://msdn.microsoft.com/en-us/library/aa373078(VS.85).aspx

Click on the "Performance Counters Functions" category.

Calling the Windows API functions from assembly language is a bit more work than doing it in either C or C++, but it certainly isn't impossible and modern assemblers/packages support features that make the task easier.

You might need to make your own headers {with constant definitions, macros, function prototypes, etc.} for the more obscure API functions; but first, -- depending on which assembler/library/package you decide to go with -- you should check out the associated forums to see if headers already exist for the functions you want to use:

http://www.masm32.com/board/index.php?
http://www.asmcommunity.net/board/
http://www.artofasm.com/
http://board.flatassembler.net/

Hope I've helped!

This article has been dead for over six months. Start a new discussion instead.