Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.3 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #if 0
  4. UCHAR key[] = { 0x67, 0xdf, 0x40, 0xd3, 0x4d, 0xd2, 0x34, 0x6e, 0x98, 0x2e, 0xca, 0x8c, 0x01, 0x81, 0xb4, 0x88 };
  5. /* Old code. */
  6. ULONG Map (ULONG v1, ULONG v2) {
  7. ULONG y = v1;
  8. ULONG z = v2;
  9. ULONG sum = 0;
  10. ULONG a = key [0];
  11. ULONG b = key [1];
  12. ULONG c = key [2];
  13. ULONG d = key [3];
  14. ULONG delta = 0x9E3779B9;
  15. ULONG n = 8;
  16. ULONG value;
  17. while (n-- > 0) {
  18. sum += delta;
  19. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  20. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  21. }
  22. value = y ^ z;
  23. return value;
  24. }
  25. #endif
  26. /* New code with unrolled loop. */
  27. ULONG Map (ULONG v1, ULONG v2) {
  28. ULONG y = v1;
  29. ULONG z = v2;
  30. ULONG sum = 0;
  31. const ULONG a = 0x67; //key [0];
  32. const ULONG b = 0xdf; //key [1];
  33. const ULONG c = 0x40; //key [2];
  34. const ULONG d = 0xd3; //key [3];
  35. const ULONG delta = 0x9E3779B9;
  36. sum += delta;
  37. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  38. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  39. sum += delta;
  40. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  41. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  42. sum += delta;
  43. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  44. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  45. sum += delta;
  46. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  47. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  48. sum += delta;
  49. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  50. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  51. sum += delta;
  52. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  53. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  54. sum += delta;
  55. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  56. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  57. sum += delta;
  58. y += (z << 4) + a ^ z + sum ^ (z >> 5) + b;
  59. z += (y << 4) + c ^ y + sum ^ (y >> 5) + d;
  60. return y ^ z;
  61. }
  62. int __cdecl wmain (int argc, char ** argv) {
  63. ULONG id = 0;
  64. ULONG bin = 0;
  65. ULONG hash = 0;
  66. ULONG client_ipaddr = 0x65040c0c;
  67. USHORT svr_port = 0x844;
  68. USHORT client_port = 0x8b;
  69. id = Map(client_ipaddr, ((svr_port << 16) + client_port));
  70. bin = id % 60;
  71. hash = id % 4096;
  72. return 0;
  73. }