NMS Posted November 12, 2023 Share Posted November 12, 2023 Hello. I'm trying to call function "LeCreateProcess" in LoaderDLL.dll but having issues getting any results back. I barely understand C++. I got most values from here https://github.com/xupefei/Locale-Emulator within the https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs I'm attaching also LocaleEmulator.dll but according to Dependency Walker the function is located in LoaderDLL.dll The goal is to run an application, in this instance, with a Japanese locale. Program itself works fine but in Windows 11 there's no easy way of adding custom options into Context menu where this program would be located if clicked on exe. #include <Date.au3> Local $sProgramPath = "PATH TO ANY EXE FILE" Local $hDLL = DllOpen("PATH TO LOADER.DLL") If @error Then MsgBox(0, "Error", "Failed to open dll") DllClose($hDLL) Exit EndIf Local $SHIFT_JIS = 932 Local $LANG_JAPANESE = 0x411 Local $SHIFTJIS_CHARSET = 128 Local $LEB = DllStructCreate("struct; UINT AnsiCodePage; UINT OemCodePage; UINT LocaleID; UINT DefaultCharset; UINT HookUiLanguageApi; WCHAR DefaultFaceName[64]; PTR Timezone; endstruct") ;Unsure about last two values DllStructSetData($LEB, "AnsiCodePage", $SHIFT_JIS) DllStructSetData($LEB, "OemCodePage", $SHIFT_JIS) DllStructSetData($LEB, "LocaleID", $LANG_JAPANESE) DllStructSetData($LEB, "DefaultCharset", $SHIFTJIS_CHARSET) DllStructSetData($LEB, "HookUiLanguageApi", 0) DllStructSetData($LEB, "DefaultFaceName", "") ;I'm not sure about this part DllStructSetData($LEB, "Timezone", _Date_Time_GetTimeZoneInformation()) ;This seems correct but I don't know if that information is formatted correctly Local $tProcessInfo = DllStructCreate($tagPROCESS_INFORMATION) ;From help file. I don't know if this is enough Local $aResult = DllCall($hDLL, "none", "LeCreateProcess", "struct*", $LEB, "wstr", $sProgramPath, "ptr", Null, "wstr", @WorkingDir, "ptr", Null, "ptr", Null, "struct*", $tProcessInfo, "ptr", Null, "ptr", Null, "ptr", Null, "ptr", Null) If @error Then MsgBox(0, "Error", "Error - " & @Extended) DllClose($hDLL) Exit EndIf DllClose($hDLL) Any help is appreciated! LoaderDll.dll LocaleEmulator.dll Link to comment Share on other sites More sharing options...
UEZ Posted November 12, 2023 Share Posted November 12, 2023 (edited) ... public static extern uint LeCreateProcess(IntPtr leb, [MarshalAs(UnmanagedType.LPWStr), In] string applicationName, [MarshalAs(UnmanagedType.LPWStr), In] string commandLine, [MarshalAs(UnmanagedType.LPWStr), In] string currentDirectory, uint creationFlags, ref STARTUPINFO startupInfo, out PROCESS_INFORMATION processInformation, IntPtr processAttributes, IntPtr threadAttributes, IntPtr environment, IntPtr token); ... internal struct LEB { internal uint AnsiCodePage; internal uint OemCodePage; internal uint LocaleID; internal uint DefaultCharset; internal uint HookUILanguageAPI; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] internal byte[] DefaultFaceName; internal RTL_TIME_ZONE_INFORMATION Timezone; } ... From what I understood is $tagLEB = "struct;uint AnsiCodePage;uint OemCodePage;uint LocaleID;uint DefaultCharset;uint HookUILanguageAPI;byte DefaultFaceName[64];" & _ "long Bias;wchar StandardName[32];" & _ ;RTL_TIME_ZONE_INFORMATION "word wYearSD;word wMonthSD;word wDayOfWeekSD;word wDaySD;word wHourSD;word wMinuteSD;word wSecondSD;word wMillisecondsSD; " & _ ;SYSTEMTIME "long StandardBias;wchar DaylightName[32];" & _ "word wYearDD;word wMonthDD;word wDayOfWeekDD;word wDayDD;word wHourDD;word wMinuteDD;word wSecondDD;word wMillisecondsDD; " & _ "long DaylightBias;endstruct" $tLEB = DllStructCreate($tagLEB) $tSI = DllStructCreate($tagSTARTUPINFO) $tPI = DllStructCreate($tagPROCESS_INFORMATION) Local $aResult = DllCall($hDLL, "ptr", "LeCreateProcess", "struct*", $tLEB, "wstr", $applicationName, "wstr", $commandLine, "wstr", $currentDirectory, "uint", $creationFlags, "struct*", _ $tSI, "struct*", $tPI, "ptr", $processAttributes, "ptr", $threadAttributes, "ptr", $environment, "ptr", $token) I don't know if "IntPtr" from cs is "ptr" or rather "int_ptr". Edited November 12, 2023 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Andreik Posted November 12, 2023 Share Posted November 12, 2023 31 minutes ago, UEZ said: I don't know if "IntPtr" from cs is "ptr" or rather "int_ptr". It's a pointer exposed as a platform-specific size integer so it would be more appropriate to use int_ptr. Link to comment Share on other sites More sharing options...
NMS Posted November 12, 2023 Author Share Posted November 12, 2023 (edited) No luck on the above either. I have found a reference to the function in a different program https://github.com/Artikash/Textractor/blob/master/GUI/mainwindow.cpp. On line 231 that seems to make the call, with most arguments unused other than $tagLEB, path, directory and process info. https://github.com/xupefei/Locale-Emulator-Core/blob/master/LoaderDll/LoaderDll.cpp Edited November 12, 2023 by NMS Link to comment Share on other sites More sharing options...
UEZ Posted November 13, 2023 Share Posted November 13, 2023 (edited) Can you try this: expandcollapse popup#include <Date.au3> #include <WinAPIDiag.au3> $tagRTL_TIME_ZONE_INFORMATION = "long Bias;wchar StandardName[32];" & _ "ushort Year1;ushort Month1;ushort Day1;ushort Hour1;ushort Minute1;ushort Second1;ushort Milliseconds1;ushort Weekday1;" & _ ;TIME_FIELDS "long StandardBias;wchar DaylightName[32];" & _ "ushort Year2;ushort Month2;ushort Day2;ushort Hour2;ushort Minute2;ushort Second2;ushort Milliseconds2;ushort Weekday2;" & _ ;TIME_FIELDS "long DaylightBias" $tagLEB = "struct;ulong AnsiCodePage;ulong OemCodePage;ulong LocaleID;ulong DefaultCharset;ulong HookUiLanguageApi;wchar DefaultFaceName[64];" & $tagRTL_TIME_ZONE_INFORMATION & ";endstruct" $tLEB = DllStructCreate($tagLEB) $tTimeZone = DllStructCreate($tagRTL_TIME_ZONE_INFORMATION, DllStructGetPtr($tLEB) + 148) DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $tTimeZone) ;~ _WinAPI_DisplayStruct($tTimeZone, $tagTIME_ZONE_INFORMATION) Global $SHIFT_JIS = 932 Global $LANG_JAPANESE = 0x411 Global $SHIFTJIS_CHARSET = 128 $tLEB.AnsiCodePage = $SHIFT_JIS $tLEB.OemCodePage = $SHIFT_JIS $tLEB.LocaleID = $LANG_JAPANESE $tLEB.DefaultCharset = $SHIFTJIS_CHARSET $tLEB.HookUiLanguageApi = 0 $sAppName = "c:\Windows\notepad.exe" $sCmdLine = "" $sCurrentDir = "c:\Windows" $creationFlags = 0 $tSI = DllStructCreate($tagSTARTUPINFO) $tSI.size = DllStructGetSize($tSI) $tPI = DllStructCreate($tagPROCESS_INFORMATION) $tSA = Null ;DllStructCreate($tagSECURITY_ATTRIBUTES) $tTA = Null ;DllStructCreate($tagSECURITY_ATTRIBUTES) $environment = Null $token = Null Local $aResult = DllCall("LoaderDll.dll", "long", "LeCreateProcess", "struct*", $tLEB, "wstr", $sAppName, "wstr", $sCmdLine, "wstr", $sCurrentDir, "ulong", $creationFlags, _ "struct*", $tSI, "struct*", $tPI, "struct*", $tSA, "struct*", $tTA, "ptr", $environment, "handle", $token) You have to fill the appropriate struct values first. Edit: it still crashes when GetTimeZoneInformation is called (0xc0000005 (Access Violation)). Edited November 13, 2023 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
NMS Posted November 15, 2023 Author Share Posted November 15, 2023 Thanks for giving this another shot regardless. I'll keep trying and see if I can figure this out. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now