| 141 | } |
| 142 | |
| 143 | fn apply_dll_format( |
| 144 | replacements: &mut HashMap<&'static str, String>, |
| 145 | main_rs_path: &Path, |
| 146 | is_proxy: bool, |
| 147 | ) -> PathBuf { |
| 148 | let dll_cargo_conf = r#" |
| 149 | [lib] |
| 150 | crate-type = ["cdylib"]"#; |
| 151 | replacements.insert("{{DLL_FORMAT}}", dll_cargo_conf.to_string()); |
| 152 | |
| 153 | let dll_main_fn = if is_proxy { |
| 154 | r#" |
| 155 | const DLL_PROCESS_ATTACH: u32 = 1; |
| 156 | const DLL_PROCESS_DETACH: u32 = 0; |
| 157 | |
| 158 | #[no_mangle] |
| 159 | #[allow(non_snake_case, unused_variables, unreachable_patterns)] |
| 160 | extern "system" fn DllMain( |
| 161 | dll_module: usize, |
| 162 | call_reason: u32, |
| 163 | _: *mut ()) |
| 164 | -> bool |
| 165 | { |
| 166 | match call_reason { |
| 167 | DLL_PROCESS_ATTACH => { |
| 168 | unsafe { proxy::init(); } |
| 169 | main(); |
| 170 | } |
| 171 | DLL_PROCESS_DETACH => (), |
| 172 | _ => () |
| 173 | } |
| 174 | |
| 175 | true |
| 176 | } |
| 177 | "# |
| 178 | } else { |
| 179 | r#" |
| 180 | const DLL_PROCESS_ATTACH: u32 = 1; |
| 181 | const DLL_PROCESS_DETACH: u32 = 0; |
| 182 | |
| 183 | #[no_mangle] |
| 184 | #[allow(non_snake_case, unused_variables, unreachable_patterns)] |
| 185 | extern "system" fn DllMain( |
| 186 | dll_module: usize, |
| 187 | call_reason: u32, |
| 188 | _: *mut ()) |
| 189 | -> bool |
| 190 | { |
| 191 | match call_reason { |
| 192 | DLL_PROCESS_ATTACH => (), |
| 193 | DLL_PROCESS_DETACH => (), |
| 194 | _ => () |
| 195 | } |
| 196 | |
| 197 | true |
| 198 | } |
| 199 | #[no_mangle] |
| 200 | pub extern "C" fn DllRegisterServer() {{ |