Bug fixes.

This commit is contained in:
Noomen Hamza 1999-05-08 10:50:34 +00:00 committed by Alexandre Julliard
parent 115d8ccaab
commit c4cd0bf6c8
3 changed files with 73 additions and 50 deletions

View File

@ -31,18 +31,7 @@
#define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */ #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */
#define REG_RESOURCE_LIST 8 /* resource list? huh? */ #define REG_RESOURCE_LIST 8 /* resource list? huh? */
#define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */ #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */
#define REG_RESOURCE_REQUIREMENTS_LIST 10
#define HEX_REG_NONE 0x80000000
#define HEX_REG_SZ 0x80000001
#define HEX_REG_EXPAND_SZ 0x80000002
#define HEX_REG_BINARY 0x80000003
#define HEX_REG_DWORD 0x80000004
#define HEX_REG_DWORD_LITTLE_ENDIAN 0x80000004
#define HEX_REG_DWORD_BIG_ENDIAN 0x80000005
#define HEX_REG_LINK 0x80000006
#define HEX_REG_MULTI_SZ 0x80000007
#define HEX_REG_RESOURCE_LIST 0x80000008
#define HEX_REG_FULL_RESOURCE_DESCRIPTOR 0x80000009
#define HKEY_CLASSES_ROOT ((HKEY) 0x80000000) #define HKEY_CLASSES_ROOT ((HKEY) 0x80000000)
#define HKEY_CURRENT_USER ((HKEY) 0x80000001) #define HKEY_CURRENT_USER ((HKEY) 0x80000001)

View File

@ -183,22 +183,19 @@ static void debug_print_value (LPBYTE lpbData, LPKEYVALUE key)
{ {
switch(key->type) switch(key->type)
{ {
case HEX_REG_EXPAND_SZ: case REG_EXPAND_SZ:
case HEX_REG_SZ:
case REG_SZ: case REG_SZ:
TRACE_(reg)(" Value %s, Data(sz)=%s\n", TRACE_(reg)(" Value %s, Data(sz)=%s\n",
debugstr_w(key->name), debugstr_w(key->name),
debugstr_w((LPCWSTR)lpbData)); debugstr_w((LPCWSTR)lpbData));
break; break;
case HEX_REG_DWORD:
case REG_DWORD: case REG_DWORD:
TRACE_(reg)(" Value %s, Data(dword)=0x%08lx\n", TRACE_(reg)(" Value %s, Data(dword)=0x%08lx\n",
debugstr_w(key->name), debugstr_w(key->name),
(DWORD)*lpbData); (DWORD)*lpbData);
break; break;
case HEX_REG_MULTI_SZ:
case REG_MULTI_SZ: case REG_MULTI_SZ:
{ {
int i; int i;
@ -215,16 +212,7 @@ static void debug_print_value (LPBYTE lpbData, LPKEYVALUE key)
} }
break; break;
case HEX_REG_NONE: default:
case HEX_REG_BINARY:
case HEX_REG_LINK:
case HEX_REG_RESOURCE_LIST:
case HEX_REG_FULL_RESOURCE_DESCRIPTOR:
case REG_NONE:
case REG_LINK:
case REG_RESOURCE_LIST:
case REG_FULL_RESOURCE_DESCRIPTOR:
case REG_BINARY:
{ {
char szTemp[100]; /* 3*32 + 3 + 1 */ char szTemp[100]; /* 3*32 + 3 + 1 */
int i; int i;
@ -241,12 +229,6 @@ static void debug_print_value (LPBYTE lpbData, LPKEYVALUE key)
debugstr_w(key->name), debugstr_w(key->name),
szTemp); szTemp);
} }
break;
default:
FIXME_(reg)(" Value %s, Unknown data type %ld\n",
debugstr_w(key->name),
key->type);
} /* switch */ } /* switch */
} /* if */ } /* if */
} }

View File

