외규장각 도서 환수 모금 캠페인

Search Results for 'Study'

98 POSTS

  1. 2007.06.27 평영 발차기(1)
  2. 2007.06.27 Avoiding UpdateData from codeproject
  3. 2007.06.27 updatedata와 thread
  4. 2007.06.21 Inside ExeCryptor 2
  5. 2007.06.21 NTLDR is Missing.

평영 발차기(1)

Posted 2007. 6. 27. 23:28, Filed under: Study/Swim
출처 - http://flier.co.kr/   

평영의 이미지를 전체적으로 잡은 뒤, 다리를 기초로 하여 리듬을 느껴가야 하는지 또는 팔 동작을 기초로 해야 하는지는 논란이 있을 것이다. 또 "넘실거리기"방법으로 보면 오히려 접영의 허리 동작으로부터 느낌을 얻는 편이 좋을지도 모른다.
 
     그러나 이것은 결국 개인차의 문제일 것이다. 그저 유의해야 할 것은 평영은 다른 영법보다 훨씬 다리의 추진 파워율이 높다는 것이다.
   
     그리고 어떤 변형된 자세가 있다고 해도 평영의 다리 동작에는 공통의 기본 동작이 있다. 우선 이것을 익혀야 한다. 그리고 나서 모든 변종이 성립된다는 점, 끈기 있는 기본연습이 없으면 어떤 새 영법도 효과가 없음을 강조하고 싶다.
   
     위의 그림과 같이 발과 다리 동작은 그렇게 복잡하지 않다. 그저 ②에서 ③에 걸쳐 그리고 ⑥에서 ①에 걸치듯이 무릎과 발목과 발끝이 반대 동작을 하는 파동성 동작이 있다. 이것이 윕(Whip : 채찍과 같은) Kick을 만든다.
 
    그것은 결코 다리를 굽혔다 펴는 단손한 피스톤 동작이 아니다. 항상 휘듯이 끝으로 전달해 가는 원심성 동작이다. 이 기본적인 동작에 허리의 파동성이 더해져 더욱 흐르는 듯한 연속 스피드가 생기는 것이다.
 
---------

허리를 사용해야하는 건가
Response : ,

Avoiding UpdateData from codeproject

Posted 2007. 6. 27. 10:25, Filed under: Study/Computer Science
출처 - http://www.codeproject.com/cpp/avoidupdatedata.asp

Introduction

Microsoft does not adequately document the correct way to work with controls. It is left up to the programmer to somehow magically infer the correct way to do this. Unfortunately, all of the evidence suggests that UpdateData is the correct way to handle the problem of accessing control information while working inside a dialog. This is not correct. In fact, it is dangerous to use it. It is simply the wrong way to go about it.

After I posted this essay, one reader, Doug Harrison, sent me a critique. I'm including his comments at the end, because some of them point out some potential flaws in my approach, and are valid points. I also disagree with a couple, and I'll tell you why, and you can judge for yourself what you want to do. But a Wave of the Flounder Fin to Doug, who took the time to send me a message.

You should never call UpdateData in a modal dialog. Just Don't Do It. Ever. There are many reasons. One reason is that the OnOK handler calls UpdateData to store the control values in the associated member variables. The OnCancel handler does not call UpdateData. Therefore, the assumed behavior, or the should-be-assumed behavior, is that if you set a collection of member variables before calling DoModal, upon successful completion of the dialog the member variables will hold the new control values, and upon error completion the member variables will have the same values that you put into them. This makes calling a modal dialog very simple:

CMyDialog dlg;
dlg.m_Count = somecounter;
dlg.m_Text = sometext;
dlg.m_Option = someBool;













dlg.DoModal( );


somecounter = dlg.m_Count;
sometext = dlg.m_Text;
someBool = dlg.m_Option;

Nothing to it! But if you ever call UpdateData yourself, this simple paradigm won't work. That's because if the user clicks Cancel, you've already messed over the values to represent some intermediate state that the user has just chosen to reject.

