@@ -684,7 +684,7 @@ bool DebugProcess(DWORD unTimeout, bool* pbContinue, bool* pbStopped) {
684
684
}
685
685
686
686
int _tmain (int argc, PTCHAR argv[], PTCHAR envp[]) {
687
- _tprintf_s (_T (" HiJack [Version 1.0.0 ]\n\n " ));
687
+ _tprintf_s (_T (" HiJack [Version 1.0.3 ]\n\n " ));
688
688
689
689
if (argc < 2 ) {
690
690
_tprintf_s (_T (" Usage variations:\n " ));
@@ -715,12 +715,12 @@ int _tmain(int argc, PTCHAR argv[], PTCHAR envp[]) {
715
715
return EXIT_FAILURE;
716
716
}
717
717
718
- auto ProcessPath = GetProcessPath ( GetCurrentProcess ()) ;
719
- if (ProcessPath. empty () ) {
718
+ PTCHAR szSelfProcessPath = NtCurrentTeb ()-> ProcessEnvironmentBlock -> ProcessParameters -> ImagePathName . Buffer ;
719
+ if (!szSelfProcessPath ) {
720
720
return EXIT_FAILURE;
721
721
}
722
722
723
- if (RegSetValueEx (hKey, _T (" Debugger" ), 0 , REG_SZ, reinterpret_cast <const BYTE*>(ProcessPath. c_str ()) , (static_cast <DWORD>(ProcessPath. length ( )) + 1 ) * sizeof (TCHAR)) != ERROR_SUCCESS) {
723
+ if (RegSetValueEx (hKey, _T (" Debugger" ), 0 , REG_SZ, reinterpret_cast <const BYTE*>(szSelfProcessPath) , (static_cast <DWORD>(_tcslen (szSelfProcessPath )) + 1 ) * sizeof (TCHAR)) != ERROR_SUCCESS) {
724
724
_tprintf_s (_T (" ERROR: RegSetValueEx (Error = 0x%08X)\n " ), GetLastError ());
725
725
RegCloseKey (hKey);
726
726
return EXIT_FAILURE;
@@ -747,23 +747,30 @@ int _tmain(int argc, PTCHAR argv[], PTCHAR envp[]) {
747
747
}
748
748
749
749
HKEY hKey = nullptr ;
750
- if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKey, NULL , nullptr , NULL , KEY_READ | KEY_WRITE, NULL , &hKey, NULL ) != ERROR_SUCCESS) {
750
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKey, NULL , nullptr , NULL , KEY_WRITE, NULL , &hKey, NULL ) != ERROR_SUCCESS) {
751
751
_tprintf_s (_T (" ERROR: RegCreateKeyEx (Error = 0x%08X)\n " ), GetLastError ());
752
752
return EXIT_FAILURE;
753
753
}
754
754
755
755
RegDeleteValue (hKey, _T (" Debugger" ));
756
+ RegCloseKey (hKey);
757
+
758
+ hKey = nullptr ;
759
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, szKey, NULL , nullptr , NULL , KEY_READ, NULL , &hKey, NULL ) != ERROR_SUCCESS) {
760
+ _tprintf_s (_T (" ERROR: RegCreateKeyEx (Error = 0x%08X)\n " ), GetLastError ());
761
+ return EXIT_FAILURE;
762
+ }
756
763
757
- DWORD unKeysCount = 0 ;
758
- if (RegQueryInfoKey (hKey, nullptr , nullptr , nullptr , &unKeysCount , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , nullptr ) != ERROR_SUCCESS) {
764
+ DWORD unValuesCount = 0 ;
765
+ if (RegQueryInfoKey (hKey, nullptr , nullptr , nullptr , nullptr , nullptr , nullptr , &unValuesCount , nullptr , nullptr , nullptr , nullptr ) != ERROR_SUCCESS) {
759
766
_tprintf_s (_T (" ERROR: RegQueryInfoKey (Error = 0x%08X)\n " ), GetLastError ());
760
767
RegCloseKey (hKey);
761
768
return EXIT_SUCCESS;
762
769
}
763
770
764
771
RegCloseKey (hKey);
765
772
766
- if (!unKeysCount ) {
773
+ if (!unValuesCount ) {
767
774
if (RegDeleteKey (HKEY_LOCAL_MACHINE, szKey) != ERROR_SUCCESS) {
768
775
_tprintf_s (_T (" WARNING: RegDeleteKey (Error = 0x%08X)\n " ), GetLastError ());
769
776
}
0 commit comments