const blocks for lazy import
This commit is contained in:
@@ -22,8 +22,8 @@ macro_rules! lazy_import {
|
||||
extern "C" fn __initial($($pname: $ptype),*) $(-> $rtype)? {
|
||||
unsafe {
|
||||
let import = $crate::win32::importer::find_import_hashed(
|
||||
$crate::hash_utf8($module.as_bytes()),
|
||||
$crate::hash_utf8(stringify!($name).as_bytes())
|
||||
const { $crate::hash_utf8($module.as_bytes()) },
|
||||
const { $crate::hash_utf8(stringify!($name).as_bytes()) }
|
||||
).unwrap_or(0);
|
||||
FUNC = core::mem::transmute(import);
|
||||
FUNC($($pname),*)
|
||||
@@ -48,8 +48,8 @@ macro_rules! lazy_import {
|
||||
Some(function) => function,
|
||||
None => unsafe {
|
||||
let import = core::mem::transmute($crate::win32::importer::find_import_hashed(
|
||||
x::hash_utf8($module.as_bytes()),
|
||||
x::hash_utf8(stringify!($name).as_bytes())
|
||||
const { x::hash_utf8($module.as_bytes()) },
|
||||
const { x::hash_utf8(stringify!($name).as_bytes()) }
|
||||
).unwrap_or(0));
|
||||
FUNC = Some(import);
|
||||
import
|
||||
|
||||
@@ -130,17 +130,17 @@ pub struct ImageBaseRelocation {
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ImageExportDirectory {
|
||||
pub export_flags: u32,
|
||||
pub timestamp: u32,
|
||||
pub major_version: u16,
|
||||
pub minor_version: u16,
|
||||
pub name_rva: u32,
|
||||
pub ordinal_base: u32,
|
||||
pub address_table_entries: u32,
|
||||
pub number_of_name_pointers: u32,
|
||||
pub export_address_table_rva: u32,
|
||||
pub name_pointer_rva: u32,
|
||||
pub ordinal_table_rva: u32,
|
||||
/* 0x00 */pub export_flags: u32,
|
||||
/* 0x04 */pub timestamp: u32,
|
||||
/* 0x06 */pub major_version: u16,
|
||||
/* 0x08 */pub minor_version: u16,
|
||||
/* 0x0C */pub name_rva: u32,
|
||||
/* 0x10 */pub ordinal_base: u32,
|
||||
/* 0x14 */pub address_table_entries: u32,
|
||||
/* 0x18 */pub number_of_name_pointers: u32,
|
||||
/* 0x1C */pub export_address_table_rva: u32,
|
||||
/* 0x20 */pub name_pointer_rva: u32,
|
||||
/* 0x24 */pub ordinal_table_rva: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
use std::mem::offset_of;
|
||||
use x::win32::ImageOptionalHeader64;
|
||||
|
||||
#[test]
|
||||
pub fn test_distance() {
|
||||
let _ = x::dur![ 5 days 4 hours 7 minutes 2 seconds 2 minutes ];
|
||||
|
||||
@@ -11,5 +11,5 @@ x::lazy_import! { "kernel32.dll"
|
||||
#[cfg(feature = "win32")]
|
||||
pub fn test_exports() {
|
||||
let a = LoadLibraryA(x::cstr!("user32.dll"));
|
||||
println!("{} -> {}",a.into_usize(), unsafe { a.nt_header().optional_header.size_of_image });
|
||||
println!("{:X} -> {:X}",a.into_usize(), unsafe { a.nt_header().optional_header.size_of_image });
|
||||
}
|
||||
Reference in New Issue
Block a user