Doug Harrison sent me a critique which points out a serious flaw in the above sequence. It is a flaw I never knew about because I have never used a particular feature of dialogs (well, I used it, didn't like it, and chose to deliberately avoid it). But his critique is well-taken, and you should read it. I've included it at the end.

Another reason to avoid UpdateData is that UpdateData restores all the state. This means you have to remember to save that state! I found this the greatest problem I had in managing the use of UpdateData before I figured out that it was simply a Bad Idea. You have to make sure, every time a change is made, that you copy all the values out of the controls, via UpdateData, so that if you want to make another change and restore the values you have the correct set, not some mix of some previous values and current values. This drove me crazy. It will probably drive you crazy, too.

In addition, if you call UpdateData, it snaps values from memory into all of your edit controls. This will immediately cause a set of OnChange (WM_COMMAND/EN_CHANGE) notifications, as each edit control is returned. Now assume that there is some issue about consistency checking, such that modifying control A affects the value in control B. But if you do UpdateData, you have to deal with the fact that this flurry of events may happen in an order other than the expected order from a user, and you have to make all sorts of provisions to deal with it, such as always setting a flag that indicates if the change should be reacted to or not.

Overall, I found that the three programs I wrote using UpdateData were harder to write, harder to debug, and much harder to maintain, than any program before or since in which I did not make any use of UpdateData. To me, ease of maintenance is one of the most important concerns. Low cost of development is also important.

The correct way, I have found, is to use control variables. If you don't understand what a control variable is, click the hyperlink to read my essay on them.

So how do you get the values of the controls while the dialog is active? Just use the control variable to access the control! For example, to determine if the OK button should be enabled, and it can only be enabled if the text value is nonblank you can write:

CString s;
c_Text.GetWindowText(s);
s.TrimLeft();
c_OK.EnableWindow(s.GetLength() != 0);

Far easier than having to remember how to call UpdateData (is it TRUE or FALSE for the argument?) and avoids the danger of messing over the OK/Cancel behavior.

Where do you write the above code? Where do you write the above code? Well, that's another essay!

OK, I'll relent, just a bit, and tell you another reason to not use UpdateData, which is the only reason I have found to use UpdateData (keep reading, that's not a typo that makes the sentence look contradictory!) I have a client who is offended by the situation where you have made some changes in a dialog, gotten confused, and had to click Cancel to get out of the dialog, only to immediately re-enter it to start over. He insisted that every dialog in his product have a Reset button that reset the dialog to its original state. If you avoid UpdateData this becomes easy: you use UpdateData. What I mean is, if you avoid gratuitous, pointless, useless, UpdateData calls (that is, in almost every dialog I can think of, any call on UpdateData), then the original information is left intact, and a single UpdateData call will restore all the original values. But note that the only use of UpdateData is to load the controls with the original input values, and this will not work if you have used it to grab the values back at intermediate points; in this case, you have destroyed the input state. Actually, I like his style, and so, like most dogmatists, I have to say "but there is an exception". Thus far, it is the only exception I've found for non-database applications (see Doug Harrison's comments, which follow below). Since I have written, literally, hundreds of dialogs in the last five years or so, and after the first three applications have never called UpdateData, with the one exception of resetting all of the state to the original input state, I cannot get terribly excited about any claims that this call is the right way to do general dialogs. Or that an explicit call of UpdateData even has any place in them, other than the reset case.

Some Comments from Doug Harrison

Doug Harrison took the time to reply to my essay. He raises some interesting points, and one of them shows that I haven't used a number of dialog features which can lead to some problems. I include a slightly edited version of his comments here, so you can read them and make your own choices.


Doug writes:

I haven't read all your essays, but I do have some comments concerning your OnUpdateData essay.

There are some problems with the sequence below:

CMyDialog dlg;
dlg.m_Count = somecounter;
dlg.m_Text = sometext;
dlg.m_Option = someBool;
dlg.DoModal( );
somecounter = dlg.m_Count;
sometext = dlg.m_Text;
someBool = dlg.m_Option;

1. You shouldn't rely on users to initialize the dialog members directly. As with almost every class, it's much better if the ctor has that responsibility.

