GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • MemoryModule.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎MemoryModule.c‎

Copy file name to clipboardExpand all lines: MemoryModule.c
+5-4Lines 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 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.