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.

84 lines
2.4 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: this is a short program to test the bitmask functionality
  5. //================================================================================
  6. #include <mm.h>
  7. #include <array.h>
  8. #include <bitmask.h>
  9. #include <stdio.h>
  10. PM_BITMASK Bit;
  11. VOID _cdecl
  12. main(
  13. VOID
  14. )
  15. {
  16. DWORD Error;
  17. DWORD Offset;
  18. DWORD BitSize;
  19. DWORD ToSet;
  20. DWORD ToSet1, ToSet2;
  21. DWORD InUseSize;
  22. DWORD UsedSize;
  23. BOOL OldState;
  24. LPBYTE InUse;
  25. LPBYTE Used;
  26. Error = MemBitInit(&Bit, 0x01000000);
  27. printf("MemBitInit(0x01000000)=%ld\n", Error);
  28. for( ToSet = 0; ToSet < 0x01000000 ; ToSet ++ ) {
  29. if( 0 == ( ToSet % 35 ) ) continue;
  30. Error = MemBitSetOrClear(
  31. Bit,
  32. ToSet,
  33. TRUE,
  34. &OldState
  35. );
  36. if( ERROR_SUCCESS != Error || OldState ) {
  37. printf("MemBitSetOrClear(%ld)=%ld,OldState=%ld\n", ToSet, Error, OldState);
  38. }
  39. }
  40. printf("Set all stuff\n");
  41. Error = MemBitConvertToCluster(
  42. Bit,
  43. 0,
  44. &InUse,
  45. &InUseSize,
  46. &Used,
  47. &UsedSize
  48. );
  49. printf("MemBitconvert: %ld\n", Error);
  50. if( ERROR_SUCCESS != Error )return;
  51. printf("InUseSize= %ld, UsedSize = %ld\n", InUseSize, UsedSize);
  52. printf("InUse[0] = %ld\n", *(LPDWORD)InUse);
  53. InUse += sizeof(DWORD); InUseSize -= sizeof(DWORD);
  54. while(InUseSize) {
  55. Offset = *(LPDWORD)InUse;
  56. InUse+= sizeof(DWORD);
  57. for( ToSet = 0; ToSet < 32; ToSet ++ )
  58. if( (1<<ToSet) & *(LPDWORD)InUse )
  59. printf("InUse [ %ld ] \n", Offset + ToSet );
  60. InUse+= sizeof(DWORD);
  61. InUseSize -= sizeof(DWORD)*2;
  62. }
  63. printf("Used[0] = %ld\n", *(LPDWORD)Used);
  64. Used += sizeof(DWORD);
  65. UsedSize -= sizeof(DWORD);
  66. while( UsedSize ) {
  67. Offset = *(LPDWORD)Used;
  68. Used += sizeof(DWORD);
  69. UsedSize -= sizeof(DWORD);
  70. printf("Used [ %ld ] \n", Offset);
  71. }
  72. }