The address of the PEB :type: :class:`int`
(self)
| 1149 | |
| 1150 | @utils.fixedpropety |
| 1151 | def peb_addr(self): |
| 1152 | """The address of the PEB |
| 1153 | |
| 1154 | :type: :class:`int` |
| 1155 | """ |
| 1156 | if windows.current_process.bitness == 32 and self.bitness == 64: |
| 1157 | x = windows.remotectypes.transform_type_to_remote64bits(PROCESS_BASIC_INFORMATION) |
| 1158 | # Fuck-it <3 |
| 1159 | data = (ctypes.c_char * ctypes.sizeof(x))() |
| 1160 | windows.syswow64.NtQueryInformationProcess_32_to_64(self.handle, ProcessInformation=data, ProcessInformationLength=ctypes.sizeof(x)) |
| 1161 | peb_offset = x.PebBaseAddress.offset |
| 1162 | peb_addr = struct.unpack("<Q", data[x.PebBaseAddress.offset: x.PebBaseAddress.offset+8])[0] |
| 1163 | elif windows.current_process.bitness == 64 and self.bitness == 32: |
| 1164 | information_type = 26 |
| 1165 | y = ULONGLONG() |
| 1166 | winproxy.NtQueryInformationProcess(self.handle, information_type, byref(y), sizeof(y)) |
| 1167 | peb_addr = y.value |
| 1168 | else: |
| 1169 | information_type = 0 |
| 1170 | x = PROCESS_BASIC_INFORMATION() |
| 1171 | winproxy.NtQueryInformationProcess(self.handle, information_type, x) |
| 1172 | peb_addr = ctypes.cast(x.PebBaseAddress, PVOID).value |
| 1173 | if peb_addr is None: |
| 1174 | raise ValueError("Could not get peb addr of process {0}".format(self.name)) |
| 1175 | return peb_addr |
| 1176 | |
| 1177 | # Not a fixedpropety to prevent ref-cycle and uncollectable WinProcess |
| 1178 | # Try with a weakref ? |