GeezerVison is showing github.com — Use DWORD directly to avoid cast. · smithellis/MemoryModule@83899ac
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: MemoryModule.c +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -584,7 +584,7 @@ HMEMORYMODULE MemoryLoadLibraryEx(const void *data, |
584 | 584 | FARPROC MemoryGetProcAddress(HMEMORYMODULE module, LPCSTR name) |
585 | 585 | { |
586 | 586 | unsigned char *codeBase = ((PMEMORYMODULE)module)->codeBase; |
587 | | - int idx; |
| 587 | + DWORD idx; |
588 | 588 | PIMAGE_EXPORT_DIRECTORY exports; |
589 | 589 | PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE)module, IMAGE_DIRECTORY_ENTRY_EXPORT); |
590 | 590 | if (directory->Size == 0) { |
@@ -613,22 +613,23 @@ FARPROC MemoryGetProcAddress(HMEMORYMODULE module, LPCSTR name) |
613 | 613 | DWORD i; |
614 | 614 | DWORD *nameRef = (DWORD *) (codeBase + exports->AddressOfNames); |
615 | 615 | WORD *ordinal = (WORD *) (codeBase + exports->AddressOfNameOrdinals); |
616 | | - idx = -1; |
| 616 | + BOOL found = FALSE; |
617 | 617 | for (i=0; i<exports->NumberOfNames; i++, nameRef++, ordinal++) { |
618 | 618 | if (_stricmp(name, (const char *) (codeBase + (*nameRef))) == 0) { |
619 | 619 | idx = *ordinal; |
| 620 | + found = TRUE; |
620 | 621 | break; |
621 | 622 | } |
622 | 623 | } |
623 | 624 |
|
624 | | - if (idx == -1) { |
| 625 | + if (!found) { |
625 | 626 | // exported symbol not found |
626 | 627 | SetLastError(ERROR_PROC_NOT_FOUND); |
627 | 628 | return NULL; |
628 | 629 | } |
629 | 630 | } |
630 | 631 |
|
631 | | - if ((DWORD)idx > exports->NumberOfFunctions) { |
| 632 | + if (idx > exports->NumberOfFunctions) { |
632 | 633 | // name <-> ordinal number don't match |
633 | 634 | SetLastError(ERROR_PROC_NOT_FOUND); |
634 | 635 | return NULL; |
|