Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

misc.cpp 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <cstdio>
  2. #include <ntdll.h>
  3. #include "structs.h"
  4. #include "misc.h"
  5. BOOL is_WOW64()
  6. {
  7. return NULL != __readfsdword(0xC0);
  8. }
  9. VOID print_os_info()
  10. {
  11. _KUSER_SHARED_DATA* _kuser_s_d = GET_KUSER_SHARED_DATA();
  12. ULONG majorVersion = _kuser_s_d->NtMajorVersion;
  13. ULONG minorVersion = _kuser_s_d->NtMinorVersion;
  14. NT_PRODUCT_TYPE productType = _kuser_s_d->NtProductType;
  15. _PEB* p = (_PEB*)__readfsdword(0x30);
  16. ULONG buildID = p->NtBuildNumber;
  17. printf("Running on %i.%i %i %X (x%s)\n", majorVersion, minorVersion, buildID, productType, (is_WOW64() ? "64" : "86"));
  18. }
  19. DWORD hash(const char* str)
  20. {
  21. return hash((const unsigned char*)str, strlen(str));
  22. }
  23. DWORD hash(const unsigned char* buf, const size_t sz)
  24. {
  25. unsigned int hash = 5381;
  26. for(unsigned int i = 0; i < sz; i++)
  27. hash = ((hash << 5) + hash) + (unsigned int)buf[i];
  28. return hash;
  29. }
  30. BOOL is_executable(LPVOID addr)
  31. {
  32. MEMORY_BASIC_INFORMATION mbi = {0};
  33. if(!VirtualQuery(addr, &mbi, sizeof(MEMORY_BASIC_INFORMATION)))
  34. {
  35. return FALSE;
  36. }
  37. return (mbi.Protect & PAGE_EXECUTE);
  38. }
  39. BOOL is_Win8()
  40. {
  41. KUSER_SHARED_DATA* _kuser_s_d = GET_KUSER_SHARED_DATA();
  42. ULONG majorVersion = _kuser_s_d->NtMajorVersion;
  43. ULONG minorVersion = _kuser_s_d->NtMinorVersion;
  44. return 6 == majorVersion && 2 == minorVersion;
  45. }