use buffer APIs instead of raw memcpy, fix plugin bypass