DroopyLib

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

17/07/12 : Library 4.61.003
RegSetValue() Unicode bug fixed by Korolev Michael
GetPidProcess() Unicode bug fixed by SeregaZ
Thanks to Korolev Michael and SeregaZ :wink:
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

ABBKlaus wrote:There is nothing wrong with TailBite, you are using the ASCII versions of the Windows-API and your structure definition is wrong !
Hello ABBKlaus, the function works well, what's wrong with the structure definition ?
Regards
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

i think for check all bugs need to make search in unicode sourse droopy for PeekS and other command, that have some difference in standart and unicode variants.
this all commands probably can works wrong in unicode:
Image

for check it all i dont know tasks, where many of this commands is apply. who can do it? :)
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: DroopyLib

Post by ABBKlaus »

Your structure defines szExeFile as byte, MSDN says character !

If Byte is used you can only use the Ascii versions of the functions Process32First / Process32Next.

The correct command for reading this buffer should be Nom.s=UCase(PeekS(@Process\szExeFile, -1, #PB_Ascii)) and not #PB_UTF8 as SeregaZ said.

Code: Select all

Structure PROCESSENTRY33 
  dwSize.l 
  cntUsage.l 
  th32ProcessID.l 
  th32DefaultHeapID.l 
  th32ModuleID.l 
  cntThreads.l 
  th32ParentProcessID.l 
  pcPriClassBase.l 
  dwFlags.l 
  szExeFile.b[#MAX_PATH]  ; <- Byte !
EndStructure
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

Thanks a lot ABBKlaus :wink:
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: DroopyLib

Post by Korolev Michael »

Good, very good.

Hm. Can't find updated source.
Former user of pirated PB.
Now registered user :].
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

18/07/12 : Library 4.61.004
GetPidProcess() Unicode bug fixed by ABBKlaus
GetMacAddress() Unicode bug fixed
HardDiskModel() Unicode bug fixed
GetUserSid() Unicode bug fixed
EnumProcessInit() Unicode bug fixed
SearchProcess() Unicode bug fixed
GetFileVersion() Unicode bug fixed
IpToHostName() Bug detected when Compiled as Unicode
ApiCommandlineInit() Bug detected when Compiled as Unicode
IECSendMessage() Bug detected when Compiled as Unicode
The library installer can extract the source when you click on the 'Extract' button
The source code is also avalible in a purebasic subfolder called Library_Source
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

niiiiceeeee! :)

and one more - i think last one about GetPidProcess :) what do you think if we add some small break in the function - can it work a litle faster? i mean:

Code: Select all

        While ProcessFound 
          Nom.s=UCase(PeekS(@Process\szExeFile, -1, #PB_Ascii))
          Nom=GetFilePart(Nom)
          Debug Nom
          If Nom=Name 
            Recherche =1 
            Pid=Process\th32ProcessID
            ; *****************************
            Break ; i mean this break! 
            ; *****************************
          EndIf
          ProcessFound = CallFunctionFast(ProcessNext, Snapshot, Process) 
        Wend
with this break, according to my theory, enumeration of process must stop when coincidence found and function does not continue to search for more to end of list of process.

and in the droopy help you forgot to change my code "Len(Name.s)" to ABBKlaus's "-1" :)
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

20/07/12 : Library 4.61.005
UnicodeCompilation Tips added
DownloadWithCallback Code added
LogoffDetect() Help added
CloseWindowsEx() added
SimulateKeyPress() Help added
SetWindowMinButton() Function added
SetWindowMaxButton() Function added
SetWindowCloseButton() Function added
WindowsExit() Deleted (replaced by SetWindowsCloseButton)
MiniInventory Code added
PureInventory Code added
SimulatePurebasicEvent Tips added
URLDownloadToFileEx() added
GetPidProcess() tweaked by SeregaZ
thanks to SeregaZ :wink:
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: DroopyLib

Post by ABBKlaus »

SeregaZ wrote:niiiiceeeee! :)

and one more - i think last one about GetPidProcess :) what do you think if we add some small break in the function - can it work a litle faster? i mean:

