Andreik Posted November 2, 2012 Share Posted November 2, 2012 (edited) Hey guys, I'm trying to get CPU's manufacturer ID string using cpuid instruction. I have a binary code obtained with FASM UDF and I use native DllCallAddress function to call the binary code in memory. All things are fine but I can't manage the result. After executing cpuid the result is stored in 3 different registers ebc, ecx and edx and only eax is returned by DllCallAddress function. Is there any way to get all obtained data in a single call or should I call the function 3 times and everytime copy ebc, ecx and edx in eax before return?? Edited November 2, 2012 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
KaFu Posted November 2, 2012 Share Posted November 2, 2012 Hmmm, I really don't know , but maybe reading from registry is sufficient as a workaround? RegRead ("HKEY_LOCAL_MACHINEHARDWAREDESCRIPTIONSystemCentralProcessor0","VendorIdentifier") OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
DicatoroftheUSA Posted November 2, 2012 Share Posted November 2, 2012 (edited) From the command line "wmic cpu" There is a straight up equivelent. expandcollapse popup; Generated by AutoIt Scriptomatic November 02, 2012 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output &= "AddressWidth: " & $objItem.AddressWidth & @CRLF $Output &= "Architecture: " & $objItem.Architecture & @CRLF $Output &= "Availability: " & $objItem.Availability & @CRLF $Output &= "Caption: " & $objItem.Caption & @CRLF $Output &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF $Output &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF $Output &= "CpuStatus: " & $objItem.CpuStatus & @CRLF $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output &= "CurrentClockSpeed: " & $objItem.CurrentClockSpeed & @CRLF $Output &= "CurrentVoltage: " & $objItem.CurrentVoltage & @CRLF $Output &= "DataWidth: " & $objItem.DataWidth & @CRLF $Output &= "Description: " & $objItem.Description & @CRLF $Output &= "DeviceID: " & $objItem.DeviceID & @CRLF $Output &= "ErrorCleared: " & $objItem.ErrorCleared & @CRLF $Output &= "ErrorDescription: " & $objItem.ErrorDescription & @CRLF $Output &= "ExtClock: " & $objItem.ExtClock & @CRLF $Output &= "Family: " & $objItem.Family & @CRLF $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output &= "L2CacheSize: " & $objItem.L2CacheSize & @CRLF $Output &= "L2CacheSpeed: " & $objItem.L2CacheSpeed & @CRLF $Output &= "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output &= "Level: " & $objItem.Level & @CRLF $Output &= "LoadPercentage: " & $objItem.LoadPercentage & @CRLF $Output &= "Manufacturer: " & $objItem.Manufacturer & @CRLF $Output &= "MaxClockSpeed: " & $objItem.MaxClockSpeed & @CRLF $Output &= "Name: " & $objItem.Name & @CRLF $Output &= "NumberOfCores: " & $objItem.NumberOfCores & @CRLF $Output &= "NumberOfLogicalProcessors: " & $objItem.NumberOfLogicalProcessors & @CRLF $Output &= "OtherFamilyDescription: " & $objItem.OtherFamilyDescription & @CRLF $Output &= "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output &= "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output &= "ProcessorId: " & $objItem.ProcessorId & @CRLF $Output &= "ProcessorType: " & $objItem.ProcessorType & @CRLF $Output &= "Revision: " & $objItem.Revision & @CRLF $Output &= "Role: " & $objItem.Role & @CRLF $Output &= "SocketDesignation: " & $objItem.SocketDesignation & @CRLF $Output &= "Status: " & $objItem.Status & @CRLF $Output &= "StatusInfo: " & $objItem.StatusInfo & @CRLF $Output &= "Stepping: " & $objItem.Stepping & @CRLF $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output &= "SystemName: " & $objItem.SystemName & @CRLF $Output &= "UniqueId: " & $objItem.UniqueId & @CRLF $Output &= "UpgradeMethod: " & $objItem.UpgradeMethod & @CRLF $Output &= "Version: " & $objItem.Version & @CRLF $Output &= "VoltageCaps: " & $objItem.VoltageCaps & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Processor" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc Edit: Sorry I assumed this was for general support, I doubt it helps for what you are looking for. Edited November 2, 2012 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki Link to comment Share on other sites More sharing options...
water Posted November 2, 2012 Share Posted November 2, 2012 As Andreik uses binary code or DLLCalls performance might be an issue. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Andreik Posted November 2, 2012 Author Share Posted November 2, 2012 (edited) Thanks guys for inputs but I'm not interesed especially to get this specific information as much to know how to get all data from this registers in a single call. If I would need just to get VendorID your code would be nice. EDIT: I'm such an idiot, I could pass a string and add the content of registers to it. #AutoIt3Wrapper_UseX64=n #include <Memory.au3> MsgBox(0,"",GetVendorID()) Func GetVendorID() $Code = "0x" & _ ; use32 "55" & _ ; push ebp "89E5" & _ ; mov ebp, esp "60" & _ ; pushad "B800000000" & _ ; mov eax,0 "0FA2" & _ ; cpuid "8B7D08" & _ ; mov edi, [ebp + 08] "891F" & _ ; mov [edi], ebx "895704" & _ ; mov [edi + 4], edx "894F08" & _ ; mov [edi + 8], ecx "B000" & _ ; mov al, 0 "88470C" & _ ; mov [edi + 12], al "61" & _ ; popad "5D" & _ ; pop ebp "C20400" ; ret 4 $iSize = BinaryLen($Code) $pBuffer = _MemVirtualAlloc(0,$iSize,$MEM_COMMIT,$PAGE_EXECUTE_READWRITE) $tBuffer = DllStructCreate("byte Code[" & $iSize & "]",$pBuffer) DllStructSetData($tBuffer,"Code",$Code) $aRet = DllCallAddress("int",$pBuffer,"str","") _MemVirtualFree($pBuffer,$iSize,$MEM_DECOMMIT) Return $aRet[1] EndFunc Edited November 2, 2012 by Andreik trancexx and Bilgus 2 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
danielkza Posted November 3, 2012 Share Posted November 3, 2012 As Andreik uses binary code or DLLCalls performance might be an issue.Why would you ever need to get the VendorID more than once? Link to comment Share on other sites More sharing options...
Mat Posted November 4, 2012 Share Posted November 4, 2012 You would have to create a struct in AutoIt, pass the pointer to fasm, then fill it with the register values. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Andreik Posted November 4, 2012 Author Share Posted November 4, 2012 (edited) Why would you ever need to get the VendorID more than once?You should read above that initialy I choose this strange method.After executing cpuid the result is stored in 3 different registers ebc, ecx and edx and only eax is returned by DllCallAddress function. Is there any way to get all obtained data in a single call or should I call the function 3 times and everytime copy ebc, ecx and edx in eax before return??@Mat thank you man Edited November 4, 2012 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
danielkza Posted November 4, 2012 Share Posted November 4, 2012 Is that a dumb question? You should read above.My remark applies even if you want the whole CPU information. Performance is irrelevant since you never need to do it more than once: use WMI which is the easy route, or DLLCall some other library, there's no point in trying to do it in assembly yourself. Link to comment Share on other sites More sharing options...
Andreik Posted November 4, 2012 Author Share Posted November 4, 2012 Ohh now your point it's more clear. muttley It's right but looks very ugly to call almost same code 3 times when I was sure it can be done in a single call. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 4, 2012 Share Posted November 4, 2012 It can be a single call. You just have to return a more complex structure. Link to comment Share on other sites More sharing options...
trancexx Posted November 4, 2012 Share Posted November 4, 2012 (edited) Raise hand who didn't bother much reading Andreik's posts. Let's see: Mat, Richard, ... Btw, very nice code Andreik, you are even taking care of surely null-terminating the string. Well done. Edited November 4, 2012 by trancexx Andreik 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 5, 2012 Share Posted November 5, 2012 It's called a confirmation. Link to comment Share on other sites More sharing options...
trancexx Posted November 6, 2012 Share Posted November 6, 2012 (edited) It's called a confirmation.If I would say "A rite of initiation in some churches?", that would be like we are playing Jeopardy. Can you confirm that too? Edited November 6, 2012 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 7, 2012 Share Posted November 7, 2012 If I would say "A rite of initiation in some churches?", that would be like we are playing Jeopardy. Can you confirm that too?You are the person on this forum that I have the most difficulty formulating replies to. Link to comment Share on other sites More sharing options...
trancexx Posted November 7, 2012 Share Posted November 7, 2012 That's because you try too hard. Don't worry Richard, I'm sure it's my fault. Yes, I know you are not worried. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jchd Posted November 8, 2012 Share Posted November 8, 2012 Wikipeding is enough to get it (if at all needed). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now