Skip to content

Commit 83899ac

Browse files
committed
Use DWORD directly to avoid cast.
1 parent 6276f44 commit 83899ac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

MemoryModule.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data,
584584
FARPROC MemoryGetProcAddress(HMEMORYMODULE module, LPCSTR name)
585585
{
586586
unsigned char *codeBase = ((PMEMORYMODULE)module)->codeBase;
587-
int idx;
587+
DWORD idx;
588588
PIMAGE_EXPORT_DIRECTORY exports;
589589
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE)module, IMAGE_DIRECTORY_ENTRY_EXPORT);
590590
if (directory->Size == 0) {
@@ -613,22 +613,23 @@ FARPROC MemoryGetProcAddress(HMEMORYMODULE module, LPCSTR name)
613613
DWORD i;
614614
DWORD *nameRef = (DWORD *) (codeBase + exports->AddressOfNames);
615615
WORD *ordinal = (WORD *) (codeBase + exports->AddressOfNameOrdinals);
616-
idx = -1;
616+
BOOL found = FALSE;
617617
for (i=0; i<exports->NumberOfNames; i++, nameRef++, ordinal++) {
618618
if (_stricmp(name, (const char *) (codeBase + (*nameRef))) == 0) {
619619
idx = *ordinal;
620+
found = TRUE;
620621
break;
621622
}
622623
}
623624

624-
if (idx == -1) {
625+
if (!found) {
625626
// exported symbol not found
626627
SetLastError(ERROR_PROC_NOT_FOUND);
627628
return NULL;
628629
}
629630
}
630631

631-
if ((DWORD)idx > exports->NumberOfFunctions) {
632+
if (idx > exports->NumberOfFunctions) {
632633
// name <-> ordinal number don't match
633634
SetLastError(ERROR_PROC_NOT_FOUND);
634635
return NULL;

0 commit comments

Comments
 (0)