Does "physicaldrive0" always represent the HDD which installed the Windows OS ?

If not, how can I get the number of the HDD which installed the Windows OS in kernel driver? e.g. physicaldrive1, physicaldrive2 …

Concerning your original question, consider the scenario when you have more than one Windows installation on your physical machine.

Concerning the second one, all you ave to do is to use Google. If you bothered yourself with typing “GetSystemDirectory kernel” in a search box you would immediately get

  1. A thread where Mr.Noone answers your question.

https://community.osr.com/discussion/comment/178115/#Comment_178115

  1. Once you are looking for"off-shelf solutions" you would get the following link

http://www.driverentry.com/resources/systemrootpath.htm

This code sample demonstrates how to use ZwOpenSymbolicLinkObject() and ZwQuerySymbolicLinkObject() in order to query “\SystemRoot” (i.e. to do what Mr.Noone suggests in above mentioned post). If it is still not enough, this link also mentions the other possibilities like getting the info you are looking for from the registry, and even tells you the precise location where it may be found
(i.e. HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PathName.)

The funniest thing here that getting all this requires much less effort, compared to starting a thread and asking a question on NTDEV.
Funny,ugh…

Anton Bassov

Thank you very much…