microsoft / Detours

Detours is a software package for monitoring and instrumenting API calls on Windows. It is distributed in source code form.
MIT License
5.02k stars 981 forks source link

Maintenance: Clean up some compiler warnings #166

Closed rchildre3 closed 3 years ago

rchildre3 commented 3 years ago

Spotted with MinGW32 g++

i686-w64-mingw32-g++ -c -Wall -Wextra -Wpedantic ./creatwth.cpp

# In file included from ./creatwth.cpp:329:
# ./uimports.cpp: In function 'BOOL UpdateImports32(HANDLE, HMODULE, const CHAR**, DWORD)':
# ./uimports.cpp:109:48: warning: NULL used in arithmetic [-Wpointer-arith]
#   109 |     if (inh.IMPORT_DIRECTORY.VirtualAddress != NULL && inh.IMPORT_DIRECTORY.Size == 0) {
#       |                                                ^~~~
# ./creatwth.cpp: In function 'BOOL DetourUpdateProcessWithDllEx(HANDLE, HMODULE, BOOL, const CHAR**, DWORD)':
# ./creatwth.cpp:624:80: warning: NULL used in arithmetic [-Wpointer-arith]
#   624 |     if (hModule == NULL || LoadNtHeaderFromProcess(hProcess, hModule, &inh) == NULL) {
#       |                                                                                ^~~~
Microsoft Reviewers: Open in CodeFlow
ghost commented 3 years ago

CLA assistant check
All CLA requirements met.

bgianfo commented 3 years ago

Nice finds, thanks for the PR!

ghost commented 3 years ago

Hello @bgianfo!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 5 hours 38 minutes. No worries though, I will be back when the time is right! :wink:

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.
sonyps5201314 commented 3 years ago

@rchildre3, @bgianfo In this PR, the inequality sign in the original text was written as an equal sign, inh.IMPORT_DIRECTORY.VirtualAddress != NULL => inh.IMPORT_DIRECTORY.VirtualAddress == 0 ??? which destroyed the original intent. It is estimated that it should be reproduced without testing.

rchildre3 commented 3 years ago

@sonyps5201314 @bgianfo Apologies, fixed in #168