• Welcome to Valhalla Legends Archive.
 

SID_SYSTEMINFO (0x2B)

Started by Barabajagal, February 06, 2007, 02:11 PM

Previous topic - Next topic

Barabajagal

#15
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?

UserLoser

I am pretty sure there were some bit shifting used in calculating this value.

Barabajagal

...Any further information on that would be much appreciated.

UserLoser

Quote from: [RealityRipple] on February 11, 2007, 01:57 AM
...Any further information on that would be much appreciated.

See: battle.snp

Hdx

#19
Wow. I am in Battle.snp and its got some crazy/stupid crap >.<
.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
Who in there right freakin mind does crap like that!?!?!?!?
~Hdx

.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

~Hdx

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Barabajagal

#20
For those of you using vb... that converts to
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


Still working on the drive size issue...

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.


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

ShadowDancer

#22
edit: i havent said anything productive :(
Quote from: MyndFyre-vL
No. We help people who help themselves.
http://sourceforge.net/projects/d2gs
http://assembla.com/space/d2gs

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.

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?

UserLoser

Quote from: [RealityRipple] on February 11, 2007, 03:13 PM
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?

Should have already been there if you use BnetDocs.  There are some ways yes, but can get messy

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....