Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Jul 26th, 2019 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -module(module_cp).
  2.  
  3. -export([rename_module/3,load_module_copy/1]).
  4.  
  5. rename_module(Bin, OldName, NewName) ->
  6.     case length(OldName) =/= length(NewName) of
  7.         %% sometimes there are problems if names don't have the same length
  8.         true -> {error,name_lengths_differ};
  9.         false ->
  10.             S = binary_to_list(Bin),
  11.             Tmp = string:replace(S, OldName, NewName),
  12.             RenamedBin = list_to_binary(lists:flatten(Tmp)),
  13.             {ok, RenamedBin}
  14.     end.
  15.  
  16. load_module_copy(Mod) ->
  17.     ModName = atom_to_list(Mod),
  18.     {Mod, Bin, _} = code:get_object_code(Mod),
  19.     NewName = case ModName of
  20.         [$x|TL] -> [$y|TL];
  21.         [_|TL] -> [$x|TL]
  22.     end,
  23.     {ok, RenamedBin} = rename_module(Bin, ModName, NewName),
  24.     code:load_binary(list_to_atom(NewName), "", RenamedBin).
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top