Skip to content

Commit c14712e

Browse files
committed
More arm exploration of api responses
1 parent 779d35a commit c14712e

File tree

10 files changed

+192
-14
lines changed

10 files changed

+192
-14
lines changed

ctypes_generation/definitions/functions/sysinfo.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ BOOL LookupAccountNameW(
5959
LPWSTR ReferencedDomainName,
6060
LPDWORD cchReferencedDomainName,
6161
PSID_NAME_USE peUse
62+
);
63+
64+
PVOID GetNativeSystemInfo(
65+
[out] LPSYSTEM_INFO lpSystemInfo
66+
);
67+
68+
PVOID GetSystemInfo(
69+
[out] LPSYSTEM_INFO lpSystemInfo
6270
);

ctypes_generation/definitions/structures/system_info.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,22 @@ typedef enum _COMPUTER_NAME_FORMAT {
6767
ComputerNamePhysicalDnsFullyQualified,
6868
ComputerNameMax
6969
} COMPUTER_NAME_FORMAT;
70+
71+
typedef struct _SYSTEM_INFO {
72+
union {
73+
DWORD dwOemId;
74+
struct {
75+
WORD wProcessorArchitecture;
76+
WORD wReserved;
77+
} DUMMYSTRUCTNAME;
78+
} DUMMYUNIONNAME;
79+
DWORD dwPageSize;
80+
LPVOID lpMinimumApplicationAddress;
81+
LPVOID lpMaximumApplicationAddress;
82+
DWORD_PTR dwActiveProcessorMask;
83+
DWORD dwNumberOfProcessors;
84+
DWORD dwProcessorType;
85+
DWORD dwAllocationGranularity;
86+
WORD wProcessorLevel;
87+
WORD wProcessorRevision;
88+
} SYSTEM_INFO, *LPSYSTEM_INFO;

docs/source/winfuncs_generated.rst

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,42 @@ Functions
12121212

12131213
.. function:: LookupAccountNameW(lpSystemName, lpAccountName, Sid, cbSid, ReferencedDomainName, cchReferencedDomainName, peUse)
12141214

1215+
.. function:: GetNativeSystemInfo(lpSystemInfo)
1216+
1217+
.. function:: GetSystemInfo(lpSystemInfo)
1218+
1219+
.. function:: IsWow64Process(hProcess, Wow64Process)
1220+
1221+
.. function:: IsWow64Process2(hProcess, pProcessMachine, pNativeMachine)
1222+
1223+
.. function:: IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
1224+
1225+
.. function:: GetSystemWow64DirectoryA(lpBuffer, uSize)
1226+
1227+
.. function:: GetSystemWow64DirectoryW(lpBuffer, uSize)
1228+
1229+
.. function:: GetSystemWow64Directory2A(lpBuffer, uSize, ImageFileMachineType)
1230+
1231+
.. function:: GetSystemWow64Directory2W(lpBuffer, uSize, ImageFileMachineType)
1232+
1233+
.. function:: Wow64DisableWow64FsRedirection(OldValue)
1234+
1235+
.. function:: Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection)
1236+
1237+
.. function:: Wow64RevertWow64FsRedirection(OlValue)
1238+
1239+
.. function:: Wow64GetThreadContext(hThread, lpContext)
1240+
1241+
.. function:: Wow64SetThreadContext(hThread, lpContext)
1242+
1243+
.. function:: Wow64SetThreadDefaultGuestMachine(Machine)
1244+
1245+
.. function:: Wow64SuspendThread(hThread)
1246+
1247+
.. function:: NtWow64ReadVirtualMemory64(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
1248+
1249+
.. function:: NtWow64WriteVirtualMemory64(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten)
1250+
12151251
.. function:: FileTimeToSystemTime(lpFileTime, lpSystemTime)
12161252

12171253
.. function:: SystemTimeToFileTime(lpSystemTime, lpFileTime)
@@ -1368,12 +1404,8 @@ Functions
13681404

13691405
.. function:: ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
13701406

1371-
.. function:: NtWow64ReadVirtualMemory64(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead)
1372-
13731407
.. function:: WriteProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten)
13741408

1375-
.. function:: NtWow64WriteVirtualMemory64(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesWritten)
1376-
13771409
.. function:: GetCurrentProcess()
13781410

13791411
.. function:: CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)
@@ -1466,14 +1498,6 @@ Functions
14661498

14671499
.. function:: DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped)
14681500

1469-
.. function:: Wow64DisableWow64FsRedirection(OldValue)
1470-
1471-
.. function:: Wow64RevertWow64FsRedirection(OldValue)
1472-
1473-
.. function:: Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection)
1474-
1475-
.. function:: Wow64GetThreadContext(hThread, lpContext)
1476-
14771501
.. function:: SetConsoleCtrlHandler(HandlerRoutine, Add)
14781502

14791503
.. function:: GlobalAlloc(uFlags, dwBytes)
@@ -1528,8 +1552,6 @@ Functions
15281552

15291553
.. function:: GetProcessId(Process)
15301554

