Yes, formally בְּמֶ֫שֶׁךְ is a preposition with a noun in the construct state ("in the duration of"), which is used de facto as a prepositional expression. Who thinks of it as an adverb, since it cannot stand alone?