Valhalla Legends Forums Archive | Battle.net Bot Development | SID_SYSTEMINFO (0x2B)

AuthorMessageTime
Barabajagal
Anyone happen to know how all these values are gathered? a packet log of SSHR returns:

[code]
Processors:  01 00 00 00
Architecture: 00 00 00 00
Level:        06 00 00 00
Timing:      00 05 00 00
Phys Mem:    00 04 00 00
Page Mem:    FF 0F 00 00
Free Disk:    17 0F 00 00
[/code]

I've used a few API calls, but I can't get all the data to show up the same. Using GetSystemInfo, I can get the processor count, what i think is the architecture (dwOemID), and nothing else. using GetDiskFreeSpaceExA gets me nothing, since my free disk space is too big for a long to handle. Physical and page file memory much the same. Anybody got a clue as to how to get this data?
February 6, 2007, 8:11 PM
Myndfyr
Page Mem is 4095, which suggests to me that it's telling Blizzard your process memory, 4gb.

Free Disk is 3863.  Does your disk have a 1024-multiple of that available?
February 6, 2007, 8:23 PM
Barabajagal
I have 53,062,500,352 bytes free on my primary hard drive. Not divisible by 3863 evenly. My page file is set to 4095 megs, and I apparently can get that through dwPageSize with GetSystemInfo. I can also get the RAM size. Any idea about the other values?

Edit: Ran it again and got a Timing of B8 0B 00 00 this time.