1531-
.. function:: Wow64SetThreadContext(hThread, lpContext)
1532-
15331555
.. function:: GetMappedFileNameW(hProcess, lpv, lpFilename, nSize)
15341556

15351557
.. function:: GetMappedFileNameA(hProcess, lpv, lpFilename, nSize)

docs/source/winstructs_generated.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25612,6 +25612,67 @@ _SYSTEM_BASIC_INFORMATION
2561225612

2561325613
:class:`CHAR`
2561425614

25615+
_SYSTEM_INFO
25616+
''''''''''''
25617+
.. class:: LPSYSTEM_INFO
25618+
25619+
Pointer to :class:`_SYSTEM_INFO`
25620+
25621+
.. class:: SYSTEM_INFO
25622+
25623+
Alias for :class:`_SYSTEM_INFO`
25624+
25625+
.. class:: _SYSTEM_INFO
25626+
25627+
.. attribute:: DUMMYUNIONNAME
25628+
25629+
:class:`_ANON__SYSTEM_INFO_SUB_UNION_1`
25630+
25631+
25632+
.. attribute:: dwPageSize
25633+
25634+
:class:`DWORD`
25635+
25636+
25637+
.. attribute:: lpMinimumApplicationAddress
25638+
25639+
:class:`LPVOID`
25640+
25641+
25642+
.. attribute:: lpMaximumApplicationAddress
25643+
25644+
:class:`LPVOID`
25645+
25646+
25647+
.. attribute:: dwActiveProcessorMask
25648+
25649+
:class:`DWORD_PTR`
25650+
25651+
25652+
.. attribute:: dwNumberOfProcessors
25653+
25654+
:class:`DWORD`
25655+
25656+
25657+
.. attribute:: dwProcessorType
25658+
25659+
:class:`DWORD`
25660+
25661+
25662+
.. attribute:: dwAllocationGranularity
25663+
25664+
:class:`DWORD`
25665+
25666+
25667+
.. attribute:: wProcessorLevel
25668+
25669+
:class:`WORD`
25670+
25671+
25672+
.. attribute:: wProcessorRevision
25673+
25674+
:class:`WORD`
25675+
2561525676
_TIME_ZONE_INFORMATION
2561625677
''''''''''''''''''''''
2561725678
.. class:: LPTIME_ZONE_INFORMATION

tests/test_syswow.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ def test_print_syswow_state():
2222
print(f"{env['PROCESSOR_ARCHITECTURE']=}")
2323
print(f"{env.get('PROCESSOR_ARCHITEW6432')=}")
2424

25+
print("")
26+
print("GetSystemInfo")
27+
windows.utils.sprint(windows.utils.get_system_info(native=False), name="SystemInfo")
28+
print("")
29+
print("GetNativeSystemInfo")
30+
windows.utils.sprint(windows.utils.get_system_info(native=True), name="NativeSystemInfo")
31+
2532
@process_syswow_only
2633
class TestSyswowCurrentProcess(object):
2734
def test_exec_syswow(self):

windows/generated_def/meta.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12641,6 +12641,7 @@
1264112641
'LPSTARTUPINFOEXW',
1264212642
'LPSTARTUPINFOW',
1264312643
'LPSYSTEMTIME',
12644+
'LPSYSTEM_INFO',
1264412645
'LPTHREADENTRY32',
1264512646
'LPTIME_ZONE_INFORMATION',
1264612647
'LPTLIBATTR',
@@ -13458,6 +13459,7 @@
1345813459
'SYSTEM_HANDLE64',
1345913460
'SYSTEM_HANDLE_INFORMATION',
1346013461
'SYSTEM_HANDLE_INFORMATION64',
13462+
'SYSTEM_INFO',
1346113463
'SYSTEM_MANDATORY_LABEL_ACE',
1346213464
'SYSTEM_MODULE32',
1346313465
'SYSTEM_MODULE64',
@@ -14034,6 +14036,7 @@
1403414036
'_SYSTEM_HANDLE64',
1403514037
'_SYSTEM_HANDLE_INFORMATION',
1403614038
'_SYSTEM_HANDLE_INFORMATION64',
14039+
'_SYSTEM_INFO',
1403714040
'_SYSTEM_MANDATORY_LABEL_ACE',
1403814041
'_SYSTEM_MODULE32',
1403914042
'_SYSTEM_MODULE64',
@@ -14798,6 +14801,7 @@
1479814801
'GetModuleHandleW',
1479914802
'GetNamedSecurityInfoA',
1480014803
'GetNamedSecurityInfoW',
14804+
'GetNativeSystemInfo',
1480114805
'GetNumberOfEventLogRecords',
1480214806
'GetOverlappedResult',
1480314807
'GetParent',
@@ -14834,6 +14838,7 @@
1483414838
'GetSidSubAuthorityCount',
1483514839
'GetStdHandle',
1483614840
'GetStringConditionFromBinary',
14841+
'GetSystemInfo',
1483714842
'GetSystemMetrics',
1483814843
'GetSystemTime',
1483914844
'GetSystemTimeAsFileTime',

windows/generated_def/winfuncs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,6 +3025,16 @@
30253025
LookupAccountNameWPrototype = WINFUNCTYPE(BOOL, LPCWSTR, LPCWSTR, PSID, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE)
30263026
LookupAccountNameWParams = ((1, 'lpSystemName'), (1, 'lpAccountName'), (1, 'Sid'), (1, 'cbSid'), (1, 'ReferencedDomainName'), (1, 'cchReferencedDomainName'), (1, 'peUse'))
30273027

3028+
#def GetNativeSystemInfo(lpSystemInfo):
3029+
# return GetNativeSystemInfo.ctypes_function(lpSystemInfo)
3030+
GetNativeSystemInfoPrototype = WINFUNCTYPE(PVOID, LPSYSTEM_INFO)
3031+
GetNativeSystemInfoParams = ((1, 'lpSystemInfo'),)
3032+
3033+
#def GetSystemInfo(lpSystemInfo):
3034+
# return GetSystemInfo.ctypes_function(lpSystemInfo)
3035+
GetSystemInfoPrototype = WINFUNCTYPE(PVOID, LPSYSTEM_INFO)
3036+
GetSystemInfoParams = ((1, 'lpSystemInfo'),)
3037+
30283038
#def IsWow64Process(hProcess, Wow64Process):
30293039
# return IsWow64Process.ctypes_function(hProcess, Wow64Process)
30303040
IsWow64ProcessPrototype = WINFUNCTYPE(BOOL, HANDLE, PBOOL)

windows/generated_def/winstructs.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11136,6 +11136,36 @@ class _SYSTEM_BASIC_INFORMATION(Structure):
1113611136
PSYSTEM_BASIC_INFORMATION = POINTER(_SYSTEM_BASIC_INFORMATION)
1113711137
SYSTEM_BASIC_INFORMATION = _SYSTEM_BASIC_INFORMATION
1113811138

11139+
class _ANON__ANON__SYSTEM_INFO_SUB_UNION_1_SUB_STRUCTURE_1(Structure):
11140+
_fields_ = [
11141+
("wProcessorArchitecture", WORD),
11142+
("wReserved", WORD),
11143+
]
11144+
11145+
class _ANON__SYSTEM_INFO_SUB_UNION_1(Union):
11146+
_anonymous_ = ("DUMMYSTRUCTNAME",)
11147+
_fields_ = [
11148+
("dwOemId", DWORD),
11149+
("DUMMYSTRUCTNAME", _ANON__ANON__SYSTEM_INFO_SUB_UNION_1_SUB_STRUCTURE_1),
11150+
]
11151+
11152+
class _SYSTEM_INFO(Structure):
11153+
_anonymous_ = ("DUMMYUNIONNAME",)
11154+
_fields_ = [
11155+
("DUMMYUNIONNAME", _ANON__SYSTEM_INFO_SUB_UNION_1),
11156+
("dwPageSize", DWORD),
11157+
("lpMinimumApplicationAddress", LPVOID),
11158+
("lpMaximumApplicationAddress", LPVOID),
11159+
("dwActiveProcessorMask", DWORD_PTR),
11160+
("dwNumberOfProcessors", DWORD),
11161+
("dwProcessorType", DWORD),
11162+
("dwAllocationGranularity", DWORD),
11163+
("wProcessorLevel", WORD),
11164+
("wProcessorRevision", WORD),
11165+
]
11166+
LPSYSTEM_INFO = POINTER(_SYSTEM_INFO)
11167+
SYSTEM_INFO = _SYSTEM_INFO
11168+
1113911169
class _TIME_ZONE_INFORMATION(Structure):
1114011170
_fields_ = [
1114111171
("Bias", LONG),

windows/utils/winutils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,14 @@ def create_file(name, access=gdef.GENERIC_READ, share=gdef.FILE_SHARE_READ, secu
552552
# addr = windows.winproxy.MapViewOfFile(h, dwDesiredAccess=FILE_MAP_READ, dwNumberOfBytesToMap=1)
553553
# return addr
554554

555+
def get_system_info(native=False):
556+
res = gdef.SYSTEM_INFO()
557+
if native:
558+
windows.winproxy.GetNativeSystemInfo(res)
559+
else:
560+
windows.winproxy.GetSystemInfo(res)
561+
return res
562+
555563
def decompress_buffer(buffer, comptype=gdef.COMPRESSION_FORMAT_LZNT1, uncompress_size=None):
556564
if uncompress_size is None:
557565
uncompress_size = len(buffer) * 10

windows/winproxy/apis/kernel32.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,14 @@ def GetWindowsDirectoryW(lpBuffer, uSize=None):
407407
def GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType):
408408
return GetProductInfo.ctypes_function(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, pdwReturnedProductType)
409409

410+
@Kernel32Proxy(error_check=no_error_check)
411+
def GetNativeSystemInfo(lpSystemInfo):
412+
return GetNativeSystemInfo.ctypes_function(lpSystemInfo)
413+
414+
@Kernel32Proxy(error_check=no_error_check)
415+
def GetSystemInfo(lpSystemInfo):
416+
return GetSystemInfo.ctypes_function(lpSystemInfo)
417+
410418
## Io
411419

412420
@Kernel32Proxy()

0 commit comments

Comments
 (0)