Garrysmod runs on top of HL2. Using HL2 Assets and the source engine. Before garrysmod, garry was using cheat codes in HL2 to mess around and well, he decided to code an actual tool to make it easier to mess with vs typing in commands. Garrysmod was created.