So, to make it more clear, I still need to determine the Level, Timing, and Disk space.
February 6, 2007, 8:32 PM
TheMinistered
Isn't this what msdn is for?  All of this data should be easily available through some api call, which I dunno off the top of my head except the ones you listed.  BUT YOU SHOULD BE ABLE TO FIND THIS SHIT ;)
February 7, 2007, 5:10 AM
UserLoser
GetSystemInfo, GlobalMemoryStatus, GetDiskFreeSpace should be sufficient enough to build the packet.
February 8, 2007, 12:01 AM
Barabajagal
You'd think it would. But like I said, the client returns 3863 for the hard drive free space when it was 53,062,500,352 bytes, and I can't find any divisors to get that result reliably. There's also no Processor Level or Timing variables in any APIs I can find.
February 8, 2007, 12:24 AM
Skywing
[quote author=[RealityRipple] link=topic=16255.msg164257#msg164257 date=1170894249]
You'd think it would. But like I said, the client returns 3863 for the hard drive free space when it was 53,062,500,352 bytes, and I can't find any divisors to get that result reliably. There's also no Processor Level or Timing variables in any APIs I can find.
[/quote]
Perhaps it might be more productive to analyze how an actual game client builds this message?
February 8, 2007, 1:46 AM
Barabajagal
How would I go about doing that? I have no knowledge in current day assembly (I only know MONITOR for the Commodore 64 and 128). If I did, I'd be working on Lockdown, not a packet that only one ancient client uses.
February 8, 2007, 1:59 AM
UserLoser
[quote author=[RealityRipple] link=topic=16255.msg164269#msg164269 date=1170899970]
How would I go about doing that? I have no knowledge in current day assembly (I only know MONITOR for the Commodore 64 and 128). If I did, I'd be working on Lockdown, not a packet that only one ancient client uses.
[/quote]

Then perhaps you should be spending your time on something else, but like I said, GetDiskFreeSpace will give you what you need for the last part of that message.
February 8, 2007, 2:07 AM
Skywing
[quote author=[RealityRipple] link=topic=16255.msg164269#msg164269 date=1170899970]
How would I go about doing that? I have no knowledge in current day assembly (I only know MONITOR for the Commodore 64 and 128). If I did, I'd be working on Lockdown, not a packet that only one ancient client uses.
[/quote]
There is no time like the present to learn.

I would recommend getting yourself a diassembler, a debugger (includes extensive documentation and some tutorials and walkthroughs on various real world debugging scenarios), and some x86 assembly language documentation.  Some documentation on Win32 calling conventions would additionally be useful, as you're likely just going to need to figure out some simple calls to standard Win32 functions.  You can find information on Win32 APIs online at MSDN.

All of the above are freely available, and spending a short time learning how to use them will be the start of building some valuable skills for a software development job to boot.
February 8, 2007, 2:23 AM
Barabajagal
Thank you for the links Sky, I'll check em out when my computer isn't being such a little bitch and I can replace the RAM that's been corrupted.
UserLoser, GetDiskFreeSpace returns: 8 sectors per cluster , 512 bytes per sector , 16038174 free clusters , 29302552 total clusters, and SSHR now gives me 1F 0F 00 00 (I reformatted completely last night, so the numbers are a bit different now). 1F 0F 00 00 means 3871, right? I still don't see how it gets the value...
February 8, 2007, 2:37 AM
Barabajagal
Well that's nice... I now get DF 05 00 00 (1503) for a page file size, since I set my page file to be anywhere from 1024 megs to 4095 megs. The GetSystemInfo API returns 4096, though. Guess I'll have to wait till I can disassemble it myself.
February 8, 2007, 11:10 PM
UserLoser
IIRC, performs math on sectors per cluster, bytes per sector, and free clusters, not sure though.
February 8, 2007, 11:24 PM
Barabajagal
I've tried  bytes per sector * sectors per cluster * free clusters, which gives me 65692360704 free bytes total. Divide that by 3871 to see if there's any multiple there, and you get 16970385.095324205631619736502196. Definitely not an even multiple. I've tried other such combinations of the values, and gotten nothing that links 3871. If I'm doing something wrong, I'd really like to know.
February 8, 2007, 11:29 PM
Barabajagal
Well, if i use the non-standard SYSTEM_INFO definition, I can get the Processor Level, but I still can't figure out the timing or how to get the correct hard drive info. The disassembler is too big for me to download on dial up, so that's not really an option for me at the moment.

I've tried a few logs to figure out what the timing is, and it started at 2840, went up to 2850 the next time, then 2860, 2870, and back down to 2850. I'm a bit confused as to what it is...
February 10, 2007, 11:59 PM
Barabajagal
I just added 12 gb of useless data [10% of my total drive space] (using the DOS DEBUG command), and the "Free Disk Space" didn't change at all. It's still at 1F 0F 00 00, like it's been since I reformatted. It's either the total disk size, or not hard drive related at all.

Edit: Used Partition Magic to remove about 1 GB (1077514240 bytes). Total sectors dropped from 29302552 to 29039487 (263065 sector difference). the Disk Space field went from 1F 0F 00 00 to 1B 0B 00 00. This isn't making much sense to me... since if you divide the sector difference (263065) by the field difference (1028 [3871-2843 {F1F-B1B}]), you get a bit under 256. it would then make sense that if you multiply 256 by the current Field (2843 [B1B]), you would get the current number of sectors, which is 29039487. Instead, you get 727808....

Am I doing something completely wrong here?
February 11, 2007, 3:46 AM
UserLoser
I am pretty sure there were some bit shifting used in calculating this value.
February 11, 2007, 7:44 AM
Barabajagal
...Any further information on that would be much appreciated.
February 11, 2007, 7:57 AM
UserLoser
[quote author=[RealityRipple] link=topic=16255.msg164554#msg164554 date=1171180627]
...Any further information on that would be much appreciated.
[/quote]

See: battle.snp
February 11, 2007, 8:12 AM
HdxBmx27
Wow. I am in Battle.snp and its got some crazy/stupid crap >.<
[code].text:19014006 loc_19014006:                          ; CODE XREF: sub_19013FD0+49j
.text:19014006                add    eax, ebx
.text:19014008                add    eax, ebx
.text:1901400A                add    eax, ebx
.text:1901400C                add    eax, ebx
.text:1901400E                add    eax, ebx
.text:19014010                add    eax, ebx
.text:19014012                add    eax, ebx
.text:19014014                add    eax, ebx
.text:19014016                add    eax, ebx
.text:19014018                dec    ecx
.text:19014019                jnz    short loc_19014006
[/code]Who in there right freakin mind does crap like that!?!?!?!?
~Hdx

[code].text:19013FD0
.text:19013FD0 ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
.text:19013FD0
.text:19013FD0 ; Attributes: bp-based frame
.text:19013FD0
.text:19013FD0 sub_19013FD0    proc near              ; CODE XREF: sub_19013010:loc_190131F2p
.text:19013FD0
.text:19013FD0 RootPathName    = byte ptr -174h
.text:19013FD0 SystemInfo      = _SYSTEM_INFO ptr -70h
.text:19013FD0 Buffer          = _MEMORYSTATUS ptr -4Ch
.text:19013FD0 var_2C          = dword ptr -2Ch
.text:19013FD0 var_28          = dword ptr -28h
.text:19013FD0 var_24          = dword ptr -24h
.text:19013FD0 var_20          = dword ptr -20h
.text:19013FD0 var_1C          = dword ptr -1Ch
.text:19013FD0 var_18          = dword ptr -18h
.text:19013FD0 var_14          = dword ptr -14h
.text:19013FD0 NumberOfFreeClusters= dword ptr -10h
.text:19013FD0 SectorsPerCluster= dword ptr -0Ch
.text:19013FD0 TotalNumberOfClusters= dword ptr -8
.text:19013FD0 BytesPerSector  = dword ptr -4
.text:19013FD0
.text:19013FD0                push    ebp
.text:19013FD1                mov    ebp, esp
.text:19013FD3                sub    esp, 174h
.text:19013FD9                push    ebx
.text:19013FDA                push    esi
.text:19013FDB                push    edi
.text:19013FDC                mov    edi, ds:GetTickCount
.text:19013FE2                call    edi ; GetTickCount
.text:19013FE4                mov    ebx, eax
.text:19013FE6                call    edi ; GetTickCount
.text:19013FE8                mov    esi, eax
.text:19013FEA                cmp    esi, ebx
.text:19013FEC                jnz    short loc_19013FF6
.text:19013FEE
.text:19013FEE loc_19013FEE:                          ; CODE XREF: sub_19013FD0+24j
.text:19013FEE                call    edi ; GetTickCount
.text:19013FF0                mov    esi, eax
.text:19013FF2                cmp    esi, ebx
.text:19013FF4                jz      short loc_19013FEE
.text:19013FF6
.text:19013FF6 loc_19013FF6:                          ; CODE XREF: sub_19013FD0+1Cj
.text:19013FF6                xor    ebx, ebx
.text:19013FF8                call    edi ; GetTickCount
.text:19013FFA                sub    eax, esi
.text:19013FFC                cmp    eax, 32h
.text:19013FFF                jnb    short loc_19014025
.text:19014001
.text:19014001 loc_19014001:                          ; CODE XREF: sub_19013FD0+53j
.text:19014001                mov    ecx, 2710h
.text:19014006
.text:19014006 loc_19014006:                          ; CODE XREF: sub_19013FD0+49j
.text:19014006                add    eax, ebx
.text:19014008                add    eax, ebx
.text:1901400A                add    eax, ebx
.text:1901400C                add    eax, ebx
.text:1901400E                add    eax, ebx
.text:19014010                add    eax, ebx
.text:19014012                add    eax, ebx
.text:19014014                add    eax, ebx
.text:19014016                add    eax, ebx
.text:19014018                dec    ecx
.text:19014019                jnz    short loc_19014006
.text:1901401B                inc    ebx
.text:1901401C                call    edi ; GetTickCount
.text:1901401E                sub    eax, esi
.text:19014020                cmp    eax, 32h
.text:19014023                jb      short loc_19014001
.text:19014025
.text:19014025 loc_19014025:                          ; CODE XREF: sub_19013FD0+2Fj
.text:19014025                lea    eax, [ebp+SystemInfo]
.text:19014028                push    eax            ; lpSystemInfo
.text:19014029                call    ds:GetSystemInfo
.text:1901402F                lea    ecx, [ebp+Buffer]
.text:19014032                mov    [ebp+Buffer.dwLength], 20h
.text:19014039                push    ecx            ; lpBuffer
.text:1901403A                call    ds:GlobalMemoryStatus
.text:19014040                lea    edx, [ebp+RootPathName]
.text:19014046                push    104h            ; nSize
.text:1901404B                push    edx            ; lpFilename
.text:1901404C                push    0              ; hModule
.text:1901404E                call    ds:GetModuleFileNameA
.text:19014054                lea    eax, [ebp+TotalNumberOfClusters]
.text:19014057                lea    ecx, [ebp+NumberOfFreeClusters]
.text:1901405A                push    eax            ; lpTotalNumberOfClusters
.text:1901405B                lea    edx, [ebp+BytesPerSector]
.text:1901405E                push    ecx            ; lpNumberOfFreeClusters
.text:1901405F                lea    eax, [ebp+SectorsPerCluster]
.text:19014062                push    edx            ; lpBytesPerSector
.text:19014063                lea    ecx, [ebp+RootPathName]
.text:19014069                push    eax            ; lpSectorsPerCluster
.text:1901406A                push    ecx            ; lpRootPathName
.text:1901406B                mov    byte ptr [ebp-171h], 0
.text:19014072                call    ds:GetDiskFreeSpaceA
.text:19014078                mov    eax, dword ptr [ebp+SystemInfo.anonymous_0]
.text:1901407B                mov    edx, [ebp+SystemInfo.dwNumberOfProcessors]
.text:1901407E                and    eax, 0FFFFh
.text:19014083                mov    [ebp+var_2C], edx
.text:19014086                mov    [ebp+var_28], eax
.text:19014089                lea    edx, [ebx+ebx+5]
.text:1901408D                mov    eax, 0CCCCCCCDh
.text:19014092                mov    ecx, dword ptr [ebp+SystemInfo.wProcessorLevel]
.text:19014095                mul    edx
.text:19014097                shr    edx, 3
.text:1901409A                and    ecx, 0FFFFh
.text:190140A0                push    1Ch
.text:190140A2                lea    eax, [edx+edx*4]
.text:190140A5                mov    edx, [ebp+Buffer.dwTotalPageFile]
.text:190140A8                shl    eax, 1
.text:190140AA                mov    [ebp+var_20], eax
.text:190140AD                mov    eax, [ebp+TotalNumberOfClusters]
.text:190140B0                imul    eax, [ebp+BytesPerSector]
.text:190140B4                imul    eax, [ebp+SectorsPerCluster]
.text:190140B8                mov    [ebp+var_24], ecx
.text:190140BB                mov    ecx, [ebp+Buffer.dwTotalPhys]
.text:190140BE                add    ecx, 0A0000h
.text:190140C4                shr    ecx, 14h
.text:190140C7                shr    edx, 14h
.text:190140CA                mov    [ebp+var_1C], ecx
.text:190140CD                mov    [ebp+var_18], edx
.text:190140D0                shr    eax, 14h
.text:190140D3                lea    edx, [ebp+var_2C]
.text:190140D6                mov    cl, 2Bh
.text:190140D8                mov    [ebp+var_14], eax
.text:190140DB                call    SendBNCSMessage
.text:190140E0                pop    edi
.text:190140E1                pop    esi
.text:190140E2                pop    ebx
.text:190140E3                mov    esp, ebp
.text:190140E5                pop    ebp
.text:190140E6                retn
.text:190140E6 sub_19013FD0    endp
.text:190140E6
[/code]
~Hdx
February 11, 2007, 9:33 AM
Barabajagal
For those of you using vb... that converts to
[code]FirstTick = GetTickCount
    Do
        CurrentTick = GetTickCount
    Loop While CurrentTick = FirstTick
    ProcessorSpeed = GetTickCount - CurrentTick
    Do
        For I = 10000 To 0 Step -1
            ProcessorSpeed = ProcessorSpeed + Counter + Counter + Counter + Counter_
+ Counter + Counter + Counter + Counter
            Counter = Counter + 1
        Next I
        ProcessorSpeed = GetTickCount - CurrentTick
    Loop While ProcessorSpeed < &H32[/code]

Still working on the drive size issue...
February 11, 2007, 9:42 AM
Barabajagal
Figured it out. If there's a better way to do the Hard Drive size thing in vb, I'd LOVE to know. This way seems so crappy, but it works.

[code]
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Private Declare Function GetDiskFreeSpaceA Lib "kernel32"_
(ByVal lpRootPathName As String, lpSectorsPerCluster As Long,_
lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long

Private Type SYSTEM_INFO
    wProcessorArchitecture          As Integer
    wReserved                        As Integer
    dwPageSize                      As Long
    lpMinimumApplicationAddress      As Long
    lpMaximumApplicationAddress      As Long
    dwActiveProcessorMask            As Long
    dwNumberOfProcessors            As Long
    dwProcessorType                  As Long
    dwAllocationGranularity          As Long
    wProcessorLevel                  As Integer
    wProcessorRevision              As Integer
End Type

Private Type MEMORYSTATUS
    dwLength                        As Long
    dwMemoryLoad                    As Long
    dwTotalPhys                      As Long
    dwAvailPhys                      As Long
    dwTotalPageFile                  As Long
    dwAvailPageFile                  As Long
    dwTotalVirtual                  As Long
    dwAvailVirtual                  As Long
End Type

Public Sub GetSysInfo(ByRef ProcCount As Long, ByRef ProcArch As Long,_
ByRef ProcLev As Long, ByRef ProcTime As Long, ByRef TotalMem As Long,_
ByRef PageFile As Long, ByRef DiskSpace As Long)
Dim Mem            As MEMORYSTATUS
Dim sys            As SYSTEM_INFO
Dim DrSize        As Double
Dim SperC          As Long
Dim BperS          As Long
Dim Free          As Long
Dim Total          As Long
Dim FirstTick      As Long
Dim CurrentTick    As Long
Dim ProcessorSpeed As Double
Dim Counter        As Long
Dim I              As Integer
    FirstTick = GetTickCount
    Do
        CurrentTick = GetTickCount
    Loop While CurrentTick = FirstTick
    ProcessorSpeed = GetTickCount - CurrentTick
    Do
        For I = 10000 To 0 Step -1
            ProcessorSpeed = ProcessorSpeed + Counter + Counter + Counter + Counter_
  + Counter + Counter + Counter + Counter
            Counter = Counter + 1
        Next I
        ProcessorSpeed = GetTickCount - CurrentTick
    Loop While ProcessorSpeed < &H32
    GetSystemInfo sys
    GlobalMemoryStatus Mem
    GetDiskFreeSpaceA Left$(App.Path, 3), SperC, BperS, Free, Total
    DrSize = CDbl(Total) * SperC * BperS
    ProcCount = sys.dwNumberOfProcessors
    ProcArch = sys.wProcessorArchitecture
    ProcLev = sys.wProcessorLevel
    ProcTime = ProcessorSpeed
    PageFile = RShift(CDbl(Mem.dwTotalPageFile), &H14)
    TotalMem = RShift(CDbl(Mem.dwTotalPhys), &H16)
    DiskSpace = CDbl("&H" & Right$(Hex$(RShift(DrSize, &H14)), 3))
End Sub

Private Function RShift(ByVal pnValue As Double, ByVal pnShift As Long) As Long
Dim Shft As String
    Shft = Str$(pnValue / (2 ^ pnShift))
    If InStr(Shft, ".") > 0 Then
        RShift = CLng(Left$(Shft, InStr(Shft, ".") - 1))
    Else
        RShift = CLng(Shft)
    End If
End Function
[/code]
February 11, 2007, 12:13 PM
ShadowDancer
edit: i havent said anything productive :(
February 11, 2007, 12:15 PM
UserLoser
RealityRipple forgot to comment that UserLoser wrote that code initially in C++ before RealityRipple crappily converted it to VB after UserLoser reversed the function in Starcraft Shareware's battle.snp for about five minutes last night then sent the resulting code to Hdx on AIM.

It looks like you guys never validated my processor timing calculation either and are just using my priliminary code that was untested, good job.
February 11, 2007, 9:00 PM
Barabajagal
Actually, I already added you to the credits in my bot last night for it... but I guess I should thank you on here. The processor timing code gives me 62 almost every time I run it, which seems way too fast compared to the client's result, but seeing as I still don't know assembly (and can't download anything from Skywing's post due to my 1.5 kb/s dial up), I can't help myself.

One other question: on my RShift function, i know it should be div (\), not divide (/), but div can't handle large numbers like hard drive sizes. Is there any OTHER way to cut off decimals without rounding up besides the crappy way I made at 4 AM last night?
February 11, 2007, 9:13 PM
UserLoser
[quote author=[RealityRipple] link=topic=16255.msg164576#msg164576 date=1171228416]
Actually, I already added you to the credits in my bot last night for it... but I guess I should thank you on here. The processor timing code gives me 62 almost every time I run it, which seems way too fast compared to the client's result, but seeing as I still don't know assembly (and can't download anything from Skywing's post due to my 1.5 kb/s dial up), I can't help myself.

One other question: on my RShift function, i know it should be div (\), not divide (/), but div can't handle large numbers like hard drive sizes. Is there any OTHER way to cut off decimals without rounding up besides the crappy way I made at 4 AM last night?
[/quote]

Should have already been there if you use BnetDocs.  There are some ways yes, but can get messy
February 11, 2007, 9:32 PM
Barabajagal
I already have a thank-you to "The Staff and Members of BNetDocs...", but now you're specifically thanked. So is the way I did it the best way in the limited language I'm using? I really need to learn more PowerBasic....
February 11, 2007, 9:35 PM

Search