Author: rharabien Date: Sun Jul 10 11:49:52 2011 New Revision: 52601
URL: http://svn.reactos.org/svn/reactos?rev=52601&view=rev Log: [NTDLL/LDR] - Don't use -1 for USHORT LDR_DATA_TABLE_ENTRY::LoadCount. When comparing ((USHORT)-1) == 0xFFFF vs (int)-1 it ends in comparison 0xFFFF vs 0xFFFFFFFF with is wrong. Fixes shutdown from shell See issue #6345 for more details.
Modified: trunk/reactos/dll/ntdll/ldr/ldrutils.c
Modified: trunk/reactos/dll/ntdll/ldr/ldrutils.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrutils.c?re... ============================================================================== --- trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] Sun Jul 10 11:49:52 2011 @@ -105,7 +105,7 @@ FALSE, &Entry)) { - if (Entry->LoadCount != -1) + if (Entry->LoadCount != 0xFFFF) { /* Perform the required action */ switch (Flags) @@ -117,7 +117,7 @@ Entry->LoadCount--; break; case LDRP_UPDATE_PIN: - Entry->LoadCount = -1; + Entry->LoadCount = 0xFFFF; break; }
@@ -149,7 +149,7 @@ FALSE, &Entry)) { - if (Entry->LoadCount != -1) + if (Entry->LoadCount != 0xFFFF) { /* Perform the required action */ switch (Flags) @@ -161,7 +161,7 @@ Entry->LoadCount--; break; case LDRP_UPDATE_PIN: - Entry->LoadCount = -1; + Entry->LoadCount = 0xFFFF; break; }
@@ -218,7 +218,7 @@ FALSE, &Entry)) { - if (Entry->LoadCount != -1) + if (Entry->LoadCount != 0xFFFF) { /* Perform the required action */ switch (Flags) @@ -230,7 +230,7 @@ Entry->LoadCount--; break; case LDRP_UPDATE_PIN: - Entry->LoadCount = -1; + Entry->LoadCount = 0xFFFF; break; }
@@ -1963,7 +1963,7 @@ }
/* Update load count, unless it's locked */ - if (LdrEntry->LoadCount != -1) LdrEntry->LoadCount++; + if (LdrEntry->LoadCount != 0xFFFF) LdrEntry->LoadCount++; LdrpUpdateLoadCount2(LdrEntry, LDRP_UPDATE_REFCOUNT);
/* Check if we failed */ @@ -1982,7 +1982,7 @@ goto Quickie; } } - else if (LdrEntry->LoadCount != -1) + else if (LdrEntry->LoadCount != 0xFFFF) { /* Increase load count */ LdrEntry->LoadCount++; @@ -2014,7 +2014,7 @@ else { /* We were already loaded. Are we a DLL? */ - if ((LdrEntry->Flags & LDRP_IMAGE_DLL) && (LdrEntry->LoadCount != -1)) + if ((LdrEntry->Flags & LDRP_IMAGE_DLL) && (LdrEntry->LoadCount != 0xFFFF)) { /* Increase load count */ LdrEntry->LoadCount++; @@ -2026,7 +2026,7 @@ else { /* Not a DLL, just increase the load count */ - if (LdrEntry->LoadCount != -1) LdrEntry->LoadCount++; + if (LdrEntry->LoadCount != 0xFFFF) LdrEntry->LoadCount++; } }
@@ -2084,7 +2084,7 @@ }
/* Check the current Load Count */ - if (LdrEntry->LoadCount != -1) + if (LdrEntry->LoadCount != 0xFFFF) { /* Decrease it */ LdrEntry->LoadCount--;