Skip to content

Commit

Permalink
change some api type from size_t to int
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSizuku committed Apr 8, 2024
1 parent 41cd0dc commit 1a76acd
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion project/windll_winhook/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LDFLAGS= # tcc can not remove at at stdcall in i686
else
endif

all: prepare libwinhook
all: prepare libwinhook libwinhook_test helloexe hellodll

clean:
@rm -rf $(BUILD_DIR)/*libwinhook*
Expand Down
8 changes: 4 additions & 4 deletions project/windll_winhook/libwinhook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\debug\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32d</IntDir>
<TargetName>$(ProjectName)32d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32</IntDir>
<TargetName>$(ProjectName)32</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\debug\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64d</IntDir>
<TargetName>$(ProjectName)64d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64</IntDir>
<TargetName>$(ProjectName)64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down
8 changes: 4 additions & 4 deletions project/windll_winhook/libwinhook_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
<IntDir>$(SolutionDir)\build\obj\debug\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32d</IntDir>
<TargetName>$(ProjectName)32d</TargetName>
<OutDir>$(SolutionDir)\build</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\debug\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64d</IntDir>
<TargetName>$(ProjectName)64d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32</IntDir>
<TargetName>$(ProjectName)32</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\build\</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64</IntDir>
<TargetName>$(ProjectName)64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down
2 changes: 1 addition & 1 deletion project/windll_winpe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LDFLAGS= # tcc can not remove at at stdcall in i686
else
endif

all: prepare libwinpe
all: prepare libwinpe libwinpe_test

clean:
@rm -rf $(BUILD_DIR)/*libwinpe*
Expand Down
8 changes: 4 additions & 4 deletions project/windll_winpe/libwinpe.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\debug\i686</IntDir>
<IntDir>$(SolutionDir)\build\$(ProjectName)32d</IntDir>
<TargetName>$(ProjectName)32d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32</IntDir>
<TargetName>$(ProjectName)32</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\debug\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64d</IntDir>
<TargetName>$(ProjectName)64d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64</IntDir>
<TargetName>$(ProjectName)64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down
8 changes: 4 additions & 4 deletions project/windll_winpe/libwinpe_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>$(ProjectName)32</TargetName>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>$(ProjectName)64</TargetName>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\release\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>$(ProjectName)64d</TargetName>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\debug\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64d</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>$(ProjectName)32d</TargetName>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\release\debug\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32d</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
10 changes: 5 additions & 5 deletions project/winexe_winloader/winloader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
<IntDir>$(SolutionDir)\build\obj\debug\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32d</IntDir>
<TargetName>$(ProjectName)32d</TargetName>
<OutDir>$(SolutionDir)\build</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\debug\x86_64</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64d</IntDir>
<TargetName>$(ProjectName)64d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\i686</IntDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)32</IntDir>
<TargetName>$(ProjectName)32</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)\build\</OutDir>
<IntDir>$(SolutionDir)\build\obj\release\x86_64</IntDir>
<OutDir>$(SolutionDir)\build</OutDir>
<IntDir>$(SolutionDir)\build\obj\$(ProjectName)64</IntDir>
<TargetName>$(ProjectName)64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down
12 changes: 6 additions & 6 deletions src/commdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@
wprintf(format, ##__VA_ARGS__);
#define DummyPrintf(format, ...)
#define LOG(format, ...) LogTagPrintf(format, "I", ##__VA_ARGS__)
#define LOGL(format, ...) LogTagWprintf(format, L"I", ##__VA_ARGS__)
#define LOGL(format, ...) LogTagWprintf(format, "I", ##__VA_ARGS__)
#define LOGe(format, ...) LogTagPrintf(format, "E", ##__VA_ARGS__)
#define LOGLe(format, ...) LogTagWprintf(format, L"E", ##__VA_ARGS__)
#define LOGLe(format, ...) LogTagWprintf(format, "E", ##__VA_ARGS__)
#define LOGw(format, ...) LogTagPrintf(format, "W", ##__VA_ARGS__)
#define LOGLw(format, ...) LogTagWprintf(format, L"W", ##__VA_ARGS__)
#define LOGLw(format, ...) LogTagWprintf(format, "W", ##__VA_ARGS__)
#define LOGi(format, ...) LogTagPrintf(format, "I", ##__VA_ARGS__)
#define LOGLi(format, ...) LogTagWprintf(format, L"I", ##__VA_ARGS__)
#define LOGLi(format, ...) LogTagWprintf(format, "I", ##__VA_ARGS__)
#define LOGd(format, ...) LogTagPrintf(format, "D", ##__VA_ARGS__)
#define LOGLd(format, ...) LogTagWprintf(format, L"D", ##__VA_ARGS__)
#define LOGLd(format, ...) LogTagWprintf(format, "D", ##__VA_ARGS__)
#define LOGv(format, ...) LogTagPrintf(format, "V", ##__VA_ARGS__)
#define LOGLv(format, ...) LogTagWprintf(format, L"V", ##__VA_ARGS__)
#define LOGLv(format, ...) LogTagWprintf(format, "V", ##__VA_ARGS__)
#endif // LOG_LEVEL_
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_LEVEL_INFO
Expand Down
8 changes: 4 additions & 4 deletions src/winhook.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ BOOL winhook_iathook(LPCSTR targetDllName, PROC pfnOrg, PROC pfgNew)
* @return: success hook numbers
*/
WINHOOK_API
int winhook_inlinehooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], size_t n);
int winhook_inlinehooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], int n);

