What do I do with per-user data when I uninstall?
Why isn't QuickEdit on by default in console windows?
Because it breaks console mode applications using the mouse.
Does creating a thread from DllMain deadlock or doesn't it?
Posted by nsylvain at 9:32 AM 0 comments
for (LONG_PTR h = 0; h < 0xFFFF; ++h) {
HANDLE handle = (HANDLE)(h);
DoSomething(handle);
}
ExpLookupHandleTableEntry
mov edi, edi
push ebp
mov ebp, esp
and [ebp+Handle], 0FFFFFFFCh ; Unset the last 2 bits
mov eax, [ebp+Handle]
mov ecx, [ebp+HandleTable]
mov edx, [ebp+Handle]
shr eax, 2 ; Shift right the last 2 bits
cmp edx, [ecx+38h] ; HandleTable->NextHandleNeedingPool
jnb loc_49DDF8
Posted by nsylvain at 7:37 PM 1 comments
!token -n
Posted by nsylvain at 3:21 PM 0 comments
typedef struct _SYSTEM_HANDLE_INFORMATION {
USHORT ProcessId;
USHORT CreatorBackTraceIndex;
UCHAR ObjectTypeNumber;
UCHAR Flags;
USHORT Handle;
PVOID Object;
ACCESS_MASK GrantedAccess;
} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
typedef struct _SYSTEM_HANDLE_INFORMATION_EX {
ULONG NumberOfHandles;
SYSTEM_HANDLE_INFORMATION Information[1];
} SYSTEM_HANDLE_INFORMATION_EX, *PSYSTEM_HANDLE_INFORMATION_EX;
There is another factor making this task a little bit more complex to achieve: The function is really picky about the buffer size.
Usually you can call the function with a NULL buffer and 0 for the size and then get back the size you need to allocate your buffer. This does not work here. The return value is 0xC0000004 : The specified information record length does not match the length required for the specified information class.
If you try with a SYSTEM_HANDLE_INFORMATION buffer, it won't work either. You need to pass to the function a buffer large enough to hold the number of handles and the first handle if you want to get the size needed back. This is a little bit weird.
Finally, the code:
// Get the number of handles on the system
DWORD buffer_size = 0;
SYSTEM_HANDLE_INFORMATION_EX temp_info;
NTSTATUS status = NtQuerySystemInformation(
SystemHandleInformation, &temp_info,
sizeof(temp_info), &buffer_size);
SYSTEM_HANDLE_INFORMATION_EX *system_handles =
(SYSTEM_HANDLE_INFORMATION_EX*)(new BYTE[buffer_size]);
status = NtQuerySystemInformation(SystemHandleInformation,
system_handles,
buffer_size, &buffer_size);
printf("nb of handles = %d", system_handles->NumberOfHandles);
Posted by nsylvain at 11:26 AM 1 comments
win64 win32
-------------------------------
bool 1 1
BYTE 1 1
char 1 1
-------------------------------
SHORT 2 2
wchar_t 2 2
WORD 2 2
-------------------------------
BOOL 4 4
DWORD 4 4
float 4 4
HRESULT 4 4
int 4 4
long 4 4
unsigned int 4 4
unsigned long 4 4
-------------------------------
HANDLE 8 4
INT_PTR 8 4
LONG_PTR 8 4
ULONG_PTR 8 4
void* 8 4
-------------------------------
__int64 8 8
double 8 8
LONGLONG 8 8
ULONGLONG 8 8
-------------------------------
FLOAT128 16 16
-------------------------------
Posted by nsylvain at 4:10 PM 0 comments
NtSetInformationThread(hThread, ThreadHideFromDebugger, NULL, 0);
4 ThreadPriority
16 ThreadBasePriority
2 ThreadAffinityMask
2069 ThreadImpersonationToken
16 ThreadQuerySetWin32StartAddress
16 ThreadZeroTlsCell
16 ThreadPriority
490 ThreadBasePriority
4 ThreadAffinityMask
6293 ThreadImpersonationToken
71 ThreadZeroTlsCell
1 ThreadPriorityBoost
460 Unknown - 0x16
481 Unknown - 0x18
10 Unknown - 0x19
Posted by nsylvain at 8:50 PM 2 comments
Posted by nsylvain at 7:57 PM 0 comments
Posted by nsylvain at 7:33 PM 0 comments
Posted by nsylvain at 8:41 AM 1 comments