Skip to content

Commit

Permalink
MSVC support
Browse files Browse the repository at this point in the history
  • Loading branch information
jchv committed Jul 22, 2024
1 parent 9ddf92d commit 4b8d3eb
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Configure
run: nix develop --command make -j4 slipstream
run: nix develop --command make -j8 all
- name: Upload
uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ CFLAGS :=

LDFLAGS := -nodefaultlibs -nostartfiles -lkernel32 -luser32 -Wl,--enable-stdcall-fixup -s

LDFLAGS_MSVCRT := third_party/msvcrt/msvcrt.lib third_party/msvcrt/rtsyms.o

OBJS := \
obj/dll/rugburn/main.o \
obj/hooks/kernel32/inject.o \
Expand All @@ -22,15 +24,12 @@ OBJS := \
obj/common.o \
obj/config.o \
obj/hex.o \
obj/ijl.o \
obj/json.o \
obj/patch.o \
obj/regex.o

IJL15OBJS := $(wildcard third_party/ijl/*.obj)

LDFLAGS_MSVCRT := third_party/msvcrt/msvcrt.lib third_party/msvcrt/exceptlist.o

TESTOBJS := \
$(OBJS) \
obj/exe/test/main.o
Expand Down
53 changes: 47 additions & 6 deletions rugburn.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
<EntryPointSymbol>DllMain</EntryPointSymbol>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;$(ProjectDir)\third_party\msvcrt\msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -126,7 +127,8 @@
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
<EntryPointSymbol>DllMain</EntryPointSymbol>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;$(ProjectDir)\third_party\msvcrt\msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -149,7 +151,8 @@
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
<EntryPointSymbol>DllMain</EntryPointSymbol>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;$(ProjectDir)\third_party\msvcrt\msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -172,11 +175,11 @@
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>export.def</ModuleDefinitionFile>
<EntryPointSymbol>DllMain</EntryPointSymbol>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;shlwapi.lib;$(ProjectDir)\third_party\msvcrt\msvcrt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\bootstrap.c" />
<ClCompile Include="src\common.c" />
<ClCompile Include="src\config.c" />
<ClCompile Include="src\dll\rugburn\main.c" />
Expand All @@ -187,7 +190,6 @@
<ClCompile Include="src\hooks\user32\window.c" />
<ClCompile Include="src\hooks\wininet\netredir.c" />
<ClCompile Include="src\hooks\ws2_32\redir.c" />
<ClCompile Include="src\ijlfwd.c" />
<ClCompile Include="src\json.c" />
<ClCompile Include="src\patch.c" />
<ClCompile Include="src\regex.c" />
Expand All @@ -201,6 +203,45 @@
<None Include="README.md" />
<None Include="src\third_party\lend\COPYING" />
</ItemGroup>
<ItemGroup>
<Object Include="third_party\ijl\aan_fdct.obj" />
<Object Include="third_party\ijl\aan_fdct1.obj" />
<Object Include="third_party\ijl\aan_idct.obj" />
<Object Include="third_party\ijl\aan_idct1.obj" />
<Object Include="third_party\ijl\cc_ss_decoder.obj" />
<Object Include="third_party\ijl\cc_ss_decoder1.obj" />
<Object Include="third_party\ijl\cc_ss_encoder.obj" />
<Object Include="third_party\ijl\cc_ss_encoder1.obj" />
<Object Include="third_party\ijl\cpuid.obj" />
<Object Include="third_party\ijl\cpuid1.obj" />
<Object Include="third_party\ijl\decoder_parser.obj" />
<Object Include="third_party\ijl\decode_buffer.obj" />
<Object Include="third_party\ijl\encoder_parser.obj" />
<Object Include="third_party\ijl\encode_buffer.obj" />
<Object Include="third_party\ijl\encode_buffer1.obj" />
<Object Include="third_party\ijl\fileio.obj" />
<Object Include="third_party\ijl\frame_decoder.obj" />
<Object Include="third_party\ijl\frame_encoder.obj" />
<Object Include="third_party\ijl\globals.obj" />
<Object Include="third_party\ijl\huff_decode.obj" />
<Object Include="third_party\ijl\huff_encode.obj" />
<Object Include="third_party\ijl\huff_encode1.obj" />
<Object Include="third_party\ijl\init.obj" />
<Object Include="third_party\ijl\ipp_fdct.obj" />
<Object Include="third_party\ijl\ipp_fdct1.obj" />
<Object Include="third_party\ijl\ipp_idct.obj" />
<Object Include="third_party\ijl\ipp_idct1.obj" />
<Object Include="third_party\ijl\jpgintfc.obj" />
<Object Include="third_party\ijl\mdecode.obj" />
<Object Include="third_party\ijl\precomp.obj" />
<Object Include="third_party\ijl\scan_decoder.obj" />
<Object Include="third_party\ijl\scan_encoder.obj" />
<Object Include="third_party\ijl\tables.obj" />
<Object Include="third_party\ijl\timing.obj" />
<Object Include="third_party\ijl\trace.obj" />
<Object Include="third_party\ijl\versionl.obj" />
<Object Include="third_party\msvcrt\rtsyms.o" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
127 changes: 123 additions & 4 deletions rugburn.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="src\bootstrap.c" />
<ClCompile Include="src\common.c" />
<ClCompile Include="src\dll\rugburn\main.c" />
<ClCompile Include="src\hooks\hooks.c" />
<ClCompile Include="src\hooks\kernel32\inject.c" />
<ClCompile Include="src\hooks\user32\window.c" />
<ClCompile Include="src\hooks\wininet\netredir.c" />
<ClCompile Include="src\hooks\ws2_32\redir.c" />
<ClCompile Include="src\ijlfwd.c" />
<ClCompile Include="src\patch.c" />
<ClCompile Include="src\ld.c" />
<ClCompile Include="src\json.c" />
Expand All @@ -21,9 +19,130 @@
<ClCompile Include="src\hooks\comctl32\dynamic_patch.c" />
</ItemGroup>
<ItemGroup>
<None Include="exportvs.def" />
<None Include="LICENSE.md" />
<None Include="README.md" />
<None Include="src\third_party\lend\COPYING" />
<None Include="export.def" />
</ItemGroup>
</Project>
<ItemGroup>
<Filter Include="ijl15">
<UniqueIdentifier>{749b9e28-ce49-4aa7-999d-be4bb1077fc1}</UniqueIdentifier>
</Filter>
<Filter Include="msvcrt">
<UniqueIdentifier>{94f8af0b-1247-4f4a-929d-819e5285c358}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Object Include="third_party\ijl\aan_fdct.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\aan_fdct1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\aan_idct.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\aan_idct1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\cc_ss_decoder.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\cc_ss_decoder1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\cc_ss_encoder.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\cc_ss_encoder1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\cpuid.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\cpuid1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\decode_buffer.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\decoder_parser.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\encode_buffer.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\encode_buffer1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\encoder_parser.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\fileio.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\frame_decoder.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\frame_encoder.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\globals.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\huff_decode.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\huff_encode.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\huff_encode1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\init.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\ipp_fdct.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\ipp_fdct1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\ipp_idct.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\ipp_idct1.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\jpgintfc.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\mdecode.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\precomp.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\scan_decoder.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\scan_encoder.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\tables.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\timing.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\trace.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\ijl\versionl.obj">
<Filter>ijl15</Filter>
</Object>
<Object Include="third_party\msvcrt\rtsyms.o">
<Filter>msvcrt</Filter>
</Object>
</ItemGroup>
</Project>
27 changes: 27 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,33 @@ VOID InitCommon() {
#pragma function(memset)
#endif

// MSVCRT runtime functions
#ifdef _MSC_VER
void __declspec(naked) _aullshr() {
__asm {
cmp cl,40h
jae RETZERO
cmp cl,20h
jae MORE32
shrd eax,edx,cl
shr edx,cl
ret
MORE32:
mov eax,edx
xor edx,edx
and cl,1Fh
shr eax,cl
ret
RETZERO:
xor eax,eax
xor edx,edx
ret
}
}
#else
unsigned long long __stdcall _aullshr(unsigned long long a, long b) { return a >> b; }
#endif

// C standard library functions
int strcmp(LPCSTR dest, LPCSTR src) {
int cmp;
Expand Down
12 changes: 0 additions & 12 deletions src/ijl.c

This file was deleted.

Binary file not shown.

0 comments on commit 4b8d3eb

Please sign in to comment.