mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-24 14:45:00 -07:00
build_dll; Require an entry point procedure main
This commit is contained in:
+24
-1
@@ -1,6 +1,29 @@
|
||||
#import "win32.odin"
|
||||
#import "fmt.odin"
|
||||
|
||||
|
||||
main :: proc() {
|
||||
get_proc :: proc(lib: win32.HMODULE, name: string) -> proc() {
|
||||
buf: [4096]byte
|
||||
copy(buf[:], name as []byte)
|
||||
|
||||
proc_handle := win32.GetProcAddress(lib, ^buf[0])
|
||||
return proc_handle as proc()
|
||||
}
|
||||
|
||||
lib := win32.LoadLibraryA(("example.dll\x00" as string).data)
|
||||
if lib == nil {
|
||||
fmt.println("Could not load library")
|
||||
return
|
||||
}
|
||||
defer win32.FreeLibrary(lib)
|
||||
|
||||
proc_handle := get_proc(lib, "some_thing")
|
||||
if proc_handle == nil {
|
||||
fmt.println("Could not load 'some_thing'")
|
||||
return
|
||||
}
|
||||
|
||||
some_thing := (proc_handle as proc())
|
||||
some_thing()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user