00025 {
00026 LONG
Status;
00027
DWORD iValue;
00028 LPWSTR lpszValue;
00029
DWORD cchValue;
00030
DWORD dwType;
00031
PBYTE lpbData;
00032
DWORD cbData;
00033 BOOLEAN KeyNameAlreadyPrinted;
00034
00035
00036
00037
00038
00039 lpszValue = ( LPWSTR )malloc( (cchMaxValueName + 1)*
sizeof( WCHAR ) );
00040 lpbData = ( LPBYTE )malloc( cbMaxValueData );
00041
if( ( lpszValue ==
NULL ) ||
00042 ( lpbData ==
NULL ) ) {
00043 printf(
"ERROR: Unable to allocate memory, cchMaxValueName = %d, cbMaxValuedata = %d \n",
00044 cchMaxValueName, cbMaxValueData );
00045
if( lpszValue !=
NULL ) {
00046 free( lpszValue );
00047 }
00048
if( lpbData !=
NULL ) {
00049 free( lpbData );
00050 }
00051
return;
00052 }
00053
00054
00055
00056
00057
00058 KeyNameAlreadyPrinted =
FALSE;
00059
for( iValue = 0; iValue < cValues; iValue++ ) {
00060 cchValue = cchMaxValueName + 1;
00061 cbData = cbMaxValueData;
00062
Status = RegEnumValueW( Key,
00063 iValue,
00064 lpszValue,
00065 &cchValue,
00066 0,
00067 &dwType,
00068 lpbData,
00069 &cbData );
00070
00071
if(
Status != ERROR_SUCCESS ) {
00072
if( !KeyNameAlreadyPrinted ) {
00073 KeyNameAlreadyPrinted =
TRUE;
00074 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00075 }
00076 printf( MSG_ERROR_REG_ENUM_VALUE, iValue, Status );
00077
continue;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
switch( dwType ) {
00087
00088
case REG_BINARY:
00089
00090
if( cbData == 0 ) {
00091
if( !KeyNameAlreadyPrinted ) {
00092 KeyNameAlreadyPrinted =
TRUE;
00093 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00094 }
00095 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00096 lpszValue, cchValue,
"REG_BINARY", cbData );
00097 }
00098
break;
00099
00100
case REG_DWORD:
00101
00102
if( cbData !=
sizeof(
DWORD ) ) {
00103
if( !KeyNameAlreadyPrinted ) {
00104 KeyNameAlreadyPrinted =
TRUE;
00105 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00106 }
00107 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00108 lpszValue, cchValue,
"REG_DWORD", cbData );
00109 }
00110
break;
00111
00112
case REG_DWORD_BIG_ENDIAN:
00113
00114
if( cbData !=
sizeof(
DWORD ) ) {
00115
if( !KeyNameAlreadyPrinted ) {
00116 KeyNameAlreadyPrinted =
TRUE;
00117 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00118 }
00119 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00120 lpszValue, cchValue,
"REG_DWORD_BIG_ENDIAN", cbData );
00121 }
00122
break;
00123
00124
case REG_EXPAND_SZ:
00125
00126
if( ( cbData != 0 ) && ( ( cbData %
sizeof( WCHAR ) ) == 0 )) {
00127
if( *( ( PWCHAR )( lpbData + cbData -
sizeof( WCHAR ) ) ) != ( WCHAR )
'\0' ) {
00128
if( !KeyNameAlreadyPrinted ) {
00129 KeyNameAlreadyPrinted =
TRUE;
00130 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00131 }
00132 printf( MSG_ERROR_VALUE_NOT_NUL_TERMINATED,
00133 lpszValue, cchValue,
"REG_EXPAND_SZ" );
00134 }
00135 }
else {
00136
if( !KeyNameAlreadyPrinted ) {
00137 KeyNameAlreadyPrinted =
TRUE;
00138 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00139 }
00140 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00141 lpszValue, cchValue,
"REG_EXPAND_SZ", cbData );
00142 }
00143
break;
00144
00145
case REG_LINK:
00146
00147
if( cbData == 0 ) {
00148
if( !KeyNameAlreadyPrinted ) {
00149 KeyNameAlreadyPrinted =
TRUE;
00150 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00151 }
00152 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00153 lpszValue, cchValue,
"REG_LINK", cbData );
00154 }
00155
break;
00156
00157
case REG_MULTI_SZ:
00158
00159
if( ( cbData != 0 ) && ( ( cbData %
sizeof( WCHAR ) ) == 0 )) {
00160
if( *( ( PWCHAR )( lpbData + cbData -
sizeof( WCHAR ) ) ) != ( WCHAR )
'\0' ) {
00161
if( !KeyNameAlreadyPrinted ) {
00162 KeyNameAlreadyPrinted =
TRUE;
00163 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00164 }
00165 printf( MSG_ERROR_VALUE_NOT_NUL_TERMINATED,
00166 lpszValue, cchValue,
"REG_MULTI_SZ" );
00167 }
00168 }
else {
00169
if( !KeyNameAlreadyPrinted ) {
00170 KeyNameAlreadyPrinted =
TRUE;
00171 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00172 }
00173 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00174 lpszValue, cchValue,
"REG_MULTI_SZ", cbData );
00175 }
00176
break;
00177
00178
case REG_NONE:
00179
00180
if( cbData != 0 ) {
00181
if( !KeyNameAlreadyPrinted ) {
00182 KeyNameAlreadyPrinted =
TRUE;
00183 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00184 }
00185 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00186 lpszValue, cchValue,
"REG_NONE", cbData );
00187 }
00188
break;
00189
00190
case REG_RESOURCE_LIST:
00191
00192
if( cbData == 0 ) {
00193
if( !KeyNameAlreadyPrinted ) {
00194 KeyNameAlreadyPrinted =
TRUE;
00195 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00196 }
00197 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00198 lpszValue, cchValue,
"REG_RESOURCE_LIST", cbData );
00199 }
00200
break;
00201
00202
00203
case REG_SZ:
00204
00205
if( ( cbData != 0 ) && ( ( cbData %
sizeof( WCHAR ) ) == 0 ) ) {
00206
if( *( ( PWCHAR )( lpbData + cbData -
sizeof( WCHAR ) ) ) != ( WCHAR )
'\0' ) {
00207
if( !KeyNameAlreadyPrinted ) {
00208 KeyNameAlreadyPrinted =
TRUE;
00209 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00210 }
00211 printf( MSG_ERROR_VALUE_NOT_NUL_TERMINATED,
00212 lpszValue, cchValue,
"REG_SZ" );
00213 }
00214 }
else {
00215
if( !KeyNameAlreadyPrinted ) {
00216 KeyNameAlreadyPrinted =
TRUE;
00217 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00218 }
00219 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00220 lpszValue, cchValue,
"REG_SZ", cbData );
00221 }
00222
break;
00223
00224
case REG_FULL_RESOURCE_DESCRIPTOR:
00225
00226
if( cbData == 0 ) {
00227
if( !KeyNameAlreadyPrinted ) {
00228 KeyNameAlreadyPrinted =
TRUE;
00229 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00230 }
00231 printf( MSG_ERROR_VALUE_INCORRECT_SIZE,
00232 lpszValue, cchValue,
"REG_FULL_RESOURCE_DESCRIPTOR", cbData );
00233 }
00234
break;
00235
00236
default:
00237
00238
if( !KeyNameAlreadyPrinted ) {
00239 KeyNameAlreadyPrinted =
TRUE;
00240 printf( MSG_COMPLETE_KEY_NAME, PredefinedKeyName, CompleteKeyName );
00241 }
00242 printf( MSG_ERROR_VALUE_UNKNOWN_DATA,
00243 lpszValue, cchValue, dwType, cbData );
00244
break;
00245
00246 }
00247 }
00248
00249
00250
00251
00252 free( lpszValue );
00253 free( lpbData );
00254 }