Since there is no official SDK example for golang, I studied it and found that it was feasible.
HWID and serial information can be successfully detected through CGO, but Marker cannot be detected by VMProtect.
After adding C.VMProtectBeginUltra(C.CString(“protect”) to my other project, Marker can be detected, but Marker’s name cannot be recognized, and the content that needs to be protected cannot be detected.
Marker can be detected in c code,can’t detected in Go func, like:
/*
void VMP(){
VMProtectBeginUltra("protect");
//CODE
VMProtectEnd();
}
*/
import "C"
My demo code:
package main
// #include <stdbool.h>
// #include <stdlib.h>
// #include "VMProtectSDK.h"
// #cgo LDFLAGS: -L . -lVMProtectSDK
import "C"
import (
"fmt"
"unsafe"
)
func main() {
Cprotect := C.CString("protect")
defer C.free(unsafe.Pointer(Cprotect))
//it's not work
C.VMProtectBeginUltra(Cprotect)
serial := "CMQz+nTnrgqB4OUBXAwCT9k40JM5qqVCQFSD4IAqega6C3KPidYeqE3iuVNelEbYYykEl2eTrzbjU424kGAsCz+Y478jMVfco6gVWoWDd+FwZrRU06dWdhkBzvzsVxnHmtdpN9An7pKEvH4RCEyqcc19WjBgas4TlSjOBUjXNMtx9txsGVev06nmgOUhx9gELi6R/e9xDMqhnK5Ys58jh52xTjuWUtw58qtRlJyMAnE4YSC8YRH4awnnkOAOFsRqpwMJB2uRIgHjfdkhd5JFUDU1UHFFH8ASZ0w1ti464OSybPB9AmlP+2L/1+ZonvkID3bjHIHPG2Tr55BGE0nxDQ=="
nSize := C.VMProtectGetCurrentHWID(nil, 0)
hw := new(C.char)
C.VMProtectGetCurrentHWID(hw, nSize)
hwid := C.GoString(hw)
Cserial := C.CString(serial)
defer C.free(unsafe.Pointer(Cserial))
kstate := C.VMProtectSetSerialNumber(Cserial)
var sd C.VMProtectSerialNumberData
C.VMProtectGetSerialNumberData(&sd, C.sizeof_VMProtectSerialNumberData)
var user string
for _, v := range sd.wUserName {
if v != 0 {
user += fmt.Sprintf("%c", v)
}
}
//it's work
fmt.Println("HWID: ", hwid)
//it's work
fmt.Println("Is Protected: ", C.VMProtectIsProtected())
//it's work
fmt.Println(kstate)
//it's work
fmt.Println(user)
C.VMProtectEnd()
return
}