I have a new problem, the code of FREAK works fine for exit a DLL, without execute the rest of DLL.
Directly of the AttachProcess function
It's really useful, for test if a program have the autorisation to use the DLL
It works fine when the DLL called by a PB program, else when the DLL called with VB6, i have an error 48
"File no found : PureBasic.dll"
Somebody know why VB call don't works ?
What is the difference of the DLL management between PB and VB6 ?
Code: Alles auswählen
ProcedureDLL AttachProcess(Instance)
Global AppPath.s
AppPath = Space(200)
GetCurrentDirectory_(200, @AppPath)
AppPath = Trim(AppPath)
If Right(AppPath,1) <> "\"
AppPath + "\"
EndIf
Global NomExecutable.s
Application.s = Space(255)
GetModuleFileName_(0, @Application, 255)
NomExecutable = GetFilePart(Application)
Application = ""
Global AutorisationAppli = #False
ReadFile(1, AppPath + "Autorisation")
Repeat
Donnee$ = ReadString(1)
NomAppliFichier.s = StringField(UCase(Trim(Donnee$)), 1, "=")
If FindString(UCase(Trim(NomExecutable)), NomAppliFichier, 1)
AutorisationAppli = #True
Break
EndIf
Until Eof(1) <> 0
CloseFile(1)
If AutorisationAppli = #False
MessageRequester(NomDLL, Space(8) + "Le logiciel " + NomExecutable + " n'est pas autorisé à utiliser " + NomDll + "," + Chr(13) + "veuillez contacter le développeur pour obtenir une autorisation.")
!ADD esp, 8 ; remove Instance variable and return address from stack
!MOV eax, 0 ; set returnvalue to 0
!RET 12 ; return from DllEntryPoint
Else
ProcedureReturn ; return normally
EndIf
EndProcedure