update test assemblies

This commit is contained in:
Kadir Yamamoto
2023-03-25 11:49:02 +09:00
parent fc765e3a01
commit 448994ee82
5 changed files with 22 additions and 69 deletions
-59
View File
@@ -1,59 +0,0 @@
use crate::primitives::{IUnknown, IUnknownVtbl, Interface, GUID, HRESULT};
use std::{ffi::c_void, ops::Deref};
use windows::core::BSTR;
#[repr(C)]
pub struct _StringWriter {
pub vtable: *const _StringWriterVtbl,
}
#[repr(C)]
pub struct _StringWriterVtbl {
pub parent: IUnknownVtbl,
pub GetTypeInfoCount: *const c_void,
pub GetTypeInfo: *const c_void,
pub GetIDsOfNames: *const c_void,
pub Invoke: *const c_void,
pub ToString: unsafe extern "system" fn(this: *mut c_void, pRetVal: *mut *mut u16) -> HRESULT,
}
impl _StringWriter {
pub fn to_string(&self) -> Result<String, String> {
let mut buffer = BSTR::new();
let hr = unsafe { (*self).ToString(&mut buffer as *mut _ as *mut *mut u16) };
if hr.is_err() {
return Err(format!("Failed while running `ToString`: {:?}", hr));
}
Ok(buffer.to_string())
}
#[inline]
pub unsafe fn ToString(&self, pRetVal: *mut *mut u16) -> HRESULT {
((*self.vtable).ToString)(self as *const _ as *mut _, pRetVal)
}
}
impl Interface for _StringWriter {
const IID: GUID = GUID::from_values(
0xcb9f94c0,
0xd691,
0x3b62,
[0xb0, 0xb2, 0x3c, 0xe5, 0x30, 0x9c, 0xfa, 0x62],
);
fn vtable(&self) -> *const c_void {
self.vtable as *const _ as *const c_void
}
}
impl Deref for _StringWriter {
type Target = IUnknown;
#[inline]
fn deref(&self) -> &IUnknown {
unsafe { &*(self as *const _StringWriter as *const IUnknown) }
}
}
+6
View File
@@ -1,6 +1,8 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace WithArgs
{
@@ -17,6 +19,10 @@ namespace WithArgs
Console.WriteLine($"___ ({s.Length}) {s}");
}
Console.Error.WriteLine("[!] If I had any errors, they would be here, in `stderr`!");
Console.WriteLine("[*] Bye!");
Console.WriteLine();
}
}
+9 -10
View File
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WithArgs</RootNamespace>
<AssemblyName>WithArgs</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
@@ -78,15 +77,15 @@
<AssemblyName>with_args_x64</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs"/>
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+5
View File
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
using System.Threading;
namespace WithExit
{
@@ -15,6 +16,10 @@ namespace WithExit
Environment.Exit(-1);
Console.WriteLine("[!] I am still alive!");
Console.Error.WriteLine("[!] If I had any errors, they would be here, in `stderr`!");
Console.WriteLine("[*] Bye!");
Console.WriteLine();
}
}
+2
View File
@@ -11,6 +11,8 @@ namespace WithoutArgs
Console.WriteLine($"[*] Hello World from `{Assembly.GetExecutingAssembly().FullName}`!");
Console.WriteLine($"[*] I am running in `{AppDomain.CurrentDomain}`!");
Console.WriteLine("[*] I have no arguments and live a happy life!");
Console.Error.WriteLine("[!] But if I didn't live a happy life, all my error would be here, in `stderr`!");
Console.WriteLine("[*] Bye!");
Console.WriteLine();