mirror of
https://github.com/yamakadi/clroxide
synced 2026-06-08 18:28:14 +00:00
update test assemblies
This commit is contained in:
@@ -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) }
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user