flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] wrmsr crash (reading microcode rev)

Author
Thread Post new topic Reply to topic
jmurray



Joined: 28 Sep 2019
Posts: 8
Location: Plymouth, UK
jmurray
Hello,

I'm running into a problem with my DLL procedure where it crashes the program on the wrmsr instruction. I'm trying to follow the Intel procedure to read the CPU's microcode revision.

The procedure is as follows:

[code]
proc ReturnCPURevision uses rcx ;from Intel's IA-32 Volume 3A Ch9 9.11.7.1
push rcx
;fasm manual: wrmsr writes the contents of registers EDX and EAX into the 64-bit MSR of the address specified in the ECX register
;EAX+EDX -> MSR; MSR[ECX];
xor eax,eax ;clear EAX
xor edx,edx ;clear EDX
mov ecx,08BH ;IA32_BIOS_SIGN_ID
wrmsr ;load 0 to MSR at 8BH
mov eax,01H
cpuid
mov ecx,08BH ;IA32_BIOS_SIGN_ID
rdmsr ;Read Model Specific Register
;"If there is an update active in the processor, its revision is returned in the EDX register after the RDMSR instruction executes"
pop rcx
;mov [rcx],edx
ret
endp
[/code]

Any help would be appreciated as I can't seem to find why this doesn't work.


Last edited by jmurray on 13 Apr 2020, 15:32; edited 1 time in total
Post 12 Apr 2020, 21:36
View user's profile Send private message Send e-mail Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 706
Location: Belarus
DimonSoft
Intel® 64 and IA-32 Architectures Software Developer’s Manual wrote:
This instruction must be executed at privilege level 0 or in real-address mode; otherwise, a general protection exception #GP(0) is generated.
Post 12 Apr 2020, 21:42
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
jmurray: You will need to make a driver for Windows and execute the code within the driver context.

A normal user mode program has no chance to do this.

Writing and installing a driver can range from easy to hard depending upon your version of Windows. XP and below you have a much easier time. Vista and above you will find many barriers.
Post 12 Apr 2020, 21:55
View user's profile Send private message Visit poster's website Reply with quote
jmurray



Joined: 28 Sep 2019
Posts: 8
Location: Plymouth, UK
jmurray
Thank you both for replying.

I found it a bit odd that the "Intel Processor Identification Utility" program seemed to be able to view the CPU's revision. And it didn't mention requiring a driver. I'm now presuming that this is read from the registry instead

Thank you for your help. I had hoped it was possible to accurately read it from software somehow.
Post 13 Apr 2020, 15:32
View user's profile Send private message Send e-mail Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
Agner Fog's driver might jump-start your effort if you want to pursue this ...
https://www.agner.org/optimize/#testp

In my own experience, without driver signing on Windows 10 it requires turning off the check at boot every time the driver is needed. Driver signing is expensive. For this type of work, Windows is becoming more effort than it's worth. Yet, your use case might differ. Intel can afford driver signing.

_________________
¯\(°_o)/¯ unlicense.org
Post 13 Apr 2020, 18:13
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.