unable to use GetProcAddress on x64 mklml.dll Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
smarq8
Posts: 69
Joined: 16 Jan 2016, 00:33

unable to use GetProcAddress on x64 mklml.dll

28 Feb 2019, 16:00

Hello.
I try to use mklml.dll with my script but somehow I'm unable to load any functions from it
I already use this method for libopenblas.dll and everything work fine. I also watch mklml.dll witch DllExplorer so I'm 100% sure certain function even exist.

my pc spec:
W7Ux64
AHK 1.1.30.01 U64

any suggestion what is going wrong?

dll files: https://github.com/intel/mkl-dnn/releases/tag/v0.17.4

Code: Select all

;msgbox,% "Hello"
vsSub(0,0,0,0)
return

dll_getAdr(dllFile,func){
	if(!InStr(FileExist(dllFile),"A")){
		msgbox,% "Not found dll: " dllFile "`n" func
	}
	handle := DllCall("LoadLibrary","Str",dllFile)
	DllError("LoadLibrary",handle,A_LastError,ErrorLevel,dllFile "/" func)
	adr := DllCall("GetProcAddress","Ptr",handle,"AStr",func,"Ptr")
	DllError("GetProcAddress",adr,A_LastError,ErrorLevel,dllFile "/" func)
	return adr
}
vsSub(cnt,a,b,r){
	;msgbox,% A_ThisFunc "`n" a "`n" b "`n" r
	;r[i] = a[i] - b[i]
	static dllFile := "mklml.dll"
	static vsSub := dll_getAdr(dllFile,"vsSub")
	msgbox,% vsSub
	;DllCall(vsSub
	;,"int",cnt
	;,"ptr",a
	;,"ptr",b
	;,"ptr",r
	;,"cdecl")
}

DllError(fName,ret,LastError,EL,param){
	;if(ret==0 || LastError!=0){
	if(ret==0){ ;lastError==127 falszywe?
		msgbox,% "Function: " fName
		. "`nreturn: " ret 
		. "`nErrorLevel: " EL 
		. "`nLastErrorCode: " A_LastError
		. "`nLastErrorMessage: " GetErrorString(A_LastError)	
		. "`nParam: " param
	}
}
GetErrorString(Errornumber)
{
	bufferSize = 1024 ; Arbitrary, should be large enough for most uses
	VarSetCapacity(buffer, bufferSize, 0)
	FORMAT_MESSAGE_FROM_SYSTEM = 0x1000
	LANG_SYSTEM_DEFAULT = 0x10000
	LANG_USER_DEFAULT = 0x20000
	
	DllCall("FormatMessage"
		, "UInt", FORMAT_MESSAGE_FROM_SYSTEM
		, "UInt", 0
		, "UInt", Errornumber
		, "UInt", LANG_USER_DEFAULT
		, "Str" , buffer
		, "UInt", bufferSize
		, "UInt", 0)
	
	return buffer
}
Last edited by smarq8 on 28 Feb 2019, 22:21, edited 1 time in total.
teadrinker
Posts: 1316
Joined: 29 Mar 2015, 09:41
Contact:

Re: unable to use GetProcAddress on x64 mklml.dll

28 Feb 2019, 19:55

The libiomp5md.dll library must also be present in the script working directory.
teadrinker
Posts: 1316
Joined: 29 Mar 2015, 09:41
Contact:

Re: unable to use GetProcAddress on x64 mklml.dll  Topic is solved

28 Feb 2019, 22:38

For me it works like this:

Code: Select all

hLib := DllCall("LoadLibrary", Str, "mklml.dll", Ptr)
pAddr := DllCall("GetProcAddress", Ptr, hLib, AStr, "cblas_chpr", Ptr)
DllCall("FreeLibrary", Ptr, hLib)
MsgBox, % pAddr
smarq8
Posts: 69
Joined: 16 Jan 2016, 00:33

Re: unable to use GetProcAddress on x64 mklml.dll

01 Mar 2019, 00:25

@teadrinker
thanks
probably now it will work fine

Code: Select all

dll_getAdr(dllFile,func){
	if(!InStr(FileExist(dllFile),"A")){
		msgbox,% "Not found dll: " dllFile "`n" func
	}
	handle := DllCall("LoadLibrary","Str",dllFile,"ptr") ; <---------------- missing return type
	DllError("LoadLibrary",handle,A_LastError,ErrorLevel,dllFile "/" func)
	adr := DllCall("GetProcAddress","Ptr",handle,"AStr",func,"Ptr")
	DllError("GetProcAddress",adr,A_LastError,ErrorLevel,dllFile "/" func)
	msgbox,% handle "`n" adr "`n" func
	return adr
}

Return to “Ask For Help”

Who is online

Users browsing this forum: adrian88888888, Albireo, BNOLI, jadams, kdaube, MSN [Bot], NaNoMister, swagfag, vsub, Xtra and 382 guests