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

Implement console DeviceIoControl codes #29

Merged
merged 6 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions COREDLL/COREDLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="stdio_wcecl.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="winuser_wcecl.h" />
</ItemGroup>
Expand All @@ -258,6 +259,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdio_wcecl.cpp" />
<ClCompile Include="strsafe_wcecl.cpp" />
<ClCompile Include="wcecl_dialogs.cpp" />
<ClCompile Include="wcecl_memtools.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions COREDLL/COREDLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<ClInclude Include="winuser_wcecl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdio_wcecl.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand Down Expand Up @@ -77,6 +80,9 @@
<ClCompile Include="windows_wcecl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdio_wcecl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Exports.def">
Expand Down
2 changes: 1 addition & 1 deletion COREDLL/Exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ EXPORTS
_wcsupr @232
vfwprintf=vfwprintf_WCECL @721
fflush @1122
fgetws=fgetws_WCECL @1143
fgetws @1143
fputwc @1141
fputws @1144
_getstdfilex=_getstdfilex_WCECL @1100
Expand Down
69 changes: 4 additions & 65 deletions COREDLL/other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,59 +194,14 @@ void CeLogSetZones(DWORD dwZoneUser, // User-defined zones
// wtf!?
}

FILE* WINAPI _getstdfilex_WCECL(DWORD type)
{
switch (type)
{
case 0:
return stdin;
case 1:
return stdout;
case 2:
return stderr;
default:
Assert32(FALSE);
return NULL;
}
}

BOOL WINAPI SetStdioPathW_WCECL(
DWORD id,
PWSTR pwszPath)
{
/* TODO: test */
switch (id)
{
case 0:
return (_wfreopen(pwszPath, L"r", stdin) != NULL);
case 1:
return (_wfreopen(pwszPath, L"w", stdout) != NULL);
case 2:
return (_wfreopen(pwszPath, L"w", stderr) != NULL);
default:
Assert32(FALSE);
return NULL;
}
}

BOOL WINAPI GetStdioPathW_WCECL(
DWORD id,
PWSTR pwszBuf,
LPDWORD lpdwLen)
void* _fileno_WCECL(FILE* file)
{
/* TODO: test */
FILE* filePtr = _getstdfilex_WCECL(id);
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(filePtr));
if (GetFinalPathNameByHandleW(hFile, pwszBuf, *lpdwLen, 0) < *lpdwLen)
void* result = WceclTryGetOrAllocStdHandle(file);
if (result != NULL)
{
return TRUE;
return result;
}

return FALSE;
}

void* _fileno_WCECL(FILE* file)
{
return (void*)_get_osfhandle(_fileno(file));
}

Expand All @@ -271,22 +226,6 @@ int WINAPI WideCharToMultiByte_WCECL(
lpUsedDefaultChar);
}

wchar_t* fgetws_WCECL(wchar_t* w, int count, FILE* file)
{
wchar_t* result = fgetws(w, count, file);
if (result == NULL &&
file == stdin && count > 2)
{
result = w;
wsprintf(w, L"");
}
else
{
return result;
}
return result;
}

// Stubs
Stub(_chkstk_WCECL);
Stub(WaitForAPIReady);
Expand Down
2 changes: 2 additions & 0 deletions COREDLL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ BOOL ProgramErrorDialog(LPCWSTR Text, BOOL YesNo);
VOID DisplayAssert32ErrorDialog(LPCWSTR ExpressionText, LPCWSTR Comment, BOOL ShowLastError);
DWORD GetBaseAddress(HANDLE pHandle);
HMODULE GetModule(HANDLE pHandle);

#include "stdio_wcecl.h"
Loading