⌨ DEVELOPMENT
[C/C++] string replace all 문자열 모두 치환
[C/C++] string replace all 문자열 모두 치환
2015.12.11std::string ReplaceAllSTL의 std::string를 이용하여 간단하게 문자열을 치환할 수 있다. 기본적으론 string.replace가 존재하며 해당 기능은 1번만 치환되므로 모든 문자를 치환하려면 추가로 작업을 해주어야 한다. 다음 코드를 보자 #include std::string replace_all( __in const std::string &message, __in const std::string &pattern, __in const std::string &replace ) { std::string result = message; std::string::size_type pos = 0; while ((pos = result.find(pattern)) != std::string:..
[C/C++] 폴더 전체 경로 중 파일명만 가져오기
[C/C++] 폴더 전체 경로 중 파일명만 가져오기
2015.12.10Path 관련해선 MS에서 제공되는 다양한 API가 존재한다. 그 중 파일명을 가져오기위해서 직접 parsing을 해서 사용하다가 API를 찾게되었다. 바로 PathStripPath 라는 API 이다. Removes the path portion of a fully qualified path and file. 즉 전체 경로 중 실제 경로 부분만 제거한다는 의미이다. MSDN의 예제를 보면 TCHAR szPath1[] = TEXT("c:\\dir1\\file.txt"); PathStripPath(szPath1); // Result: szPath1 == file.txt TCHAR szPath2[] = TEXT("c:\\windows\\system32\\directx\\dinput\\joystick.ini")..
안전모드에서도 디바이스 드라이버를 로드하기
안전모드에서도 디바이스 드라이버를 로드하기
2015.04.26안전모드에서 디바이스 드라이버를 사용하기 위해서는 드라이버를 정적 로딩을 해야 한다. 정적 로딩을 하기 위해서는 CreateService() 호출시 SERVICE_BOOT_START 로 등록후 리부팅을 해야 한다. SERVICE_BOOT_START 로 등록하기 위해서는 .sys 파일이 c:\windows\system32\drivers 에 있어야 한다. 정적 등록된 드라이버를 안전모드에서 사용하기 위해서는 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\MinimalHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network 에 드라이버 이름으로 키를 만드고 (확장자 불필요), 기본값..
관리자 권한으로 생성한 MMF User 권한으로 접근하기
관리자 권한으로 생성한 MMF User 권한으로 접근하기
2015.04.03서비스스 뿐만 아니라, 시스템이나 관리자 권한으로 생성한 MMF나 혹은 PIPE를 유저 권한으로 읽거나 하려면 반드시라고 해도 좋을 만큼 권한에 관한 문제가 발생합니다. DWORD dwRes; PSID pEveryoneSID = NULL, pAdminSID = NULL; PACL pACL = NULL; PSECURITY_DESCRIPTOR pSD = NULL; EXPLICIT_ACCESS ea; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY; SECURITY_ATTRIBUTES sa; // Create a well-know..
System Error Codes (0-499)
System Error Codes (0-499)
2015.03.30Note The information on this page is intended to be used by programmers so that the software they write can better deal with errors. If you are an end-user that is experiencing difficulty with an application you are installing or running, contact customer support for the software that is displaying the error message. To obtain support for a Microsoft product, go to http://support.microsoft.com.T..
C++에서 C#의 Delegate 사용
C++에서 C#의 Delegate 사용
2015.03.22// Callback의 개념. class Car{ typedef void(*SIGNAL)(); SIGNAL signal;public: Car(SIGNAL s = 0) : signal(s) { } void SpeedUp( int speed ) { cout
Windbg 명령어 모음
Windbg 명령어 모음
2015.03.21eb eb 주소값 00 00 00 00 00 : 주소값부터 시작해서 5바이트를 00으로 채운다. - 심볼이 맞는지 확인하는 명령 0:000> !chksym ntdll - ntdll의 Export 함수 변경여부 확인하는 명령 0:000> !chkimg ntdll -d - notepad.exe의 _EPROCESS 주소 찾기 kd> !process 0 0 notepad.exe - notepad.exe의 스레드 주소 찾기(full detail 얻기) kd> !process _EPROCESS 7 PROCESS 8a3ceda0 SessionId: 0 Cid: 00f0 Peb: 7ffd7000 ParentCid: 0748 DirBase: 53ca5000 ObjectTable: e180c200 HandleCount: ..
Kernel debugging Windbg Symbol Path
Kernel debugging Windbg Symbol Path
2015.03.21Windbg에서 디버깅을 하기위해선 심볼을 설정해주어야한다. File -> Symbol Search Path 에 다음과 같이 입력해주면 된다. SRV*c:\symbols*http://msdl.microsoft.com/download/symbols 커널디버깅 중 심볼을 로드하는경우kd> .reload 명령어를 통하여 심볼을 재등록하도록 한다.