Skip to content

Commit 3057bab

Browse files
authored
fix: properly convert int to resource type (#3)
Fixes #2.
1 parent 72e6950 commit 3057bab

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

internal/winapi/winapi.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,21 @@ func LoadLibraryEx(name string, flags uint32) (windows.Handle, error) {
116116

117117
// MakeIntResource converts an integer value to a resource type compatible with the resource-management functions.
118118
// This macro is used in place of a string containing the name of the resource.
119-
func MakeIntResource(id uintptr) *uint16 {
120-
return (*uint16)(unsafe.Pointer(id))
119+
func MakeIntResource(i int) uintptr {
120+
return uintptr(uint16(i))
121121
}
122122

123123
// EnumResourceNamesA enumerates resources of a specified type within a binary module. For Windows Vista and later,
124124
// this is typically a language-neutral Portable Executable (LN file), and the enumeration will also include resources
125125
// from the corresponding language-specific resource files (.mui files) that contain localizable language resources.
126126
// It is also possible for hModule to specify an .mui file, in which case only that file is searched for resources.
127-
func EnumResourceNamesA(hModule windows.Handle, lpcStr *uint16, lpEnumFunc EnumResNameProcA, lParam *int32) error {
127+
func EnumResourceNamesA(hModule windows.Handle, lpcStr uintptr, lpEnumFunc EnumResNameProcA, lParam *int32) error {
128128
if err := enumResourceNamesA.Find(); err != nil {
129129
return err
130130
}
131131
r1, _, e1 := enumResourceNamesA.Call(
132132
uintptr(hModule),
133-
uintptr(unsafe.Pointer(lpcStr)),
133+
lpcStr,
134134
windows.NewCallback(lpEnumFunc),
135135
uintptr(unsafe.Pointer(lParam)),
136136
)

0 commit comments

Comments
 (0)