Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode compatibility on Windows #7235

Closed
62 tasks
mrexodia opened this issue Apr 10, 2017 · 11 comments
Closed
62 tasks

Unicode compatibility on Windows #7235

mrexodia opened this issue Apr 10, 2017 · 11 comments
Labels
enhancement refactor Windows Microsoft Windows platform support issues

Comments

@mrexodia
Copy link
Contributor

mrexodia commented Apr 10, 2017

Make sure to check if these are still the case. They are hardlinked to a specific commit.

Currently quite a lot of Windows APIs called use the ANSI version of the API is used which means r2 won't work on unicode paths etc. I will add an exhaustive list of all the places here later.

ADVAPI32.dll

CreateServiceA

LookupPrivilegeValueA

OpenSCManagerA

OpenServiceA

StartServiceA

KERNEL32.dll

CreateDirectoryA

CreateFileA

CreateFileMappingA

CreateNamedPipeA

CreateProcessA

DeleteFileA

FillConsoleOutputCharacterA

FormatMessageA

GetEnvironmentVariableA

GetLogicalDriveStringsA

GetModuleFileNameA

GetModuleHandleA

GetShortPathNameA

GetTempFileNameA

LoadLibraryA

lstrlenA

MoveFileExA

QueryDosDeviceA

QueryFullProcessImageNameA

ReadConsoleInputA

RemoveDirectoryA

SetEnvironmentVariableA

USER32.dll

GetClipboardData

@Maijin Maijin added enhancement Windows Microsoft Windows platform support issues labels Apr 10, 2017
@XVilka
Copy link
Contributor

XVilka commented Jul 4, 2017

@xarkes just in case you haven't seen this. :)

@josediazfer
Copy link
Contributor

Apply this changes (convert from ANSI to UNICODE) have an impact in radare core functions (you must convert types and functions aka char *to wchar_t, fgets to fgetws...etc):

For example:

R_API bool r_sys_mkdir(const char *dir) {
	if (r_sandbox_enable (0)) {
		return false;
	}
#if __WINDOWS__ && !defined(__CYGWIN__)
	return CreateDirectory (dir, NULL) != 0;
#else
	return mkdir (dir, 0755) != -1;
#endif
}

I think that we have to decide which radare functions pass to unicode before perform this task.
When we have that functions to change then progressively make changes:

For example:

  • First step:
R_API bool r_sys_mkdir(const char *dir) {
	if (r_sandbox_enable (0)) {
		return false;
	}
#if __WINDOWS__ && !defined(__CYGWIN__)
        wchar_t *wdir = char2wchar(dir);
        return CreateDirectory (wdir, NULL) != 0;
#else
	return mkdir (dir, 0755) != -1;
#endif
}
  • Second step:
R_API bool r_sys_mkdir(const wchar_t *dir) {
   if (r_sandbox_enable (0)) {
   	return false;
   }
#if __WINDOWS__ && !defined(__CYGWIN__)
       return CreateDirectory (dir, NULL) != 0;
#else
	return mkdir (dir, 0755) != -1;
#endif
}

@mrexodia
Copy link
Contributor Author

mrexodia commented Oct 18, 2017 via email

@josediazfer
Copy link
Contributor

it's true, you're right. Its not need change "dir" parameter to wchar type and it's not good idea. I'm not sure if we need use SetConsoleOutputCP(CP_UTF8) SetConsoleCP(CP_UTF8) and MultiByteToWideChar() (utf-8 to wchar), I will research it tomorrow.
Thanks!

@josediazfer
Copy link
Contributor

I've already made the changes. (https://github.com/josediazfer/radare2/tree/win32_char_to_unicode)
You can check and test!

Comments and suggestions are welcome

@Maijin
Copy link
Contributor

Maijin commented Oct 26, 2017

Please do a Pull request not this.

@XVilka
Copy link
Contributor

XVilka commented Nov 3, 2017

@josediazfer @mrexodia so, can be this closed?

@josediazfer
Copy link
Contributor

josediazfer commented Nov 3, 2017

Yes can be closed it

@Maijin Maijin closed this as completed Nov 3, 2017
@mrexodia
Copy link
Contributor Author

mrexodia commented Nov 3, 2017

Ehm? I don't think that PR was merged

@Maijin
Copy link
Contributor

Maijin commented Nov 3, 2017

527ff71

@mrexodia
Copy link
Contributor Author

mrexodia commented Nov 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement refactor Windows Microsoft Windows platform support issues
Projects
None yet
Development

No branches or pull requests

4 participants