mirror of
https://github.com/ropnop/go-clr
synced 2026-06-08 17:11:59 +00:00
114 lines
2.9 KiB
Go
114 lines
2.9 KiB
Go
// +build windows
|
|
|
|
package clr
|
|
|
|
import (
|
|
"golang.org/x/sys/windows"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// from mscorlib.tlh
|
|
|
|
type Assembly struct {
|
|
vtbl *AssemblyVtbl
|
|
}
|
|
|
|
type AssemblyVtbl struct {
|
|
QueryInterface uintptr
|
|
AddRef uintptr
|
|
Release uintptr
|
|
GetTypeInfoCount uintptr
|
|
GetTypeInfo uintptr
|
|
GetIDsOfNames uintptr
|
|
Invoke uintptr
|
|
get_ToString uintptr
|
|
Equals uintptr
|
|
GetHashCode uintptr
|
|
GetType uintptr
|
|
get_CodeBase uintptr
|
|
get_EscapedCodeBase uintptr
|
|
GetName uintptr
|
|
GetName_2 uintptr
|
|
get_FullName uintptr
|
|
get_EntryPoint uintptr
|
|
GetType_2 uintptr
|
|
GetType_3 uintptr
|
|
GetExportedTypes uintptr
|
|
GetTypes uintptr
|
|
GetManifestResourceStream uintptr
|
|
GetManifestResourceStream_2 uintptr
|
|
GetFile uintptr
|
|
GetFiles uintptr
|
|
GetFiles_2 uintptr
|
|
GetManifestResourceNames uintptr
|
|
GetManifestResourceInfo uintptr
|
|
get_Location uintptr
|
|
get_Evidence uintptr
|
|
GetCustomAttributes uintptr
|
|
GetCustomAttributes_2 uintptr
|
|
IsDefined uintptr
|
|
GetObjectData uintptr
|
|
add_ModuleResolve uintptr
|
|
remove_ModuleResolve uintptr
|
|
GetType_4 uintptr
|
|
GetSatelliteAssembly uintptr
|
|
GetSatelliteAssembly_2 uintptr
|
|
LoadModule uintptr
|
|
LoadModule_2 uintptr
|
|
CreateInstance uintptr
|
|
CreateInstance_2 uintptr
|
|
CreateInstance_3 uintptr
|
|
GetLoadedModules uintptr
|
|
GetLoadedModules_2 uintptr
|
|
GetModules uintptr
|
|
GetModules_2 uintptr
|
|
GetModule uintptr
|
|
GetReferencedAssemblies uintptr
|
|
get_GlobalAssemblyCache uintptr
|
|
}
|
|
|
|
func NewAssemblyFromPtr(ppv uintptr) *Assembly {
|
|
return (*Assembly)(unsafe.Pointer(ppv))
|
|
}
|
|
|
|
func (obj *Assembly) QueryInterface(riid *windows.GUID, ppvObject *uintptr) uintptr {
|
|
ret, _, _ := syscall.Syscall(
|
|
obj.vtbl.QueryInterface,
|
|
3,
|
|
uintptr(unsafe.Pointer(obj)),
|
|
uintptr(unsafe.Pointer(riid)),
|
|
uintptr(unsafe.Pointer(ppvObject)))
|
|
return ret
|
|
}
|
|
|
|
func (obj *Assembly) AddRef() uintptr {
|
|
ret, _, _ := syscall.Syscall(
|
|
obj.vtbl.AddRef,
|
|
1,
|
|
uintptr(unsafe.Pointer(obj)),
|
|
0,
|
|
0)
|
|
return ret
|
|
}
|
|
|
|
func (obj *Assembly) Release() uintptr {
|
|
ret, _, _ := syscall.Syscall(
|
|
obj.vtbl.Release,
|
|
1,
|
|
uintptr(unsafe.Pointer(obj)),
|
|
0,
|
|
0)
|
|
return ret
|
|
}
|
|
|
|
func (obj *Assembly) GetEntryPoint(pMethodInfo *uintptr) uintptr {
|
|
ret, _, _ := syscall.Syscall(
|
|
obj.vtbl.get_EntryPoint,
|
|
2,
|
|
uintptr(unsafe.Pointer(obj)),
|
|
uintptr(unsafe.Pointer(pMethodInfo)),
|
|
0)
|
|
return ret
|
|
}
|