Code: Select all

        While ProcessFound 
          Nom.s=UCase(PeekS(@Process\szExeFile, -1, #PB_Ascii))
          Nom=GetFilePart(Nom)
          Debug Nom
          If Nom=Name 
            Recherche =1 
            Pid=Process\th32ProcessID
            ; *****************************
            Break ; i mean this break! 
            ; *****************************
          EndIf
          ProcessFound = CallFunctionFast(ProcessNext, Snapshot, Process) 
        Wend
with this break, according to my theory, enumeration of process must stop when coincidence found and function does not continue to search for more to end of list of process.

and in the droopy help you forgot to change my code "Len(Name.s)" to ABBKlaus's "-1" :)
The break was already included in my version, i don't know why Droopy won't include it :?

http://www.purebasic.fr/english/viewtop ... 32#p385232
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

The break was already included in my version, i don't know why Droopy won't include it :?
Because i miss it :oops:
Thanks you ABBKlaus :wink:
Mohawk70
Enthusiast
Enthusiast
Posts: 404
Joined: Thu May 11, 2006 1:04 am
Location: Florida, USA

ComputerSerialNumber() Broken in - DroopyLib 4.61.005

Post by Mohawk70 »

Updated to DroopyLib 4.61.005 just now and ComputerSerialNumber() returns
n/a
Yesterday it was working fine and returned ( not sure which version DroopyLib that was )
LUS410B0729121AFF22548
WinXP Home x86 SP3
PureBasic 4.61 x86
DroopyLib 4.61.005

This may be a bug in DroopyLib 4.61.005 or maybe it was caused by a Windows update,

I'm not sure. Please look into this.
HP Z800 Workstation
CPU : Dual Xeon 5690 3.46GHz
RAM : 96GB RAM ( 8GB x 12 )
PSU : 1100W
GPU : NVIDIA RTX 3050 8GB
STORAGE : 9TB
(4) 2TB Seagate IronWolf Pro HDD
(1) 1TB Samsung 870 EVO SSD
Korolev Michael
Enthusiast
Enthusiast
Posts: 200
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: DroopyLib

Post by Korolev Michael »

Please update changelog.
Former user of pirated PB.
Now registered user :].
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: DroopyLib

Post by ABBKlaus »

@Mohawk70 it was an unicode issue, unfortunately my result is always "System Serial Number" :?

Here is the bugfixed version of ComputerSerialNumber() :

Code: Select all

EnableExplicit

ProcedureDLL.l String2Unicode(string.s) ; Converts string To Unicode
  Protected *out
  *out = AllocateMemory((Len(string)+1)*2) ; Hint : memory pointer has to be freed later !
  PokeS(*out,string,-1,#PB_Unicode)
  ProcedureReturn *out  
EndProcedure 

ProcedureDLL.s Unicode2String(Pointer) ; Converts Unicode to string
  ProcedureReturn PeekS(Pointer,-1,#PB_Unicode)
EndProcedure

;{ WMI CONSTANT FUNCTIONs STRUCTUREs
#VT_EMPTY = 0 
#VT_NULL = 1
#VT_I2 = 2
#VT_I4 = 3 
#VT_R4 = 4
#VT_R8 = 5
#VT_CY = 6
#VT_DATE = 7
#VT_BSTR = 8
#VT_DISPATCH = 9
#VT_ERROR = 10
#VT_BOOL = 11
#VT_VARIANT = 12
#VT_UNKNOWN = 13
#VT_DECIMAL = 14
#VT_I1 = 16 
#VT_UI1 = 17
#VT_UI2 = 18
#VT_UI4 = 19
#VT_I8 = 20
#VT_UI8 = 21
#VT_INT = 22
#VT_UINT = 23
#VT_VOID = 24
#VT_HRESULT = 25
#VT_PTR = 26
#VT_SAFEARRAY = 27
#VT_CARRAY = 28
#VT_USERDEFINED = 29
#VT_LPSTR = 30
#VT_LPWSTR = 31
#VT_RECORD = 36
#VT_INT_PTR = 37
#VT_UINT_PTR = 38 
#VT_FILETIME = 64 
#VT_BLOB = 65 
#VT_STREAM = 66 
#VT_STORAGE = 67 
#VT_STREAMED_OBJECT = 68 
#VT_STORED_OBJECT = 69 
#VT_BLOB_OBJECT = 70 
#VT_CF = 71 
#VT_CLSID = 72
#VT_VERSIONED_STREAM = 73
#VT_BSTR_BLOB = $FFF 
#VT_VECTOR = $1000 
#VT_ARRAY = $2000 
#VT_BYREF = $4000 
#VT_RESERVED = $8000 
#VT_ILLEGAL = $FFFF 
#VT_ILLEGALMASKED = $FFF 
#VT_TYPEMASK = $FFF 
#COINIT_MULTITHREAD = 0
#RPC_C_AUTHN_LEVEL_CONNECT = 2
#RPC_C_IMP_LEVEL_IDENTIFY = 2
#EOAC_NONE = 0
#RPC_C_AUTHN_WINNT = 10
#RPC_C_AUTHZ_NONE = 0
#RPC_C_AUTHN_LEVEL_CALL = 3
#RPC_C_IMP_LEVEL_IMPERSONATE = 3
#CLSCTX_INPROC_SERVER = 1
#wbemFlagReturnImmediately = 16
#wbemFlagForwardOnly = 32
#IFlags = #wbemFlagReturnImmediately + #wbemFlagForwardOnly
#WBEM_INFINITE = $FFFFFFFF
#VARIANT_FALSE = $0000 
#WMISeparator = "," 
;}

ProcedureDLL.s WMI(WMICommand.s,Caption) ; Interrogate WMI Database
  Protected hres,wmi$,k,i,uReturn,nDim,val.s,plUbound,z,rgVar,wcharbuf1,wcharbuf2,wcharbuf3,wcharbuf4
  Protected loc.IWbemLocator
  Protected svc.IWbemServices
  Protected pUnk.IUnknown
  Protected pEnumerator.IEnumWbemClassObject
  Protected pclsObj.IWbemClassObject
  Protected x.Variant
  
  ;// Caption = #true if you want caption
  ;// MSDN : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_wmi.asp
  
  ;- WMI Initialize
  CoInitializeEx_(0,#COINIT_MULTITHREAD)
  hres=CoInitializeSecurity_(0, -1,0,0,#RPC_C_AUTHN_LEVEL_CONNECT,#RPC_C_IMP_LEVEL_IDENTIFY,0,#EOAC_NONE,0)
  If hres <> 0: MessageRequester("ERROR", "unable to call CoInitializeSecurity", #MB_OK)
    Goto WMI_Cleanup
  EndIf
  hres=CoCreateInstance_(?CLSID_WbemLocator,0,#CLSCTX_INPROC_SERVER,?IID_IWbemLocator,@loc.IWbemLocator)
  If hres <> 0: MessageRequester("ERROR", "unable to call CoCreateInstance", #MB_OK)
    Goto WMI_Cleanup
  EndIf
  wcharbuf1=String2Unicode("root\cimv2")
  hres=loc\ConnectServer(wcharbuf1,0,0,0,0,0,0,@svc.IWbemServices)
  If hres <> 0: MessageRequester("ERROR", "unable to call IWbemLocator::ConnectServer", #MB_OK)
    Goto WMI_Cleanup
  EndIf
  hres=svc\queryinterface(?IID_IUnknown,@pUnk.IUnknown)
  hres=CoSetProxyBlanket_(svc,#RPC_C_AUTHN_WINNT,#RPC_C_AUTHZ_NONE,0,#RPC_C_AUTHN_LEVEL_CALL,#RPC_C_IMP_LEVEL_IMPERSONATE,0,#EOAC_NONE)
  If hres <> 0: MessageRequester("ERROR", "unable to call CoSetProxyBlanket", #MB_OK)
    Goto WMI_Cleanup
  EndIf
  hres=CoSetProxyBlanket_(pUnk,#RPC_C_AUTHN_WINNT,#RPC_C_AUTHZ_NONE,0,#RPC_C_AUTHN_LEVEL_CALL,#RPC_C_IMP_LEVEL_IMPERSONATE,0,#EOAC_NONE)
  If hres <> 0: MessageRequester("ERROR", "unable to call CoSetProxyBlanket", #MB_OK)
    Goto WMI_Cleanup
  EndIf
  pUnk\release()
  
  
  ;- CallData
  k=CountString(WMICommand,#WMISeparator)
  Dim wmitxt$(k)
  For i=0 To k
    wmitxt$(i) = Trim(StringField(WMICommand,i+1,#WMISeparator))
  Next
  
  wcharbuf2=String2Unicode("WQL")
  wcharbuf3=String2Unicode(wmitxt$(0))
  hres=svc\ExecQuery(wcharbuf2,wcharbuf3, #IFlags,0,@pEnumerator.IEnumWbemClassObject)
  If hres <> 0: MessageRequester("ERROR", "unable to call IWbemServices::ExecQuery", #MB_OK)
    Goto WMI_Cleanup
  EndIf
  hres=pEnumerator\reset()
  
  Repeat
    hres=pEnumerator\Next(#WBEM_INFINITE, 1, @pclsObj.IWbemClassObject, @uReturn)
    For i=1 To k
      wcharbuf4=String2Unicode(wmitxt$(i))
      hres=pclsObj\get(wcharbuf4, 0, @x.Variant, 0, 0)
      
      Select x\vt
          
        Case 8200
          val.s=""
          nDim=SafeArrayGetDim_(x\lVal)
          SafeArrayGetUBound_(x\lVal, nDim, @plUbound)
          ;Dim rgVar(plUbound)
          For z=0 To plUbound
            SafeArrayGetElement_(x\lVal, @z, @rgVar)
            val.s=val.s+", "+Unicode2String(rgVar)
          Next
          val.s=Mid(val.s, 3, Len(val.s))
          
        Case 8195
          val.s=""
          nDim=SafeArrayGetDim_(x\scode)
          SafeArrayGetUBound_(x\scode, nDim, @plUbound)
          ;Dim rgVar(plUbound)
          For z=0 To plUbound
            SafeArrayGetElement_(x\scode, @z, @rgVar)
            val.s=val.s + ", " +  Str(rgVar) 
          Next
          val.s=Mid(val.s, 3, Len(val.s))
          
        Case 11
          If x\boolVal=0
            val.s="FALSE" 
          ElseIf x\boolVal=-1
            val.s="TRUE"
          EndIf
          
        Case 8
          val.s=Unicode2String(x\bstrVal)
          
        Case 3
          val.s=Str(x\lVal)
          
        Case 1
          val.s="n/a"
          
        Default
          val.s=""
          
      EndSelect
      
      If uReturn <> 0
        If wmi$<>"" : wmi$+#CRLF$ : EndIf
        
        If Caption ; Show caption
          wmi$=wmi$+wmitxt$(i)+" = "+val
        Else
          wmi$=wmi$+val
        EndIf
      EndIf
      If wcharbuf4
        FreeMemory(wcharbuf4)
        wcharbuf4=0
      EndIf
    Next
  Until uReturn = 0
  
  WMI_Cleanup:
  ;- Cleanup
  If svc
    svc\release()
  EndIf
  If loc
    loc\release()
  EndIf
  If pEnumerator
    pEnumerator\release()
  EndIf
  If pclsObj
    pclsObj\release()
  EndIf
  CoUninitialize_()
  If wcharbuf1
    FreeMemory(wcharbuf1)
  EndIf
  If wcharbuf2
    FreeMemory(wcharbuf2)
  EndIf
  If wcharbuf3
    FreeMemory(wcharbuf3)
  EndIf
  ProcedureReturn wmi$
EndProcedure

;{- WMI DataSection
DataSection
  
  CLSID_IEnumWbemClassObject:
  ;1B1CAD8C-2DAB-11D2-B604-00104B703EFD
  Data.l $1B1CAD8C
  Data.w $2DAB, $11D2
  Data.b $B6, $04, $00, $10, $4B, $70, $3E, $FD
  IID_IEnumWbemClassObject:
  ;7C857801-7381-11CF-884D-00AA004B2E24
  Data.l $7C857801
  Data.w $7381, $11CF
  Data.b $88, $4D, $00, $AA, $00, $4B, $2E, $24
  CLSID_WbemLocator:
  ;4590f811-1d3a-11d0-891f-00aa004b2e24
  Data.l $4590F811
  Data.w $1D3A, $11D0
  Data.b $89, $1F, $00, $AA, $00, $4B, $2E, $24
  IID_IWbemLocator:
  ;dc12a687-737f-11cf-884d-00aa004b2e24
  Data.l $DC12A687
  Data.w $737F, $11CF
  Data.b $88, $4D, $00, $AA, $00, $4B, $2E, $24
  IID_IUnknown:
  ;00000000-0000-0000-C000-000000000046
  Data.l $00000000
  Data.w $0000, $0000
  Data.b $C0, $00, $00, $00, $00, $00, $00, $46
  
EndDataSection
;}

ProcedureDLL.s ComputerSerialNumber() ; Retrieve the Computer Serial Number
  ProcedureReturn WMI("SELECT * FROM Win32_BIOs,SerialNumber",#False)
EndProcedure

Debug ComputerSerialNumber()
Mohawk70
Enthusiast
Enthusiast
Posts: 404
Joined: Thu May 11, 2006 1:04 am
Location: Florida, USA

Re: DroopyLib

Post by Mohawk70 »

Thank you !
HP Z800 Workstation
CPU : Dual Xeon 5690 3.46GHz
RAM : 96GB RAM ( 8GB x 12 )
PSU : 1100W
GPU : NVIDIA RTX 3050 8GB
STORAGE : 9TB
(4) 2TB Seagate IronWolf Pro HDD
(1) 1TB Samsung 870 EVO SSD
Post Reply