This is one I disagree with. Only the caller knows what the values are, the default constructor cannot possibly know any details of the calling site. To avoid this, you have to modify the constructor by hand to add the necessary parameters. This, at least the one time I tried it a few versions back, horribly confused the ClassWizard, which proceeded to corrupt the source file.It made me sufficiently nervous that I've not tried it again. The technique of using the constructor, which he shows below (and, which in my opinion as well is a better way to do it), still requires pulling the data out afterward. Microsoft works in an illusory world in which all of these parameters have to be simple scalars, a restriction so brain-dead that I cannot imagine why anyone could ever imagine it is sufficient. I'd rather pass in a pointer to a structure, but then I can't use ClassWizard to deal with the value variables, because it won't parse structure accesses, or anything other than a simple variable. Since I still have to set everything up, and pull it back out, I prefer the symmetry of seeing the assignments. My inclination would be to have a ClassWizard which would allow me to specify a list of parameters which would be passed in as references, and which would update the variables only upon completely successful completion (that is, all validation was passed). In the absence of something useful, I consider the names of the member variables to be initialized to be part of the specification of the interface. Note that only place I ever use the m_ prefix is a member variable which is used to pass parameters to the dialog from the caller; in no other place anywhere in any dialog I write will you ever find an m_ variable that is used for any other purpose. So I disagree with this point, but only because the tools are still primitive. The bottom line is that Microsoft has a long way to go in providing the necessary automation. In the absence of decent automation, I prefer to do it myself. I'm not opposed to automation, just to poor automation. --jmn

2. If you care about the values of those members upon return from the dialog, you must care what DoModal returns. To see why, consider that if there's a validation error, UpdateData doesn't run to completion when called from OnOK, and the user can subsequently exit the dialog by canceling it. The code above is subject to storing a mix of new and old values in that scenario, despite the user canceling the dialog, depending on which DDV call in DoDataExchange failed, as well as the order of the DDX/DDV calls.

Thus, the code above is better written as:

CMyDialog dlg(somecounter,sometext,someBool);
if (dlg.DoModal() == IDOK)
   {
    // User said OK, and validation succeeded, 
    //so update application state
   }

In this point he is absolutely correct. Since I never use DDV, for what I think are sound reasons, I would never have encountered this case. If you do use DDV, or think you might use DDV in the future, you need to use the more formally correct form he shows here.--jmn

Also, I can't agree with the premise, "Never call UpdateData." The function definitely has its uses, even in modal dialogs. For example, consider a dialog box that (in part) contains some controls that provide an interface to a simple database of (key,item) pairs, such as an STL map. There is a Save button, and pressing it saves the current record.

I must admit that I've never wanted to do this; I tend to favor writing the code explicitly so that I have some idea of what is going on. This is not a "I don't trust automation, and I'm a Real Programmer". It is a "The automation produces something that is far too simplistic to meet my needs". But if you want to do this, then the issue is that the dialog itself, rather than the caller, cares about the state, and this is a valid point. --jmn

3. To write the Save function of your own, you need to fill the dialog data members, and you use UpdateData for that. If you go to the controls, as you suggest, you bypass necessary dialog data validation as you complicate your code with a lot of control querying. Going directly to the controls is valid only in contexts in which you don't care that the dialog data doesn't reflect the current state of the controls.

