All pastes #525375 Raw Edit

Something

public text v1 · immutable
#525375 ·published 2007-05-31 10:31 UTC
rendered paste body
Code:

	sizeBits = index[6];

	printf("sizeBits in %s = %i\n",image->filename, sizeBits);
	printf("Tokensize in the string heap: %i\n", sizeBits & IL_META_SIZE_FLAG_STRREF ? 4 : 2);
	printf("Tokensize in the guid heap: %i\n", sizeBits & IL_META_SIZE_FLAG_GUIDREF ? 4 : 2);
	printf("Tokensize in the blob heap: %i\n", sizeBits & IL_META_SIZE_FLAG_BLOBREF ? 4 : 2);

	/* Determine the size of each of the token structures */
	strRefSize = (sizeBits & IL_META_SIZE_FLAG_STRREF) ? 4 : 2;
	guidRefSize = (sizeBits & IL_META_SIZE_FLAG_GUIDREF) ? 4 : 2;
	blobRefSize = (sizeBits & IL_META_SIZE_FLAG_BLOBREF) ? 4 : 2;

	printf("Tokensize in the string heap: %i\n", strRefSize);
	printf("Tokensize in the guid heap: %i\n", guidRefSize);
	printf("Tokensize in the blob heap: %i\n", blobRefSize);

	/* Record the size of STRREF's and BLOBREF's for later */
	image->strRefBig = (strRefSize == 4) ? 1 : 0;
	image->blobRefBig = (blobRefSize == 4) ? 1 : 0;
	image->guidRefBig = (guidRefSize == 4) ? 1 : 0;

	printf("Tokensizeflag for the string heap: %i\n", image->strRefBig);
	printf("Tokensizeflag for the guid heap: %i\n", image->guidRefBig);
	printf("Tokensizeflag for the blob heap: %i\n", image->blobRefBig);

Output:

sizeBits in /home/kt/Downloads/DotNet/Tests/mscorlib.dll = 5
Tokensize in the string heap: 4
Tokensize in the guid heap: 2
Tokensize in the blob heap: 4
Tokensize in the string heap: 4
Tokensize in the guid heap: 2
Tokensize in the blob heap: 4
Tokensizeflag for the string heap: 0
Tokensizeflag for the guid heap: 0
Tokensizeflag for the blob heap: 0
metadata error in token 0x02000001: bad FieldDef index
mscorlib.dll: invalid metadata in image