Skip to content

Commit

Permalink
Fixed to work with 32 bit Unity
Browse files Browse the repository at this point in the history
  • Loading branch information
nike4613 committed Jul 23, 2019
1 parent 02647aa commit bcab2ee
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 6 deletions.
9 changes: 5 additions & 4 deletions Proxy/Proxy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<ModuleDefinitionFile>$(MSBuildProjectDirectory)\proxy.def</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>
</DelayLoadDLLs>
Expand Down Expand Up @@ -147,8 +146,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<ModuleDefinitionFile>$(MSBuildProjectDirectory)\proxy.def</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>
</DelayLoadDLLs>
Expand All @@ -172,6 +170,9 @@
<ItemGroup>
<ResourceCompile Include="proxy.rc" />
</ItemGroup>
<ItemGroup>
<None Include="proxy.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Target Name="AfterBuild">
<Exec Command="$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine($(MSBuildProjectDirectory), '..', 'BuildUtils', 'ducible.exe')))) $(OutDir)$(MSBuildProjectName).dll $(OutDir)$(MSBuildProjectName).pdb" />
Expand Down
5 changes: 5 additions & 0 deletions Proxy/Proxy.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="proxy.def">
<Filter>Other</Filter>
</None>
</ItemGroup>
</Project>
17 changes: 15 additions & 2 deletions Proxy/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ void *ownMonoJitInitVersion(const char *root_domain_name, const char *runtime_ve
opts[0] = "";
ownMonoJitParseOptions(0, opts);
}
#ifdef WIN32
if (debug_info) {
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
}
#endif

void *domain = mono_jit_init_version(root_domain_name, runtime_version);

if (debug_info) {
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
#ifdef WIN64
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
#endif
mono_debug_domain_create(domain);
}

Expand Down Expand Up @@ -147,14 +154,20 @@ void ownMonoJitParseOptions(int argc, char * argv[])
setOptions = TRUE;

int size = argc;
#ifdef WIN64
if (debug) size += 2;
#elif defined(WIN32)
if (debug) size += 1;
#endif

char** arguments = memalloc(sizeof(char*) * size);
_ASSERTE(arguments != nullptr);
memcpy(arguments, argv, sizeof(char*) * argc);
if (debug) {
//arguments[argc++] = "--debug";
arguments[argc++] = "--soft-breakpoints";
#ifdef WIN64
arguments[argc++] = "--soft-breakpoints";
#endif
if (debug_server)
arguments[argc] = "--debugger-agent=transport=dt_socket,address=0.0.0.0:10000,server=y";
else
Expand Down
52 changes: 52 additions & 0 deletions Proxy/proxy.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
LIBRARY proxy.dll
EXPORTS
WinHttpAddRequestHeaders @1
WinHttpAutoProxySvcMain @2
WinHttpCheckPlatform @3
WinHttpCloseHandle @4
WinHttpConnect @5
WinHttpConnectionDeleteProxyInfo @6
WinHttpConnectionFreeNameList @7
WinHttpConnectionFreeProxyInfo @8
WinHttpConnectionFreeProxyList @9
WinHttpConnectionGetNameList @10
WinHttpConnectionGetProxyInfo @11
WinHttpConnectionGetProxyList @12
WinHttpConnectionSetProxyInfo @13
WinHttpCrackUrl @14
WinHttpCreateProxyResolver @15
WinHttpCreateUrl @16
WinHttpDetectAutoProxyConfigUrl @17
WinHttpFreeProxyResult @18
WinHttpGetDefaultProxyConfiguration @19
WinHttpGetIEProxyConfigForCurrentUser @20
WinHttpGetProxyForUrl @21
WinHttpGetProxyForUrlEx @22
WinHttpGetProxyResult @23
WinHttpGetTunnelSocket @24
WinHttpOpen @25
WinHttpOpenRequest @26
WinHttpProbeConnectivity @27
WinHttpQueryAuthSchemes @28
WinHttpQueryDataAvailable @29
WinHttpQueryHeaders @30
WinHttpQueryOption @31
WinHttpReadData @32
WinHttpReceiveResponse @33
WinHttpResetAutoProxy @34
WinHttpSaveProxyCredentials @35
WinHttpSendRequest @36
WinHttpSetCredentials @37
WinHttpSetDefaultProxyConfiguration @38
WinHttpSetOption @39
WinHttpSetStatusCallback @40
WinHttpSetTimeouts @41
WinHttpTimeFromSystemTime @42
WinHttpTimeToSystemTime @43
WinHttpWebSocketClose @44
WinHttpWebSocketCompleteUpgrade @45
WinHttpWebSocketQueryCloseStatus @46
WinHttpWebSocketReceive @47
WinHttpWebSocketSend @48
WinHttpWebSocketShutdown @49
WinHttpWriteData @50
8 changes: 8 additions & 0 deletions proxygen/proxy_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def main():
proxies = io.StringIO()
proxy_add = io.StringIO()
proxy_def = io.StringIO()
proxy_def_file = io.StringIO()

count = 0

Expand All @@ -32,13 +33,20 @@ def main():
proxies.write(f"{name}\n")
proxy_add.write(f"ADD_ORIGINAL({count}, {name});\n")
proxy_def.write(f"PROXY({count}, {name});\n")
proxy_def_file.write(f" {name} @{count+1}\n")
count = count + 1

with open(f"{path}\\templates\\proxy_template.c", "r") as proxy_file:
new_proxy = string.Template(proxy_file.read()).safe_substitute(proxy_count=count, proxy_add=proxy_add.getvalue(), proxy_def=proxy_def.getvalue())

with open(f"{path}\\..\\Proxy\\proxy.c", "w") as proxy_c_file:
proxy_c_file.write(new_proxy)

with open(f"{path}\\templates\\proxy_template.def", "r") as proxy_file:
new_proxy_def = string.Template(proxy_file.read()).safe_substitute(proxy_exports=proxy_def_file.getvalue())

with open(f"{path}\\..\\Proxy\\proxy.def", "w") as proxy_def_file:
proxy_def_file.write(new_proxy_def)

if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions proxygen/templates/proxy_template.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBRARY proxy.dll
EXPORTS
${proxy_exports}

0 comments on commit bcab2ee

Please sign in to comment.