1 29 package com.eaio.nativecall; 30 31 37 public class Win32Verifier implements Verifier { 38 39 42 public Win32Verifier() {} 43 44 50 public boolean supports() throws SecurityException { 51 return System.getProperty("os.name").startsWith("Windows"); 52 } 53 54 66 public String verifyModuleName(String module) { 67 if (module == null || module.length() == 0) { 68 return getDefaultModule(); 69 } 70 if (module.indexOf('/') != -1) { 71 module = module.replace('/', '\\'); 72 } 73 return module; 74 } 75 76 83 public String verifyFunctionName(String function) { 84 if (function == null || function.length() == 0) { 85 throw new NullPointerException (); 86 } 87 return function; 88 } 89 90 96 public String getDefaultModule() { 97 return "kernel32"; 98 } 99 100 111 public Object handleString(String val, String module, String function) { 112 if (function.charAt(function.length() - 1) == 'W') { 113 char[] buf = new char[val.length() + 1]; 114 val.getChars(0, val.length(), buf, 0); 115 return buf; 116 } 117 byte[] buf = new byte[val.length() + 1]; 118 val.getBytes(0, val.length(), buf, 0); 119 return buf; 120 } 121 122 } 123 | Popular Tags |