netmaestro and srod, your the experts.
Try this code and tear it apart if you like, or give me some suggestions.
I've been kind of busy lately and haven't had time to work on it lately.
some of this stuff. What I was really trying to do was to list the function
along with how many and what variables etc are used with each function.
It's easy to get the function name. But how to use it? I don't know?
if found. Try it on some microsoft dll's.
past by changing the internal address so it can't call home.
in this code is right.
would cause it to be wavy.
Code: Select all
;NOTE: CHANGE DRIVE AND PROGRAM LOCATIONS
;ACCORDING TO WHERE THEY ARE AT ON YOUR SYSTEM.
#SILENT_YNBOX = $C4 ;this gives you the silent yes no box
;Libfile.s ="c:\purebasic4_0\work\dlls\rmchart.dll"
agn:
Libfile.s = OpenFileRequester ( "Select DLL file", "", "DLL (*.dll)|*.dll", 0 )
If Trim(Libfile)=""
End
EndIf
;seperate path and file, and create info file with same name_info.txt
;GetFilePart retrieves the file part of full path. Eg: if full path is "C:\PureBasic\PB.exe", result will be "PB.exe"
;FileName$ = GetFilePart(FullPathName$)
f$=GetFilePart(Libfile)
;GetPathPart retrieves path part of full path. Eg: if full path is "C:\PureBasic\PB.exe", result will be "C:\PureBasic\".
;Path$ = GetPathPart(FullPathName$)
pth$ = GetPathPart(Libfile)
f$=Left(f$,Len(f$)-4)+"_info.txt"
File$=pth$+f$
CreateFile(1,File$)
WriteStringN(1,Libfile)
WriteStringN(1,Space(15)+"(best viewed with Font:Fixedsys or Courier Style:Regular Size:12)")
WriteStringN(1," ")
adrs=0
dat$=""
www_info$=""
at_end=0
If ReadFile(0,Libfile)
Repeat
adrs+1
If at_end=0 ;Use to speed up file search until "VERSION_INFO" is found.
car=ReadCharacter(0) ;This method is needed to remove the nulls between characters.
If car>31
dat$=dat$+Chr(car)
If Len(dat$)>100
dat$=Mid(dat$,70,999)
EndIf
EndIf
Else
car=ReadCharacter(0)
If car>31 And car<127
dat$=dat$+Chr(car)
If Len(dat$)>100
dat$=Mid(dat$,60,999)
EndIf
EndIf
EndIf
If FindString(LCase(dat$),"http://",1)>0
p=FindString(LCase(dat$),"http://",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
If Right(dat2$,5)="13 10"
car=1
EndIf
Until car=1
la$=Hex(adrs-7)+" "
www_info$=www_info$+la$+dat$+"\"
dat$=""
EndIf
If FindString(LCase(dat$),"www.",1)>0
p=FindString(LCase(dat$),"www.",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
If Right(dat2$,5)="13 10"
car=1
EndIf
Until car=1
If Len(dat$)>10
la$=Hex(adrs-4)+" "
www_info$=www_info$+la$+dat$+"\"
EndIf
dat$=""
EndIf
If FindString(LCase(dat$),"ftp://",1)>0
p=FindString(LCase(dat$),"ftp://",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
If Right(dat2$,5)="13 10"
car=1
EndIf
Until car=1
la$=Hex(adrs-6)+" "
ftp_info$=ftp_info$+la$+dat$+"\"
dat$=""
EndIf
If FindString(UCase(dat$), "VS_VERSION_INFO",1)>0
p=FindString(UCase(dat$), "VS_VERSION_INFO",1)
dat$=Mid(dat$,p,999)
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="VERSION_INFO "+Mid(dat$,16,999)
WriteStringN(1,"File location address: "+Hex(adrs-15))
WriteStringN(1,info$)
dat$=""
dat2$=""
at_end=1
EndIf
If at_end=1
If FindString(LCase(dat$),"stringfileinfo",1)>0
p=FindString(LCase(dat$),"stringfileinfo",1)
dat$=Mid(dat$,p,999)
dat2$=""
got=0
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
got=1
EndIf
Until got=1;car>0 And car<32
info$="StringFileInfo "+Mid(dat$,15,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"companyname",1)>0
p=FindString(LCase(dat$),"companyname",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="CompanyName "+Mid(dat$,12,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"filedescription",1)>0
p=FindString(LCase(dat$),"filedescription",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="FileDescription "+Mid(dat$,16,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"fileversion",1)>0
p=FindString(LCase(dat$),"fileversion",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="FileVersion "+Mid(dat$,12,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"internalname",1)>0
p=FindString(LCase(dat$),"internalname",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="InternalName "+Mid(dat$,13,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"legalcopyright",1)>0
p=FindString(LCase(dat$),"legalcopyright",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="LegalCopyright "+Mid(dat$,15,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"originalfilename",1)>0
p=FindString(LCase(dat$),"originalfilename",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="OriginalFilename "+Mid(dat$,17,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"productname",1)>0
p=FindString(LCase(dat$),"productname",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="ProductName "+Mid(dat$,12,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"productversion",1)>0
p=FindString(LCase(dat$),"productversion",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="ProductVersion "+Mid(dat$,15,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"varfileinfo",1)>0
p=FindString(LCase(dat$),"varfileinfo",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
Until car=1
info$="VarFileInfo "+Mid(dat$,15,999)
WriteStringN(1, info$)
dat$=""
EndIf
If FindString(LCase(dat$),"translation",1)>0
p=FindString(LCase(dat$),"translation",1)
dat$=Mid(dat$,p,999)
dat2$=""
Repeat
adrs+1
car=ReadCharacter(0)
Until car<>0
If car>31 And car<127
dat$=dat$+Chr(car)
EndIf
Repeat
adrs+1
car=ReadCharacter(0)
dat2$=dat2$+" "+Str(car)
If car>31 And car<127
dat$=dat$+Chr(car)
l=Len(dat$)
EndIf
If Right(dat2$,5)="0 0 0"
car=1
EndIf
If Right(dat2$,5)="4 4 0"
car=1
EndIf
Until car=1
info$="Translation "+Mid(dat$,15,999)
WriteStringN(1, info$)
dat$=""
at_end=0
EndIf
EndIf
Until Eof(0)<>0
CloseFile(0)
Delay(1000)
EndIf
If Len(www_info$)>0
WriteStringN(1, " ")
WriteStringN(1, "Location address File http info:")
If FindString(www_info$,"\",1)>0
While FindString(www_info$,"\",1)>0
p=FindString(www_info$,"\",1)
l$=Left(www_info$,p-1)
WriteStringN(1, l$)
www_info$=Mid(www_info$,p+1,999)
Wend
Else
WriteStringN(1, www_info$)
EndIf
EndIf
If Len(ftp_info$)>0
WriteStringN(1, " ")
WriteStringN(1, "Location address File ftp info:")
If FindString(ftp_info$,"\",1)>0
While FindString(ftp_info$,"\",1)>0
p=FindString(ftp_info$,"\",1)
l$=Left(ftp_info$,p-1)
WriteStringN(1, l$)
ftp_info$=Mid(ftp_info$,p+1,999)
Wend
Else
WriteStringN(1, ftp_info$)
EndIf
EndIf
WriteStringN(1, " ")
WriteStringN(1, " ")
OpenLibrary(0,Libfile)
Delay(1000)
WriteStringN(1,"See what functions this version offers")
WriteStringN(1," ")
WriteStringN(1,"FN #"+Space(3)+"Function Address"+Space(2)+"Function Name"+Space(30)+"Hex Values Found at Address")
n=1
;Result = ExamineLibraryFunctions(#Library)
;To examine the functions contained in a library.
If ExamineLibraryFunctions(0)
;Result = NextLibraryFunction()
;Allows you to step through the functions in the library
While NextLibraryFunction()
;Result$ = LSet(String$, Length [, Character$]) eg: , 40,"_") = 40 _ characters added.
;Result$ = LibraryFunctionName()
;Returns the name of the function in the library currently being examined
lfn$ = LSet(LibraryFunctionName(), 40,"_")
;Result.l = LibraryFunctionAddress()
;Returns the address of the function in the library currently being examined.
;Text$ = PeekS(*MemoryBuffer [, Length [, Flags]])
;Very useful to read a string at the specified memory address.
;The string should be ended by a '0' character, else it will
;read the memory until a '0' character is encounter.
;Text$ = PeekS(LibraryFunctionAddress())
;Text$ = PeekS(LibraryFunctionAddress(),-1,#PB_UTF8)
;Text$ = PeekS(LibraryFunctionAddress(),-1,#PB_Unicode)
Text$ = PeekS(LibraryFunctionAddress(),-1,#PB_Ascii)
n$ = LSet(Str(n), 10,"_")
;hex #
;lfa$ = Str(LibraryFunctionAddress())
lfa = LibraryFunctionAddress()
lfa$=Hex(lfa)
lfa$ = LSet(lfa$, 15,"_")
lfnd$=LSet(n$+lfa$+lfn$,63,"_")
;CallDebugger
;convert text to hex values
text3$=""
For a =1 To Len(text$)
a$=Mid(text$,a,1)
ha=Asc(a$)
ha$=Hex(ha)
If Len(ha$)<2
ha$="0"+ha$
EndIf
text3$=text3$+ha$+" "
Next a
text$=text3$
If Len(Text$)>54
fl=0
While Len(Text$)>54
LText$=Left(Text$,54)
If fl=0
WriteStringN(1,lfnd$+LText$)
fl=1
EndIf
Text$=Mid(Text$,55,99999)
Text2$ = LSet(" ", 28,"_")+" continued"+LSet(" ", 25,"_")+Left(Text$,54)
WriteStringN(1,Text2$)
Text$=Mid(Text$,55,99999)
Wend
If Trim(text$)<>""
Text2$ = LSet(" ", 28,"_")+" continued"+LSet(" ", 25,"_")+Text$
WriteStringN(1,Text2$)
EndIf
WriteStringN(1," ") ;add divider space
Else
WriteStringN(1,lfnd$+Text$)
EndIf
n+1
Delay(10)
Wend
CloseFile(1)
EndIf
;CloseLibrary(0)
Delay(10)
RunProgram("c:\windows\notepad.exe" , f$, pth$, #PB_Program_Wait)
result=MessageRequester(" ","Examine another DLL file ? ",#PB_MessageRequester_YesNo);#SILENT_YNBOX)
If result<>7
;CloseLibrary(0)
Goto agn
EndIf
End