Improved Windows DLL calls

This commit is contained in:
Eduard Urbach 2024-08-19 11:11:45 +02:00
parent fa1dce31f3
commit ed6cee0acc
Signed by: eduard
GPG key ID: 49226B848C78F6C8
12 changed files with 124 additions and 68 deletions

View file

@ -3,6 +3,26 @@ package dll
// List is a slice of DLLs.
type List []DLL
// Append adds a function for the given DLL if it doesn't exist yet.
func (list List) Append(dllName string, funcName string) List {
for _, dll := range list {
if dll.Name != dllName {
continue
}
for _, fn := range dll.Functions {
if fn == funcName {
return list
}
}
dll.Functions = append(dll.Functions, funcName)
return list
}
return append(list, DLL{Name: dllName, Functions: []string{funcName}})
}
// Index returns the position of the given function name.
func (list List) Index(dllName string, funcName string) int {
index := 0