WINHOOK_API
int winhook_inlineunhooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], size_t n);
int winhook_inlineunhooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], int n);

#ifdef WINHOOK_IMPLEMENTATION
#include <stdio.h>
Expand Down Expand Up @@ -700,7 +700,7 @@ BOOL winhook_iathookpe(LPCSTR targetDllName, void* mempe, PROC pfnOrg, PROC pfnN
#include "stb_minhook.h"
#endif

int winhook_inlinehooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], size_t n)
int winhook_inlinehooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], int n)
{
int i;
MH_Initialize();
Expand All @@ -716,7 +716,7 @@ int winhook_inlinehooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], si
return i;
}

int winhook_inlineunhooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], size_t n)
int winhook_inlineunhooks(PVOID pfnTargets[], PVOID pfnNews[], PVOID pfnOlds[], int n)
{
int i;
for(i=0; i<n ;i++)
Expand Down
11 changes: 5 additions & 6 deletions src/winpe.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,10 @@ size_t STDCALL winpe_appendsecth(void *mempe, PIMAGE_SECTION_HEADER psecth);
#endif

#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include <winternl.h>

#ifdef _DEBUG
#include <assert.h>
#else
#define assert(x)
#endif

// PE high order fnctions
void* STDCALL winpe_memload_file(const char *path, size_t *pmemsize, bool_t same_align)
{
Expand Down Expand Up @@ -390,7 +385,9 @@ void* STDCALL winpe_memLoadLibraryEx(void *mempe, size_t imagebase, DWORD flag,
PFN_VirtualQuery pfnVirtualQuery = (PFN_VirtualQuery)pfnGetProcAddress(hmod_kernel32, name_VirtualQuery);
PFN_VirtualAlloc pfnVirtualAlloc = (PFN_VirtualAlloc)pfnGetProcAddress(hmod_kernel32, name_VirtualAlloc);
PFN_VirtualProtect pfnVirtualProtect =(PFN_VirtualProtect)pfnGetProcAddress(hmod_kernel32, name_VirtualProtect);
#ifdef _DEBUG
assert(pfnVirtualQuery!=0 && pfnVirtualAlloc!=0 && pfnVirtualProtect!=0);
#endif

// find proper imagebase
size_t imagesize = winpe_imagesizeval(mempe, 0);
Expand Down Expand Up @@ -787,7 +784,9 @@ size_t STDCALL winpe_membindiat(void *mempe,
funcva = (size_t)pfnGetProcAddress((HMODULE)dllbase, funcname);
if(!funcva) continue;
pFtThunk[j].u1.Function = funcva;
#ifdef _DEBUG
assert(funcva == (size_t)GetProcAddress((HMODULE)dllbase, funcname));
#endif
iat_count++;
}
}
Expand Down

0 comments on commit 1a76acd

Please sign in to comment.