I agree, if you are using DDV. Since I believe that DDV is deeply flawed in its basic design (it only validates when you click OK, and I don't like the way it works; I prefer to do continuous validation, enabling/disabling OK as the validity of the data changes, and even displaying the status of what is missing, incorrect, or inconsistent in the status line or other location. So I have deliberately chosen to avoid the DDV mechanism in favor of a far more user-friendly (in my estimation) system. Check out my essays on dialog box state maintenance and on a real-time instantly-reactive validation mechanism. If you choose to use DDV, then his point about bypassing the checking is correct. --jmn

4. You need to override OnOK, because you want to give the user the chance to save any changes. So, you write a QuerySave function, which calls Save if the user gives the OK. In general, if you override OnOK, your override must call UpdateData. In this database example, it's also appropriate to override OnCancel and have it go through the QuerySave bit, so OnCancel can also call UpdateData in some scenarios.

I also agree, if you are working in a model in which after clicking OK you ask "Save changes?" and require a confirmation. I've always worked on the model that if the user clicks OK the intent is to save any changes, and if the user didn't want to save the changes, the user would click "Cancel". If you otherwise override OnOK, you can certainly call CDialog::OnOK which implicitly calls UpdateData, since calling CDialog::OnOK eventually invokes the virtual method. --jmn

Aside: When you override OnOK, if your UpdateData call and other validation are successful, the correct way to end the dialog is to call EndDialog, usually as EndDialog(IDOK), instead of calling CDialog::OnOK. This avoids a pointless second call of UpdateData.

Yes, this is correct, if you choose to use this style. Since I choose to not use this style, it has not been a problem for me. One concern I have is that by calling EndDialog, you are stating that you know that the implementation of CDialog::OnOK is just UpdateData followed by EndDialog. This tends to violate the notion of inheritance abstraction, which bothers me. In particular, if you later subclass the dialog (another feature Microsoft doesn't support at all), then the superclass may be the class that does this, and doing an EndDialog explicitly in the subclass will bypass the superclass method and produce incorrect results. But the statement he makes is correct, at least in this version of MFC. --jmn


The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.

Send mail to newcomer@flounder.com with questions or comments about this article.
Copyright © 1999 CompanyLongName All Rights Reserved
www.flounder.com/mvp_tips.htm
Response : ,

updatedata와 thread

Posted 2007. 6. 27. 10:18, Filed under: Study/Computer Science
How to use "updatedata" in a thread ? Unconfirmed/Anonymous posting  penny15  6:46 12 Nov '03 
I am a beginer in MFC programmation, I would like to use UpdateDate in order to refresh my Cdialog windows in a thread function
Thank you for your help.
Re: How to use "updatedata" in a thread ?   Joseph M. Newcomer 17:04 16 Nov '03
(a) you can't. It is that simple. Not possible. It will simply crash your app. Which is what it is supposed to do! It cannot under any circumstancces be called from a thread.

(b) WHY???? UpdateData is one of the worst ideas to have hit the programming community (as my essay says). Not only is it impossible to use it from a thread, but even considering the use of it for any purpose is, in my estimation, a fundamental design mistake.

Read my essay on threads. Just send notices to the main GUI thread to update what you need to have updated, and do something sensible, like SetWindowText, to update it (note that even if you could get UpdateData to work, it would STILL be a mistake, since it could be updating a string value that is BEING CHANGED RIGHT NOW by the thread, so it can't work anyway! The threads absolutely, positively MUST NOT touch any window owned by the main GUI thread (PostMessage does not constitute a "touch")

Re: How to use "updatedata" in a thread ?   satoufe 16:25 8 Jun '04

Hello, i would know if you arrived to call UpdataData within a thread...I am trying but always i v got error message Debug assertion..


need your help..
-> 이게 바로 내가 겪었던 문제! 윈도우 핸들을 통째로 쓰레드로 넘겨서 거기서 updatedata()를 호출하고 다른 프로시저를 쭉 실행해 나갈려고했는데 안된다.

결국은 updateadata() 부분을 빼고 나머지 부분만 쓰레드에서 구현했음.
Re: How to use "updatedata" in a thread ?   Joseph M. Newcomer 23:23 8 Jun '04
The rule is very simple: DO NOT EVER TOUCH A WINDOW FROM A THREAD. PostMessage is touching the thread's queue, not the window to which the message is being sent, so that is safe. UpdateData would be insane. Personally, I think it is insane to ever use UpdateData at all, so the fact that it makes no sense from a thread is pretty irrelevant to me. Note also that you cannot call SetWindowText, AddString, or pretty much any other method of a window from a thread that does not own it.

Bottom line: UpdateData is guaranteed to fail if called from a thread. Do not even contemplate the possibility it being a useful function to call from a thread that does not own the dialog. Second rule: do not consider the possibility of creating a dialog that is owned by the thread. That just puts you back in the same fix.

If you have thought you saw this all work successfully, you have seen an illusion. The illusion will eventually fail completely and unexpectedly in a way guaranteed to maximize embarrassment, safety risks, or your customer's loss of faith in your product.
----
DO NOT EVER TOUCH A WINDOW FROM A THREAD

그런 거였구나. 이상한 debug assertion 나는거 피해가느라고 엄청 고생하다가 결국은 포기했는데.

출처 - http://www.codeproject.com
Response : ,

Inside ExeCryptor

Posted 2007. 6. 21. 16:01, Filed under: Study/Computer Science

Most of the available protection schemes use a so called 'mounted scheme' (the protection program adds code to your program that makes it encrypted, compressed and debugger protected). When your program is started this code unpacks, decrypts and adjusts your application back to its original state.

In such a case a cracker's actions are obvious: he suppresses the anti-debugging tricks and dgumps the unpacked and decrypted application code. Then after having disassembled and analyzed the code, he simply needs a little patching and he gets a fully functional unprotected copy.

What are the weak points of such protection?

Protection code added to an applications is usually more or less standard and soon or later it becomes the subject of detailed analysis. Once the security code is analyzed, reverse engineering of the protected application becomes a snap. In addition there are many automatic deprotectors that crackers can use for most popular protection solutions.
Protected code of your application is encrypted. But before it can be executed the protector has to decrypt it and pass the control to it. This moment can be intercepted by an intruder so he can get the access to the original code for analyzing/modification.

EXECryptor uses a conceptually new approach to protect software applications. The core of the protection technology is a brand new concept of the code transformation called "Code Morphing". This technology protects the code on the CPU-command level. It is known the x86 processors command system is redundant and allows the execution of the same 'code' using various different system commands. EXECryptor breaks up the protected code into several processor commands or small command snippets and replace them by others, while maintaining the same end result. Thus EXECryptor obfuscates the code not on the source level but on the level of the CPU commands.

The Code Morphing is multilevel technology containing hundreds of unique code transformation patterns. In addition this technology includes the special layer that transforms some commands into Virtual Machine commands (like P-Code). EXECryptor's Code Morphing turns binary code into an undecipherable mess that is not similar to normal compiled code, and completely hides execution logic of the protected code.

Unlike other code protectors, there is no concept of code decryption with EXECryptor. Protected code blocks are always in the executable state, and they are executed as a transformed code. The original code is completely lost and code restoration is an NP-hard problem.

In addition you do not have to worry about the size or speed of your program because you don't need to transform its entire code. You have to protect only critical parts of your code, responsible for serial number verification, trial expiration date, and other evaluation restrictions. The rest of application code remains intact and software execution speed remains the same.

Below is a code sample generated by Delphi and a partial (the full listing contains over 500 instructions) listing of the transformed code.

Source code:
{$I crypt_start.inc}
  WriteLn('Test OK');
{$I crypt_end.inc}

After compilation
Protected code (partial)
사용자 삽입 이미지
사용자 삽입 이미지

----------
ExeCryptor라는 실행압축
OllyDbg 에서 안읽어져서 참 난감하다.
어떤 방식으로 이루어지는지 궁금해서 요 며칠간 뜯어보고 있다.

도무지 모르겠다 ㅋ
tls 섹션에 등록된 콜백합수를 이용해서 복호화 루틴을 수행한다는 것.
소스코드 레벨에서가 아니라 하드웨어 레벨에서 소스 변경을 통해 압축한다는것.
(그래서 올리에서 처리할 수 없는 명령어라면서 팅기는 건가 -_-)

여튼 난감 난감
쉬운거 부터 봐야겠다~

출처- http://www.strongbit.com/execryptor_inside.asp

Response : ,

NTLDR is Missing.

Posted 2007. 6. 21. 10:12, Filed under: Study/Computer Science

어제 막 잠들려는 찰라에 철희가 갑자기 전화와서 컴퓨터가 안된다고 -_-

NTLDR is missing
Press Ctrl Alt Del to Restart

윈도우즈 업데이트를 하고 나서 다음에 부팅하는데 저런 메세지가 나왔단다.
M$는 업데이트도 제대로 못해서 Nt Loader를 날려먹냐 -_-;

해결책은 뭐 그냥 윈도 다시 까는거.
XP 같은 경우는 씨디에 복구(R)  기능이 있으니까 해결은 된다만..

그러고 나서 오늘 아침에 다시 찾아보니까.
원인도 굉장히 다양하고 해결책도 다양하네..

Response : ,

« Previous : 1 : ··· : 5 : 6 : 7 : 8 : 9 : 10 : 11 : ··· : 20 : Next »

Recent Posts

Recent Comments

Recent Trackbacks

Total hit (Today , Yesterday )

Admin Write Post