From cc5bf5ecd5823a3b33d17e7e41a44fe3e097a3be Mon Sep 17 00:00:00 2001 From: Rafal Harabien Date: Sun, 10 Jul 2011 11:49:52 +0000 Subject: [PATCH] [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. svn path=/trunk/; revision=52601 --- reactos/dll/ntdll/ldr/ldrutils.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/reactos/dll/ntdll/ldr/ldrutils.c b/reactos/dll/ntdll/ldr/ldrutils.c index f41c371563d..5705e49c81a 100644 --- a/reactos/dll/ntdll/ldr/ldrutils.c +++ b/reactos/dll/ntdll/ldr/ldrutils.c @@ -105,7 +105,7 @@ LdrpUpdateLoadCount3(IN PLDR_DATA_TABLE_ENTRY LdrEntry, FALSE, &Entry)) { - if (Entry->LoadCount != -1) + if (Entry->LoadCount != 0xFFFF) { /* Perform the required action */ switch (Flags) @@ -117,7 +117,7 @@ LdrpUpdateLoadCount3(IN PLDR_DATA_TABLE_ENTRY LdrEntry, Entry->LoadCount--; break; case LDRP_UPDATE_PIN: - Entry->LoadCount = -1; + Entry->LoadCount = 0xFFFF; break; } @@ -149,7 +149,7 @@ LdrpUpdateLoadCount3(IN PLDR_DATA_TABLE_ENTRY LdrEntry, FALSE, &Entry)) { - if (Entry->LoadCount != -1) + if (Entry->LoadCount != 0xFFFF) { /* Perform the required action */ switch (Flags) @@ -161,7 +161,7 @@ LdrpUpdateLoadCount3(IN PLDR_DATA_TABLE_ENTRY LdrEntry, Entry->LoadCount--; break; case LDRP_UPDATE_PIN: - Entry->LoadCount = -1; + Entry->LoadCount = 0xFFFF; break; } @@ -218,7 +218,7 @@ LdrpUpdateLoadCount3(IN PLDR_DATA_TABLE_ENTRY LdrEntry, FALSE, &Entry)) { - if (Entry->LoadCount != -1) + if (Entry->LoadCount != 0xFFFF) { /* Perform the required action */ switch (Flags) @@ -230,7 +230,7 @@ LdrpUpdateLoadCount3(IN PLDR_DATA_TABLE_ENTRY LdrEntry, Entry->LoadCount--; break; case LDRP_UPDATE_PIN: - Entry->LoadCount = -1; + Entry->LoadCount = 0xFFFF; break; } @@ -1963,7 +1963,7 @@ StartLoop: } /* 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 @@ StartLoop: goto Quickie; } } - else if (LdrEntry->LoadCount != -1) + else if (LdrEntry->LoadCount != 0xFFFF) { /* Increase load count */ LdrEntry->LoadCount++; @@ -2014,7 +2014,7 @@ StartLoop: 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 @@ StartLoop: 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 @@ LdrUnloadDll(IN PVOID BaseAddress) } /* Check the current Load Count */ - if (LdrEntry->LoadCount != -1) + if (LdrEntry->LoadCount != 0xFFFF) { /* Decrease it */ LdrEntry->LoadCount--;