diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3077e45..38e0ee7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,19 +43,22 @@ jobs: run: | C:\WinDDK\7600.16385.1\bin\setenv.bat C:\WinDDK\7600.16385.1 fre x64 WIN7 && D: && cd ${{ github.workspace }}\srcdir && build /g /w shell: cmd - - name: Upload artifact x86 + - name: Upload artifact i386 uses: actions/upload-artifact@v4 with: - name: nativeshell + name: nativeshell-i386 path: | ${{ github.workspace }}\srcdir\objfre_wxp_x86\i386\native.exe ${{ github.workspace }}\srcdir\install\* ${{ github.workspace }}\srcdir\README.md retention-days: 1 - - name: Upload artifact x64 + - name: Upload artifact amd64 uses: actions/upload-artifact@v4 with: - name: nativeshell-x64-alpha - path: ${{ github.workspace }}\srcdir\objfre_win7_amd64\amd64\native.exe + name: nativeshell-amd64 + path: | + ${{ github.workspace }}\srcdir\objfre_win7_amd64\amd64\native.exe + ${{ github.workspace }}\srcdir\install\* + ${{ github.workspace }}\srcdir\README.md retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a58db3a..550ba9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,15 +14,6 @@ jobs: name: Release runs-on: ubuntu-latest steps: - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: nativeshell - - name: Display structure of downloaded files - run: ls -R - - name: Prepare release artifact - run: | - zip -r --junk-paths nativeshell.zip ./* - name: Create release uses: actions/create-release@v1 id: create_release @@ -31,17 +22,43 @@ jobs: prerelease: false release_name: Release ${{ github.ref }} tag_name: ${{ github.ref }} - body: NT Native Executable and install files + body: NT native executable and install files env: GITHUB_TOKEN: ${{ github.token }} - - name: Upload release artifact + - name: Download i386 binary + uses: actions/download-artifact@v4 + working-directory: ${{ github.workspace }}/i386 + with: + name: nativeshell-i386 + - name: Prepare release i386 binary + working-directory: ${{ github.workspace }}/i386 + run: | + zip -r --junk-paths nativeshell.zip ./* + - name: Release i386 binary uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ github.token }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/nativeshell.zip + asset_path: ${{ github.workspace }}/i386/nativeshell.zip asset_name: nativeshell-${GITHUB_REF##*/}.i386.zip asset_content_type: application/zip - + - name: Download amd64 binary + uses: actions/download-artifact@v4 + working-directory: ${{ github.workspace }}/amd64 + with: + name: nativeshell-amd64 + - name: Prepare release amd64 binary + working-directory: ${{ github.workspace }}/amd64 + run: | + zip -r --junk-paths nativeshell.zip ./* + - name: Release amd64 binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ github.workspace }}/amd64/nativeshell.zip + asset_name: nativeshell-${GITHUB_REF##*/}.amd64.zip + asset_content_type: application/zip diff --git a/.gitignore b/.gitignore index 9fcf6aa..9517560 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ objfre_wxp_x86 objfre_win7_amd64 *.err -*.wrn \ No newline at end of file +*.wrn +*.cmd \ No newline at end of file diff --git a/b.cmd b/b.cmd deleted file mode 100644 index 437c622..0000000 --- a/b.cmd +++ /dev/null @@ -1 +0,0 @@ -build /g /w /M 2 diff --git a/file.c b/file.c index 23de4d5..ba2589c 100644 --- a/file.c +++ b/file.c @@ -90,7 +90,6 @@ RtlCliSetCurrentDirectory(PCHAR Directory) GetFullPath(Directory, buf, TRUE); RtlInitUnicodeString(&us, buf); RtlSetCurrentDirectory_U(&us); - RtlFreeUnicodeString(&us); return STATUS_SUCCESS; } diff --git a/hardware.c b/hardware.c index 73d0215..72b4cfa 100644 --- a/hardware.c +++ b/hardware.c @@ -247,10 +247,15 @@ RtlCliListHardwareTree(VOID) // Get the root node's child // Status = RtlCliGetChildOrSibling(ROOT_NAME, Buffer, PNP_GET_CHILD_DEVICE); - + if (!NT_SUCCESS(Status)) { + RtlCliDisplayString("NtPlugPlayControl get root node failed.\n"); + } // // Now get the entire tree // Status = RtlCliListSubNodes(ROOT_NAME, NULL, Buffer); + if (!NT_SUCCESS(Status)) { + RtlCliDisplayString("NtPlugPlayControl get child nodes failed.\n"); + } return Status; } diff --git a/main.c b/main.c index 0a8f7c8..b324c95 100644 --- a/main.c +++ b/main.c @@ -36,9 +36,9 @@ HANDLE hKey; #define __APP_VER__ "0.13.2" #if defined(_M_AMD64) || defined(_AMD64_) -#define __NCLI_VER__ __APP_VER__ "-alpha (x64)" +#define __NCLI_VER__ __APP_VER__ "-alpha x64" #else -#define __NCLI_VER__ __APP_VER__ " (x86)" +#define __NCLI_VER__ __APP_VER__ " x86" #endif WCHAR *helpstr[] = @@ -168,8 +168,6 @@ RtlClipProcessMessage(PCHAR Command) // RtlInitUnicodeString(&CurrentDirectoryString, CurrentDirectory); RtlCliPrintString(&CurrentDirectoryString); - - RtlFreeUnicodeString(&CurrentDirectoryString); } else if (!_strnicmp(Command, "dir", 3)) { @@ -343,21 +341,19 @@ RtlClipProcessMessage(PCHAR Command) RtlAnsiStringToUnicodeString(&us, &as, TRUE); NtClose(hKeyboard); - //RtlCliDisplayString("Keyboard is closed\n"); CreateNativeProcess(filename, us.Buffer, &hProcess); - RtlFreeAnsiString(&as); RtlFreeUnicodeString(&us); - //RtlCliDisplayString("Waiting for process terminations\n"); NtWaitForSingleObject(hProcess, FALSE, NULL); RtlCliOpenInputDevice(&hKeyboard, KeyboardType); - //RtlCliDisplayString("Keyboard restored\n"); } else { - RtlCliDisplayString("%s not recognized\n", Command); + RtlCliDisplayString("%s not recognized\n" + "Add .exe if you want to lauch executable file." + "\nType \"help\" for the list of commands.\n", Command); } } } @@ -434,10 +430,7 @@ main(INT argc, // // Show banner // - RtlCliDisplayString("Native Shell [Version " __NCLI_VER__ "] (" __DATE__ " " __TIME__ ")\n"); - RtlCliDisplayString("(C) Copyright 2010-2025 amdf\n"); - RtlCliDisplayString("(C) Copyright 2006 TinyKRNL Project\n\n"); - RtlCliDisplayString("Type \"help\".\n\n"); + RtlCliDisplayString("Native Shell v" __NCLI_VER__ " (" __DATE__ " " __TIME__ ")\n\n"); // // Setup keyboard input diff --git a/ndk/mmtypes.h b/ndk/mmtypes.h index 5ba1c31..98f7fe9 100644 --- a/ndk/mmtypes.h +++ b/ndk/mmtypes.h @@ -302,8 +302,8 @@ typedef struct _SECTION_IMAGE_INFORMATION { PVOID TransferAddress; ULONG ZeroBits; - ULONG MaximumStackSize; - ULONG CommittedStackSize; + SIZE_T MaximumStackSize; + SIZE_T CommittedStackSize; ULONG SubSystemType; union { @@ -314,22 +314,32 @@ typedef struct _SECTION_IMAGE_INFORMATION }; ULONG SubSystemVersion; }; - ULONG GpValue; + union + { + struct + { + USHORT MajorOperatingSystemVersion; + USHORT MinorOperatingSystemVersion; + }; + ULONG OperatingSystemVersion; + }; USHORT ImageCharacteristics; - USHORT DllChracteristics; + USHORT DllCharacteristics; USHORT Machine; - UCHAR ImageContainsCode; + BOOLEAN ImageContainsCode; union { + UCHAR ImageFlags; struct { - UCHAR ComPlusNativeReady:1; - UCHAR ComPlusILOnly:1; - UCHAR ImageDynamicallyRelocated:1; - UCHAR ImageMappedFlat:1; - UCHAR Reserved:4; + UCHAR ComPlusNativeReady : 1; + UCHAR ComPlusILOnly : 1; + UCHAR ImageDynamicallyRelocated : 1; + UCHAR ImageMappedFlat : 1; + UCHAR BaseBelow4gb : 1; + UCHAR ComPlusPrefer32bit : 1; + UCHAR Reserved : 2; }; - UCHAR ImageFlags; }; ULONG LoaderFlags; ULONG ImageFileSize; diff --git a/ntfile.c b/ntfile.c index 80df7c1..a7cfb77 100644 --- a/ntfile.c +++ b/ntfile.c @@ -314,11 +314,9 @@ BOOLEAN NtFileDeleteFile(PCWSTR filename) if (!NT_SUCCESS(status)) { - RtlFreeUnicodeString(&us); return FALSE; } - RtlFreeUnicodeString(&us); return TRUE; } @@ -353,18 +351,15 @@ BOOLEAN NtFileCreateDirectory(PCWSTR dirname) if (NT_SUCCESS(status)) { NtClose(hFile); - RtlFreeUnicodeString(&us); return TRUE; } /* if it already exists then return success */ if (status == STATUS_OBJECT_NAME_COLLISION) { - RtlFreeUnicodeString(&us); return TRUE; } - RtlFreeUnicodeString(&us); return FALSE; } diff --git a/precomp.h b/precomp.h index 9b1b826..61d54dc 100644 --- a/precomp.h +++ b/precomp.h @@ -192,7 +192,7 @@ NTSTATUS RegReadValue(HANDLE hKey, PWCHAR key_name, OUT PULONG type, OUT PVOID d // Misc -void FillUnicodeStringWithAnsi(OUT PUNICODE_STRING us, IN PCHAR as); +// void FillUnicodeStringWithAnsi(OUT PUNICODE_STRING us, IN PCHAR as); //=========================================================== // diff --git a/process.c b/process.c index 4435965..162d046 100644 --- a/process.c +++ b/process.c @@ -46,18 +46,26 @@ NTSTATUS CreateNativeProcess(IN PCWSTR file_name, IN PCWSTR cmd_line, OUT PHANDL status = RtlCreateUserProcess(&imgpath, OBJ_CASE_INSENSITIVE, processparameters, NULL, NULL, NULL, FALSE, NULL, NULL, &processinformation); - if (processinformation.ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_NATIVE) - { - RtlCliDisplayString("\nThe %S application cannot be run in native mode.\n", file_name); - return STATUS_UNSUCCESSFUL; - } - if (!NT_SUCCESS(status)) { RtlCliDisplayString("RtlCreateUserProcess failed\n"); return STATUS_UNSUCCESSFUL; } + if (processinformation.ImageInformation.SubSystemType != IMAGE_SUBSYSTEM_NATIVE) + { + RtlCliDisplayString("\nThe %S application cannot be run in native mode.\n" + "Subsystem: %d\n" + "Subsystem version: %d\n" + "Machine: %d\n", + file_name, + processinformation.ImageInformation.SubSystemType, + processinformation.ImageInformation.SubSystemVersion, + processinformation.ImageInformation.Machine + ); + return STATUS_UNSUCCESSFUL; + } + status = NtResumeThread(processinformation.ThreadHandle, NULL); if (!NT_SUCCESS(status)) diff --git a/shell.c b/shell.c index 888fb95..dacc77c 100644 --- a/shell.c +++ b/shell.c @@ -39,7 +39,6 @@ BOOL GetFullPath(IN PCSTR filename, OUT PWSTR out, IN BOOL add_slash) } RtlFreeUnicodeString(&us); - RtlFreeAnsiString(&as); } else { RtlInitAnsiString(&as, filename); @@ -57,7 +56,6 @@ BOOL GetFullPath(IN PCSTR filename, OUT PWSTR out, IN BOOL add_slash) } RtlFreeUnicodeString(&us); - RtlFreeAnsiString(&as); } return TRUE; } @@ -183,7 +181,6 @@ BOOL FolderExists(PCWSTR foldername) RtlInitUnicodeString(&u_filename, foldername); RtlDosPathNameToNtPathName_U(u_filename.Buffer, &nt_filename, NULL, NULL); - RtlFreeUnicodeString(&u_filename); InitializeObjectAttributes(&oa, &nt_filename, OBJ_CASE_INSENSITIVE, 0, 0); st = NtQueryAttributesFile(&oa, &fbi); @@ -211,7 +208,6 @@ BOOL FileExists(PCWSTR filename) RtlInitUnicodeString(&u_filename, filename); RtlDosPathNameToNtPathName_U(u_filename.Buffer, &nt_filename, NULL, NULL); - RtlFreeUnicodeString(&u_filename); InitializeObjectAttributes(&oa, &nt_filename, OBJ_CASE_INSENSITIVE, 0, 0); st = NtQueryAttributesFile(&oa, &fbi); @@ -327,18 +323,18 @@ UINT GetStringLength(WCHAR* pszInput) } // Note: This function allocates memory for "us" variable. -void FillUnicodeStringWithAnsi(OUT PUNICODE_STRING us, IN PCHAR as) -{ - ANSI_STRING ansi_string; +// void FillUnicodeStringWithAnsi(OUT PUNICODE_STRING us, IN PCHAR as) +// { +// ANSI_STRING ansi_string; - RtlInitAnsiString(&ansi_string, as); +// RtlInitAnsiString(&ansi_string, as); - if (!NT_SUCCESS(RtlAnsiStringToUnicodeString(us, &ansi_string, TRUE))) - { - RtlCliDisplayString("RtlAnsiStringToUnicodeString() failed\n"); - return; - } +// if (!NT_SUCCESS(RtlAnsiStringToUnicodeString(us, &ansi_string, TRUE))) +// { +// RtlCliDisplayString("RtlAnsiStringToUnicodeString() failed\n"); +// return; +// } - RtlFreeAnsiString(&ansi_string); - return; -} \ No newline at end of file +// RtlFreeAnsiString(&ansi_string); +// return; +// } \ No newline at end of file diff --git a/sysinfo.c b/sysinfo.c index 54945c0..8c965cf 100644 --- a/sysinfo.c +++ b/sysinfo.c @@ -336,15 +336,6 @@ RtlCliDumpSysInfo(VOID) NULL); if (!NT_SUCCESS(Status)) return Status; - // - // Query basic system information - // - Status = NtQuerySystemInformation(SystemFileCacheInformation, - &CacheInfo, - sizeof(CacheInfo), - NULL); - if (!NT_SUCCESS(Status)) return Status; - // // Display Header // FIXME: Center it @@ -488,13 +479,19 @@ RtlCliDumpSysInfo(VOID) // // Display FileSystem Cache Information // - RtlCliDisplayString("[CACHE] Size: %dKB. Peak: %dKB. " - "Min WS: %dKB. Max WS: %dKB\n", - CacheInfo.CurrentSize / 1024, - CacheInfo.PeakSize / 1024, - CacheInfo.MinimumWorkingSet, - CacheInfo.MaximumWorkingSet); - + Status = NtQuerySystemInformation(SystemFileCacheInformation, + &CacheInfo, + sizeof(CacheInfo), + NULL); + if (NT_SUCCESS(Status)) { + RtlCliDisplayString("[CACHE] Size: %dKB. Peak: %dKB. " + "Min WS: %dKB. Max WS: %dKB\n", + CacheInfo.CurrentSize / 1024, + CacheInfo.PeakSize / 1024, + CacheInfo.MinimumWorkingSet, + CacheInfo.MaximumWorkingSet); + } + // // Return success //