• C

How would I catch the Processor Id...???

Hello all,

I need to catch the CPU Unique Id for my applications' processing. Ay idea how I can do this...? I'm not an expert, but yes I am quite familiar with C.
Any help would be more than helpful.

Thanks
mathursaurabhAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
On Intel/AMD, like

#pragma warning(disable:4035) // disable: 'function' : no return value

DWORD GetCPUID () {

#define cpuid __asm _emit 0xF0 0xA2   // hex opcode for CPUID
 __asm{
  xor eax, eax
  _emit 0xF0 0xA2
 }

 // return value is the content of EAX
}

#pragma warning(default:4035)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajeev_devinCommented:
>> _emit 0xF0 0xA2
Is this correct. As I know _emit can define a single byte.

By the way what the function is doing.
Can you please explain.
0
Infinity08Commented:
Well, here's some nice info for IA-32 :

http://www.sandpile.org/ia32/cpuid.htm

from this site :

http://www.sandpile.org/
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

grg99Commented:
It depends on what exact hardware and software you're running under.  

If you're running on the bare metal, with complete control of the code from CPU reset to your app, you can get at this info.

If there's a bootup BIOS in the way, it can turn off or fake this feature.

If you're running in protected or virtual 86 mode, the kernel can trap and fudge the results of this instruction.

Also there are many variations of the CPUID:  the original 486 CPUID, the Pentium "1" CPU ID, the AMD extended CPUID, the processor serial number CPUID, and more.    Which one are you looking for?




0
NopiusCommented:
"I need to catch the CPU Unique Id for my applications' processing"
What OS and what hardware are you using?

BTW your application may not be shure that it's running on specific CPU, even when you reach next line of your C application.
0
mathursaurabhAuthor Commented:
> On Intel/AMD, like
>
>#pragma warning(disable:4035) // disable: 'function' : no return value
>
>DWORD GetCPUID () {
>
>#define cpuid __asm _emit 0xF0 0xA2   // hex opcode for CPUID
> __asm{
>  xor eax, eax
>  _emit 0xF0 0xA2
> }
>
> // return value is the content of EAX
>}
>
>#pragma warning(default:4035)

Thanks for the response jkr, but I am confused how am I supposed to use the folowing code snippet..?? Can you please details it a btit more..??
Also if you can let me know how to call a C file from with-in a shell script while your .rpm package is getting installed. This C file would provide the necessary inout to the shell script which would then forward this input to the installing software. Any clue on this...??


Thanks
0
grayeCommented:
There's a pretty good tutorial on the use of the CPUID at http://www.paradicesoftware.com/specs/cpuid/index.htm
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.