Author: dchapyshev Date: Sat Jul 4 12:48:18 2009 New Revision: 41764
URL: http://svn.reactos.org/svn/reactos?rev=41764&view=rev Log: - GetProcessHeap -> RtlGetProcessHeap - Add checks at heap allocation - Add some debug prints
Modified: trunk/reactos/dll/win32/kernel32/file/backup.c trunk/reactos/dll/win32/kernel32/file/dir.c trunk/reactos/dll/win32/kernel32/file/dosdev.c trunk/reactos/dll/win32/kernel32/file/volume.c trunk/reactos/dll/win32/kernel32/misc/atom.c trunk/reactos/dll/win32/kernel32/misc/comm.c trunk/reactos/dll/win32/kernel32/misc/icustubs.cpp trunk/reactos/dll/win32/kernel32/misc/profile.c trunk/reactos/dll/win32/kernel32/misc/res.c trunk/reactos/dll/win32/kernel32/misc/stubs.c trunk/reactos/dll/win32/kernel32/process/session.c
Modified: trunk/reactos/dll/win32/kernel32/file/backup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/bac... ============================================================================== --- trunk/reactos/dll/win32/kernel32/file/backup.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/backup.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -32,6 +32,7 @@ LPVOID * lpContext ) { + UNIMPLEMENTED; SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } @@ -51,6 +52,7 @@ LPVOID * lpContext ) { + UNIMPLEMENTED; SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } @@ -71,6 +73,7 @@ LPVOID * lpContext ) { + UNIMPLEMENTED; SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; }
Modified: trunk/reactos/dll/win32/kernel32/file/dir.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/dir... ============================================================================== --- trunk/reactos/dll/win32/kernel32/file/dir.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/dir.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -1030,7 +1030,7 @@ } else { - Name = RtlAllocateHeap(GetProcessHeap(), + Name = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, (wcslen(lpFileName) + wcslen(lpExtension) + 1) * sizeof(WCHAR));
Modified: trunk/reactos/dll/win32/kernel32/file/dosdev.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/dos... ============================================================================== --- trunk/reactos/dll/win32/kernel32/file/dosdev.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/dosdev.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -76,6 +76,7 @@ LPCWSTR lpTargetPath ) { + UNIMPLEMENTED; return FALSE; }
Modified: trunk/reactos/dll/win32/kernel32/file/volume.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/vol... ============================================================================== --- trunk/reactos/dll/win32/kernel32/file/volume.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/file/volume.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -917,7 +917,7 @@ BufferLength = sizeof(MOUNTDEV_NAME) + 50 * sizeof(WCHAR); do { - MountDevName = RtlAllocateHeap(GetProcessHeap(), 0, BufferLength); + MountDevName = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); if (MountDevName == NULL) { NtClose(FileHandle); @@ -964,7 +964,7 @@ MountPoint->DeviceNameOffset = sizeof(MOUNTMGR_MOUNT_POINT); MountPoint->DeviceNameLength = MountDevName->NameLength; RtlCopyMemory(MountPoint + 1, MountDevName->Name, MountDevName->NameLength); - RtlFreeHeap(GetProcessHeap(), 0, MountDevName); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountDevName);
RtlInitUnicodeString(&NtFileName, L"\??\MountPointManager"); InitializeObjectAttributes(&ObjectAttributes, &NtFileName, 0, NULL, NULL); @@ -974,17 +974,17 @@ if (!NT_SUCCESS(Status)) { SetLastErrorByStatus(Status); - RtlFreeHeap(GetProcessHeap(), 0, MountPoint); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint); return FALSE; }
BufferLength = sizeof(MOUNTMGR_MOUNT_POINTS); do { - MountPoints = RtlAllocateHeap(GetProcessHeap(), 0, BufferLength); + MountPoints = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength); if (MountPoints == NULL) { - RtlFreeHeap(GetProcessHeap(), 0, MountPoint); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint); NtClose(FileHandle); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; @@ -996,7 +996,7 @@ MountPoints, BufferLength); if (!NT_SUCCESS(Status)) { - RtlFreeHeap(GetProcessHeap(), 0, MountPoints); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints); if (Status == STATUS_BUFFER_OVERFLOW) { BufferLength = MountPoints->Size; @@ -1004,7 +1004,7 @@ } else if (!NT_SUCCESS(Status)) { - RtlFreeHeap(GetProcessHeap(), 0, MountPoint); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint); NtClose(FileHandle); SetLastErrorByStatus(Status); return FALSE; @@ -1013,7 +1013,7 @@ } while (!NT_SUCCESS(Status));
- RtlFreeHeap(GetProcessHeap(), 0, MountPoint); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint); NtClose(FileHandle);
/* @@ -1055,14 +1055,14 @@ Result = FALSE; }
- RtlFreeHeap(GetProcessHeap(), 0, MountPoints); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints);
return Result; } } }
- RtlFreeHeap(GetProcessHeap(), 0, MountPoints); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; @@ -1091,7 +1091,7 @@ if ((ret = GetVolumeNameForVolumeMountPointW( pathW, volumeW, len ))) FilenameW2A_N( lpszVolumeName, len, volumeW, -1 );
- RtlFreeHeap( GetProcessHeap(), 0, pathW ); + RtlFreeHeap( RtlGetProcessHeap(), 0, pathW ); return ret; }
@@ -1107,7 +1107,7 @@ { DWORD size = 1024; HANDLE mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, 0, 0 ); + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, INVALID_HANDLE_VALUE ); if (mgr == INVALID_HANDLE_VALUE) return INVALID_HANDLE_VALUE;
for (;;) @@ -1115,7 +1115,7 @@ MOUNTMGR_MOUNT_POINT input; MOUNTMGR_MOUNT_POINTS *output;
- if (!(output = RtlAllocateHeap( GetProcessHeap(), 0, size ))) + if (!(output = RtlAllocateHeap( RtlGetProcessHeap(), 0, size ))) { SetLastError( ERROR_NOT_ENOUGH_MEMORY ); break; @@ -1127,7 +1127,7 @@ { if (GetLastError() != ERROR_MORE_DATA) break; size = output->Size; - RtlFreeHeap( GetProcessHeap(), 0, output ); + RtlFreeHeap( RtlGetProcessHeap(), 0, output ); continue; } CloseHandle( mgr ); @@ -1135,7 +1135,7 @@ output->Size = 0; if (!FindNextVolumeW( output, volume, len )) { - RtlFreeHeap( GetProcessHeap(), 0, output ); + RtlFreeHeap( RtlGetProcessHeap(), 0, output ); return INVALID_HANDLE_VALUE; } return (HANDLE)output; @@ -1154,8 +1154,18 @@ DWORD len ) { - WCHAR *buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - HANDLE handle = FindFirstVolumeW( buffer, len ); + WCHAR *buffer = NULL; + HANDLE handle; + + buffer = RtlAllocateHeap( RtlGetProcessHeap(), 0, len * sizeof(WCHAR) ); + + if (!buffer) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return INVALID_HANDLE_VALUE; + } + + handle = FindFirstVolumeW( buffer, len );
if (handle != INVALID_HANDLE_VALUE) { @@ -1165,7 +1175,7 @@ handle = INVALID_HANDLE_VALUE; } } - RtlFreeHeap( GetProcessHeap(), 0, buffer ); + RtlFreeHeap( RtlGetProcessHeap(), 0, buffer ); return handle; }
@@ -1178,7 +1188,7 @@ HANDLE hFindVolume ) { - return RtlFreeHeap(GetProcessHeap(), 0, hFindVolume); + return RtlFreeHeap(RtlGetProcessHeap(), 0, hFindVolume); }
/*
Modified: trunk/reactos/dll/win32/kernel32/misc/atom.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ato... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/atom.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/atom.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -340,6 +340,12 @@ 0, AtomInfoLength);
+ if (!AtomInfo) + { + SetLastErrorByStatus(STATUS_NO_MEMORY); + return 0; + } + /* Query the name */ Status = NtQueryInformationAtom(Atom, AtomBasicInformation,
Modified: trunk/reactos/dll/win32/kernel32/misc/comm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/com... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/comm.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/comm.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -741,7 +741,14 @@ if (lpszName) { len = MultiByteToWideChar( CP_ACP, 0, lpszName, -1, NULL, 0 ); + lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + if (!lpDeviceW) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + MultiByteToWideChar( CP_ACP, 0, lpszName, -1, lpDeviceW, len ); } r = SetDefaultCommConfigW(lpDeviceW,lpCC,dwSize);
Modified: trunk/reactos/dll/win32/kernel32/misc/icustubs.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/icu... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/icustubs.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/icustubs.cpp [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -45,17 +45,17 @@
void free(void * memory) { - RtlFreeHeap(GetProcessHeap(), 0, memory); + RtlFreeHeap(RtlGetProcessHeap(), 0, memory); }
void * malloc(size_t size) { - return RtlAllocateHeap(GetProcessHeap(), 0, size); + return RtlAllocateHeap(RtlGetProcessHeap(), 0, size); }
void * realloc(void * memory, size_t size) { - return RtlReAllocateHeap(GetProcessHeap(), 0, memory, size); + return RtlReAllocateHeap(RtlGetProcessHeap(), 0, memory, size); }
int __cdecl _purecall()
Modified: trunk/reactos/dll/win32/kernel32/misc/profile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/pro... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/profile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/profile.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -488,6 +488,7 @@ { len = (int)(szLineEnd - szValueStart); key->value = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ); + if (!key->value) break; memcpy(key->value, szValueStart, len * sizeof(WCHAR)); key->value[len] = '\0'; } @@ -1155,6 +1156,7 @@ int len = (int)(p - def_val) + 1;
defval_tmp = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + if (!defval_tmp) return 0; memcpy(defval_tmp, def_val, len * sizeof(WCHAR)); defval_tmp[len] = '\0'; def_val = defval_tmp; @@ -1384,6 +1386,12 @@ }
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!bufferW) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + RtlCreateUnicodeStringFromAsciiz(§ionW, section); if (filename) RtlCreateUnicodeStringFromAsciiz(&filenameW, filename); else filenameW.Buffer = NULL;
Modified: trunk/reactos/dll/win32/kernel32/misc/res.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/res... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/res.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/res.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -97,6 +97,7 @@ return (LPWSTR) (UINT_PTR) LOWORD(str); len = (lstrlenW( str ) + 1) * sizeof (WCHAR); ret = HeapAlloc( GetProcessHeap(), 0, len ); + if (!ret) return NULL; memcpy( ret, str, len ); return ret; } @@ -285,6 +286,7 @@ if (!restype) { restype = HeapAlloc( GetProcessHeap(), 0, sizeof *restype ); + if (!restype) return FALSE; restype->id = res_strdupW( Type ); list_init( &restype->children ); add_resource_dir_entry( &updates->root, restype ); @@ -294,6 +296,7 @@ if (!resname) { resname = HeapAlloc( GetProcessHeap(), 0, sizeof *resname ); + if (!resname) return FALSE; resname->id = res_strdupW( Name ); list_init( &resname->children ); add_resource_dir_entry( &restype->children, resname ); @@ -468,6 +471,7 @@
string = (const IMAGE_RESOURCE_DIR_STRING_U*) (((const char *)root) + entry->NameOffset); s = HeapAlloc(GetProcessHeap(), 0, (string->Length + 1)*sizeof (WCHAR) ); + if (!s) return NULL; memcpy( s, string->NameString, (string->Length + 1)*sizeof (WCHAR) ); s[string->Length] = 0;
Modified: trunk/reactos/dll/win32/kernel32/misc/stubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/stu... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/stubs.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/stubs.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -661,8 +661,14 @@ LPSTR volume, DWORD len) { - WCHAR *buffer = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + WCHAR *buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, len * sizeof(WCHAR)); BOOL ret; + + if (!buffer) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + }
if ((ret = FindNextVolumeW( handle, buffer, len ))) {
Modified: trunk/reactos/dll/win32/kernel32/process/session.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/process/... ============================================================================== --- trunk/reactos/dll/win32/kernel32/process/session.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/process/session.c [iso-8859-1] Sat Jul 4 12:48:18 2009 @@ -9,6 +9,9 @@ * 2001-12-07 created */ #include <k32.h> +#include <wine/debug.h> + +WINE_DEFAULT_DEBUG_CHANNEL(kernel32session);
DWORD ActiveConsoleSessionId = 0;
@@ -19,6 +22,7 @@ DWORD WINAPI DosPathToSessionPathW (DWORD SessionID, LPWSTR InPath, LPWSTR * OutPath) { + UNIMPLEMENTED; return 0; }
@@ -39,6 +43,7 @@ DosPathToSessionPathA (DWORD SessionId, LPSTR InPath, LPSTR * OutPath) { //DosPathToSessionPathW (SessionId,InPathW,OutPathW); + UNIMPLEMENTED; return 0; }