In the first solo riff, Carlos Santana is playing in the key of Dm, which means that the solo is based off of the D Pentatonic Minor scale.
Remember, the Dm would be in the 1st position, the Gm would be in the 4th position, and the Am would be in the 5th position.
The beginning of this solo is played by itself, which sets up the rest of the solo.
This guitar would be considered a keyboard part, but in this case, it can logically be played on the guitar.
Complete Transcription To “Black Magic Woman” (PDF)