@ -71,18 +71,18 @@ static const dataTypeMap typeMap[] =
{"hex(7):", REG_MULTI_SZ}, {"hex(7):", REG_MULTI_SZ},
{"hex(8):", REG_RESOURCE_LIST}, {"hex(8):", REG_RESOURCE_LIST},
{"hex(9):", REG_FULL_RESOURCE_DESCRIPTOR}, {"hex(9):", REG_FULL_RESOURCE_DESCRIPTOR},
{"hex(80000000):", REG_NONE}, {"hex(10):", REG_RESOURCE_REQUIREMENTS_LIST},
{"hex(80000001):", REG_SZ}, {"hex(80000000):", 0x80000000},
{"hex(80000002):", REG_EXPAND_SZ}, {"hex(80000001):", 0x80000001},
{"hex(80000003):", REG_BINARY}, {"hex(80000002):", 0x80000002},
{"hex(80000004):", REG_DWORD}, {"hex(80000003):", 0x80000003},
{"hex(80000005):", REG_DWORD_BIG_ENDIAN}, {"hex(80000004):", 0x80000004},
{"hex(80000006):", REG_LINK}, {"hex(80000005):", 0x80000005},
{"hex(80000007):", REG_MULTI_SZ}, {"hex(80000006):", 0x80000006},
{"hex(80000008):", REG_RESOURCE_LIST}, {"hex(80000007):", 0x80000007},
{"hex(80000009):", REG_FULL_RESOURCE_DESCRIPTOR}, {"hex(80000008):", 0x80000008},
{"hex(8000000a):", REG_BINARY}, /* REG_RESOURCE_REQUIREMENTS_LIST}, !Exist */ {"hex(80000009):", 0x80000000},
{"hex(8000000A):", REG_BINARY}, /* REG_RESOURCE_REQUIREMENTS_LIST}, !Exist */ {"hex(8000000a):", 0x8000000A}
}; };
const static int LAST_TYPE_MAP = sizeof(typeMap)/sizeof(dataTypeMap); const static int LAST_TYPE_MAP = sizeof(typeMap)/sizeof(dataTypeMap);
@ -229,7 +229,7 @@ HKEY getDataType(LPSTR *lpValue)
for (; counter < LAST_TYPE_MAP; counter++) for (; counter < LAST_TYPE_MAP; counter++)
{ {
LONG len = strlen(typeMap[counter].mask); LONG len = strlen(typeMap[counter].mask);
if ( strncmp( *lpValue, typeMap[counter].mask, len) == IDENTICAL) if ( strncmpi( *lpValue, typeMap[counter].mask, len) == IDENTICAL)
{ {
/* /*
* We found it, modify the value's pointer in order to skip the data * We found it, modify the value's pointer in order to skip the data
@ -480,7 +480,7 @@ static HRESULT setValue(LPSTR *argv)
DWORD dwType = NULL; DWORD dwType = NULL;
DWORD dwDataType; DWORD dwDataType;
CHAR lpsCurrentValue[KEY_MAX_LEN]; LPSTR lpsCurrentValue;
LPSTR keyValue = argv[0]; LPSTR keyValue = argv[0];
LPSTR keyData = argv[1]; LPSTR keyData = argv[1];
@ -489,6 +489,7 @@ static HRESULT setValue(LPSTR *argv)
if ( (keyValue == NULL) || (keyData == NULL) ) if ( (keyValue == NULL) || (keyData == NULL) )
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
lpsCurrentValue=HeapAlloc(GetProcessHeap(), 0,KEY_MAX_LEN);
/* /*
* Default registry values are encoded in the input stream as '@' but as * Default registry values are encoded in the input stream as '@' but as
* blank in the wine registry. * blank in the wine registry.
@ -508,6 +509,12 @@ static HRESULT setValue(LPSTR *argv)
(LPBYTE)lpsCurrentValue, (LPBYTE)lpsCurrentValue,
&dwSize); &dwSize);
while(hRes==ERROR_MORE_DATA){
dwSize+=KEY_MAX_LEN;
lpsCurrentValue=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpsCurrentValue,dwSize);
hRes = RegQueryValueExA(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpsCurrentValue,&dwSize);
}
if( ( strlen(lpsCurrentValue) == 0 ) || /* The value is not existing */ if( ( strlen(lpsCurrentValue) == 0 ) || /* The value is not existing */
( bForce )) /* -force option */ ( bForce )) /* -force option */
{ {
@ -690,7 +697,7 @@ static void processQueryValue(LPSTR cmdline)
if( (keyValue[0] == '@') && (strlen(keyValue) == 1) ) if( (keyValue[0] == '@') && (strlen(keyValue) == 1) )
{ {
LONG lLen = KEY_MAX_LEN; LONG lLen = KEY_MAX_LEN;
CHAR lpsData[KEY_MAX_LEN]; CHAR* lpsData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
/* /*
* We need to query the key default value * We need to query the key default value
*/ */
@ -700,6 +707,12 @@ static void processQueryValue(LPSTR cmdline)
(LPBYTE)lpsData, (LPBYTE)lpsData,
&lLen); &lLen);
while(hRes==ERROR_MORE_DATA){
lLen+=KEY_MAX_LEN;
lpsData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpsData,lLen);
hRes = RegQueryValue(currentKeyHandle,currentKeyName,(LPBYTE)lpsData,&lLen);
}
if (hRes == ERROR_SUCCESS) if (hRes == ERROR_SUCCESS)
{ {
lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen); lpsRes = HeapAlloc( GetProcessHeap(), 0, lLen);
@ -709,7 +722,7 @@ static void processQueryValue(LPSTR cmdline)
else else
{ {
DWORD dwLen = KEY_MAX_LEN; DWORD dwLen = KEY_MAX_LEN;
BYTE lpbData[KEY_MAX_LEN]; BYTE* lpbData=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,KEY_MAX_LEN);
DWORD dwType; DWORD dwType;
/* /*
* We need to query a specific value for the key * We need to query a specific value for the key
@ -722,6 +735,12 @@ static void processQueryValue(LPSTR cmdline)
(LPBYTE)lpbData, (LPBYTE)lpbData,
&dwLen); &dwLen);
while(hRes==ERROR_MORE_DATA){
dwLen+=KEY_MAX_LEN;
lpbData=HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,lpbData,dwLen);
hRes = RegQueryValueEx(currentKeyHandle,keyValue,NULL,&dwType,(LPBYTE)lpbData,&dwLen);
}
if (hRes == ERROR_SUCCESS) if (hRes == ERROR_SUCCESS)
{ {
/* /*
@ -730,6 +749,7 @@ static void processQueryValue(LPSTR cmdline)
switch ( dwType ) switch ( dwType )
{ {
case REG_SZ: case REG_SZ:
case REG_EXPAND_SZ:
{ {
lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen); lpsRes = HeapAlloc( GetProcessHeap(), 0, dwLen);
strncpy(lpsRes, lpbData, dwLen); strncpy(lpsRes, lpbData, dwLen);
@ -747,6 +767,8 @@ static void processQueryValue(LPSTR cmdline)
} }
} }
} }
HeapFree(GetProcessHeap(), 0, lpbData);
} }
@ -904,9 +926,13 @@ int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
LPSTR token = NULL; /* current token analized */ LPSTR token = NULL; /* current token analized */
LPSTR stdInput = NULL; /* line read from stdin */ LPSTR stdInput = NULL; /* line read from stdin */
INT cmdIndex = -1; /* index of the command in array */ INT cmdIndex = -1; /* index of the command in array */
LPSTR nextLine = NULL;
ULONG currentSize = STDIN_MAX_LEN;
stdInput = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN); stdInput = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN);
if (stdInput == NULL) nextLine = HeapAlloc(GetProcessHeap(), 0, STDIN_MAX_LEN);
if (stdInput == NULL || nextLine== NULL)
return NOT_ENOUGH_MEMORY; return NOT_ENOUGH_MEMORY;
/* /*
@ -946,8 +972,13 @@ int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
/* /*
* read a line * read a line
*/ */
stdInput = fgets(stdInput, STDIN_MAX_LEN, stdin); ULONG curSize=STDIN_MAX_LEN;
char* s=NULL;
while((NULL!=(stdInput=fgets(stdInput,curSize,stdin))) && (NULL==(s=strchr(stdInput,'\n'))) ){
fseek(stdin,-curSize,SEEK_CUR+1);
stdInput=HeapReAlloc(GetProcessHeap(), 0,stdInput,curSize+=STDIN_MAX_LEN);
}
/* /*
* Make some handy generic stuff here... * Make some handy generic stuff here...
*/ */
@ -957,6 +988,24 @@ int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
if( stdInput[0] == '#' ) /* this is a comment, skip */ if( stdInput[0] == '#' ) /* this is a comment, skip */
continue; continue;
while( stdInput[strlen(stdInput) -1] == '\\' ){ /* a '\' char in the end of the current line means */
/* that this line is not complete and we have to get */
stdInput[strlen(stdInput) -1]= NULL; /* the rest in the next lines */
nextLine = fgets(nextLine, STDIN_MAX_LEN, stdin);
nextLine[strlen(nextLine)-1] = NULL;
if ( (strlen(stdInput)+strlen(nextLine)) > currentSize){
stdInput=HeapReAlloc(GetProcessHeap(),0,stdInput,strlen(stdInput)+STDIN_MAX_LEN);
currentSize+=STDIN_MAX_LEN;
}
strcat(stdInput,nextLine+2);
}
} }
/* /*
@ -975,7 +1024,10 @@ int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
if ( commandSaveRegistry[cmdIndex] != FALSE ) if ( commandSaveRegistry[cmdIndex] != FALSE )
SHELL_SaveRegistry(); SHELL_SaveRegistry();
HeapFree(GetProcessHeap(), 0, nextLine);
HeapFree(GetProcessHeap(), 0, stdInput); HeapFree(GetProcessHeap(), 0, stdInput);
return SUCCESS; return SUCCESS;
} }